1
2 // Copyright 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/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 struct Q_sizeof_less
20 {
21 template<class T, class U> using fn = mp_bool<(sizeof(T) < sizeof(U))>;
22 };
23
main()24 int main()
25 {
26 using boost::mp11::mp_list;
27 using boost::mp11::mp_max_element_q;
28
29 {
30 using L1 = mp_list<void>;
31
32 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L1, Q_sizeof_less>, void>));
33
34 using L2 = mp_list<char[2], char[4], char[3], char[1]>;
35
36 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L2, Q_sizeof_less>, char[4]>));
37
38 using L3 = mp_list<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>;
39
40 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L3, Q_sizeof_less>, char[4]>));
41 }
42
43 {
44 using L1 = std::tuple<void>;
45
46 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L1, Q_sizeof_less>, void>));
47
48 using L2 = std::tuple<char[2], char[4], char[3], char[1]>;
49
50 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L2, Q_sizeof_less>, char[4]>));
51
52 using L3 = std::tuple<char[2], char[4], char[2], char[3], char[1], char[2], char[1]>;
53
54 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_max_element_q<L3, Q_sizeof_less>, char[4]>));
55 }
56
57 return boost::report_errors();
58 }
59