...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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())); } }; } }