]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/concept/struct/fold_left.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / concept / struct / fold_left.cpp
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 #include <boost/hana/assert.hpp>
6 #include <boost/hana/concept/struct.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/fold_left.hpp>
9 #include <boost/hana/integral_constant.hpp>
10
11 #include "minimal_struct.hpp"
12 #include <laws/base.hpp>
13 #include <support/minimal_product.hpp>
14 namespace hana = boost::hana;
15 using hana::test::ct_eq;
16
17
18 template <int i = 0>
19 struct undefined { };
20
21 struct MoveOnly {
22 MoveOnly() = default;
23 MoveOnly(MoveOnly&&) = default;
24 MoveOnly(MoveOnly const&) = delete;
25 MoveOnly& operator=(MoveOnly&&) = default;
26 MoveOnly& operator=(MoveOnly const&) = delete;
27 };
28
29 int main() {
30 constexpr auto pair = ::minimal_product;
31 ct_eq<999> s{};
32 hana::test::_injection<0> f{};
33
34 BOOST_HANA_CONSTANT_CHECK(hana::equal(
35 hana::fold_left(obj(), s, undefined<>{}),
36 s
37 ));
38
39 BOOST_HANA_CONSTANT_CHECK(hana::equal(
40 hana::fold_left(obj(ct_eq<0>{}), s, f),
41 f(s, pair(hana::int_c<0>, ct_eq<0>{}))
42 ));
43
44 BOOST_HANA_CONSTANT_CHECK(hana::equal(
45 hana::fold_left(obj(ct_eq<0>{}, ct_eq<1>{}), s, f),
46 f(f(s, pair(hana::int_c<0>, ct_eq<0>{})), pair(hana::int_c<1>, ct_eq<1>{}))
47 ));
48
49 BOOST_HANA_CONSTANT_CHECK(hana::equal(
50 hana::fold_left(obj(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), s, f),
51 f(f(f(s, pair(hana::int_c<0>, ct_eq<0>{})),
52 pair(hana::int_c<1>, ct_eq<1>{})),
53 pair(hana::int_c<2>, ct_eq<2>{}))
54 ));
55
56 // fold_left with move-only members
57 hana::fold_left(obj(MoveOnly{}), 0, [](int, auto) { return 0; });
58 hana::fold_left(obj(MoveOnly{}, MoveOnly{}), 0, [](int, auto) { return 0; });
59 }