]>
Commit | Line | Data |
---|---|---|
1 | // Copyright Louis Dionne 2013-2022 | |
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/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; | |
15 | ||
16 | ||
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') | |
20 | ); | |
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); | |
25 | ||
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', ""); | |
29 | ||
30 | int main() { } |