• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2015, 2017 Peter Dimov.
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 //
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
8 
9 
10 #include <boost/mp11/algorithm.hpp>
11 #include <boost/mp11/list.hpp>
12 #include <boost/core/lightweight_test_trait.hpp>
13 #include <type_traits>
14 #include <tuple>
15 #include <utility>
16 
17 struct X1 {};
18 struct X2 {};
19 struct X3 {};
20 struct X4 {};
21 
main()22 int main()
23 {
24     using boost::mp11::mp_list;
25     using boost::mp11::mp_replace_front;
26     using boost::mp11::mp_replace_first;
27 
28     {
29         using L1 = mp_list<X1>;
30 
31         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L1, void>, mp_list<void>>));
32         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L1, void>, mp_list<void>>));
33 
34         using L2 = mp_list<X1, X2>;
35 
36         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L2, void>, mp_list<void, X2>>));
37         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L2, void>, mp_list<void, X2>>));
38 
39         using L3 = mp_list<X1, X2, X3>;
40 
41         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L3, void>, mp_list<void, X2, X3>>));
42         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L3, void>, mp_list<void, X2, X3>>));
43 
44         using L4 = mp_list<X1, X2, X3, X4>;
45 
46         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L4, void>, mp_list<void, X2, X3, X4>>));
47         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L4, void>, mp_list<void, X2, X3, X4>>));
48     }
49 
50     {
51         using L1 = std::tuple<X1>;
52 
53         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L1, void>, std::tuple<void>>));
54         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L1, void>, std::tuple<void>>));
55 
56         using L2 = std::tuple<X1, X2>;
57 
58         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L2, void>, std::tuple<void, X2>>));
59         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L2, void>, std::tuple<void, X2>>));
60 
61         using L3 = std::tuple<X1, X2, X3>;
62 
63         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L3, void>, std::tuple<void, X2, X3>>));
64         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L3, void>, std::tuple<void, X2, X3>>));
65 
66         using L4 = std::tuple<X1, X2, X3, X4>;
67 
68         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L4, void>, std::tuple<void, X2, X3, X4>>));
69         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L4, void>, std::tuple<void, X2, X3, X4>>));
70     }
71 
72     {
73         using L2 = std::pair<X1, X2>;
74 
75         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_front<L2, void>, std::pair<void, X2>>));
76         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_replace_first<L2, void>, std::pair<void, X2>>));
77     }
78 
79     return boost::report_errors();
80 }
81