| 1 | // Copyright Louis Dionne 2013-2022 |
| 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/detail/unpack_flatten.hpp> |
| 7 | #include <boost/hana/equal.hpp> |
| 8 | #include <boost/hana/tuple.hpp> |
| 9 | |
| 10 | #include <laws/base.hpp> |
| 11 | namespace hana = boost::hana; |
| 12 | using hana::test::ct_eq; |
| 13 | |
| 14 | |
| 15 | int main() { |
| 16 | constexpr auto f = hana::test::_injection<0>{}; |
| 17 | |
| 18 | { |
| 19 | auto tuples = hana::make_tuple(); |
| 20 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 21 | hana::detail::unpack_flatten(tuples, f), |
| 22 | f() |
| 23 | )); |
| 24 | } |
| 25 | |
| 26 | { |
| 27 | auto tuples = hana::make_tuple(hana::make_tuple()); |
| 28 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 29 | hana::detail::unpack_flatten(tuples, f), |
| 30 | f() |
| 31 | )); |
| 32 | } |
| 33 | |
| 34 | { |
| 35 | auto tuples = hana::make_tuple(hana::make_tuple(), hana::make_tuple()); |
| 36 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 37 | hana::detail::unpack_flatten(tuples, f), |
| 38 | f() |
| 39 | )); |
| 40 | } |
| 41 | |
| 42 | { |
| 43 | auto tuples = hana::make_tuple(hana::make_tuple(), |
| 44 | hana::make_tuple(), |
| 45 | hana::make_tuple()); |
| 46 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 47 | hana::detail::unpack_flatten(tuples, f), |
| 48 | f() |
| 49 | )); |
| 50 | } |
| 51 | |
| 52 | { |
| 53 | auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{})); |
| 54 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 55 | hana::detail::unpack_flatten(tuples, f), |
| 56 | f(ct_eq<0>{}) |
| 57 | )); |
| 58 | } |
| 59 | |
| 60 | { |
| 61 | auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{})); |
| 62 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 63 | hana::detail::unpack_flatten(tuples, f), |
| 64 | f(ct_eq<0>{}, ct_eq<1>{}) |
| 65 | )); |
| 66 | } |
| 67 | |
| 68 | { |
| 69 | auto tuples = hana::make_tuple(hana::make_tuple(), |
| 70 | hana::make_tuple(ct_eq<0>{})); |
| 71 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 72 | hana::detail::unpack_flatten(tuples, f), |
| 73 | f(ct_eq<0>{}) |
| 74 | )); |
| 75 | } |
| 76 | |
| 77 | { |
| 78 | auto tuples = hana::make_tuple(hana::make_tuple(), |
| 79 | hana::make_tuple(ct_eq<0>{}, ct_eq<1>{})); |
| 80 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 81 | hana::detail::unpack_flatten(tuples, f), |
| 82 | f(ct_eq<0>{}, ct_eq<1>{}) |
| 83 | )); |
| 84 | } |
| 85 | |
| 86 | { |
| 87 | auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), |
| 88 | hana::make_tuple(ct_eq<1>{})); |
| 89 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 90 | hana::detail::unpack_flatten(tuples, f), |
| 91 | f(ct_eq<0>{}, ct_eq<1>{}) |
| 92 | )); |
| 93 | } |
| 94 | |
| 95 | { |
| 96 | auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), |
| 97 | hana::make_tuple(ct_eq<1>{}), |
| 98 | hana::make_tuple(ct_eq<2>{})); |
| 99 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 100 | hana::detail::unpack_flatten(tuples, f), |
| 101 | f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) |
| 102 | )); |
| 103 | } |
| 104 | |
| 105 | { |
| 106 | auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), |
| 107 | hana::make_tuple(ct_eq<1>{}), |
| 108 | hana::make_tuple(ct_eq<2>{}, ct_eq<3>{})); |
| 109 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 110 | hana::detail::unpack_flatten(tuples, f), |
| 111 | f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) |
| 112 | )); |
| 113 | } |
| 114 | } |
| 115 | |