File indexing completed on 2025-01-18 09:53:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_UNITS_DETAIL_ONE_HPP
0012 #define BOOST_UNITS_DETAIL_ONE_HPP
0013
0014 #include <boost/units/operators.hpp>
0015
0016 namespace boost {
0017
0018 namespace units {
0019
0020 struct one { BOOST_CONSTEXPR one() {} };
0021
0022
0023 inline BOOST_CONSTEXPR one make_one() {
0024 return(one());
0025 }
0026
0027 template<class T>
0028 struct multiply_typeof_helper<one, T>
0029 {
0030 typedef T type;
0031 };
0032
0033 template<class T>
0034 struct multiply_typeof_helper<T, one>
0035 {
0036 typedef T type;
0037 };
0038
0039 template<>
0040 struct multiply_typeof_helper<one, one>
0041 {
0042 typedef one type;
0043 };
0044
0045 template<class T>
0046 inline BOOST_CONSTEXPR T operator*(const one&, const T& t)
0047 {
0048 return(t);
0049 }
0050
0051 template<class T>
0052 inline BOOST_CONSTEXPR T operator*(const T& t, const one&)
0053 {
0054 return(t);
0055 }
0056
0057 inline BOOST_CONSTEXPR one operator*(const one&, const one&)
0058 {
0059 return(one());
0060 }
0061
0062 template<class T>
0063 struct divide_typeof_helper<T, one>
0064 {
0065 typedef T type;
0066 };
0067
0068 template<class T>
0069 struct divide_typeof_helper<one, T>
0070 {
0071 typedef T type;
0072 };
0073
0074 template<>
0075 struct divide_typeof_helper<one, one>
0076 {
0077 typedef one type;
0078 };
0079
0080 template<class T>
0081 inline BOOST_CONSTEXPR T operator/(const T& t, const one&)
0082 {
0083 return(t);
0084 }
0085
0086 template<class T>
0087 inline BOOST_CONSTEXPR T operator/(const one&, const T& t)
0088 {
0089 return(1/t);
0090 }
0091
0092 inline BOOST_CONSTEXPR one operator/(const one&, const one&)
0093 {
0094 return(one());
0095 }
0096
0097 template<class T>
0098 inline BOOST_CONSTEXPR bool operator>(const boost::units::one&, const T& t) {
0099 return(1 > t);
0100 }
0101
0102 template<class T>
0103 BOOST_CONSTEXPR T one_to_double(const T& t) { return t; }
0104
0105 inline BOOST_CONSTEXPR double one_to_double(const one&) { return 1.0; }
0106
0107 template<class T>
0108 struct one_to_double_type { typedef T type; };
0109
0110 template<>
0111 struct one_to_double_type<one> { typedef double type; };
0112
0113 }
0114
0115 }
0116
0117 #endif