diff --git a/include/boost/ratio/detail/mpl/abs.hpp b/include/boost/ratio/detail/mpl/abs.hpp new file mode 100644 index 0000000..8d6ef48 --- /dev/null +++ b/include/boost/ratio/detail/mpl/abs.hpp @@ -0,0 +1,79 @@ +//////////////////////////////////////////////////////////////////// +// +// Copyright Vicente J. Botet Escriba 2010 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. +// +//////////////////////////////////////////////////////////////////// +#ifndef BOOST_MPL_ABS_HPP_INCLUDED +#define BOOST_MPL_ABS_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace mpl { + +template< typename Tag > struct abs_impl; + +template< typename T > struct abs_tag +{ + typedef typename T::tag type; +}; + +template< + typename BOOST_MPL_AUX_NA_PARAM(N) + > +struct abs + : abs_impl< + typename abs_tag::type + >::template apply::type +{ + BOOST_MPL_AUX_LAMBDA_SUPPORT(1, abs, (N)) +}; + +BOOST_MPL_AUX_NA_SPEC(1, abs) + +template< + typename T + , T n1 + > +struct abs_c + : abs > +{ +}; + +#if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) +namespace aux { +template< typename T, T n > struct abs_wknd +{ + BOOST_STATIC_CONSTANT(T, value = (n < 0 ? -n : n)); + typedef integral_c type; +}; +} +#endif + +template<> +struct abs_impl +{ +#if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) + template< typename N > struct apply + : aux::abs_wknd< typename N::value_type, N::value > +#else + template< typename N > struct apply + : integral_c< typename N::value_type, ((N::value < 0) ? (-N::value) : N::value ) > +#endif + { + }; +}; + +}} + +#endif // BOOST_MPL_ABS_HPP_INCLUDED diff --git a/include/boost/ratio/detail/mpl/gcd.hpp b/include/boost/ratio/detail/mpl/gcd.hpp new file mode 100644 index 0000000..22d5e2f --- /dev/null +++ b/include/boost/ratio/detail/mpl/gcd.hpp @@ -0,0 +1,89 @@ +//////////////////////////////////////////////////////////////////// +// +// Copyright Vicente J. Botet Escriba 2010 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. +// +//////////////////////////////////////////////////////////////////// +#ifndef BOOST_MPL_GCD_HPP_INCLUDED +#define BOOST_MPL_GCD_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace mpl { + +template< typename Tag1, typename Tag2 > struct gcd_impl; + +template< typename T > struct gcd_tag +{ + typedef typename T::tag type; +}; + +template< + typename BOOST_MPL_AUX_NA_PARAM(N1) + , typename BOOST_MPL_AUX_NA_PARAM(N2) + > +struct gcd + : gcd_impl< + typename gcd_tag::type + , typename gcd_tag::type + >::template apply::type +{ + BOOST_MPL_AUX_LAMBDA_SUPPORT(2, gcd, (N1, N2)) +}; + +BOOST_MPL_AUX_NA_SPEC(2, gcd) + +template< + typename T + , T n1 + , T n2 + > +struct gcd_c + : gcd,integral_c > +{ +}; + +namespace aux { + template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 > + struct gcd_aux + + : gcd_aux::type, + //~ T1, + (n1 % n2), (n1 % n2)==0> + {}; + + template + struct gcd_aux : integral_c + {}; + + template + struct gcd_aux : integral_c + {}; +} + +template<> +struct gcd_impl +{ + template< typename N1, typename N2 > struct apply + : abs > + { + }; +}; + +}} + +#endif // BOOST_MPL_GCD_HPP_INCLUDED diff --git a/include/boost/ratio/detail/mpl/lcm.hpp b/include/boost/ratio/detail/mpl/lcm.hpp new file mode 100644 index 0000000..80d3b98 --- /dev/null +++ b/include/boost/ratio/detail/mpl/lcm.hpp @@ -0,0 +1,89 @@ +//////////////////////////////////////////////////////////////////// +// +// Copyright Vicente J. Botet Escriba 2010 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. +// +//////////////////////////////////////////////////////////////////// +#ifndef BOOST_MPL_LCM_HPP_INCLUDED +#define BOOST_MPL_LCM_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace mpl { + +template< typename Tag1, typename Tag2 > struct lcm_impl; + +template< typename T > struct lcm_tag +{ + typedef typename T::tag type; +}; + +template< + typename BOOST_MPL_AUX_NA_PARAM(N1) + , typename BOOST_MPL_AUX_NA_PARAM(N2) + > +struct lcm + : lcm_impl< + typename lcm_tag::type + , typename lcm_tag::type + >::template apply::type +{ + BOOST_MPL_AUX_LAMBDA_SUPPORT(2, lcm, (N1, N2)) +}; + +BOOST_MPL_AUX_NA_SPEC(2, lcm) + +template< + typename T + , T n1 + , T n2 + > +struct lcm_c + : lcm,integral_c > +{ +}; + + +namespace aux { + template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 > + struct lcm_aux + + : abs::type, + ( n1 / gcd, integral_c >::value * n2 ) + > > + {}; + + template + struct lcm_aux : integral_c + {}; + + template + struct lcm_aux : integral_c + {}; +} + +template<> +struct lcm_impl +{ + template< typename N1, typename N2 > struct apply + : abs > + { + }; +}; + +}} + +#endif // BOOST_MPL_LCM_HPP_INCLUDED diff --git a/include/boost/ratio/detail/mpl/sign.hpp b/include/boost/ratio/detail/mpl/sign.hpp new file mode 100644 index 0000000..31ef57b --- /dev/null +++ b/include/boost/ratio/detail/mpl/sign.hpp @@ -0,0 +1,79 @@ +//////////////////////////////////////////////////////////////////// +// +// Copyright Vicente J. Botet Escriba 2010 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. +// +//////////////////////////////////////////////////////////////////// +#ifndef BOOST_MPL_SIGN_HPP_INCLUDED +#define BOOST_MPL_SIGN_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace mpl { + +template< typename Tag > struct sign_impl; + +template< typename T > struct sign_tag +{ + typedef typename T::tag type; +}; + +template< + typename BOOST_MPL_AUX_NA_PARAM(N) + > +struct sign + : sign_impl< + typename sign_tag::type + >::template apply::type +{ + BOOST_MPL_AUX_LAMBDA_SUPPORT(1, sign, (N)) +}; + +BOOST_MPL_AUX_NA_SPEC(1, sign) + +template< + typename T + , T n1 + > +struct sign_c + : sign > +{ +}; + +#if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) +namespace aux { +template< typename T, T n > struct sign_wknd +{ + BOOST_STATIC_CONSTANT(T, value = (n == 0 ? 0 : (n < 0 ? -1 : 1))); + typedef integral_c type; +}; +} +#endif + +template<> +struct sign_impl +{ +#if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) + template< typename N > struct apply + : aux::sign_wknd< typename N::value_type, N::value > +#else + template< typename N > struct apply + : integral_c< typename N::value_type, (N::value == 0 ? 0 : (N::value < 0 ? -1 : 1)) > +#endif + { + }; +}; + +}} + +#endif // BOOST_MPL_SIGN_HPP_INCLUDED diff --git a/include/boost/ratio/detail/overflow_helpers.hpp b/include/boost/ratio/detail/overflow_helpers.hpp index fcac882..6e3fc94 100644 --- a/include/boost/ratio/detail/overflow_helpers.hpp +++ b/include/boost/ratio/detail/overflow_helpers.hpp @@ -32,14 +32,8 @@ time2_demo contained this comment: #ifndef BOOST_RATIO_DETAIL_RATIO_OPERATIONS_HPP #define BOOST_RATIO_DETAIL_RATIO_OPERATIONS_HPP -//~ #include -//~ #include -//~ #include -//~ #include -#include -#include -//~ #include -//~ #include +#include +#include #include #include #include diff --git a/include/boost/ratio/ratio.hpp b/include/boost/ratio/ratio.hpp index 7c92738..3d198a2 100644 --- a/include/boost/ratio/ratio.hpp +++ b/include/boost/ratio/ratio.hpp @@ -33,10 +33,10 @@ time2_demo contained this comment: #define BOOST_RATIO_RATIO_HPP #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include