AMDG On 02/21/2013 10:25 AM, Ryan wrote:
Thanks for the link it was helpful. I tried both methods and they both compiled. It seems we can use the simpler form of decltype because it provides perfect forwarding. Is this a correct interpretation?
Yes. The two are equivalent. decltype is a bit nicer, as long as you know that you'll only be using a compiler that supports it.
Neither of these two typedef seems to behave as I expected. When creating a quantity with these typedefs I had to call them as a method to get the code to compile.
quantitysi::velocity a(2.3 * nautical_miles_per_hour1()); quantitysi::velocity b(2.4 * nautical_miles_per_hour2()); quantitysi::velocity c(2.5 * si::meters_per_second);
Is there a way to get my type of nautical_miles_per_hour to behave like meters_per_second?
The difference is that meters_per_second is an object, not a type: static const si::velocity meters_per_second; At this point, I prefer to use the type, because I don't like having to come up with two different names for the type and the global constant. I suppose that it would also be possible to use only the object, and use decltype whenever you need a type.
//Provided for the Discussion using namespace boost::units; typedef metric::nautical_mile_base_unit::unit_type nautical_mile_unit; typedef metric::hour_base_unit::unit_type hour_unit;
typedef decltype(nautical_mile_unit() / hour_unit()) nautical_miles_per_hour1; typedef divide_typeof_helper
::type nautical_miles_per_hour2;
In Christ, Steven Watanabe