« Return to Thread: Units of data

Re: Units of data

by Steven Watanabe-4 :: Rate this Message:

Reply to Author | View in Thread

AMDG

Zachary Turner wrote:

> Thanks for your help so far!  I know I'm probably just making this too
> difficult, but it's still not working.  I guess I should just post a
> complete sample so that we can eliminate the snip factor from the list
> of possible causes  (I put them in the boost namespace for the sake of
> consistency but the same problem arises regardless).
>
> <snip>
>  
> void foo()
> {
> using boost::units::quantity;
> using namespace boost::units::data_capacity;
>
>         //Both of these fail with the message that there is no
> conversion to the destination
>         //type because the construcor is explicit
> quantity<data_capacity> compressed_size = 1000 * bytes;
> quantity<data_capacity, int> compressed_size2 = 1000 * bytes;
>  

Implicit conversion between different units is not allowed.
Try
quantity<data_capacity> compressed_size(1000 * bytes);

> //Succeeds but gives a horribly long warning about conversion from
> 'double' to 'const int'
> //at file 'boost/units/detail/conversion_impl.hpp(342)', reference to
> class template instantiation at
> //boost/units/quantity.hpp(182)
>         quantity<data_capacity, int> compressed_size3(1000 * bytes);
> }
>  

I'll commit a fix as soon as the regression tests finish locally.

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

 « Return to Thread: Units of data