Warning, file /include/boost/units/pow.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_POW_HPP
0012 #define BOOST_UNITS_POW_HPP
0013
0014 #include <boost/type_traits/is_integral.hpp>
0015
0016 #include <boost/units/operators.hpp>
0017 #include <boost/units/static_rational.hpp>
0018 #include <boost/units/detail/static_rational_power.hpp>
0019
0020
0021
0022
0023 namespace boost {
0024
0025 namespace units {
0026
0027
0028 template<class Rat,class Y>
0029 BOOST_CONSTEXPR
0030 inline typename power_typeof_helper<Y,Rat>::type
0031 pow(const Y& x)
0032 {
0033 return power_typeof_helper<Y,Rat>::value(x);
0034 }
0035
0036
0037 template<long N,class Y>
0038 BOOST_CONSTEXPR
0039 inline typename power_typeof_helper<Y,static_rational<N> >::type
0040 pow(const Y& x)
0041 {
0042 return power_typeof_helper<Y,static_rational<N> >::value(x);
0043 }
0044
0045 #ifndef BOOST_UNITS_DOXYGEN
0046
0047
0048 template<class T, long N,long D>
0049 struct power_typeof_helper<T, static_rational<N,D> >
0050 {
0051 typedef typename mpl::if_<boost::is_integral<T>, double, T>::type internal_type;
0052 typedef detail::static_rational_power_impl<static_rational<N, D>, internal_type> impl;
0053 typedef typename impl::type type;
0054
0055 static BOOST_CONSTEXPR type value(const T& x)
0056 {
0057 return impl::call(x);
0058 }
0059 };
0060
0061
0062 template<long N,long D>
0063 struct power_typeof_helper<float, static_rational<N,D> >
0064 {
0065
0066 typedef power_typeof_helper<double, static_rational<N,D> > base;
0067 typedef typename base::type type;
0068 static BOOST_CONSTEXPR type value(const double& x)
0069 {
0070 return base::value(x);
0071 }
0072 };
0073
0074 #endif
0075
0076
0077 template<class Rat,class Y>
0078 BOOST_CONSTEXPR
0079 typename root_typeof_helper<Y,Rat>::type
0080 root(const Y& x)
0081 {
0082 return root_typeof_helper<Y,Rat>::value(x);
0083 }
0084
0085
0086 template<long N,class Y>
0087 BOOST_CONSTEXPR
0088 typename root_typeof_helper<Y,static_rational<N> >::type
0089 root(const Y& x)
0090 {
0091 return root_typeof_helper<Y,static_rational<N> >::value(x);
0092 }
0093
0094 #ifndef BOOST_UNITS_DOXYGEN
0095
0096
0097 template<class T, long N,long D>
0098 struct root_typeof_helper<T,static_rational<N,D> >
0099 {
0100
0101 typedef power_typeof_helper<T, static_rational<D,N> > base;
0102 typedef typename base::type type;
0103 static BOOST_CONSTEXPR type value(const T& x)
0104 {
0105 return(base::value(x));
0106 }
0107 };
0108
0109 #endif
0110
0111 }
0112
0113 }
0114
0115 #endif