]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_nth_element_q.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / mp11 / test / mp_nth_element_q.cpp
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/mp11/function.hpp>
14 #include <boost/mp11/utility.hpp>
15 #include <boost/core/lightweight_test_trait.hpp>
16 #include <type_traits>
17 #include <tuple>
18
19 int main()
20 {
21 using boost::mp11::mp_nth_element_q;
22 using boost::mp11::mp_list_c;
23 using boost::mp11::mp_sort_q;
24 using boost::mp11::mp_less;
25 using boost::mp11::mp_at_c;
26 using boost::mp11::mp_size_t;
27 using boost::mp11::mp_rename;
28 using boost::mp11::mp_quote;
29
30 using Q_less = mp_quote<mp_less>;
31
32 {
33 using L1 = mp_list_c<int, 7, 1, 11, 3, 2, 2, 4>;
34 using L2 = mp_sort_q<L1, Q_less>;
35
36 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<0>, Q_less>, mp_at_c<L2, 0>>));
37 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<1>, Q_less>, mp_at_c<L2, 1>>));
38 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<2>, Q_less>, mp_at_c<L2, 2>>));
39 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<3>, Q_less>, mp_at_c<L2, 3>>));
40 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<4>, Q_less>, mp_at_c<L2, 4>>));
41 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<5>, Q_less>, mp_at_c<L2, 5>>));
42 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<6>, Q_less>, mp_at_c<L2, 6>>));
43 }
44
45 {
46 using L1 = mp_rename<mp_list_c<int, 7, 1, 11, 3, 2, 2, 4>, std::tuple>;
47 using L2 = mp_sort_q<L1, Q_less>;
48
49 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<0>, Q_less>, mp_at_c<L2, 0>>));
50 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<1>, Q_less>, mp_at_c<L2, 1>>));
51 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<2>, Q_less>, mp_at_c<L2, 2>>));
52 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<3>, Q_less>, mp_at_c<L2, 3>>));
53 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<4>, Q_less>, mp_at_c<L2, 4>>));
54 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<5>, Q_less>, mp_at_c<L2, 5>>));
55 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_nth_element_q<L1, mp_size_t<6>, Q_less>, mp_at_c<L2, 6>>));
56 }
57
58 return boost::report_errors();
59 }