]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/_include/auto/transform.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / _include / auto / transform.hpp
1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5 #ifndef BOOST_HANA_TEST_AUTO_TRANSFORM_HPP
6 #define BOOST_HANA_TEST_AUTO_TRANSFORM_HPP
7
8 #include <boost/hana/assert.hpp>
9 #include <boost/hana/equal.hpp>
10 #include <boost/hana/transform.hpp>
11
12 #include "test_case.hpp"
13 #include <laws/base.hpp>
14
15
16 TestCase test_transform{[] {
17 namespace hana = boost::hana;
18 using hana::test::ct_eq;
19 struct undefined { };
20 constexpr hana::test::_injection<0> f{};
21
22 BOOST_HANA_CONSTANT_CHECK(hana::equal(
23 hana::transform(MAKE_TUPLE(), undefined{}),
24 MAKE_TUPLE()
25 ));
26
27 BOOST_HANA_CONSTANT_CHECK(hana::equal(
28 hana::transform(MAKE_TUPLE(ct_eq<1>{}), f),
29 MAKE_TUPLE(f(ct_eq<1>{}))
30 ));
31
32 BOOST_HANA_CONSTANT_CHECK(hana::equal(
33 hana::transform(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), f),
34 MAKE_TUPLE(f(ct_eq<1>{}), f(ct_eq<2>{}))
35 ));
36
37 BOOST_HANA_CONSTANT_CHECK(hana::equal(
38 hana::transform(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), f),
39 MAKE_TUPLE(f(ct_eq<1>{}), f(ct_eq<2>{}), f(ct_eq<3>{}))
40 ));
41
42 BOOST_HANA_CONSTANT_CHECK(hana::equal(
43 hana::transform(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), f),
44 MAKE_TUPLE(f(ct_eq<1>{}), f(ct_eq<2>{}), f(ct_eq<3>{}), f(ct_eq<4>{}))
45 ));
46
47 #ifndef MAKE_TUPLE_NO_CONSTEXPR
48 struct incr {
49 constexpr int operator()(int i) const { return i + 1; }
50 };
51
52 static_assert(hana::equal(
53 hana::transform(MAKE_TUPLE(1), incr{}),
54 MAKE_TUPLE(2)
55 ), "");
56
57 static_assert(hana::equal(
58 hana::transform(MAKE_TUPLE(1, 2), incr{}),
59 MAKE_TUPLE(2, 3)
60 ), "");
61
62 static_assert(hana::equal(
63 hana::transform(MAKE_TUPLE(1, 2, 3), incr{}),
64 MAKE_TUPLE(2, 3, 4)
65 ), "");
66
67 static_assert(hana::equal(
68 hana::transform(MAKE_TUPLE(1, 2, 3, 4), incr{}),
69 MAKE_TUPLE(2, 3, 4, 5)
70 ), "");
71 #endif
72 }};
73
74 #endif // !BOOST_HANA_TEST_AUTO_TRANSFORM_HPP