]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | |
2 | // Copyright 2015, 2017, 2019 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/list.hpp> | |
11 | #include <boost/mp11/utility.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 | ||
22 | template<class T> using add_pointer_t = T*; | |
23 | using Q_add_pointer = boost::mp11::mp_quote_trait<std::add_pointer>; | |
24 | ||
25 | int main() | |
26 | { | |
27 | using boost::mp11::mp_list; | |
28 | using boost::mp11::mp_transform_front; | |
29 | using boost::mp11::mp_transform_first; | |
30 | using boost::mp11::mp_transform_front_q; | |
31 | using boost::mp11::mp_transform_first_q; | |
32 | ||
33 | { | |
34 | using L1 = mp_list<X1>; | |
35 | ||
36 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L1, add_pointer_t>, mp_list<X1*>>)); | |
37 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L1, add_pointer_t>, mp_list<X1*>>)); | |
38 | ||
39 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L1, Q_add_pointer>, mp_list<X1*>>)); | |
40 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L1, Q_add_pointer>, mp_list<X1*>>)); | |
41 | ||
42 | using L2 = mp_list<X1, X2>; | |
43 | ||
44 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L2, add_pointer_t>, mp_list<X1*, X2>>)); | |
45 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L2, add_pointer_t>, mp_list<X1*, X2>>)); | |
46 | ||
47 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L2, Q_add_pointer>, mp_list<X1*, X2>>)); | |
48 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L2, Q_add_pointer>, mp_list<X1*, X2>>)); | |
49 | ||
50 | using L3 = mp_list<X1, X2, X3>; | |
51 | ||
52 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L3, add_pointer_t>, mp_list<X1*, X2, X3>>)); | |
53 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L3, add_pointer_t>, mp_list<X1*, X2, X3>>)); | |
54 | ||
55 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L3, Q_add_pointer>, mp_list<X1*, X2, X3>>)); | |
56 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L3, Q_add_pointer>, mp_list<X1*, X2, X3>>)); | |
57 | ||
58 | using L4 = mp_list<X1, X2, X3, X4>; | |
59 | ||
60 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L4, add_pointer_t>, mp_list<X1*, X2, X3, X4>>)); | |
61 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L4, add_pointer_t>, mp_list<X1*, X2, X3, X4>>)); | |
62 | ||
63 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L4, Q_add_pointer>, mp_list<X1*, X2, X3, X4>>)); | |
64 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L4, Q_add_pointer>, mp_list<X1*, X2, X3, X4>>)); | |
65 | } | |
66 | ||
67 | { | |
68 | using L1 = std::tuple<X1>; | |
69 | ||
70 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L1, add_pointer_t>, std::tuple<X1*>>)); | |
71 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L1, add_pointer_t>, std::tuple<X1*>>)); | |
72 | ||
73 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L1, Q_add_pointer>, std::tuple<X1*>>)); | |
74 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L1, Q_add_pointer>, std::tuple<X1*>>)); | |
75 | ||
76 | using L2 = std::tuple<X1, X2>; | |
77 | ||
78 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L2, add_pointer_t>, std::tuple<X1*, X2>>)); | |
79 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L2, add_pointer_t>, std::tuple<X1*, X2>>)); | |
80 | ||
81 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L2, Q_add_pointer>, std::tuple<X1*, X2>>)); | |
82 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L2, Q_add_pointer>, std::tuple<X1*, X2>>)); | |
83 | ||
84 | using L3 = std::tuple<X1, X2, X3>; | |
85 | ||
86 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L3, add_pointer_t>, std::tuple<X1*, X2, X3>>)); | |
87 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L3, add_pointer_t>, std::tuple<X1*, X2, X3>>)); | |
88 | ||
89 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L3, Q_add_pointer>, std::tuple<X1*, X2, X3>>)); | |
90 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L3, Q_add_pointer>, std::tuple<X1*, X2, X3>>)); | |
91 | ||
92 | using L4 = std::tuple<X1, X2, X3, X4>; | |
93 | ||
94 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L4, add_pointer_t>, std::tuple<X1*, X2, X3, X4>>)); | |
95 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L4, add_pointer_t>, std::tuple<X1*, X2, X3, X4>>)); | |
96 | ||
97 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L4, Q_add_pointer>, std::tuple<X1*, X2, X3, X4>>)); | |
98 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L4, Q_add_pointer>, std::tuple<X1*, X2, X3, X4>>)); | |
99 | } | |
100 | ||
101 | { | |
102 | using L2 = std::pair<X1, X2>; | |
103 | ||
104 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front<L2, add_pointer_t>, std::pair<X1*, X2>>)); | |
105 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first<L2, add_pointer_t>, std::pair<X1*, X2>>)); | |
106 | ||
107 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_front_q<L2, Q_add_pointer>, std::pair<X1*, X2>>)); | |
108 | BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_first_q<L2, Q_add_pointer>, std::pair<X1*, X2>>)); | |
109 | } | |
110 | ||
111 | return boost::report_errors(); | |
112 | } |