]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_nth_element.cpp
2 // Copyright 2017 Peter Dimov.
4 // Distributed under the Boost Software License, Version 1.0.
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
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/core/lightweight_test_trait.hpp>
15 #include <type_traits>
20 using boost::mp11::mp_nth_element
;
21 using boost::mp11::mp_nth_element_c
;
22 using boost::mp11::mp_list_c
;
23 using boost::mp11::mp_sort
;
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
;
30 using L1
= mp_list_c
<int, 7, 1, 11, 3, 2, 2, 4>;
31 using L2
= mp_sort
<L1
, mp_less
>;
33 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 0, mp_less
>, mp_at_c
<L2
, 0>>));
34 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 1, mp_less
>, mp_at_c
<L2
, 1>>));
35 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 2, mp_less
>, mp_at_c
<L2
, 2>>));
36 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 3, mp_less
>, mp_at_c
<L2
, 3>>));
37 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 4, mp_less
>, mp_at_c
<L2
, 4>>));
38 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 5, mp_less
>, mp_at_c
<L2
, 5>>));
39 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 6, mp_less
>, mp_at_c
<L2
, 6>>));
41 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<0>, mp_less
>, mp_at_c
<L2
, 0>>));
42 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<1>, mp_less
>, mp_at_c
<L2
, 1>>));
43 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<2>, mp_less
>, mp_at_c
<L2
, 2>>));
44 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<3>, mp_less
>, mp_at_c
<L2
, 3>>));
45 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<4>, mp_less
>, mp_at_c
<L2
, 4>>));
46 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<5>, mp_less
>, mp_at_c
<L2
, 5>>));
47 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<6>, mp_less
>, mp_at_c
<L2
, 6>>));
51 using L1
= mp_rename
<mp_list_c
<int, 7, 1, 11, 3, 2, 2, 4>, std::tuple
>;
52 using L2
= mp_sort
<L1
, mp_less
>;
54 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 0, mp_less
>, mp_at_c
<L2
, 0>>));
55 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 1, mp_less
>, mp_at_c
<L2
, 1>>));
56 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 2, mp_less
>, mp_at_c
<L2
, 2>>));
57 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 3, mp_less
>, mp_at_c
<L2
, 3>>));
58 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 4, mp_less
>, mp_at_c
<L2
, 4>>));
59 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 5, mp_less
>, mp_at_c
<L2
, 5>>));
60 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element_c
<L1
, 6, mp_less
>, mp_at_c
<L2
, 6>>));
62 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<0>, mp_less
>, mp_at_c
<L2
, 0>>));
63 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<1>, mp_less
>, mp_at_c
<L2
, 1>>));
64 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<2>, mp_less
>, mp_at_c
<L2
, 2>>));
65 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<3>, mp_less
>, mp_at_c
<L2
, 3>>));
66 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<4>, mp_less
>, mp_at_c
<L2
, 4>>));
67 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<5>, mp_less
>, mp_at_c
<L2
, 5>>));
68 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_nth_element
<L1
, mp_size_t
<6>, mp_less
>, mp_at_c
<L2
, 6>>));
71 return boost::report_errors();