]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/map/to.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/contains.hpp>
7 #include <boost/hana/core/to.hpp>
8 #include <boost/hana/equal.hpp>
9 #include <boost/hana/map.hpp>
10 #include <boost/hana/permutations.hpp>
12 #include <laws/base.hpp>
13 #include <support/minimal_product.hpp>
14 #include <support/seq.hpp>
15 namespace hana
= boost::hana
;
19 auto key() { return hana::test::ct_eq
<i
>{}; }
22 auto val() { return hana::test::ct_eq
<-i
>{}; }
24 template <int i
, int j
>
25 auto p() { return ::minimal_product(key
<i
>(), val
<j
>()); }
28 constexpr auto foldable
= ::seq
;
29 auto sequence
= ::seq
;
33 BOOST_HANA_CONSTANT_CHECK(hana::equal(
34 hana::to_map(foldable()),
37 BOOST_HANA_CONSTANT_CHECK(hana::equal(
38 hana::to_map(foldable(p
<1, 1>())),
39 hana::make_map(p
<1, 1>())
41 BOOST_HANA_CONSTANT_CHECK(hana::equal(
42 hana::to_map(foldable(p
<1, 1>(), p
<2, 2>())),
43 hana::make_map(p
<1, 1>(), p
<2, 2>())
45 BOOST_HANA_CONSTANT_CHECK(hana::equal(
46 hana::to_map(foldable(p
<1, 1>(), p
<2, 2>(), p
<3, 3>())),
47 hana::make_map(p
<1, 1>(), p
<2, 2>(), p
<3, 3>())
51 BOOST_HANA_CONSTANT_CHECK(hana::equal(
52 hana::to_map(foldable(p
<1, 1>(), p
<1, 99>())),
53 hana::make_map(p
<1, 1>())
55 BOOST_HANA_CONSTANT_CHECK(hana::equal(
56 hana::to_map(foldable(p
<1, 1>(), p
<2, 2>(), p
<1, 99>())),
57 hana::make_map(p
<1, 1>(), p
<2, 2>())
59 BOOST_HANA_CONSTANT_CHECK(hana::equal(
60 hana::to_map(foldable(p
<1, 1>(), p
<2, 2>(), p
<1, 99>(), p
<2, 99>())),
61 hana::make_map(p
<1, 1>(), p
<2, 2>())
63 BOOST_HANA_CONSTANT_CHECK(hana::equal(
64 hana::to_map(foldable(p
<1, 1>(), p
<2, 2>(), p
<1, 99>(), p
<2, 99>(), p
<3, 3>())),
65 hana::make_map(p
<1, 1>(), p
<2, 2>(), p
<3, 3>())
71 auto check
= [=](auto ...xs
) {
72 BOOST_HANA_CONSTANT_CHECK(hana::contains(
73 hana::permutations(sequence(xs
...)),
74 hana::to
<::Seq
>(hana::make_map(xs
...))
80 check(p
<1, 1>(), p
<2, 2>());
81 check(p
<1, 1>(), p
<2, 2>(), p
<3, 3>());
82 check(p
<1, 1>(), p
<2, 2>(), p
<3, 3>(), p
<4, 4>());
85 // to_map == to<map_tag>
87 BOOST_HANA_CONSTANT_CHECK(hana::equal(
88 hana::to_map(foldable(p
<1, 1>(), p
<2, 2>(), p
<1, 99>(), p
<2, 99>(), p
<3, 3>())),
89 hana::to
<hana::map_tag
>(foldable(p
<1, 1>(), p
<2, 2>(), p
<1, 99>(), p
<2, 99>(), p
<3, 3>()))