Boost logo

Boost :

Subject: Re: [boost] [units] problems
From: Robert Ramey (ramey_at_[hidden])
Date: 2013-09-13 22:42:09


Robert Ramey wrote:
> Steven Watanabe wrote:
>> AMDG
>>
>> On 09/13/2013 03:48 PM, Robert Ramey wrote:
>>> Steven Watanabe wrote:
>>>> On 09/13/2013 01:54 PM, Robert Ramey wrote:
>>>>> <snip>
>>>>> 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;
>>>>> }
>>>>>
>>>>> <snip>
>>>>
>>>> Try static_cast.
>>>
>>> could you give me an example? That is how should the statement
>>>
>>> l2 = 1.0 * miles; // compile error
>>>
>>> be modified?
>>>
>>
>> l2 = static_cast<quantity<length, float>>(1.0 * miles);
>
> Hmmmm - OK this looks promising, but I get another compiler error
> with MSVC
> 1>z:\projects\geflightquest\simulator2\solvecpp\flight.cpp(14) : error
> C2065: 'miles' : undeclared identifier
>
> it looks like I'm missing something; Here is the test program again
> - with all the headers.
>
> #include <boost/units/systems/si/length.hpp>
> #include <boost/units/base_units/us/mile.hpp>
> #include <boost/units/quantity.hpp>
> int main(int argc, char * argv[]){
> using namespace boost::units;
> using namespace boost::units::si;
> using namespace boost::units::us;
> quantity<length, float> l1;
> l1 = 1.0 * meters;
> quantity<length, float> l2;
> l2 = static_cast<quantity<length, float> >(1.0 * miles);
> quantity<length, float> l3 = l1 + l2;
> return 0;
> }

OK my latest attempt just adds the following

>> In Christ,
>> Steven Watanabe
>>
>>
>> _______________________________________________
>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


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