Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] Creating a velocity unit
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-02-22 16:19:47


AMDG

On 02/22/2013 12:30 PM, Ryan wrote:
>>
>> Also, I should point out that you don't need the intermediate
>> typedef.
>
> BOOST_UNITS_STATIC_CONSTANT(nautical_mile,
>> metric::nautical_mile_base_unit::unit_type);
>> will work just fine.
>
>
> This was what I was looking for. I found that BOOST_UNITS_STATIC_CONSTANT
> needs to be declared outside of the class. I think is due to the namespace
> the macro uses. I couldn't though use it to declare
> nautical_miles_per_hour.
>
> BOOST_UNITS_STATIC_CONSTANT(nautical_miles,
> metric::nautical_mile_base_unit::unit_type);
> BOOST_UNITS_STATIC_CONSTANT(hours, metric::hour_base_unit::unit_type);
> BOOST_UNITS_STATIC_CONSTANT(nautical_miles_per_hour,
> decltype(BOOST_TYPEOF(nautical_miles)() / BOOST_TYPEOF(hours)())); //This
> doesn't compile
>
> I could however do the following.
>
> static const decltype(BOOST_TYPEOF(nautical_miles)() /
> BOOST_TYPEOF(hours)()) nautical_miles_per_hour;
>
> I don't understand the difference.
>

Me neither. However, you don't need to
use BOOST_TYPEOF. It would be simpler to
write:

decltype(nautical_miles / hours)

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net