Warning, file /include/boost/units/absolute.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
0012
0013
0014
0015
0016
0017 #ifndef BOOST_UNITS_ABSOLUTE_HPP
0018 #define BOOST_UNITS_ABSOLUTE_HPP
0019
0020 #include <iosfwd>
0021
0022 #include <boost/units/detail/absolute_impl.hpp>
0023
0024 namespace boost {
0025
0026 namespace units {
0027
0028
0029
0030
0031
0032
0033 template<class Y>
0034 class absolute
0035 {
0036 public:
0037 typedef absolute<Y> this_type;
0038 typedef Y value_type;
0039
0040 BOOST_CONSTEXPR absolute() : val_() { }
0041 BOOST_CONSTEXPR absolute(const value_type& val) : val_(val) { }
0042 BOOST_CONSTEXPR absolute(const this_type& source) : val_(source.val_) { }
0043
0044 BOOST_CXX14_CONSTEXPR this_type& operator=(const this_type& source) { val_ = source.val_; return *this; }
0045
0046 BOOST_CONSTEXPR const value_type& value() const { return val_; }
0047
0048 BOOST_CXX14_CONSTEXPR const this_type& operator+=(const value_type& val) { val_ += val; return *this; }
0049 BOOST_CXX14_CONSTEXPR const this_type& operator-=(const value_type& val) { val_ -= val; return *this; }
0050
0051 private:
0052 value_type val_;
0053 };
0054
0055
0056 template<class Y>
0057 BOOST_CONSTEXPR absolute<Y> operator+(const absolute<Y>& aval,const Y& rval)
0058 {
0059 return absolute<Y>(aval.value()+rval);
0060 }
0061
0062
0063 template<class Y>
0064 BOOST_CONSTEXPR absolute<Y> operator+(const Y& rval,const absolute<Y>& aval)
0065 {
0066 return absolute<Y>(aval.value()+rval);
0067 }
0068
0069
0070 template<class Y>
0071 BOOST_CONSTEXPR absolute<Y> operator-(const absolute<Y>& aval,const Y& rval)
0072 {
0073 return absolute<Y>(aval.value()-rval);
0074 }
0075
0076
0077 template<class Y>
0078 BOOST_CONSTEXPR Y operator-(const absolute<Y>& aval1,const absolute<Y>& aval2)
0079 {
0080 return Y(aval1.value()-aval2.value());
0081 }
0082
0083
0084 template<class D, class S, class T>
0085 BOOST_CONSTEXPR quantity<absolute<unit<D, S> >, T> operator*(const T& t, const absolute<unit<D, S> >&)
0086 {
0087 return(quantity<absolute<unit<D, S> >, T>::from_value(t));
0088 }
0089
0090
0091 template<class D, class S, class T>
0092 BOOST_CONSTEXPR quantity<absolute<unit<D, S> >, T> operator*(const absolute<unit<D, S> >&, const T& t)
0093 {
0094 return(quantity<absolute<unit<D, S> >, T>::from_value(t));
0095 }
0096
0097
0098 template<class Char, class Traits, class Y>
0099 std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os,const absolute<Y>& aval)
0100 {
0101
0102 os << "absolute " << aval.value();
0103
0104 return os;
0105 }
0106
0107 }
0108
0109 }
0110
0111 #if BOOST_UNITS_HAS_BOOST_TYPEOF
0112
0113 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
0114
0115 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::absolute, (class))
0116
0117 #endif
0118
0119 namespace boost {
0120
0121 namespace units {
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 #define BOOST_UNITS_DEFINE_CONVERSION_OFFSET(From, To, type_, value_) \
0134 namespace boost { \
0135 namespace units { \
0136 template<> \
0137 struct affine_conversion_helper< \
0138 reduce_unit<From::unit_type>::type, \
0139 reduce_unit<To::unit_type>::type> \
0140 { \
0141 BOOST_STATIC_CONSTEXPR bool is_defined = true; \
0142 typedef type_ type; \
0143 static BOOST_CONSTEXPR type value() { return(value_); } \
0144 }; \
0145 } \
0146 } \
0147 void boost_units_require_semicolon()
0148
0149 }
0150
0151 }
0152
0153 #endif