]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/map/fold_left.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / map / fold_left.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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/contains.hpp>
7#include <boost/hana/equal.hpp>
8#include <boost/hana/fold_left.hpp>
9#include <boost/hana/map.hpp>
10#include <boost/hana/permutations.hpp>
11#include <boost/hana/transform.hpp>
12
13#include <laws/base.hpp>
14#include <support/seq.hpp>
15#include <support/minimal_product.hpp>
16namespace hana = boost::hana;
17
18
19template <int i>
20auto key() { return hana::test::ct_eq<i>{}; }
21
22template <int i>
23auto val() { return hana::test::ct_eq<-i>{}; }
24
25template <int i, int j>
26auto p() { return ::minimal_product(key<i>(), val<j>()); }
27
28struct undefined { };
29
30int main() {
b32b8144 31 auto sequence = ::seq;
7c673cae 32
b32b8144 33 // Use pointers to work around a Clang ICE
7c673cae
FG
34 hana::test::_injection<0> f{};
35 auto* fp = &f;
36
37 hana::test::ct_eq<999> state{};
38 auto* statep = &state;
39
40 auto check = [=](auto ...pairs) {
41 auto possible_results = hana::transform(hana::permutations(sequence(pairs...)),
42 [=](auto xs) {
43 return hana::fold_left(xs, *statep, *fp);
44 }
45 );
46
47 BOOST_HANA_CONSTANT_CHECK(hana::contains(
48 possible_results,
49 hana::fold_left(hana::make_map(pairs...), state, f)
50 ));
51 };
52
53 check();
54 check(p<1, 1>());
55 check(p<1, 1>(), p<2, 2>());
56 check(p<1, 1>(), p<2, 2>(), p<3, 3>());
57 check(p<1, 1>(), p<2, 2>(), p<3, 3>(), p<4, 4>());
58}