123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #ifndef BOOST_UNITS_POW_HPP
- #define BOOST_UNITS_POW_HPP
- #include <boost/type_traits/is_integral.hpp>
- #include <boost/units/operators.hpp>
- #include <boost/units/static_rational.hpp>
- #include <boost/units/detail/static_rational_power.hpp>
- namespace boost {
- namespace units {
- template<class Rat,class Y>
- BOOST_CONSTEXPR
- inline typename power_typeof_helper<Y,Rat>::type
- pow(const Y& x)
- {
- return power_typeof_helper<Y,Rat>::value(x);
- }
- template<long N,class Y>
- BOOST_CONSTEXPR
- inline typename power_typeof_helper<Y,static_rational<N> >::type
- pow(const Y& x)
- {
- return power_typeof_helper<Y,static_rational<N> >::value(x);
- }
- #ifndef BOOST_UNITS_DOXYGEN
- template<class T, long N,long D>
- struct power_typeof_helper<T, static_rational<N,D> >
- {
- typedef typename mpl::if_<boost::is_integral<T>, double, T>::type internal_type;
- typedef detail::static_rational_power_impl<static_rational<N, D>, internal_type> impl;
- typedef typename impl::type type;
-
- static BOOST_CONSTEXPR type value(const T& x)
- {
- return impl::call(x);
- }
- };
- template<long N,long D>
- struct power_typeof_helper<float, static_rational<N,D> >
- {
-
- typedef power_typeof_helper<double, static_rational<N,D> > base;
- typedef typename base::type type;
- static BOOST_CONSTEXPR type value(const double& x)
- {
- return base::value(x);
- }
- };
- #endif
- template<class Rat,class Y>
- BOOST_CONSTEXPR
- typename root_typeof_helper<Y,Rat>::type
- root(const Y& x)
- {
- return root_typeof_helper<Y,Rat>::value(x);
- }
- template<long N,class Y>
- BOOST_CONSTEXPR
- typename root_typeof_helper<Y,static_rational<N> >::type
- root(const Y& x)
- {
- return root_typeof_helper<Y,static_rational<N> >::value(x);
- }
- #ifndef BOOST_UNITS_DOXYGEN
- template<class T, long N,long D>
- struct root_typeof_helper<T,static_rational<N,D> >
- {
-
- typedef power_typeof_helper<T, static_rational<D,N> > base;
- typedef typename base::type type;
- static BOOST_CONSTEXPR type value(const T& x)
- {
- return(base::value(x));
- }
- };
- #endif
- }
- }
- #endif
|