]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/struct/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/accessors.hpp>
6 #include <boost/hana/all_of.hpp>
7 #include <boost/hana/assert.hpp>
8 #include <boost/hana/define_struct.hpp>
9 #include <boost/hana/equal.hpp>
10 #include <boost/hana/find.hpp>
11 #include <boost/hana/optional.hpp>
12 #include <boost/hana/second.hpp>
13 #include <boost/hana/string.hpp>
16 namespace hana
= boost::hana
;
20 BOOST_HANA_DEFINE_STRUCT(Person
,
27 Person john
{"John", 30};
29 BOOST_HANA_RUNTIME_CHECK(
30 hana::find(john
, BOOST_HANA_STRING("name")) == hana::just("John")
33 BOOST_HANA_CONSTANT_CHECK(
34 hana::find(john
, BOOST_HANA_STRING("foobar")) == hana::nothing
38 BOOST_HANA_RUNTIME_CHECK(
39 hana::all_of(hana::accessors
<Person
>(), [&](auto a
) {
40 return hana::second(a
)(john
) == hana::second(a
)(john
);
44 // the above is equivalent to:
45 BOOST_HANA_RUNTIME_CHECK(hana::equal(john
, john
));