annotate DEPENDENCIES/generic/include/boost/units/pow.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and
Chris@16 2 // unit/quantity manipulation and conversion
Chris@16 3 //
Chris@16 4 // Copyright (C) 2003-2008 Matthias Christian Schabel
Chris@16 5 // Copyright (C) 2008 Steven Watanabe
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 8 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 9 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 10
Chris@16 11 #ifndef BOOST_UNITS_POW_HPP
Chris@16 12 #define BOOST_UNITS_POW_HPP
Chris@16 13
Chris@16 14 #include <boost/math_fwd.hpp>
Chris@16 15 #include <boost/type_traits/is_integral.hpp>
Chris@16 16
Chris@16 17 #include <boost/units/operators.hpp>
Chris@16 18 #include <boost/units/static_rational.hpp>
Chris@16 19 #include <boost/units/detail/static_rational_power.hpp>
Chris@16 20
Chris@16 21 /// \file
Chris@16 22 /// \brief Raise values to exponents known at compile-time.
Chris@16 23
Chris@16 24 namespace boost {
Chris@16 25
Chris@16 26 namespace units {
Chris@16 27
Chris@16 28 /// raise a value to a @c static_rational power.
Chris@16 29 template<class Rat,class Y>
Chris@16 30 inline typename power_typeof_helper<Y,Rat>::type
Chris@16 31 pow(const Y& x)
Chris@16 32 {
Chris@16 33 return power_typeof_helper<Y,Rat>::value(x);
Chris@16 34 }
Chris@16 35
Chris@16 36 /// raise a value to an integer power.
Chris@16 37 template<long N,class Y>
Chris@16 38 inline typename power_typeof_helper<Y,static_rational<N> >::type
Chris@16 39 pow(const Y& x)
Chris@16 40 {
Chris@16 41 return power_typeof_helper<Y,static_rational<N> >::value(x);
Chris@16 42 }
Chris@16 43
Chris@16 44 #ifndef BOOST_UNITS_DOXYGEN
Chris@16 45
Chris@16 46 /// raise @c T to a @c static_rational power.
Chris@16 47 template<class T, long N,long D>
Chris@16 48 struct power_typeof_helper<T, static_rational<N,D> >
Chris@16 49 {
Chris@16 50 typedef typename mpl::if_<boost::is_integral<T>, double, T>::type internal_type;
Chris@16 51 typedef detail::static_rational_power_impl<static_rational<N, D>, internal_type> impl;
Chris@16 52 typedef typename impl::type type;
Chris@16 53
Chris@16 54 static type value(const T& x)
Chris@16 55 {
Chris@16 56 return impl::call(x);
Chris@16 57 }
Chris@16 58 };
Chris@16 59
Chris@16 60 /// raise @c float to a @c static_rational power.
Chris@16 61 template<long N,long D>
Chris@16 62 struct power_typeof_helper<float, static_rational<N,D> >
Chris@16 63 {
Chris@16 64 // N.B. pathscale doesn't accept inheritance for some reason.
Chris@16 65 typedef power_typeof_helper<double, static_rational<N,D> > base;
Chris@16 66 typedef typename base::type type;
Chris@16 67 static type value(const double& x)
Chris@16 68 {
Chris@16 69 return base::value(x);
Chris@16 70 }
Chris@16 71 };
Chris@16 72
Chris@16 73 #endif
Chris@16 74
Chris@16 75 /// take the @c static_rational root of a value.
Chris@16 76 template<class Rat,class Y>
Chris@16 77 typename root_typeof_helper<Y,Rat>::type
Chris@16 78 root(const Y& x)
Chris@16 79 {
Chris@16 80 return root_typeof_helper<Y,Rat>::value(x);
Chris@16 81 }
Chris@16 82
Chris@16 83 /// take the integer root of a value.
Chris@16 84 template<long N,class Y>
Chris@16 85 typename root_typeof_helper<Y,static_rational<N> >::type
Chris@16 86 root(const Y& x)
Chris@16 87 {
Chris@16 88 return root_typeof_helper<Y,static_rational<N> >::value(x);
Chris@16 89 }
Chris@16 90
Chris@16 91 #ifndef BOOST_UNITS_DOXYGEN
Chris@16 92
Chris@16 93 /// take @c static_rational root of an @c T
Chris@16 94 template<class T, long N,long D>
Chris@16 95 struct root_typeof_helper<T,static_rational<N,D> >
Chris@16 96 {
Chris@16 97 // N.B. pathscale doesn't accept inheritance for some reason.
Chris@16 98 typedef power_typeof_helper<T, static_rational<D,N> > base;
Chris@16 99 typedef typename base::type type;
Chris@16 100 static type value(const T& x)
Chris@16 101 {
Chris@16 102 return(base::value(x));
Chris@16 103 }
Chris@16 104 };
Chris@16 105
Chris@16 106 #endif
Chris@16 107
Chris@16 108 } // namespace units
Chris@16 109
Chris@16 110 } // namespace boost
Chris@16 111
Chris@16 112 #endif // BOOST_UNITS_STATIC_RATIONAL_HPP