]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_reverse_fold.cpp
2 // Copyright 2015-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/core/lightweight_test_trait.hpp>
14 #include <boost/config.hpp>
15 #include <boost/detail/workaround.hpp>
16 #include <type_traits>
24 template<class T1
, class T2
> struct F
{};
26 using boost::mp11::mp_push_back
;
27 using boost::mp11::mp_push_front
;
29 template<class T
, class L
> using rev_push_back
= mp_push_back
<L
, T
>;
30 template<class T
, class L
> using rev_push_front
= mp_push_front
<L
, T
>;
32 using boost::mp11::mp_plus
;
36 using boost::mp11::mp_list
;
37 using boost::mp11::mp_reverse_fold
;
40 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<mp_list
<>, void, F
>, void>));
41 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<mp_list
<X1
>, void, F
>, F
<X1
, void>>));
42 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<mp_list
<X1
, X2
>, void, F
>, F
<X1
, F
<X2
, void>>>));
43 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<mp_list
<X1
, X2
, X3
>, void, F
>, F
<X1
, F
<X2
, F
<X3
, void>>>>));
44 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<mp_list
<X1
, X2
, X3
, X4
>, void, F
>, F
<X1
, F
<X2
, F
<X3
, F
<X4
, void>>>>>));
48 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<std::tuple
<>, void, F
>, void>));
49 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<std::tuple
<X1
>, void, F
>, F
<X1
, void>>));
50 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<std::tuple
<X1
, X2
>, void, F
>, F
<X1
, F
<X2
, void>>>));
51 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<std::tuple
<X1
, X2
, X3
>, void, F
>, F
<X1
, F
<X2
, F
<X3
, void>>>>));
52 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<std::tuple
<X1
, X2
, X3
, X4
>, void, F
>, F
<X1
, F
<X2
, F
<X3
, F
<X4
, void>>>>>));
56 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<std::tuple
<X1
, X2
, X3
, X4
>, mp_list
<>, rev_push_back
>, mp_list
<X4
, X3
, X2
, X1
>>));
60 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_reverse_fold
<std::tuple
<X1
, X2
, X3
, X4
>, mp_list
<>, rev_push_front
>, mp_list
<X1
, X2
, X3
, X4
>>));
63 using boost::mp11::mp_iota_c
;
64 using boost::mp11::mp_reverse
;
65 using boost::mp11::mp_size_t
;
70 using L
= mp_iota_c
<N
>;
72 using R1
= mp_reverse_fold
<L
, mp_list
<>, rev_push_front
>;
73 BOOST_TEST_TRAIT_TRUE((std::is_same
<R1
, L
>));
75 using R2
= mp_reverse_fold
<L
, mp_list
<>, rev_push_back
>;
76 BOOST_TEST_TRAIT_TRUE((std::is_same
<R2
, mp_reverse
<L
>>));
78 using R3
= mp_reverse_fold
<L
, mp_size_t
<0>, mp_plus
>;
79 BOOST_TEST_TRAIT_TRUE((std::is_same
<R3
, mp_size_t
<N
*(N
-1)/2>>));
82 return boost::report_errors();