Boost logo

Boost :

Subject: Re: [boost] [units] problems
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-09-13 16:12:57


AMDG

On 09/13/2013 01:54 PM, Robert Ramey wrote:
> <snip>
> What I expect to see is:
>
> #include <boost/units/quantity.hpp>
> #include <boost/units/systems/si/length.hpp>
> #include <boost/units/base_units/us/mile.hpp>
> void main(){
> using namespace boost::units;
> using namespace boost::units::si;
> using namespace boost::units::us;
> quantity<length, float> l1;
> l1 = 1000.0 * meters;
> quantity<length, float> l2;
> l2 = 1.0 * miles; // compile error
> quantity<length, float> l3 = l1 + l2;
> }
>
> and I expect this to pretty much work. The documentation says " Implicit
> conversions between unit systems are allowed only when the reduced units are
> identical, allowing, for example, trivial conversions between equivalent
> units in different systems (such as SI seconds and CGS seconds)" so I
> expected that it can convert miles into kilometers.

Try static_cast.

> This is a
> disappointment - but I'll assume that the authors have a good reason for
> this.
>
> <snip>
>

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