• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 //  Copyright 2015-2017 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/core/lightweight_test_trait.hpp>
11 #include <boost/mp11/list.hpp>
12 #include <type_traits>
13 #include <tuple>
14 #include <utility>
15 
16 template<class... T> struct X {};
17 template<class... T> using Y = X<T...>;
18 
main()19 int main()
20 {
21     using boost::mp11::mp_list;
22     using boost::mp11::mp_rename;
23     using boost::mp11::mp_apply;
24 
25     using L1 = mp_list<>;
26 
27     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, mp_list>, mp_list<>>));
28     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, std::tuple>, std::tuple<>>));
29     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, X>, X<>>));
30     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L1, Y>, Y<>>));
31 
32     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L1>, mp_list<>>));
33     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L1>, std::tuple<>>));
34     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L1>, X<>>));
35     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L1>, Y<>>));
36 
37     using L2 = mp_list<char>;
38 
39     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, mp_list>, mp_list<char>>));
40     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, std::tuple>, std::tuple<char>>));
41     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, X>, X<char>>));
42     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L2, Y>, Y<char>>));
43 
44     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L2>, mp_list<char>>));
45     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L2>, std::tuple<char>>));
46     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L2>, X<char>>));
47     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L2>, Y<char>>));
48 
49     using L3 = mp_list<char, double>;
50 
51     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, mp_list>, mp_list<char, double>>));
52     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, std::tuple>, std::tuple<char, double>>));
53     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, X>, X<char, double>>));
54     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, Y>, Y<char, double>>));
55     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L3, std::pair>, std::pair<char, double>>));
56 
57     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L3>, mp_list<char, double>>));
58     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L3>, std::tuple<char, double>>));
59     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L3>, X<char, double>>));
60     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L3>, Y<char, double>>));
61     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L3>, std::pair<char, double>>));
62 
63     using L4 = mp_list<int, char, float>;
64 
65     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, mp_list>, mp_list<int, char, float>>));
66     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, std::tuple>, std::tuple<int, char, float>>));
67     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, X>, X<int, char, float>>));
68     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L4, Y>, Y<int, char, float>>));
69 
70     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L4>, mp_list<int, char, float>>));
71     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L4>, std::tuple<int, char, float>>));
72     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L4>, X<int, char, float>>));
73     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L4>, Y<int, char, float>>));
74 
75     //
76 
77     using L5 = std::tuple<>;
78 
79     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, mp_list>, mp_list<>>));
80     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, std::tuple>, std::tuple<>>));
81     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, X>, X<>>));
82     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L5, Y>, Y<>>));
83 
84     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L5>, mp_list<>>));
85     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L5>, std::tuple<>>));
86     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L5>, X<>>));
87     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L5>, Y<>>));
88 
89     using L6 = std::tuple<char>;
90 
91     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, mp_list>, mp_list<char>>));
92     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, std::tuple>, std::tuple<char>>));
93     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, X>, X<char>>));
94     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L6, Y>, Y<char>>));
95 
96     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L6>, mp_list<char>>));
97     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L6>, std::tuple<char>>));
98     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L6>, X<char>>));
99     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L6>, Y<char>>));
100 
101     using L7 = std::tuple<char, double>;
102 
103     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, mp_list>, mp_list<char, double>>));
104     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, std::tuple>, std::tuple<char, double>>));
105     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, X>, X<char, double>>));
106     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, Y>, Y<char, double>>));
107     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L7, std::pair>, std::pair<char, double>>));
108 
109     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L7>, mp_list<char, double>>));
110     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L7>, std::tuple<char, double>>));
111     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L7>, X<char, double>>));
112     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L7>, Y<char, double>>));
113     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L7>, std::pair<char, double>>));
114 
115     using L8 = std::tuple<int, char, float>;
116 
117     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, mp_list>, mp_list<int, char, float>>));
118     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, std::tuple>, std::tuple<int, char, float>>));
119     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, X>, X<int, char, float>>));
120     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L8, Y>, Y<int, char, float>>));
121 
122     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L8>, mp_list<int, char, float>>));
123     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L8>, std::tuple<int, char, float>>));
124     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L8>, X<int, char, float>>));
125     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L8>, Y<int, char, float>>));
126 
127     //
128 
129     using L9 = std::pair<char, double>;
130 
131     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, mp_list>, mp_list<char, double>>));
132     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, std::tuple>, std::tuple<char, double>>));
133     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, X>, X<char, double>>));
134     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, Y>, Y<char, double>>));
135     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_rename<L9, std::pair>, std::pair<char, double>>));
136 
137     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<mp_list, L9>, mp_list<char, double>>));
138     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::tuple, L9>, std::tuple<char, double>>));
139     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<X, L9>, X<char, double>>));
140     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<Y, L9>, Y<char, double>>));
141     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_apply<std::pair, L9>, std::pair<char, double>>));
142 
143     //
144 
145     return boost::report_errors();
146 }
147