// Copyright (C) 2005 Peder Holt // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_METAMATH_DOUBLE_POWER_HPP #define BOOST_METAMATH_DOUBLE_POWER_HPP #include #include #include #include #include namespace boost { namespace metamath { namespace aux_ { template struct power_impl_double_int { typedef typename mpl::if_< mpl::bool_, N1, meta::one >::type type0; typedef typename mpl::times< type0, typename power_impl_double_int< typename mpl::times::type, (N2>>1) >::type >::type type; }; template struct power_impl_double_int { typedef meta::one type; }; template struct power_impl_int_int { BOOST_STATIC_CONSTANT(int,value0=(N2&1?N1:1)); BOOST_STATIC_CONSTANT(int,value=(value0*power_impl_int_int>1)>::value)); typedef mpl::int_ type; }; template struct power_impl_int_int { BOOST_STATIC_CONSTANT(int,value=1); typedef mpl::int_ type; }; template struct power_impl_int_int<-1,N2> { BOOST_STATIC_CONSTANT(int,value=N2&1?-1:1); typedef mpl::int_ type; }; template<> struct power_impl_int_int<-1,0> { BOOST_STATIC_CONSTANT(int,value=1); typedef mpl::int_ type; }; }//namespace aux_ template struct power_impl; template<> struct power_impl { template struct apply : aux_::power_impl_double_int::type { }; }; template<> struct power_impl { template struct apply : aux_::power_impl_int_int::type { }; }; }} //namespace boost::metamath #endif