]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/map/searchable.cpp
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)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/at_key.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/find.hpp>
9 #include <boost/hana/integral_constant.hpp>
10 #include <boost/hana/map.hpp>
11 #include <boost/hana/optional.hpp>
12 #include <boost/hana/pair.hpp>
13 #include <boost/hana/type.hpp>
14 namespace hana
= boost::hana
;
17 constexpr auto m
= hana::make_map(
18 hana::make_pair(hana::type_c
<int>, 'i'),
19 hana::make_pair(hana::type_c
<float>, 'f')
21 static_assert(hana::find(m
, hana::type_c
<int>) == hana::just('i'), "");
22 static_assert(hana::find(m
, hana::type_c
<float>) == hana::just('f'), "");
23 BOOST_HANA_CONSTANT_CHECK(hana::find(m
, hana::type_c
<void>) == hana::nothing
);
24 BOOST_HANA_CONSTANT_CHECK(hana::find(m
, hana::int_c
<3>) == hana::nothing
);
26 // operator[] is equivalent to at_key
27 static_assert(m
[hana::type_c
<int>] == 'i', "");
28 static_assert(m
[hana::type_c
<float>] == 'f', "");