/usr/include/boost/units
NameSizeModeActions
base_units/-0755rm
detail/-0755rm
physical_dimensions/-0755rm
systems/-0755rm
absolute.hpp55400644editdlrm
base_dimension.hpp36920644editdlrm
base_unit.hpp41320644editdlrm
cmath.hpp205920644editdlrm
config.hpp28290644editdlrm
conversion.hpp95180644editdlrm
derived_dimension.hpp64650644editdlrm
dim.hpp47450644editdlrm
dimension.hpp44030644editdlrm
dimensionless_quantity.hpp9950644editdlrm
dimensionless_type.hpp13150644editdlrm
dimensionless_unit.hpp9570644editdlrm
get_dimension.hpp12210644editdlrm
get_system.hpp11650644editdlrm
heterogeneous_system.hpp122580644editdlrm
homogeneous_system.hpp23990644editdlrm
io.hpp324700644editdlrm
is_dim.hpp8850644editdlrm
is_dimensionless.hpp11070644editdlrm
is_dimensionless_quantity.hpp9360644editdlrm
is_dimensionless_unit.hpp9050644editdlrm
is_dimension_list.hpp10570644editdlrm
is_quantity.hpp9160644editdlrm
is_quantity_of_dimension.hpp11150644editdlrm
is_quantity_of_system.hpp10970644editdlrm
is_unit.hpp8790644editdlrm
is_unit_of_dimension.hpp11380644editdlrm
is_unit_of_system.hpp11270644editdlrm
lambda.hpp268410644editdlrm
limits.hpp43450644editdlrm
make_scaled_unit.hpp18170644editdlrm
make_system.hpp49140644editdlrm
operators.hpp62870644editdlrm
physical_dimensions.hpp45320644editdlrm
pow.hpp30330644editdlrm
quantity.hpp418600644editdlrm
reduce_unit.hpp8680644editdlrm
scale.hpp50620644editdlrm
scaled_base_unit.hpp36430644editdlrm
static_constant.hpp24250644editdlrm
static_rational.hpp104350644editdlrm
unit.hpp134490644editdlrm
units_fwd.hpp21910644editdlrm
Edit: /usr/include/boost/units/conversion.hpp (9518B)
// Boost.Units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2008 Matthias Christian Schabel // Copyright (C) 2007-2008 Steven Watanabe // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_UNITS_CONVERSION_HPP #define BOOST_UNITS_CONVERSION_HPP /// \file /// \brief Template for defining conversions between quantities. #include namespace boost { namespace units { template struct conversion_helper; #ifdef BOOST_UNITS_DOXYGEN /// 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 /// @code /// namespace boost { /// namespace units { /// template /// struct conversion_helper, quantity > /// { /// static quantity convert(const quantity& source) /// { /// return(quantity::from_value(6 * source.value())); /// } /// }; /// } /// } /// @endcode /// /// In most cases, the predefined specializations for @c unit /// and @c absolute should be sufficient, so users should rarely /// need to use this. template struct conversion_helper { static BOOST_CONSTEXPR To convert(const From&); }; #endif /// 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(Source, Destination, type_, value_) \ namespace boost { \ namespace units { \ template<> \ struct select_base_unit_converter< \ unscale::type, \ unscale::type>::type \ > \ { \ typedef Source source_type; \ typedef reduce_unit::type destination_type; \ }; \ template<> \ struct base_unit_converter::type> \ { \ BOOST_STATIC_CONSTEXPR bool is_defined = true; \ typedef type_ type; \ static BOOST_CONSTEXPR type value() { return(value_); } \ }; \ } \ } \ void boost_units_require_semicolon() /// 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. #define BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE(Params, Source, Destination, type_, value_) \ namespace boost { \ namespace units { \ template \ struct base_unit_converter< \ Source, \ BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Destination, typename Source::dimension_type)\ > \ { \ BOOST_STATIC_CONSTEXPR bool is_defined = true; \ typedef type_ type; \ static BOOST_CONSTEXPR type value() { return(value_); } \ }; \ } \ } \ void boost_units_require_semicolon() /// 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(Source, Dest) \ namespace boost { \ namespace units { \ template<> \ struct unscaled_get_default_conversion::type> \ { \ BOOST_STATIC_CONSTEXPR bool is_defined = true; \ typedef Dest::unit_type type; \ }; \ } \ } \ void boost_units_require_semicolon() /// 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_DEFAULT_CONVERSION_TEMPLATE(Params, Source, Dest) \ namespace boost { \ namespace units { \ template \ struct unscaled_get_default_conversion \ { \ BOOST_STATIC_CONSTEXPR bool is_defined = true; \ typedef typename Dest::unit_type type; \ }; \ } \ } \ void boost_units_require_semicolon() /// 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_BASE_UNIT_WITH_CONVERSIONS(namespace_, name_, name_string_, symbol_string_, factor, unit, id)\ namespace boost { \ namespace units { \ namespace namespace_ { \ struct name_ ## _base_unit \ : base_unit { \ static BOOST_CONSTEXPR const char* name() { return(name_string_); } \ static BOOST_CONSTEXPR const char* symbol() { return(symbol_string_); } \ }; \ } \ } \ } \ BOOST_UNITS_DEFINE_CONVERSION_FACTOR(namespace_::name_ ## _base_unit, unit, double, factor); \ BOOST_UNITS_DEFAULT_CONVERSION(namespace_::name_ ## _base_unit, unit) /// Find the conversion factor between two units. template inline BOOST_CONSTEXPR typename one_to_double_type< typename detail::conversion_factor_helper::type >::type conversion_factor(const FromUnit&,const ToUnit&) { return(one_to_double(detail::conversion_factor_helper::value())); } } // namespace units } // namespace boost #endif // BOOST_UNITS_CONVERSION_HPP