annotate DEPENDENCIES/generic/include/boost/ratio/detail/mpl/lcm.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 ////////////////////////////////////////////////////////////////////
Chris@16 2 //
Chris@16 3 // Copyright Vicente J. Botet Escriba 2010
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0.
Chris@16 6 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 //
Chris@16 9 // See http://www.boost.org/libs/mpl for documentation.
Chris@16 10 //
Chris@16 11 ////////////////////////////////////////////////////////////////////
Chris@16 12 #ifndef BOOST_MPL_LCM_HPP_INCLUDED
Chris@16 13 #define BOOST_MPL_LCM_HPP_INCLUDED
Chris@16 14
Chris@16 15 #include <boost/mpl/integral_c.hpp>
Chris@16 16 #include <boost/ratio/detail/mpl/abs.hpp>
Chris@16 17 #include <boost/mpl/aux_/largest_int.hpp>
Chris@16 18 #include <boost/mpl/aux_/na_spec.hpp>
Chris@16 19 #include <boost/mpl/aux_/lambda_support.hpp>
Chris@16 20 #include <boost/mpl/aux_/config/integral.hpp>
Chris@16 21 #include <boost/mpl/aux_/config/static_constant.hpp>
Chris@16 22 #include <boost/mpl/aux_/config/dependent_nttp.hpp>
Chris@16 23 #include <boost/cstdint.hpp>
Chris@16 24
Chris@16 25 #if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \
Chris@16 26 && !defined(BOOST_MPL_PREPROCESSING_MODE) \
Chris@101 27 && !defined(__CUDACC__) \
Chris@16 28 && ( defined(BOOST_MSVC) \
Chris@16 29 || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \
Chris@16 30 )
Chris@16 31
Chris@16 32 # define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2
Chris@16 33
Chris@16 34 #endif
Chris@16 35
Chris@16 36 namespace boost { namespace mpl {
Chris@16 37
Chris@16 38 template< typename Tag1, typename Tag2 > struct lcm_impl;
Chris@16 39
Chris@16 40 template< typename T > struct lcm_tag
Chris@16 41 {
Chris@16 42 typedef typename T::tag type;
Chris@16 43 };
Chris@16 44
Chris@16 45 template<
Chris@16 46 typename BOOST_MPL_AUX_NA_PARAM(N1)
Chris@16 47 , typename BOOST_MPL_AUX_NA_PARAM(N2)
Chris@16 48 >
Chris@16 49 struct lcm
Chris@16 50 : lcm_impl<
Chris@16 51 typename lcm_tag<N1>::type
Chris@16 52 , typename lcm_tag<N2>::type
Chris@16 53 >::template apply<N1, N2>::type
Chris@16 54 {
Chris@16 55 BOOST_MPL_AUX_LAMBDA_SUPPORT(2, lcm, (N1, N2))
Chris@16 56 };
Chris@16 57
Chris@16 58 BOOST_MPL_AUX_NA_SPEC(2, lcm)
Chris@16 59
Chris@16 60 template<
Chris@16 61 typename T
Chris@16 62 , T n1
Chris@16 63 , T n2
Chris@16 64 >
Chris@16 65 struct lcm_c
Chris@16 66 : lcm<integral_c<T,n1>,integral_c<T,n2> >
Chris@16 67 {
Chris@16 68 };
Chris@16 69
Chris@16 70
Chris@16 71 namespace aux {
Chris@16 72 // Workaround for error: the type of partial specialization template parameter constant "n2"
Chris@16 73 // depends on another template parameter
Chris@16 74 // Note: this solution could be wrong for n1 or n2 = [2**63 .. 2**64-1]
Chris@16 75 #if defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
Chris@16 76 template< typename T1, boost::intmax_t n1, bool n1_is_0
Chris@16 77 , typename T2, boost::intmax_t n2, bool n2_is_0 >
Chris@16 78 struct lcm_aux
Chris@16 79 : abs<integral_c< typename aux::largest_int<T1, T2>::type,
Chris@16 80 ( n1 / gcd<integral_c<T1,n1>, integral_c<T2,n2> >::value * n2 )
Chris@16 81 > >
Chris@16 82 {};
Chris@16 83
Chris@16 84 template <typename T1, boost::intmax_t n1, typename T2, boost::intmax_t n2>
Chris@16 85 struct lcm_aux<T1, n1, false, T2, n2, true> : integral_c<T2, 0>
Chris@16 86 {};
Chris@16 87
Chris@16 88 template <typename T1, boost::intmax_t n1, typename T2, boost::intmax_t n2, bool C>
Chris@16 89 struct lcm_aux<T1, n1, true, T2, n2, C> : integral_c<T1, 0>
Chris@16 90 {};
Chris@16 91
Chris@16 92
Chris@16 93 #else // defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
Chris@16 94
Chris@16 95
Chris@16 96 template< typename T1, T1 n1, bool n1_is_0, typename T2, T2 n2, bool n2_is_0 >
Chris@16 97 struct lcm_aux
Chris@16 98
Chris@16 99 : abs<integral_c< typename aux::largest_int<T1, T2>::type,
Chris@16 100 ( n1 / gcd<integral_c<T1,n1>, integral_c<T2,n2> >::value * n2 )
Chris@16 101 > >
Chris@16 102 {};
Chris@16 103
Chris@16 104 template <typename T1, T1 n1, typename T2, T2 n2>
Chris@16 105 struct lcm_aux<T1, n1, false, T2, n2, true> : integral_c<T2, 0>
Chris@16 106 {};
Chris@16 107
Chris@16 108 template <typename T1, T1 n1, typename T2, T2 n2, bool C>
Chris@16 109 struct lcm_aux<T1, n1, true, T2, n2, C> : integral_c<T1, 0>
Chris@16 110 {};
Chris@16 111 #endif // defined(BOOST_MPL_CFG_NO_DEPENDENT_NONTYPE_PARAMETER_IN_PARTIAL_SPEC)
Chris@16 112 }
Chris@16 113
Chris@16 114 template<>
Chris@16 115 struct lcm_impl<integral_c_tag, integral_c_tag>
Chris@16 116 {
Chris@16 117 template< typename N1, typename N2 > struct apply
Chris@16 118 : abs<aux::lcm_aux< typename N1::value_type, N1::value, N1::value==0,
Chris@16 119 typename N2::value_type, N2::value, N2::value==0 > >
Chris@16 120 {
Chris@16 121 };
Chris@16 122 };
Chris@16 123
Chris@16 124 }}
Chris@16 125
Chris@16 126 #endif // BOOST_MPL_LCM_HPP_INCLUDED