• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/mp11/integral.hpp>
13 #include <boost/core/lightweight_test_trait.hpp>
14 #include <type_traits>
15 #include <tuple>
16 
17 using boost::mp11::mp_bool;
18 
19 template<class T, class U> using sizeof_less = mp_bool<(sizeof(T) < sizeof(U))>;
20 
main()21 int main()
22 {
23     using boost::mp11::mp_list;
24     using boost::mp11::mp_sort;
25 
26     {
27         using L1 = mp_list<>;
28 
29         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L1, sizeof_less>, L1>));
30 
31         using L2 = mp_list<char[2], char[4], char[3], char[1]>;
32 
33         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L2, sizeof_less>, mp_list<char[1], char[2], char[3], char[4]>>));
34 
35         using L3 = mp_list<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>;
36 
37         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L3, sizeof_less>, mp_list<char[1], char[1], char[2], char[2], char[2], char[3], char[4]>>));
38     }
39 
40     {
41         using L1 = std::tuple<>;
42 
43         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L1, sizeof_less>, L1>));
44 
45         using L2 = std::tuple<char[2], char[4], char[3], char[1]>;
46 
47         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L2, sizeof_less>, std::tuple<char[1], char[2], char[3], char[4]>>));
48 
49         using L3 = std::tuple<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>;
50 
51         BOOST_TEST_TRAIT_TRUE((std::is_same<mp_sort<L3, sizeof_less>, std::tuple<char[1], char[1], char[2], char[2], char[2], char[3], char[4]>>));
52     }
53 
54     return boost::report_errors();
55 }
56