• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/at.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/experimental/view.hpp>
9 #include <boost/hana/integral_constant.hpp>
10 #include <boost/hana/tuple.hpp>
11 
12 #include <laws/base.hpp>
13 #include <support/seq.hpp>
14 namespace hana = boost::hana;
15 using hana::test::ct_eq;
16 
17 
main()18 int main() {
19     auto container = ::seq;
20 
21     {
22         auto storage = container(ct_eq<0>{});
23         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>);
24         BOOST_HANA_CONSTANT_CHECK(hana::equal(
25             hana::at(sliced, hana::size_c<0>),
26             ct_eq<0>{}
27         ));
28     }
29 
30     {
31         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
32         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>);
33         BOOST_HANA_CONSTANT_CHECK(hana::equal(
34             hana::at(sliced, hana::size_c<0>),
35             ct_eq<0>{}
36         ));
37     }{
38         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
39         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1>);
40         BOOST_HANA_CONSTANT_CHECK(hana::equal(
41             hana::at(sliced, hana::size_c<0>),
42             ct_eq<1>{}
43         ));
44     }{
45         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
46         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>);
47         BOOST_HANA_CONSTANT_CHECK(hana::equal(
48             hana::at(sliced, hana::size_c<0>),
49             ct_eq<0>{}
50         ));
51         BOOST_HANA_CONSTANT_CHECK(hana::equal(
52             hana::at(sliced, hana::size_c<1>),
53             ct_eq<1>{}
54         ));
55     }{
56         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
57         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 0>);
58         BOOST_HANA_CONSTANT_CHECK(hana::equal(
59             hana::at(sliced, hana::size_c<0>),
60             ct_eq<1>{}
61         ));
62         BOOST_HANA_CONSTANT_CHECK(hana::equal(
63             hana::at(sliced, hana::size_c<1>),
64             ct_eq<0>{}
65         ));
66     }{
67         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
68         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 0>);
69         BOOST_HANA_CONSTANT_CHECK(hana::equal(
70             hana::at(sliced, hana::size_c<0>),
71             ct_eq<0>{}
72         ));
73         BOOST_HANA_CONSTANT_CHECK(hana::equal(
74             hana::at(sliced, hana::size_c<1>),
75             ct_eq<0>{}
76         ));
77     }
78 
79     {
80         auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{});
81         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 3>);
82         BOOST_HANA_CONSTANT_CHECK(hana::equal(
83             hana::at(sliced, hana::size_c<0>),
84             ct_eq<1>{}
85         ));
86         BOOST_HANA_CONSTANT_CHECK(hana::equal(
87             hana::at(sliced, hana::size_c<1>),
88             ct_eq<3>{}
89         ));
90     }
91 }
92