| 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/equal.hpp> |
| 7 | #include <boost/hana/experimental/view.hpp> |
| 8 | #include <boost/hana/integral_constant.hpp> |
| 9 | #include <boost/hana/length.hpp> |
| 10 | #include <boost/hana/tuple.hpp> |
| 11 | |
| 12 | #include <support/seq.hpp> |
| 13 | namespace hana = boost::hana; |
| 14 | |
| 15 | |
| 16 | template <int> struct undefined { }; |
| 17 | |
| 18 | int main() { |
| 19 | auto container = ::seq; |
| 20 | |
| 21 | { |
| 22 | auto storage = container(); |
| 23 | auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); |
| 24 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 25 | hana::length(sliced), |
| 26 | hana::size_c<0> |
| 27 | )); |
| 28 | } |
| 29 | |
| 30 | { |
| 31 | auto storage = container(undefined<0>{}); |
| 32 | auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); |
| 33 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 34 | hana::length(sliced), |
| 35 | hana::size_c<1> |
| 36 | )); |
| 37 | }{ |
| 38 | auto storage = container(undefined<0>{}); |
| 39 | auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); |
| 40 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 41 | hana::length(sliced), |
| 42 | hana::size_c<0> |
| 43 | )); |
| 44 | } |
| 45 | |
| 46 | { |
| 47 | auto storage = container(undefined<0>{}, undefined<1>{}); |
| 48 | auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); |
| 49 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 50 | hana::length(sliced), |
| 51 | hana::size_c<1> |
| 52 | )); |
| 53 | }{ |
| 54 | auto storage = container(undefined<0>{}, undefined<1>{}); |
| 55 | auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>); |
| 56 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 57 | hana::length(sliced), |
| 58 | hana::size_c<2> |
| 59 | )); |
| 60 | }{ |
| 61 | auto storage = container(undefined<0>{}, undefined<1>{}); |
| 62 | auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 0>); |
| 63 | BOOST_HANA_CONSTANT_CHECK(hana::equal( |
| 64 | hana::length(sliced), |
| 65 | hana::size_c<2> |
| 66 | )); |
| 67 | } |
| 68 | } |
| 69 | |