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
main()25 int main()
26 {
27 using boost::mp11::mp_list;
28 using boost::mp11::mp_transform_second;
29 using boost::mp11::mp_transform_second_q;
30
31 {
32 using L2 = mp_list<X1, X2>;
33
34 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L2, add_pointer_t>, mp_list<X1, X2*>>));
35 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L2, Q_add_pointer>, mp_list<X1, X2*>>));
36
37 using L3 = mp_list<X1, X2, X3>;
38
39 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L3, add_pointer_t>, mp_list<X1, X2*, X3>>));
40 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L3, Q_add_pointer>, mp_list<X1, X2*, X3>>));
41
42 using L4 = mp_list<X1, X2, X3, X4>;
43
44 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L4, add_pointer_t>, mp_list<X1, X2*, X3, X4>>));
45 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L4, Q_add_pointer>, mp_list<X1, X2*, X3, X4>>));
46 }
47
48 {
49 using L2 = std::tuple<X1, X2>;
50
51 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L2, add_pointer_t>, std::tuple<X1, X2*>>));
52 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L2, Q_add_pointer>, std::tuple<X1, X2*>>));
53
54 using L3 = std::tuple<X1, X2, X3>;
55
56 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L3, add_pointer_t>, std::tuple<X1, X2*, X3>>));
57 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L3, Q_add_pointer>, std::tuple<X1, X2*, X3>>));
58
59 using L4 = std::tuple<X1, X2, X3, X4>;
60
61 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L4, add_pointer_t>, std::tuple<X1, X2*, X3, X4>>));
62 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L4, Q_add_pointer>, std::tuple<X1, X2*, X3, X4>>));
63 }
64
65 {
66 using L2 = std::pair<X1, X2>;
67
68 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second<L2, add_pointer_t>, std::pair<X1, X2*>>));
69 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_second_q<L2, Q_add_pointer>, std::pair<X1, X2*>>));
70 }
71
72 return boost::report_errors();
73 }
74