]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/experimental/types/unpack.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / experimental / types / unpack.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)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/equal.hpp>
7 #include <boost/hana/experimental/types.hpp>
8 #include <boost/hana/type.hpp>
9 #include <boost/hana/unpack.hpp>
10
11 #include <laws/base.hpp>
12 namespace hana = boost::hana;
13
14
15 template <typename ...>
16 struct mf { struct type; };
17
18 template <int> struct x;
19
20 int main() {
21 // with a Metafunction
22 {
23 BOOST_HANA_CONSTANT_CHECK(hana::equal(
24 hana::unpack(hana::experimental::types<>{}, hana::metafunction<mf>),
25 hana::type_c<mf<>::type>
26 ));
27
28 BOOST_HANA_CONSTANT_CHECK(hana::equal(
29 hana::unpack(hana::experimental::types<x<0>>{}, hana::metafunction<mf>),
30 hana::type_c<mf<x<0>>::type>
31 ));
32
33 BOOST_HANA_CONSTANT_CHECK(hana::equal(
34 hana::unpack(hana::experimental::types<x<0>, x<1>>{}, hana::metafunction<mf>),
35 hana::type_c<mf<x<0>, x<1>>::type>
36 ));
37
38 BOOST_HANA_CONSTANT_CHECK(hana::equal(
39 hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::metafunction<mf>),
40 hana::type_c<mf<x<0>, x<1>, x<2>>::type>
41 ));
42
43 BOOST_HANA_CONSTANT_CHECK(hana::equal(
44 hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::metafunction<mf>),
45 hana::type_c<mf<x<0>, x<1>, x<2>, x<3>>::type>
46 ));
47
48 BOOST_HANA_CONSTANT_CHECK(hana::equal(
49 hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>, x<4>>{}, hana::metafunction<mf>),
50 hana::type_c<mf<x<0>, x<1>, x<2>, x<3>, x<4>>::type>
51 ));
52 }
53
54 // with a non-Metafunction
55 {
56 auto f = hana::test::_injection<0>{};
57
58 BOOST_HANA_CONSTANT_CHECK(hana::equal(
59 hana::unpack(hana::experimental::types<>{}, f),
60 f()
61 ));
62
63 BOOST_HANA_CONSTANT_CHECK(hana::equal(
64 hana::unpack(hana::experimental::types<x<0>>{}, f),
65 f(hana::type_c<x<0>>)
66 ));
67
68 BOOST_HANA_CONSTANT_CHECK(hana::equal(
69 hana::unpack(hana::experimental::types<x<0>, x<1>>{}, f),
70 f(hana::type_c<x<0>>, hana::type_c<x<1>>)
71 ));
72
73 BOOST_HANA_CONSTANT_CHECK(hana::equal(
74 hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>>{}, f),
75 f(hana::type_c<x<0>>, hana::type_c<x<1>>, hana::type_c<x<2>>)
76 ));
77
78 BOOST_HANA_CONSTANT_CHECK(hana::equal(
79 hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, f),
80 f(hana::type_c<x<0>>, hana::type_c<x<1>>, hana::type_c<x<2>>, hana::type_c<x<3>>)
81 ));
82 }
83 }