• 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/equal.hpp>
7 #include <boost/hana/experimental/view.hpp>
8 #include <boost/hana/tuple.hpp>
9 #include <boost/hana/unpack.hpp>
10 
11 #include <laws/base.hpp>
12 #include <support/seq.hpp>
13 namespace hana = boost::hana;
14 using hana::test::ct_eq;
15 
16 
main()17 int main() {
18     auto container = ::seq;
19     auto f = hana::test::_injection<0>{};
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::unpack(sliced, f),
26             f()
27         ));
28     }
29 
30     {
31         auto storage = container(ct_eq<0>{});
32         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>);
33         BOOST_HANA_CONSTANT_CHECK(hana::equal(
34             hana::unpack(sliced, f),
35             f()
36         ));
37     }{
38         auto storage = container(ct_eq<0>{});
39         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>);
40         BOOST_HANA_CONSTANT_CHECK(hana::equal(
41             hana::unpack(sliced, f),
42             f(ct_eq<0>{})
43         ));
44     }
45 
46     {
47         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
48         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>);
49         BOOST_HANA_CONSTANT_CHECK(hana::equal(
50             hana::unpack(sliced, f),
51             f()
52         ));
53     }{
54         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
55         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>);
56         BOOST_HANA_CONSTANT_CHECK(hana::equal(
57             hana::unpack(sliced, f),
58             f(ct_eq<0>{})
59         ));
60     }{
61         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
62         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>);
63         BOOST_HANA_CONSTANT_CHECK(hana::equal(
64             hana::unpack(sliced, f),
65             f(ct_eq<0>{}, ct_eq<1>{})
66         ));
67     }{
68         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
69         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1>);
70         BOOST_HANA_CONSTANT_CHECK(hana::equal(
71             hana::unpack(sliced, f),
72             f(ct_eq<1>{})
73         ));
74     }{
75         auto storage = container(ct_eq<0>{}, ct_eq<1>{});
76         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 0>);
77         BOOST_HANA_CONSTANT_CHECK(hana::equal(
78             hana::unpack(sliced, f),
79             f(ct_eq<1>{}, ct_eq<0>{})
80         ));
81     }
82 
83     {
84         auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{});
85         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>);
86         BOOST_HANA_CONSTANT_CHECK(hana::equal(
87             hana::unpack(sliced, f),
88             f()
89         ));
90     }{
91         auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{});
92         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>);
93         BOOST_HANA_CONSTANT_CHECK(hana::equal(
94             hana::unpack(sliced, f),
95             f(ct_eq<0>{})
96         ));
97     }{
98         auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{});
99         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1>);
100         BOOST_HANA_CONSTANT_CHECK(hana::equal(
101             hana::unpack(sliced, f),
102             f(ct_eq<1>{})
103         ));
104     }{
105         auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{});
106         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 2>);
107         BOOST_HANA_CONSTANT_CHECK(hana::equal(
108             hana::unpack(sliced, f),
109             f(ct_eq<2>{})
110         ));
111     }{
112         auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{});
113         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 2>);
114         BOOST_HANA_CONSTANT_CHECK(hana::equal(
115             hana::unpack(sliced, f),
116             f(ct_eq<0>{}, ct_eq<2>{})
117         ));
118     }{
119         auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{});
120         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 1>);
121         BOOST_HANA_CONSTANT_CHECK(hana::equal(
122             hana::unpack(sliced, f),
123             f(ct_eq<1>{}, ct_eq<1>{})
124         ));
125     }
126 
127     {
128         auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{});
129         auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 3, 1, 0, 2, 2>);
130         BOOST_HANA_CONSTANT_CHECK(hana::equal(
131             hana::unpack(sliced, f),
132             f(ct_eq<3>{}, ct_eq<1>{}, ct_eq<0>{}, ct_eq<2>{}, ct_eq<2>{})
133         ));
134     }
135 }
136