|
Boost : |
Subject: Re: [boost] [units] problems
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2013-09-15 21:55:30
On 9/14/2013 5:31 PM, Quoth Robert Ramey:
>> #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;
>> }
[...]
> 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 &)'
Incidentally, the reason why you're getting this error is that you're
specifying the value type as "float" but then passing it double values.
Replace your "1.0" with "1.0f" etc (or omit the "float" type parameter,
which will make it use double by default) and then you'll probably have
more luck.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk