Boost logo

Boost Users :

Subject: Re: [Boost-users] [Units] help with type-safe unit-specific conversions
From: Justin Leonard (justinleona_at_[hidden])
Date: 2009-07-23 16:26:25


> It asserts because a base_unit is just a tag type.
> Try us::foot_base_unit::unit_type.

Ah, that works as intended - do you think you could make it more explicit
in the documentation how to do this? E.g., as part of "runtime conversions",

...
typedef us_dollar_base_unit::unit_type us_dollar;
typedef euro_base_unit::unit_type euro;

void foo() {
   quantity<us_dollars> dollars(10.0*us_dollars);
   quantity<euro> euros(dollars);

   std::cout << dollars << " is " << euros << std::endl;
}

Thanks,
Justin


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