]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_transform_if.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 <type_traits>
23 using boost::mp11::mp_not
;
25 template<class T
> using add_pointer
= T
*;
26 template<class T
, class...> using is_not_ref
= mp_not
<std::is_reference
<T
>>;
27 template<class T1
, class T2
> using second
= T2
;
28 template<class T1
, class T2
, class T3
> using third
= T3
;
29 template<class T1
, class T2
, class T3
, class T4
> using fourth
= T4
;
30 template<class T1
, class T2
, class T3
, class T4
, class T5
> using fifth
= T5
;
34 using boost::mp11::mp_list
;
35 using boost::mp11::mp_transform_if
;
36 using boost::mp11::mp_size_t
;
37 using boost::mp11::mp_size
;
38 using boost::mp11::mp_fill
;
39 using boost::mp11::mp_iota
;
41 using L1
= mp_list
<X1
, X2
&, X3
const, X4
const&>;
43 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, add_pointer
, L1
>, mp_list
<X1
*, X2
&, X3
const*, X4
const&>>));
45 using L2
= std::tuple
<X1
, X2
&, X3
const, X4
const&>;
47 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, add_pointer
, L2
>, std::tuple
<X1
*, X2
&, X3
const*, X4
const&>>));
49 using L3
= std::pair
<X1
const, X2
&>;
51 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, add_pointer
, L3
>, std::pair
<X1
const*, X2
&>>));
55 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, second
, L1
, mp_fill
<L1
, void>>, mp_list
<void, X2
&, void, X4
const&>>));
56 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, second
, L2
, mp_fill
<L2
, void>>, std::tuple
<void, X2
&, void, X4
const&>>));
57 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, second
, L3
, mp_fill
<L3
, void>>, std::pair
<void, X2
&>>));
59 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, third
, L1
, L1
, mp_iota
<mp_size
<L1
>>>, mp_list
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
60 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, third
, L2
, L2
, mp_iota
<mp_size
<L2
>>>, std::tuple
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
61 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, third
, L3
, L3
, mp_iota
<mp_size
<L3
>>>, std::pair
<mp_size_t
<0>, X2
&>>));
63 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, fourth
, L1
, L1
, L1
, mp_iota
<mp_size
<L1
>>>, mp_list
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
64 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, fourth
, L2
, L2
, L2
, mp_iota
<mp_size
<L2
>>>, std::tuple
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
65 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, fourth
, L3
, L3
, L3
, mp_iota
<mp_size
<L3
>>>, std::pair
<mp_size_t
<0>, X2
&>>));
67 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, fifth
, L1
, L1
, L1
, L1
, mp_iota
<mp_size
<L1
>>>, mp_list
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
68 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, fifth
, L2
, L2
, L2
, L2
, mp_iota
<mp_size
<L2
>>>, std::tuple
<mp_size_t
<0>, X2
&, mp_size_t
<2>, X4
const&>>));
69 BOOST_TEST_TRAIT_TRUE((std::is_same
<mp_transform_if
<is_not_ref
, fifth
, L3
, L3
, L3
, L3
, mp_iota
<mp_size
<L3
>>>, std::pair
<mp_size_t
<0>, X2
&>>));
73 return boost::report_errors();