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/core/lightweight_test_trait.hpp>
13 #include <type_traits>
14 #include <tuple>
15
16 struct X1 {};
17 struct X2 {};
18 struct X3 {};
19
main()20 int main()
21 {
22 using boost::mp11::mp_list;
23 using boost::mp11::mp_partition;
24
25 {
26 using L1 = mp_list<>;
27
28 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L1, std::is_const>, mp_list<L1, L1>>));
29
30 using L2 = mp_list<X1, X1 const, X1*, X2 const, X2*, X3*>;
31
32 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_volatile>, mp_list<L1, L2>>));
33 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_const>, mp_list<mp_list<X1 const, X2 const>, mp_list<X1, X1*, X2*, X3*>>>));
34 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_pointer>, mp_list<mp_list<X1*, X2*, X3*>, mp_list<X1, X1 const, X2 const>>>));
35 }
36
37 {
38 using L1 = std::tuple<>;
39
40 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L1, std::is_const>, std::tuple<L1, L1>>));
41
42 using L2 = std::tuple<X1, X1 const, X1*, X2 const, X2*, X3*>;
43
44 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_volatile>, std::tuple<L1, L2>>));
45 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_const>, std::tuple<std::tuple<X1 const, X2 const>, std::tuple<X1, X1*, X2*, X3*>>>));
46 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_partition<L2, std::is_pointer>, std::tuple<std::tuple<X1*, X2*, X3*>, std::tuple<X1, X1 const, X2 const>>>));
47 }
48
49 return boost::report_errors();
50 }
51