Warning, file /include/boost/units/dim.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_DIM_HPP
0012 #define BOOST_UNITS_DIM_HPP
0013
0014 #include <boost/static_assert.hpp>
0015
0016 #include <boost/type_traits/is_same.hpp>
0017
0018 #include <boost/mpl/arithmetic.hpp>
0019
0020 #include <boost/units/config.hpp>
0021 #include <boost/units/static_rational.hpp>
0022 #include <boost/units/detail/dim_impl.hpp>
0023
0024
0025
0026
0027 namespace boost {
0028
0029 namespace units {
0030
0031 namespace detail {
0032
0033 struct dim_tag { };
0034
0035 }
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 template<typename T,typename V>
0061 struct dim
0062 {
0063 typedef dim type;
0064 typedef detail::dim_tag tag;
0065 typedef T tag_type;
0066 typedef V value_type;
0067 };
0068
0069 }
0070
0071 }
0072
0073 #if BOOST_UNITS_HAS_BOOST_TYPEOF
0074
0075 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
0076
0077 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dim, 2)
0078
0079 #endif
0080
0081 #ifndef BOOST_UNITS_DOXYGEN
0082
0083 namespace boost {
0084
0085 namespace mpl {
0086
0087
0088
0089 template<>
0090 struct plus_impl<boost::units::detail::dim_tag,boost::units::detail::dim_tag>
0091 {
0092 template<class T0, class T1>
0093 struct apply
0094 {
0095 BOOST_STATIC_ASSERT((boost::is_same<typename T0::tag_type,typename T1::tag_type>::value == true));
0096 typedef boost::units::dim<typename T0::tag_type, typename mpl::plus<typename T0::value_type, typename T1::value_type>::type> type;
0097 };
0098 };
0099
0100 template<>
0101 struct minus_impl<boost::units::detail::dim_tag,boost::units::detail::dim_tag>
0102 {
0103 template<class T0, class T1>
0104 struct apply
0105 {
0106 BOOST_STATIC_ASSERT((boost::is_same<typename T0::tag_type,typename T1::tag_type>::value == true));
0107 typedef boost::units::dim<typename T0::tag_type, typename mpl::minus<typename T0::value_type, typename T1::value_type>::type> type;
0108 };
0109 };
0110
0111 template<>
0112 struct times_impl<boost::units::detail::dim_tag,boost::units::detail::static_rational_tag>
0113 {
0114 template<class T0, class T1>
0115 struct apply
0116 {
0117 typedef boost::units::dim<typename T0::tag_type, typename mpl::times<typename T0::value_type, T1>::type> type;
0118 };
0119 };
0120
0121 template<>
0122 struct times_impl<boost::units::detail::static_rational_tag,boost::units::detail::dim_tag>
0123 {
0124 template<class T0, class T1>
0125 struct apply
0126 {
0127 typedef boost::units::dim<typename T1::tag_type, typename mpl::times<T0, typename T1::value_type>::type> type;
0128 };
0129 };
0130
0131 template<>
0132 struct divides_impl<boost::units::detail::dim_tag,boost::units::detail::static_rational_tag>
0133 {
0134 template<class T0, class T1>
0135 struct apply
0136 {
0137 typedef boost::units::dim<typename T0::tag_type, typename mpl::divides<typename T0::value_type, T1>::type> type;
0138 };
0139 };
0140
0141 template<>
0142 struct divides_impl<boost::units::detail::static_rational_tag,boost::units::detail::dim_tag>
0143 {
0144 template<class T0, class T1>
0145 struct apply
0146 {
0147 typedef boost::units::dim<typename T1::tag_type, typename mpl::divides<T0, typename T1::value_type>::type> type;
0148 };
0149 };
0150
0151 template<>
0152 struct negate_impl<boost::units::detail::dim_tag>
0153 {
0154 template<class T0>
0155 struct apply
0156 {
0157 typedef boost::units::dim<typename T0::tag_type,typename mpl::negate<typename T0::value_type>::type> type;
0158 };
0159 };
0160
0161 }
0162
0163 }
0164
0165 #endif
0166
0167 #endif