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/find_if.hpp>
8 #include <boost/hana/map.hpp>
9 #include <boost/hana/optional.hpp>
10
11 #include <laws/base.hpp>
12 #include <support/minimal_product.hpp>
13 namespace hana = boost::hana;
14
15
16 template <int i>
key()17 auto key() { return hana::test::ct_eq<i>{}; }
18
19 template <int i>
val()20 auto val() { return hana::test::ct_eq<-i>{}; }
21
22 template <int i, int j>
p()23 auto p() { return ::minimal_product(key<i>(), val<j>()); }
24
main()25 int main() {
26 BOOST_HANA_CONSTANT_CHECK(hana::equal(
27 hana::find_if(hana::make_map(), hana::equal.to(key<1>())),
28 hana::nothing
29 ));
30
31 BOOST_HANA_CONSTANT_CHECK(hana::equal(
32 hana::find_if(hana::make_map(p<1, 1>()), hana::equal.to(key<1>())),
33 hana::just(val<1>())
34 ));
35 BOOST_HANA_CONSTANT_CHECK(hana::equal(
36 hana::find_if(hana::make_map(p<1, 1>()), hana::equal.to(key<2>())),
37 hana::nothing
38 ));
39
40 BOOST_HANA_CONSTANT_CHECK(hana::equal(
41 hana::find_if(hana::make_map(p<1, 1>(), p<2, 2>()), hana::equal.to(key<1>())),
42 hana::just(val<1>())
43 ));
44 BOOST_HANA_CONSTANT_CHECK(hana::equal(
45 hana::find_if(hana::make_map(p<1, 1>(), p<2, 2>()), hana::equal.to(key<2>())),
46 hana::just(val<2>())
47 ));
48 BOOST_HANA_CONSTANT_CHECK(hana::equal(
49 hana::find_if(hana::make_map(p<1, 1>(), p<2, 2>()), hana::equal.to(key<3>())),
50 hana::nothing
51 ));
52 }
53