![]() |
Home | Libraries | People | FAQ | More |
boost::units::conversion_helper
// In header: <boost/units/conversion.hpp> template<typename From, typename To> struct conversion_helper { // public static functions static To convert(const From &) ; };
Template for defining conversions between quantities. This template should be specialized for every quantity that allows conversions. For example, if you have a two units called pair and dozen you would write
namespace boost {
namespace units {
template<class T0, class T1>
struct conversion_helper<quantity<dozen, T0>, quantity<pair, T1> >
{
static quantity<pair, T1> convert(const quantity<dozen, T0>& source)
{
return(quantity<pair, T1>::from_value(6 * source.value()));
}
};
}
}
In most cases, the predefined specializations for unit and absolute should be sufficient, so users should rarely need to use this.