|
Boost : |
Subject: Re: [boost] [units] problems
From: Robert Ramey (ramey_at_[hidden])
Date: 2013-09-14 01:31:38
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:
namespace boost { namespace units { namespace us {
BOOST_UNITS_STATIC_CONSTANT(miles, mile_base_unit);
} } }
But this generates an error with MSVC (and a similar message with gcc)
1>z:\projects\geflightquest\simulator2\solvecpp\flight.cpp(18) : error
C2678: binary '*' : no operator found which takes a left-hand operand of
type 'double' (or there is no acceptable conversion)
1> z:\boost_1_54_0\boost\units\detail\one.hpp(47): could be 'T
boost::units::operator *<boost::units::us::mile_base_unit>(const
boost::units::one &,const T &)'
1> with
1> [
1> T=boost::units::us::mile_base_unit
1> ]
1> z:\boost_1_54_0\boost\units\detail\one.hpp(53): or 'T
boost::units::operator *<double>(const T &,const boost::units::one &)'
1> with
1> [
1> T=double
1> ]
1> z:\boost_1_54_0\boost\units\detail\one.hpp(58): or 'boost::units::one
boost::units::operator *(const boost::units::one &,const boost::units::one
&)'
1> while trying to match the argument list '(double, const
boost::units::us::mile_base_unit)'
I went back and tried to compile the tutorial - and it failed in the same
circumstance with the same message. I tried this with current release
branch
and version 1.54 . I'm pretty much at loss here. I can't believe that I'm
the
first person to have this problem.
Any help appreciated
Robert Ramey
>> 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