• 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/ext/std/integer_sequence.hpp>
8 #include <boost/hana/ext/std/integral_constant.hpp>
9 #include <boost/hana/find_if.hpp>
10 #include <boost/hana/optional.hpp>
11 
12 #include <cstddef>
13 #include <type_traits>
14 #include <utility>
15 namespace hana = boost::hana;
16 
17 
18 struct undefined { };
19 
20 
main()21 int main() {
22     BOOST_HANA_CONSTANT_CHECK(hana::equal(
23         hana::find_if(std::index_sequence<>{},
24                       hana::equal.to(undefined{})),
25         hana::nothing
26     ));
27 
28     BOOST_HANA_CONSTANT_CHECK(hana::equal(
29         hana::find_if(std::index_sequence<0>{},
30                       hana::equal.to(std::integral_constant<std::size_t, 0>{})),
31         hana::just(std::integral_constant<std::size_t, 0>{})
32     ));
33     BOOST_HANA_CONSTANT_CHECK(hana::equal(
34         hana::find_if(std::index_sequence<0>{},
35                       hana::equal.to(std::integral_constant<std::size_t, 1>{})),
36         hana::nothing
37     ));
38 
39     BOOST_HANA_CONSTANT_CHECK(hana::equal(
40         hana::find_if(std::index_sequence<0, 1>{},
41                       hana::equal.to(std::integral_constant<std::size_t, 0>{})),
42         hana::just(std::integral_constant<std::size_t, 0>{})
43     ));
44     BOOST_HANA_CONSTANT_CHECK(hana::equal(
45         hana::find_if(std::index_sequence<0, 1>{},
46                       hana::equal.to(std::integral_constant<std::size_t, 1>{})),
47         hana::just(std::integral_constant<std::size_t, 1>{})
48     ));
49     BOOST_HANA_CONSTANT_CHECK(hana::equal(
50         hana::find_if(std::index_sequence<0, 1>{},
51                       hana::equal.to(std::integral_constant<std::size_t, 2>{})),
52         hana::nothing
53     ));
54 
55     BOOST_HANA_CONSTANT_CHECK(hana::equal(
56         hana::find_if(std::index_sequence<0, 1, 2>{},
57                       hana::equal.to(std::integral_constant<std::size_t, 0>{})),
58         hana::just(std::integral_constant<std::size_t, 0>{})
59     ));
60     BOOST_HANA_CONSTANT_CHECK(hana::equal(
61         hana::find_if(std::index_sequence<0, 1, 2>{},
62                       hana::equal.to(std::integral_constant<std::size_t, 1>{})),
63         hana::just(std::integral_constant<std::size_t, 1>{})
64     ));
65     BOOST_HANA_CONSTANT_CHECK(hana::equal(
66         hana::find_if(std::index_sequence<0, 1, 2>{},
67                       hana::equal.to(std::integral_constant<std::size_t, 2>{})),
68         hana::just(std::integral_constant<std::size_t, 2>{})
69     ));
70     BOOST_HANA_CONSTANT_CHECK(hana::equal(
71         hana::find_if(std::index_sequence<0, 1, 2>{},
72                       hana::equal.to(std::integral_constant<std::size_t, 3>{})),
73         hana::nothing
74     ));
75 
76     BOOST_HANA_CONSTANT_CHECK(hana::equal(
77         hana::find_if(std::index_sequence<0, 1, 2, 3>{},
78                       hana::equal.to(std::integral_constant<std::size_t, 0>{})),
79         hana::just(std::integral_constant<std::size_t, 0>{})
80     ));
81     BOOST_HANA_CONSTANT_CHECK(hana::equal(
82         hana::find_if(std::index_sequence<0, 1, 2, 3>{},
83                       hana::equal.to(std::integral_constant<std::size_t, 1>{})),
84         hana::just(std::integral_constant<std::size_t, 1>{})
85     ));
86     BOOST_HANA_CONSTANT_CHECK(hana::equal(
87         hana::find_if(std::index_sequence<0, 1, 2, 3>{},
88                       hana::equal.to(std::integral_constant<std::size_t, 2>{})),
89         hana::just(std::integral_constant<std::size_t, 2>{})
90     ));
91     BOOST_HANA_CONSTANT_CHECK(hana::equal(
92         hana::find_if(std::index_sequence<0, 1, 2, 3>{},
93                       hana::equal.to(std::integral_constant<std::size_t, 3>{})),
94         hana::just(std::integral_constant<std::size_t, 3>{})
95     ));
96     BOOST_HANA_CONSTANT_CHECK(hana::equal(
97         hana::find_if(std::index_sequence<0, 1, 2, 3>{},
98                       hana::equal.to(std::integral_constant<std::size_t, 4>{})),
99         hana::nothing
100     ));
101 }
102