]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/tuple/special.fold_left.cpp
1 // Copyright Louis Dionne 2013-2016
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/equal.hpp>
7 #include <boost/hana/fold_left.hpp>
8 #include <boost/hana/tuple.hpp>
9 #include <boost/hana/type.hpp>
10 namespace hana
= boost::hana
;
13 template <typename
...>
14 struct F
{ struct type
; };
22 // tuple_t and initial state
24 auto f
= hana::metafunction
<F
>;
25 auto s
= hana::type_c
<struct initial_state
>;
26 BOOST_HANA_CONSTANT_CHECK(hana::equal(
27 hana::fold_left(hana::tuple_t
<>, s
, f
),
30 BOOST_HANA_CONSTANT_CHECK(hana::equal(
31 hana::fold_left(hana::tuple_t
<x0
>, s
, f
),
32 f(s
, hana::type_c
<x0
>)
34 BOOST_HANA_CONSTANT_CHECK(hana::equal(
35 hana::fold_left(hana::tuple_t
<x0
, x1
>, s
, f
),
36 f(f(s
, hana::type_c
<x0
>), hana::type_c
<x1
>)
38 BOOST_HANA_CONSTANT_CHECK(hana::equal(
39 hana::fold_left(hana::tuple_t
<x0
, x1
, x2
>, s
, f
),
40 f(f(f(s
, hana::type_c
<x0
>), hana::type_c
<x1
>), hana::type_c
<x2
>)
42 BOOST_HANA_CONSTANT_CHECK(hana::equal(
43 hana::fold_left(hana::tuple_t
<x0
, x1
, x2
, x3
>, s
, f
),
44 f(f(f(f(s
, hana::type_c
<x0
>), hana::type_c
<x1
>), hana::type_c
<x2
>), hana::type_c
<x3
>)
48 // tuple_t and no initial state
50 auto f
= hana::metafunction
<F
>;
51 BOOST_HANA_CONSTANT_CHECK(hana::equal(
52 hana::fold_left(hana::tuple_t
<x0
>, f
),
55 BOOST_HANA_CONSTANT_CHECK(hana::equal(
56 hana::fold_left(hana::tuple_t
<x0
, x1
>, f
),
57 f(hana::type_c
<x0
>, hana::type_c
<x1
>)
59 BOOST_HANA_CONSTANT_CHECK(hana::equal(
60 hana::fold_left(hana::tuple_t
<x0
, x1
, x2
>, f
),
61 f(f(hana::type_c
<x0
>, hana::type_c
<x1
>), hana::type_c
<x2
>)
63 BOOST_HANA_CONSTANT_CHECK(hana::equal(
64 hana::fold_left(hana::tuple_t
<x0
, x1
, x2
, x3
>, f
),
65 f(f(f(hana::type_c
<x0
>, hana::type_c
<x1
>), hana::type_c
<x2
>), hana::type_c
<x3
>)