| 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/detail/variadic/drop_into.hpp> |
| 6 | |
| 7 | #include <boost/hana/assert.hpp> |
| 8 | #include <boost/hana/equal.hpp> |
| 9 | |
| 10 | #include <laws/base.hpp> |
| 11 | namespace hana = boost::hana; |
| 12 | namespace vd = hana::detail::variadic; |
| 13 | using hana::test::ct_eq; |
| 14 | |
| 15 | |
| 16 | struct non_pod { virtual ~non_pod() { } }; |
| 17 | |
| 18 | |
| 19 | int main() { |
| 20 | hana::test::_injection<0> f{}; |
| 21 | |
| 22 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 23 | vd::drop_into<0>(f)(), |
| 24 | f() |
| 25 | )); |
| 26 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 27 | vd::drop_into<0>(f)(ct_eq<0>{}), |
| 28 | f(ct_eq<0>{}) |
| 29 | )); |
| 30 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 31 | vd::drop_into<0>(f)(ct_eq<0>{}, ct_eq<1>{}), |
| 32 | f(ct_eq<0>{}, ct_eq<1>{}) |
| 33 | )); |
| 34 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 35 | vd::drop_into<0>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), |
| 36 | f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) |
| 37 | )); |
| 38 | |
| 39 | |
| 40 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 41 | vd::drop_into<1>(f)(ct_eq<0>{}), |
| 42 | f() |
| 43 | )); |
| 44 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 45 | vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}), |
| 46 | f(ct_eq<1>{}) |
| 47 | )); |
| 48 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 49 | vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), |
| 50 | f(ct_eq<1>{}, ct_eq<2>{}) |
| 51 | )); |
| 52 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 53 | vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), |
| 54 | f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) |
| 55 | )); |
| 56 | |
| 57 | |
| 58 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 59 | vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}), |
| 60 | f() |
| 61 | )); |
| 62 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 63 | vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), |
| 64 | f(ct_eq<2>{}) |
| 65 | )); |
| 66 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 67 | vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), |
| 68 | f(ct_eq<2>{}, ct_eq<3>{}) |
| 69 | )); |
| 70 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 71 | vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), |
| 72 | f(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) |
| 73 | )); |
| 74 | |
| 75 | // make sure we can use non-pods |
| 76 | vd::drop_into<1>(f)(ct_eq<0>{}, non_pod{}); |
| 77 | vd::drop_into<1>(f)(non_pod{}, ct_eq<1>{}); |
| 78 | } |
| 79 | |