diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 2f81789..efffd8b 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -384,27 +384,15 @@ namespace detail template class P> struct mp_copy_if_impl; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) - template class L, class... T, template class P> struct mp_copy_if_impl, P> { - static_assert( sizeof...(T) == 0, "T... must be empty" ); - using type = L<>; -}; - +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1910 ) + template struct _f { using type = mp_if, mp_list, mp_list<>>; }; + using type = mp_append, typename _f::type...>; #else - -template class L, template class P> struct mp_copy_if_impl, P> -{ - using type = L<>; -}; - + template using _f = mp_if, mp_list, mp_list<>>; + using type = mp_append, _f...>; #endif - -template class L, class T1, class... T, template class P> struct mp_copy_if_impl, P> -{ - using rest = typename mp_copy_if_impl, P>::type; - using type = mp_if, mp_push_front, rest>; }; } // namespace detail @@ -417,32 +405,15 @@ namespace detail template struct mp_remove_impl; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) - template class L, class... T, class V> struct mp_remove_impl, V> { - static_assert( sizeof...(T) == 0, "T... must be empty" ); - using type = L<>; -}; - +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1910 ) + template struct _f { using type = mp_if, mp_list<>, mp_list>; }; + using type = mp_append, typename _f::type...>; #else - -template class L, class V> struct mp_remove_impl, V> -{ - using type = L<>; -}; - + template using _f = mp_if, mp_list<>, mp_list>; + using type = mp_append, _f...>; #endif - -template class L, class T1, class... T> struct mp_remove_impl, T1> -{ - using type = typename mp_remove_impl, T1>::type; -}; - -template class L, class T1, class... T, class V> struct mp_remove_impl, V> -{ - using rest = typename mp_remove_impl, V>::type; - using type = mp_push_front; }; } // namespace detail @@ -455,27 +426,15 @@ namespace detail template class P> struct mp_remove_if_impl; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) - template class L, class... T, template class P> struct mp_remove_if_impl, P> { - static_assert( sizeof...(T) == 0, "T... must be empty" ); - using type = L<>; -}; - +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1910 ) + template struct _f { using type = mp_if, mp_list<>, mp_list>; }; + using type = mp_append, typename _f::type...>; #else - -template class L, template class P> struct mp_remove_if_impl, P> -{ - using type = L<>; -}; - + template using _f = mp_if, mp_list<>, mp_list>; + using type = mp_append, _f...>; #endif - -template class L, class T1, class... T, template class P> struct mp_remove_if_impl, P> -{ - using rest = typename mp_remove_if_impl, P>::type; - using type = mp_if, rest, mp_push_front>; }; } // namespace detail @@ -488,27 +447,9 @@ namespace detail template class P> struct mp_partition_impl; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1800 ) - template class L, class... T, template class P> struct mp_partition_impl, P> { - static_assert( sizeof...(T) == 0, "T... must be empty" ); - using type = L, L<>>; -}; - -#else - -template class L, template class P> struct mp_partition_impl, P> -{ - using type = L, L<>>; -}; - -#endif - -template class L, class T1, class... T, template class P> struct mp_partition_impl, P> -{ - using rest = typename mp_partition_impl, P>::type; - using type = mp_if, L, T1>, mp_second>, L, mp_push_front, T1>>>; + using type = L, P>, mp_remove_if, P>>; }; } // namespace detail diff --git a/test/mp_copy_if.cpp b/test/mp_copy_if.cpp index 1545c18..0cf54d4 100644 --- a/test/mp_copy_if.cpp +++ b/test/mp_copy_if.cpp @@ -1,5 +1,5 @@ -// Copyright 2015 Peter Dimov. +// Copyright 2015-2017 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -17,6 +18,10 @@ struct X1 {}; struct X2 {}; struct X3 {}; +using boost::mp11::mp_bool; + +template using is_even = mp_bool; + int main() { using boost::mp11::mp_list; @@ -46,5 +51,17 @@ int main() BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple>)); } + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + { + int const N = 12; + using L1 = mp_iota_c; + + using R1 = mp_copy_if; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>)); + } + return boost::report_errors(); } diff --git a/test/mp_remove_if.cpp b/test/mp_remove_if.cpp index 733f9fb..bd9b777 100644 --- a/test/mp_remove_if.cpp +++ b/test/mp_remove_if.cpp @@ -1,5 +1,5 @@ -// Copyright 2015 Peter Dimov. +// Copyright 2015-2017 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -17,6 +18,10 @@ struct X1 {}; struct X2 {}; struct X3 {}; +using boost::mp11::mp_bool; + +template using is_odd = mp_bool; + int main() { using boost::mp11::mp_list; @@ -46,5 +51,17 @@ int main() BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple>)); } + using boost::mp11::mp_iota_c; + using boost::mp11::mp_size_t; + + { + int const N = 12; + using L1 = mp_iota_c; + + using R1 = mp_remove_if; + + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_size_t<2>, mp_size_t<4>, mp_size_t<6>, mp_size_t<8>, mp_size_t<10>>>)); + } + return boost::report_errors(); }