• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 //  Copyright 2015 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/mp11/integral.hpp>
13 #include <boost/core/lightweight_test_trait.hpp>
14 #include <type_traits>
15 #include <tuple>
16 #include <utility>
17 
18 struct X1 {};
19 struct X2 {};
20 struct X3 {};
21 struct X4 {};
22 struct X5 {};
23 
main()24 int main()
25 {
26     using boost::mp11::mp_list;
27     using boost::mp11::mp_drop;
28     using boost::mp11::mp_drop_c;
29     using boost::mp11::mp_size_t;
30 
31     {
32         using L1 = mp_list<>;
33 
34         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L1, 0>, L1>));
35         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L1, mp_size_t<0>>, L1>));
36 
37         using L2 = mp_list<X1, X2, X3, X4, X5>;
38 
39         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 0>, mp_list<X1, X2, X3, X4, X5>>));
40         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 1>, mp_list<X2, X3, X4, X5>>));
41         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 2>, mp_list<X3, X4, X5>>));
42         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 3>, mp_list<X4, X5>>));
43         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 4>, mp_list<X5>>));
44         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 5>, mp_list<>>));
45 
46         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<0>>, mp_list<X1, X2, X3, X4, X5>>));
47         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<1>>, mp_list<X2, X3, X4, X5>>));
48         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<2>>, mp_list<X3, X4, X5>>));
49         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<3>>, mp_list<X4, X5>>));
50         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<4>>, mp_list<X5>>));
51         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<5>>, mp_list<>>));
52     }
53 
54     {
55         using L1 = std::tuple<>;
56 
57         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L1, 0>, L1>));
58         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L1, mp_size_t<0>>, L1>));
59 
60         using L2 = std::tuple<X1, X2, X3, X4, X5>;
61 
62         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 0>, std::tuple<X1, X2, X3, X4, X5>>));
63         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 1>, std::tuple<X2, X3, X4, X5>>));
64         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 2>, std::tuple<X3, X4, X5>>));
65         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 3>, std::tuple<X4, X5>>));
66         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 4>, std::tuple<X5>>));
67         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L2, 5>, std::tuple<>>));
68 
69         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<0>>, std::tuple<X1, X2, X3, X4, X5>>));
70         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<1>>, std::tuple<X2, X3, X4, X5>>));
71         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<2>>, std::tuple<X3, X4, X5>>));
72         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<3>>, std::tuple<X4, X5>>));
73         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<4>>, std::tuple<X5>>));
74         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L2, mp_size_t<5>>, std::tuple<>>));
75     }
76 
77     {
78         using L1 = std::pair<X1, X2>;
79 
80         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop_c<L1, 0>, L1>));
81         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_drop<L1, mp_size_t<0>>, L1>));
82     }
83 
84     return boost::report_errors();
85 }
86