Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Struct template 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.

conversion_helper public static functions

  1. static To convert(const From &);