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)
4 
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/equal.hpp>
7 #include <boost/hana/tuple.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 using hana::test::ct_eq;
14 
15 
16 template <typename ...>
17 struct F { struct type; };
18 
19 struct x0;
20 struct x1;
21 struct x2;
22 struct x3;
23 
main()24 int main() {
25     hana::test::_injection<0> f{};
26 
27     // tuple
28     BOOST_HANA_CONSTANT_CHECK(hana::equal(
29         hana::unpack(hana::make_tuple(), f),
30         f()
31     ));
32     BOOST_HANA_CONSTANT_CHECK(hana::equal(
33         hana::unpack(hana::make_tuple(ct_eq<0>{}), f),
34         f(ct_eq<0>{})
35     ));
36     BOOST_HANA_CONSTANT_CHECK(hana::equal(
37         hana::unpack(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}), f),
38         f(ct_eq<0>{}, ct_eq<1>{})
39     ));
40     BOOST_HANA_CONSTANT_CHECK(hana::equal(
41         hana::unpack(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), f),
42         f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
43     ));
44 
45     // tuple_t
46     BOOST_HANA_CONSTANT_CHECK(hana::equal(
47         hana::unpack(hana::tuple_t<>, f),
48         f()
49     ));
50     BOOST_HANA_CONSTANT_CHECK(hana::equal(
51         hana::unpack(hana::tuple_t<x0>, f),
52         f(hana::type_c<x0>)
53     ));
54     BOOST_HANA_CONSTANT_CHECK(hana::equal(
55         hana::unpack(hana::tuple_t<x0, x1>, f),
56         f(hana::type_c<x0>, hana::type_c<x1>)
57     ));
58     BOOST_HANA_CONSTANT_CHECK(hana::equal(
59         hana::unpack(hana::tuple_t<x0, x1, x2>, f),
60         f(hana::type_c<x0>, hana::type_c<x1>, hana::type_c<x2>)
61     ));
62     BOOST_HANA_CONSTANT_CHECK(hana::equal(
63         hana::unpack(hana::tuple_t<x0, x1, x2, x3>, f),
64         f(hana::type_c<x0>, hana::type_c<x1>, hana::type_c<x2>, hana::type_c<x3>)
65     ));
66 
67     // tuple_t with metafunction
68     auto g = hana::metafunction<F>;
69     BOOST_HANA_CONSTANT_CHECK(hana::equal(
70         hana::unpack(hana::tuple_t<>, g),
71         g()
72     ));
73     BOOST_HANA_CONSTANT_CHECK(hana::equal(
74         hana::unpack(hana::tuple_t<x0>, g),
75         g(hana::type_c<x0>)
76     ));
77     BOOST_HANA_CONSTANT_CHECK(hana::equal(
78         hana::unpack(hana::tuple_t<x0, x1>, g),
79         g(hana::type_c<x0>, hana::type_c<x1>)
80     ));
81     BOOST_HANA_CONSTANT_CHECK(hana::equal(
82         hana::unpack(hana::tuple_t<x0, x1, x2>, g),
83         g(hana::type_c<x0>, hana::type_c<x1>, hana::type_c<x2>)
84     ));
85     BOOST_HANA_CONSTANT_CHECK(hana::equal(
86         hana::unpack(hana::tuple_t<x0, x1, x2, x3>, g),
87         g(hana::type_c<x0>, hana::type_c<x1>, hana::type_c<x2>, hana::type_c<x3>)
88     ));
89 }
90