Warning, file /include/boost/units/conversion.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_UNITS_CONVERSION_HPP
0012 #define BOOST_UNITS_CONVERSION_HPP
0013
0014
0015
0016
0017 #include <boost/units/detail/conversion_impl.hpp>
0018
0019 namespace boost {
0020
0021 namespace units {
0022
0023 template<class From, class To>
0024 struct conversion_helper;
0025
0026 #ifdef BOOST_UNITS_DOXYGEN
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 template<class From, class To>
0052 struct conversion_helper
0053 {
0054 static BOOST_CONSTEXPR To convert(const From&);
0055 };
0056
0057 #endif
0058
0059
0060
0061
0062
0063
0064
0065 #define BOOST_UNITS_DEFINE_CONVERSION_FACTOR(Source, Destination, type_, value_) \
0066 namespace boost { \
0067 namespace units { \
0068 template<> \
0069 struct select_base_unit_converter< \
0070 unscale<Source>::type, \
0071 unscale<reduce_unit<Destination::unit_type>::type>::type \
0072 > \
0073 { \
0074 typedef Source source_type; \
0075 typedef reduce_unit<Destination::unit_type>::type destination_type; \
0076 }; \
0077 template<> \
0078 struct base_unit_converter<Source, reduce_unit<Destination::unit_type>::type> \
0079 { \
0080 BOOST_STATIC_CONSTEXPR bool is_defined = true; \
0081 typedef type_ type; \
0082 static BOOST_CONSTEXPR type value() { return(value_); } \
0083 }; \
0084 } \
0085 } \
0086 void boost_units_require_semicolon()
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 #define BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE(Params, Source, Destination, type_, value_) \
0098 namespace boost { \
0099 namespace units { \
0100 template<BOOST_PP_SEQ_ENUM(Params)> \
0101 struct base_unit_converter< \
0102 Source, \
0103 BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Destination, typename Source::dimension_type)\
0104 > \
0105 { \
0106 BOOST_STATIC_CONSTEXPR bool is_defined = true; \
0107 typedef type_ type; \
0108 static BOOST_CONSTEXPR type value() { return(value_); } \
0109 }; \
0110 } \
0111 } \
0112 void boost_units_require_semicolon()
0113
0114
0115
0116
0117
0118 #define BOOST_UNITS_DEFAULT_CONVERSION(Source, Dest) \
0119 namespace boost { \
0120 namespace units { \
0121 template<> \
0122 struct unscaled_get_default_conversion<unscale<Source>::type> \
0123 { \
0124 BOOST_STATIC_CONSTEXPR bool is_defined = true; \
0125 typedef Dest::unit_type type; \
0126 }; \
0127 } \
0128 } \
0129 void boost_units_require_semicolon()
0130
0131
0132
0133
0134
0135
0136
0137 #define BOOST_UNITS_DEFAULT_CONVERSION_TEMPLATE(Params, Source, Dest) \
0138 namespace boost { \
0139 namespace units { \
0140 template<BOOST_PP_SEQ_ENUM(Params)> \
0141 struct unscaled_get_default_conversion<Source> \
0142 { \
0143 BOOST_STATIC_CONSTEXPR bool is_defined = true; \
0144 typedef typename Dest::unit_type type; \
0145 }; \
0146 } \
0147 } \
0148 void boost_units_require_semicolon()
0149
0150
0151
0152
0153
0154
0155 #define BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(namespace_, name_, name_string_, symbol_string_, factor, unit, id)\
0156 namespace boost { \
0157 namespace units { \
0158 namespace namespace_ { \
0159 struct name_ ## _base_unit \
0160 : base_unit<name_ ## _base_unit, unit::dimension_type, id> { \
0161 static BOOST_CONSTEXPR const char* name() { return(name_string_); } \
0162 static BOOST_CONSTEXPR const char* symbol() { return(symbol_string_); } \
0163 }; \
0164 } \
0165 } \
0166 } \
0167 BOOST_UNITS_DEFINE_CONVERSION_FACTOR(namespace_::name_ ## _base_unit, unit, double, factor); \
0168 BOOST_UNITS_DEFAULT_CONVERSION(namespace_::name_ ## _base_unit, unit)
0169
0170
0171 template<class FromUnit,class ToUnit>
0172 inline
0173 BOOST_CONSTEXPR
0174 typename one_to_double_type<
0175 typename detail::conversion_factor_helper<FromUnit, ToUnit>::type
0176 >::type
0177 conversion_factor(const FromUnit&,const ToUnit&)
0178 {
0179 return(one_to_double(detail::conversion_factor_helper<FromUnit, ToUnit>::value()));
0180 }
0181
0182 }
0183
0184 }
0185
0186 #endif