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 14:41:35


Steven Watanabe <watanabesj <at> gmail.com> writes:
 
> If you substitute the correct unit types in place of the
> enum values in quantity<xxx>(some_value).value(),
> then the code above should work fine.

So I should be able to do something like:

double length_in_feet = quantity<us::foot_base_unit>(10.0*si::meters).value();

to explicitly convert from meters to feet? Right now this gives
'boost::mpl::assertion_failed' while compiling quantity.hpp.

>
> I'm not quite sure what you mean by achieving this
> implicitly using the type system. You have define
> the mapping from enum values to unit types somehow.
> There is no way for it to be deduced automatically.

My mistake, I meant to use a boost::unit instead of the enumeration inside
of quantity... The enumerations just allow for run-time user input
to control the type.

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