• 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_at;
28     using boost::mp11::mp_at_c;
29     using boost::mp11::mp_size_t;
30 
31     {
32         using L1 = mp_list<X1, X2, X3, X4, X5>;
33 
34         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 0>, X1>));
35         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 1>, X2>));
36         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 2>, X3>));
37         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 3>, X4>));
38         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 4>, X5>));
39 
40         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<0>>, X1>));
41         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<1>>, X2>));
42         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<2>>, X3>));
43         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<3>>, X4>));
44         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<4>>, X5>));
45     }
46 
47     {
48         using L1 = std::tuple<X1, X2, X3, X4, X5>;
49 
50         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 0>, X1>));
51         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 1>, X2>));
52         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 2>, X3>));
53         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 3>, X4>));
54         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 4>, X5>));
55 
56         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<0>>, X1>));
57         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<1>>, X2>));
58         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<2>>, X3>));
59         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<3>>, X4>));
60         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<4>>, X5>));
61     }
62 
63     {
64         using L1 = std::pair<X1, X2>;
65 
66         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 0>, X1>));
67         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at_c<L1, 1>, X2>));
68 
69         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<0>>, X1>));
70         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_at<L1, mp_size_t<1>>, X2>));
71     }
72 
73     return boost::report_errors();
74 }
75