• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_third;
29     using boost::mp11::mp_transform_third_q;
30 
31     {
32         using L3 = mp_list<X1, X2, X3>;
33 
34         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third<L3, add_pointer_t>, mp_list<X1, X2, X3*>>));
35         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third_q<L3, Q_add_pointer>, mp_list<X1, X2, X3*>>));
36 
37         using L4 = mp_list<X1, X2, X3, X4>;
38 
39         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third<L4, add_pointer_t>, mp_list<X1, X2, X3*, X4>>));
40         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third_q<L4, Q_add_pointer>, mp_list<X1, X2, X3*, X4>>));
41     }
42 
43     {
44         using L3 = std::tuple<X1, X2, X3>;
45 
46         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third<L3, add_pointer_t>, std::tuple<X1, X2, X3*>>));
47         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third_q<L3, Q_add_pointer>, std::tuple<X1, X2, X3*>>));
48 
49         using L4 = std::tuple<X1, X2, X3, X4>;
50 
51         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third<L4, add_pointer_t>, std::tuple<X1, X2, X3*, X4>>));
52         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_transform_third_q<L4, Q_add_pointer>, std::tuple<X1, X2, X3*, X4>>));
53     }
54 
55     return boost::report_errors();
56 }
57