Ticket #7075: 7075.patch

File 7075.patch, 3.6 KB (added by 1czajnik@…, 10 years ago)
  • detail/mpl/gcd.hpp

     
    2020#include <boost/mpl/aux_/config/eti.hpp>
    2121#include <boost/mpl/aux_/config/integral.hpp>
    2222#include <boost/mpl/aux_/config/static_constant.hpp>
     23#include <boost/mpl/aux_/config/dependent_nttp.hpp>
     24#include <boost/cstdint.hpp>
    2325
    2426#if    !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \
    2527    && !defined(BOOST_MPL_PREPROCESSING_MODE) \
     
    6567{
    6668};
    6769
     70// Workaround for error: the type of partial specialization template parameter constant "n2"
     71// depends on another template parameter
     72// Note: this solution could be wrong for n1 or n2 = [2**63 .. 2**64-1]
     73#if defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
     74
    6875namespace aux {
     76        template< typename T1, boost::intmax_t n1, bool n1_is_0
     77                , typename T2, boost::intmax_t n2, bool n2_is_0 >
     78    struct gcd_aux
     79        : gcd_aux<T2, n2, n2==0, T1, (n1 % n2), (n1 % n2)==0>
     80    {};
     81
     82    template <typename T1, boost::intmax_t n1, typename T2, boost::intmax_t n2>
     83    struct gcd_aux<T1, n1, false, T2, n2, true> : integral_c<T1, n1>
     84    {};
     85
     86    template <typename T1, boost::intmax_t n1, typename T2, boost::intmax_t n2, bool C>
     87    struct gcd_aux<T1, n1, true, T2, n2, C> : integral_c<T2, n2>
     88    {};
     89}
     90
     91#else // defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
     92
     93namespace aux {
    6994    template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 >
    7095    struct gcd_aux
    7196 
     
    84109    {};
    85110}
    86111
     112#endif // defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
     113
    87114template<>
    88115struct gcd_impl<integral_c_tag, integral_c_tag>
    89116{
  • detail/mpl/lcm.hpp

     
    2020#include <boost/mpl/aux_/config/eti.hpp>
    2121#include <boost/mpl/aux_/config/integral.hpp>
    2222#include <boost/mpl/aux_/config/static_constant.hpp>
     23#include <boost/mpl/aux_/config/dependent_nttp.hpp>
     24#include <boost/cstdint.hpp>
    2325
    2426#if    !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \
    2527    && !defined(BOOST_MPL_PREPROCESSING_MODE) \
     
    6668};
    6769
    6870
     71// Workaround for error: the type of partial specialization template parameter constant "n2"
     72// depends on another template parameter
     73// Note: this solution could be wrong for n1 or n2 = [2**63 .. 2**64-1]
     74#if defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
     75
    6976namespace aux {
     77        template< typename T1, boost::intmax_t n1, bool n1_is_0
     78                        , typename T2, boost::intmax_t n2, bool n2_is_0 >
     79    struct lcm_aux
     80        : abs<integral_c< typename aux::largest_int<T1, T2>::type,
     81            ( n1 / gcd<integral_c<T1,n1>, integral_c<T2,n2> >::value * n2 )
     82        > >
     83    {};
     84
     85    template <typename T1, boost::intmax_t n1, typename T2, boost::intmax_t n2>
     86    struct lcm_aux<T1, n1, false, T2, n2, true> : integral_c<T2, 0>
     87    {};
     88
     89    template <typename T1, boost::intmax_t n1, typename T2, boost::intmax_t n2, bool C>
     90    struct lcm_aux<T1, n1, true, T2, n2, C> : integral_c<T1, 0>
     91    {};
     92}
     93
     94#else // defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
     95
     96namespace aux {
    7097    template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 >
    7198    struct lcm_aux
    7299 
     
    84111    {};
    85112}
    86113
     114#endif // defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
     115
    87116template<>
    88117struct lcm_impl<integral_c_tag, integral_c_tag>
    89118{