forked from boostorg/mp11
Support more than 1024 list elements in mp_for_each on msvc
This commit is contained in:
@@ -970,11 +970,34 @@ template<class F> BOOST_MP11_CONSTEXPR F mp_for_each_impl( mp_list<>, F && f )
|
|||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, >= 1900 )
|
||||||
|
|
||||||
|
// msvc has a limit of 1024
|
||||||
|
|
||||||
|
template<class L, class F> BOOST_MP11_CONSTEXPR mp_if_c<mp_size<L>::value <= 1024, F> mp_for_each( F && f )
|
||||||
|
{
|
||||||
|
return detail::mp_for_each_impl( mp_rename<L, mp_list>(), std::forward<F>(f) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class L, class F> BOOST_MP11_CONSTEXPR mp_if_c<mp_size<L>::value >= 1025, F> mp_for_each( F && f )
|
||||||
|
{
|
||||||
|
using L2 = mp_rename<L, mp_list>;
|
||||||
|
|
||||||
|
using L3 = mp_take_c<L2, 1024>;
|
||||||
|
using L4 = mp_drop_c<L2, 1024>;
|
||||||
|
|
||||||
|
return mp_for_each<L4>( mp_for_each<L3>( std::forward<F>(f) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
template<class L, class F> BOOST_MP11_CONSTEXPR F mp_for_each( F && f )
|
template<class L, class F> BOOST_MP11_CONSTEXPR F mp_for_each( F && f )
|
||||||
{
|
{
|
||||||
return detail::mp_for_each_impl( mp_rename<L, mp_list>(), std::forward<F>(f) );
|
return detail::mp_for_each_impl( mp_rename<L, mp_list>(), std::forward<F>(f) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// mp_insert<L, I, T...>
|
// mp_insert<L, I, T...>
|
||||||
template<class L, class I, class... T> using mp_insert = mp_append<mp_take<L, I>, mp_push_front<mp_drop<L, I>, T...>>;
|
template<class L, class I, class... T> using mp_insert = mp_append<mp_take<L, I>, mp_push_front<mp_drop<L, I>, T...>>;
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include <boost/mp11/detail/config.hpp>
|
#include <boost/mp11/detail/config.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#if defined( BOOST_MP11_HAS_CXX14_CONSTEXPR )
|
#if defined( BOOST_MP11_HAS_CXX14_CONSTEXPR )
|
||||||
# define CONSTEXPR14 constexpr
|
# define CONSTEXPR14 constexpr
|
||||||
@@ -30,8 +31,8 @@ struct F
|
|||||||
|
|
||||||
struct G
|
struct G
|
||||||
{
|
{
|
||||||
std::size_t s;
|
std::uint32_t s;
|
||||||
CONSTEXPR14 void operator()( std::size_t i ) { s += i; }
|
CONSTEXPR14 void operator()( std::uint32_t i ) { s = s * 3 + i; }
|
||||||
};
|
};
|
||||||
|
|
||||||
using boost::mp11::mp_list;
|
using boost::mp11::mp_list;
|
||||||
@@ -55,8 +56,8 @@ int main()
|
|||||||
#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
|
#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
|
||||||
#else
|
#else
|
||||||
|
|
||||||
using L = mp_iota_c<1024>;
|
using L = mp_iota_c<1089>;
|
||||||
std::size_t const R = 523776;
|
std::uint32_t const R = 598075296;
|
||||||
|
|
||||||
BOOST_TEST_EQ( (mp_for_each<L>( G{0} ).s), R );
|
BOOST_TEST_EQ( (mp_for_each<L>( G{0} ).s), R );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user