• 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/detail/variadic/at.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 
~non_podnon_pod16 struct non_pod { virtual ~non_pod() { } };
17 
18 template <int i> struct y { };
19 
main()20 int main() {
21     BOOST_HANA_CONSTANT_CHECK(hana::equal(
22         vd::at<0>(ct_eq<0>{}),
23         ct_eq<0>{}
24     ));
25 
26     BOOST_HANA_CONSTANT_CHECK(hana::equal(
27         vd::at<0>(ct_eq<0>{}, ct_eq<1>{}),
28         ct_eq<0>{}
29     ));
30     BOOST_HANA_CONSTANT_CHECK(hana::equal(
31         vd::at<1>(y<0>{}, ct_eq<1>{}),
32         ct_eq<1>{}
33     ));
34 
35     BOOST_HANA_CONSTANT_CHECK(hana::equal(
36         vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}),
37         ct_eq<0>{}
38     ));
39     BOOST_HANA_CONSTANT_CHECK(hana::equal(
40         vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}),
41         ct_eq<1>{}
42     ));
43     BOOST_HANA_CONSTANT_CHECK(hana::equal(
44         vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}),
45         ct_eq<2>{}
46     ));
47 
48     BOOST_HANA_CONSTANT_CHECK(hana::equal(
49         vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}, y<3>{}),
50         ct_eq<0>{}
51     ));
52     BOOST_HANA_CONSTANT_CHECK(hana::equal(
53         vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}, y<3>{}),
54         ct_eq<1>{}
55     ));
56     BOOST_HANA_CONSTANT_CHECK(hana::equal(
57         vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}, y<3>{}),
58         ct_eq<2>{}
59     ));
60     BOOST_HANA_CONSTANT_CHECK(hana::equal(
61         vd::at<3>(y<0>{}, y<1>{}, y<2>{}, ct_eq<3>{}),
62         ct_eq<3>{}
63     ));
64 
65     BOOST_HANA_CONSTANT_CHECK(hana::equal(
66         vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}, y<3>{}, y<4>{}),
67         ct_eq<0>{}
68     ));
69     BOOST_HANA_CONSTANT_CHECK(hana::equal(
70         vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}, y<3>{}, y<4>{}),
71         ct_eq<1>{}
72     ));
73     BOOST_HANA_CONSTANT_CHECK(hana::equal(
74         vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}, y<3>{}, y<4>{}),
75         ct_eq<2>{}
76     ));
77     BOOST_HANA_CONSTANT_CHECK(hana::equal(
78         vd::at<3>(y<0>{}, y<1>{}, y<2>{}, ct_eq<3>{}, y<4>{}),
79         ct_eq<3>{}
80     ));
81     BOOST_HANA_CONSTANT_CHECK(hana::equal(
82         vd::at<4>(y<0>{}, y<1>{}, y<2>{}, y<3>{}, ct_eq<4>{}),
83         ct_eq<4>{}
84     ));
85 
86     // make sure we can use non-pods on both side of the fetched object
87     vd::at<0>(ct_eq<0>{}, non_pod{});
88     vd::at<1>(non_pod{}, ct_eq<1>{});
89 
90     // make sure it works with const objects
91     int const i = 1;
92     vd::at<0>(i);
93 }
94