Template for defining conversions between quantities. More...
#include <boost/units/detail/conversion_impl.hpp>
Classes | |
struct | boost::units::conversion_helper< From, To > |
Namespaces | |
boost | |
Duration formatting facet for input. | |
boost::units | |
Macros | |
#define | BOOST_UNITS_DEFINE_CONVERSION_FACTOR(Source, Destination, type_, value_) |
Defines the conversion factor from a base unit to any unit or to another base unit with the correct dimensions. More... | |
#define | BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE(Params, Source, Destination, type_, value_) |
Defines the conversion factor from a base unit to any other base unit with the same dimensions. More... | |
#define | BOOST_UNITS_DEFAULT_CONVERSION(Source, Dest) |
Specifies the default conversion to be applied when no direct conversion is available. More... | |
#define | BOOST_UNITS_DEFAULT_CONVERSION_TEMPLATE(Params, Source, Dest) |
Specifies the default conversion to be applied when no direct conversion is available. More... | |
#define | BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(namespace_, name_, name_string_, symbol_string_, factor, unit, id) |
INTERNAL ONLY Users should not create their units in namespace boost::units. More... | |
Functions | |
template<class FromUnit , class ToUnit > | |
one_to_double_type< typename detail::conversion_factor_helper < FromUnit, ToUnit >::type > ::type | boost::units::conversion_factor (const FromUnit &, const ToUnit &) |
Find the conversion factor between two units. More... | |
Template for defining conversions between quantities.
#define BOOST_UNITS_DEFAULT_CONVERSION | ( | Source, | |
Dest | |||
) |
Specifies the default conversion to be applied when no direct conversion is available.
Source is a base unit. Dest is any unit with the same dimensions.
#define BOOST_UNITS_DEFAULT_CONVERSION_TEMPLATE | ( | Params, | |
Source, | |||
Dest | |||
) |
Specifies the default conversion to be applied when no direct conversion is available.
Params is a PP Sequence of template arguments. Source is a base unit. Dest is any unit with the same dimensions. The source must not be a scaled base unit.
#define BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS | ( | namespace_, | |
name_, | |||
name_string_, | |||
symbol_string_, | |||
factor, | |||
unit, | |||
id | |||
) |
INTERNAL ONLY Users should not create their units in namespace boost::units.
If we want to make this public it needs to allow better control over the namespaces. –SJW. template that defines a base_unit and conversion to another dimensionally-consistent unit
#define BOOST_UNITS_DEFINE_CONVERSION_FACTOR | ( | Source, | |
Destination, | |||
type_, | |||
value_ | |||
) |
Defines the conversion factor from a base unit to any unit or to another base unit with the correct dimensions.
Uses of this macro must appear at global scope. If the destination unit is a base unit or a unit that contains only one base unit which is raised to the first power (e.g. feet->meters) the reverse (meters->feet in this example) need not be defined explicitly.
#define BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE | ( | Params, | |
Source, | |||
Destination, | |||
type_, | |||
value_ | |||
) |
Defines the conversion factor from a base unit to any other base unit with the same dimensions.
Params should be a Boost.Preprocessor Seq of template parameters, such as (class T1)(class T2) All uses of must appear at global scope. The reverse conversion will be defined automatically. This macro is a little dangerous, because, unlike the non-template form, it will silently fail if either base unit is scaled. This is probably not an issue if both the source and destination types depend on the template parameters, but be aware that a generic conversion to kilograms is not going to work.