]>
git.proxmox.com Git - ceph.git/blob - 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)
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>
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
;
23 MoveOnly(MoveOnly
&&) = default;
24 MoveOnly(MoveOnly
const&) = delete;
25 MoveOnly
& operator=(MoveOnly
&&) = default;
26 MoveOnly
& operator=(MoveOnly
const&) = delete;
30 constexpr auto pair
= ::minimal_product
;
32 hana::test::_injection
<0> f
{};
34 BOOST_HANA_CONSTANT_CHECK(hana::equal(
35 hana::fold_left(obj(), s
, undefined
<>{}),
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>{}))
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>{}))
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>{}))
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; });