Boost logo

Boost :

Subject: Re: [boost] Units of data
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-07-02 15:07:13


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk