Chris@16: //////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // Copyright Vicente J. Botet Escriba 2010 Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/mpl for documentation. Chris@16: // Chris@16: //////////////////////////////////////////////////////////////////// Chris@16: #ifndef BOOST_MPL_LCM_HPP_INCLUDED Chris@16: #define BOOST_MPL_LCM_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \ Chris@16: && !defined(BOOST_MPL_PREPROCESSING_MODE) \ Chris@101: && !defined(__CUDACC__) \ Chris@16: && ( defined(BOOST_MSVC) \ Chris@16: || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \ Chris@16: ) Chris@16: Chris@16: # define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2 Chris@16: Chris@16: #endif Chris@16: Chris@16: namespace boost { namespace mpl { Chris@16: Chris@16: template< typename Tag1, typename Tag2 > struct lcm_impl; Chris@16: Chris@16: template< typename T > struct lcm_tag Chris@16: { Chris@16: typedef typename T::tag type; Chris@16: }; Chris@16: Chris@16: template< Chris@16: typename BOOST_MPL_AUX_NA_PARAM(N1) Chris@16: , typename BOOST_MPL_AUX_NA_PARAM(N2) Chris@16: > Chris@16: struct lcm Chris@16: : lcm_impl< Chris@16: typename lcm_tag::type Chris@16: , typename lcm_tag::type Chris@16: >::template apply::type Chris@16: { Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT(2, lcm, (N1, N2)) Chris@16: }; Chris@16: Chris@16: BOOST_MPL_AUX_NA_SPEC(2, lcm) Chris@16: Chris@16: template< Chris@16: typename T Chris@16: , T n1 Chris@16: , T n2 Chris@16: > Chris@16: struct lcm_c Chris@16: : lcm,integral_c > Chris@16: { Chris@16: }; Chris@16: Chris@16: Chris@16: namespace aux { Chris@16: // Workaround for error: the type of partial specialization template parameter constant "n2" Chris@16: // depends on another template parameter Chris@16: // Note: this solution could be wrong for n1 or n2 = [2**63 .. 2**64-1] Chris@16: #if defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC) Chris@16: template< typename T1, boost::intmax_t n1, bool n1_is_0 Chris@16: , typename T2, boost::intmax_t n2, bool n2_is_0 > Chris@16: struct lcm_aux Chris@16: : abs::type, Chris@16: ( n1 / gcd, integral_c >::value * n2 ) Chris@16: > > Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct lcm_aux : integral_c Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct lcm_aux : integral_c Chris@16: {}; Chris@16: Chris@16: Chris@16: #else // defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC) Chris@16: Chris@16: Chris@16: template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 > Chris@16: struct lcm_aux Chris@16: Chris@16: : abs::type, Chris@16: ( n1 / gcd, integral_c >::value * n2 ) Chris@16: > > Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct lcm_aux : integral_c Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct lcm_aux : integral_c Chris@16: {}; Chris@16: #endif // defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC) Chris@16: } Chris@16: Chris@16: template<> Chris@16: struct lcm_impl Chris@16: { Chris@16: template< typename N1, typename N2 > struct apply Chris@16: : abs > Chris@16: { Chris@16: }; Chris@16: }; Chris@16: Chris@16: }} Chris@16: Chris@16: #endif // BOOST_MPL_LCM_HPP_INCLUDED