Warning, file /include/boost/units/operators.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_OPERATORS_HPP
0012 #define BOOST_UNITS_OPERATORS_HPP
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include <boost/static_assert.hpp>
0026 #include <boost/type_traits/is_same.hpp>
0027
0028 #include <boost/units/config.hpp>
0029
0030 namespace boost {
0031 namespace units {
0032
0033 #if BOOST_UNITS_HAS_TYPEOF
0034
0035 #ifndef BOOST_UNITS_DOXYGEN
0036
0037
0038 namespace typeof_ {
0039
0040
0041 template<class T> T make();
0042
0043 }
0044
0045 #endif
0046
0047 #if (BOOST_UNITS_HAS_BOOST_TYPEOF)
0048
0049 template<typename X> struct unary_plus_typeof_helper
0050 {
0051 BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (+typeof_::make<X>()))
0052 typedef typename nested::type type;
0053 };
0054
0055 template<typename X> struct unary_minus_typeof_helper
0056 {
0057 BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (-typeof_::make<X>()))
0058 typedef typename nested::type type;
0059 };
0060
0061 template<typename X,typename Y> struct add_typeof_helper
0062 {
0063 BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (typeof_::make<X>()+typeof_::make<Y>()))
0064 typedef typename nested::type type;
0065 };
0066
0067 template<typename X,typename Y> struct subtract_typeof_helper
0068 {
0069 BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (typeof_::make<X>()-typeof_::make<Y>()))
0070 typedef typename nested::type type;
0071 };
0072
0073 template<typename X,typename Y> struct multiply_typeof_helper
0074 {
0075 BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (typeof_::make<X>()*typeof_::make<Y>()))
0076 typedef typename nested::type type;
0077 };
0078
0079 template<typename X,typename Y> struct divide_typeof_helper
0080 {
0081 BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (typeof_::make<X>()/typeof_::make<Y>()))
0082 typedef typename nested::type type;
0083 };
0084
0085 #elif (BOOST_UNITS_HAS_MWERKS_TYPEOF)
0086
0087 template<typename X> struct unary_plus_typeof_helper { typedef __typeof__((+typeof_::make<X>())) type; };
0088 template<typename X> struct unary_minus_typeof_helper { typedef __typeof__((-typeof_::make<X>())) type; };
0089
0090 template<typename X,typename Y> struct add_typeof_helper { typedef __typeof__((typeof_::make<X>()+typeof_::make<Y>())) type; };
0091 template<typename X,typename Y> struct subtract_typeof_helper { typedef __typeof__((typeof_::make<X>()-typeof_::make<Y>())) type; };
0092 template<typename X,typename Y> struct multiply_typeof_helper { typedef __typeof__((typeof_::make<X>()*typeof_::make<Y>())) type; };
0093 template<typename X,typename Y> struct divide_typeof_helper { typedef __typeof__((typeof_::make<X>()/typeof_::make<Y>())) type; };
0094
0095 #elif (BOOST_UNITS_HAS_GNU_TYPEOF) || defined(BOOST_UNITS_DOXYGEN)
0096
0097 template<typename X> struct unary_plus_typeof_helper { typedef typeof((+typeof_::make<X>())) type; };
0098 template<typename X> struct unary_minus_typeof_helper { typedef typeof((-typeof_::make<X>())) type; };
0099
0100 template<typename X,typename Y> struct add_typeof_helper { typedef typeof((typeof_::make<X>()+typeof_::make<Y>())) type; };
0101 template<typename X,typename Y> struct subtract_typeof_helper { typedef typeof((typeof_::make<X>()-typeof_::make<Y>())) type; };
0102 template<typename X,typename Y> struct multiply_typeof_helper { typedef typeof((typeof_::make<X>()*typeof_::make<Y>())) type; };
0103 template<typename X,typename Y> struct divide_typeof_helper { typedef typeof((typeof_::make<X>()/typeof_::make<Y>())) type; };
0104
0105 #endif
0106
0107 #else
0108
0109 template<typename X> struct unary_plus_typeof_helper { typedef X type; };
0110 template<typename X> struct unary_minus_typeof_helper { typedef X type; };
0111
0112 template<typename X,typename Y> struct add_typeof_helper { BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
0113 template<typename X,typename Y> struct subtract_typeof_helper { BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
0114 template<typename X,typename Y> struct multiply_typeof_helper { BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
0115 template<typename X,typename Y> struct divide_typeof_helper { BOOST_STATIC_ASSERT((is_same<X,Y>::value == true)); typedef X type; };
0116
0117 #endif
0118
0119 template<typename X,typename Y> struct power_typeof_helper;
0120 template<typename X,typename Y> struct root_typeof_helper;
0121
0122 #ifdef BOOST_UNITS_DOXYGEN
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132 template<typename BaseType, typename Exponent>
0133 struct power_typeof_helper
0134 {
0135
0136 typedef detail::unspecified type;
0137
0138 static BOOST_CONSTEXPR type value(const BaseType& base);
0139 };
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 template<typename Radicand, typename Index>
0150 struct root_typeof_helper
0151 {
0152
0153 typedef detail::unspecified type;
0154
0155 static BOOST_CONSTEXPR type value(const Radicand& base);
0156 };
0157
0158 #endif
0159
0160 }
0161
0162 }
0163
0164 #endif