Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] Creating a velocity unit
From: Ryan (boost_at_[hidden])
Date: 2013-02-22 15:30:14


>
> 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.

Ryan



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