forked from boostorg/mp11
Make mp_append SFINAE-friendly; add test/mp_append_sf.cpp
This commit is contained in:
@ -26,6 +26,10 @@ template<class... L> struct mp_append_impl;
|
||||
|
||||
#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
|
||||
|
||||
template<class... L> struct mp_append_impl
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct mp_append_impl<>
|
||||
{
|
||||
using type = mp_list<>;
|
||||
@ -36,14 +40,31 @@ template<template<class...> class L, class... T> struct mp_append_impl<L<T...>>
|
||||
using type = L<T...>;
|
||||
};
|
||||
|
||||
template<template<class...> class L1, class... T1, template<class...> class L2, class... T2, class... Lr> struct mp_append_impl<L1<T1...>, L2<T2...>, Lr...>
|
||||
template<template<class...> class L1, class... T1, template<class...> class L2, class... T2> struct mp_append_impl<L1<T1...>, L2<T2...>>
|
||||
{
|
||||
using type = typename mp_append_impl<L1<T1..., T2...>, Lr...>::type;
|
||||
using type = L1<T1..., T2...>;
|
||||
};
|
||||
|
||||
template<template<class...> class L1, class... T1, template<class...> class L2, class... T2, template<class...> class L3, class... T3> struct mp_append_impl<L1<T1...>, L2<T2...>, L3<T3...>>
|
||||
{
|
||||
using type = L1<T1..., T2..., T3...>;
|
||||
};
|
||||
|
||||
template<template<class...> class L1, class... T1, template<class...> class L2, class... T2, template<class...> class L3, class... T3, template<class...> class L4, class... T4> struct mp_append_impl<L1<T1...>, L2<T2...>, L3<T3...>, L4<T4...>>
|
||||
{
|
||||
using type = L1<T1..., T2..., T3..., T4...>;
|
||||
};
|
||||
|
||||
template<template<class...> class L1, class... T1, template<class...> class L2, class... T2, template<class...> class L3, class... T3, template<class...> class L4, class... T4, template<class...> class L5, class... T5, class... Lr> struct mp_append_impl<L1<T1...>, L2<T2...>, L3<T3...>, L4<T4...>, L5<T5...>, Lr...>
|
||||
{
|
||||
using type = typename mp_append_impl<L1<T1..., T2..., T3..., T4..., T5...>, Lr...>::type;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template<class L1 = mp_list<>, class L2 = mp_list<>, class L3 = mp_list<>, class L4 = mp_list<>, class L5 = mp_list<>, class L6 = mp_list<>, class L7 = mp_list<>, class L8 = mp_list<>, class L9 = mp_list<>, class L10 = mp_list<>, class L11 = mp_list<>> struct append_11_impl;
|
||||
template<class L1 = mp_list<>, class L2 = mp_list<>, class L3 = mp_list<>, class L4 = mp_list<>, class L5 = mp_list<>, class L6 = mp_list<>, class L7 = mp_list<>, class L8 = mp_list<>, class L9 = mp_list<>, class L10 = mp_list<>, class L11 = mp_list<>> struct append_11_impl
|
||||
{
|
||||
};
|
||||
|
||||
template<
|
||||
template<class...> class L1, class... T1,
|
||||
|
@ -26,6 +26,7 @@ run mp_push_back.cpp ;
|
||||
run mp_rename.cpp ;
|
||||
run mp_append.cpp ;
|
||||
run mp_append_2.cpp ;
|
||||
run mp_append_sf.cpp ;
|
||||
run mp_replace_front.cpp ;
|
||||
run mp_replace_second.cpp ;
|
||||
run mp_replace_third.cpp ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Copyright 2015 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
|
32
test/mp_append_sf.cpp
Normal file
32
test/mp_append_sf.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
// Copyright 2019 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/utility.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_append;
|
||||
using boost::mp11::mp_valid;
|
||||
using boost::mp11::mp_list;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void, void>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void, void, void>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void, void, void, void>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, void, void, void, void, void>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, mp_list<>, void>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, mp_list<>, mp_list<>, void>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, mp_list<>, mp_list<>, mp_list<>, void>));
|
||||
BOOST_TEST_TRAIT_FALSE((mp_valid<mp_append, mp_list<>, mp_list<>, mp_list<>, mp_list<>, void>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user