]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_transform_if_q.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/mp11/utility.hpp>
14 #include <boost/core/lightweight_test_trait.hpp>
15 #include <type_traits>
24 using boost::mp11::mp_not
;
25 using boost::mp11::mp_quote
;
27 template<class T
> using add_pointer
= T
*;
28 using Q_add_pointer
= mp_quote
<add_pointer
>;
30 template<class T
, class...> using is_not_ref
= mp_not
<std::is_reference
<T
>>;
31 using Q_is_not_ref
= mp_quote
<is_not_ref
>;
33 template<class T1
, class T2
> using second
= T2
;
34 using Q_second
= mp_quote
<second
>;
36 template<class T1
, class T2
, class T3
> using third
= T3
;
37 using Q_third
= mp_quote
<third
>;
39 template<class T1
, class T2
, class T3
, class T4
> using fourth
= T4
;
40 using Q_fourth
= mp_quote
<fourth
>;
42 template<class T1
, class T2
, class T3
, class T4
, class T5
> using fifth
= T5
;
43 using Q_fifth
= mp_quote
<fifth
>;
47 using boost::mp11::mp_list
;
48 using boost::mp11::mp_transform_if_q
;
49 using boost::mp11::mp_size_t
;
50 using boost::mp11::mp_size
;
51 using boost::mp11::mp_fill
;
52 using boost::mp11::mp_iota
;
54 using L1
= mp_list
<X1
, X2
&, X3
const, X4
const&>;
56 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_add_pointer
, L1
>, mp_list
<X1
*, X2
&, X3
const*, X4
const&>>));
58 using L2
= std::tuple
<X1
, X2
&, X3
const, X4
const&>;
60 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_add_pointer
, L2
>, std::tuple
<X1
*, X2
&, X3
const*, X4
const&>>));
62 using L3
= std::pair
<X1
const, X2
&>;
64 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_add_pointer
, L3
>, std::pair
<X1
const*, X2
&>>));
68 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_second
, L1
, mp_fill
<L1
, void>>, mp_list
<void, X2
&, void, X4
const&>>));
69 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_second
, L2
, mp_fill
<L2
, void>>, std::tuple
<void, X2
&, void, X4
const&>>));
70 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_second
, L3
, mp_fill
<L3
, void>>, std::pair
<void, X2
&>>));
72 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_third
, L1
, L1
, mp_iota
<mp_size
<L1
>>>, mp_list
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
73 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_third
, L2
, L2
, mp_iota
<mp_size
<L2
>>>, std::tuple
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
74 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_third
, L3
, L3
, mp_iota
<mp_size
<L3
>>>, std::pair
<mp_size_t
<0>, X2
&>>));
76 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_fourth
, L1
, L1
, L1
, mp_iota
<mp_size
<L1
>>>, mp_list
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
77 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_fourth
, L2
, L2
, L2
, mp_iota
<mp_size
<L2
>>>, std::tuple
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
78 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_fourth
, L3
, L3
, L3
, mp_iota
<mp_size
<L3
>>>, std::pair
<mp_size_t
<0>, X2
&>>));
80 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_fifth
, L1
, L1
, L1
, L1
, mp_iota
<mp_size
<L1
>>>, mp_list
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
81 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_fifth
, L2
, L2
, L2
, L2
, mp_iota
<mp_size
<L2
>>>, std::tuple
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
82 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if_q
<Q_is_not_ref
, Q_fifth
, L3
, L3
, L3
, L3
, mp_iota
<mp_size
<L3
>>>, std::pair
<mp_size_t
<0>, X2
&>>));
86 return boost::report_errors();