
AMDG justinleona@gmail.com wrote:
I have conversions working fine for built-in types, but for both scaled types and user-defined types I don't know how to get indirect conversions to compile.
Here is an example:
#include <boost/units/quantity.hpp> #include <boost/units/systems/si.hpp> #include <boost/units/systems/si/prefixes.hpp> #include <boost/units/base_units/metric/bar.hpp>
void f() { typedef metric::bar_base_unit::unit_type bars;
typedef boost::units::scale<10,static_rational<3> > kilo_type; typedef make_scaled_unit<bars,kilo_type>::type kbars; const kbars kilobars;
typedef boost::units::scale<10,static_rational<6> > mega_type; typedef make_scaled_unit<si::pressure,mega_type>::type mpa; const mpa megapascals;
typedef boost::units::quantity<si::pressure> Pascals; typedef boost::units::quantity<mpa> Megapascals; typedef boost::units::quantity<kbars> Kilobars;
Megapascals p(.5*kilobars); std::cout << Kilobars(p) << std::endl; }
If I directly convert it works - e.g., Kilobars(Pascals(p)). Do I need to use BOOST_UNITS_DEFAULT_CONVERSION to set a default conversion? If so - which part(s) of the chain need it?
This ought to just work. Fixed in the trunk. In Christ, Steven Watanabe