]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/struct/searchable.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / struct / searchable.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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
b32b8144
FG
5#include <boost/hana/accessors.hpp>
6#include <boost/hana/all_of.hpp>
7c673cae
FG
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>
b32b8144 12#include <boost/hana/second.hpp>
7c673cae
FG
13#include <boost/hana/string.hpp>
14
15#include <string>
16namespace hana = boost::hana;
17
18
19struct Person {
20 BOOST_HANA_DEFINE_STRUCT(Person,
21 (std::string, name),
22 (unsigned short, age)
23 );
24};
25
26int main() {
27 Person john{"John", 30};
28
29 BOOST_HANA_RUNTIME_CHECK(
30 hana::find(john, BOOST_HANA_STRING("name")) == hana::just("John")
31 );
32
33 BOOST_HANA_CONSTANT_CHECK(
34 hana::find(john, BOOST_HANA_STRING("foobar")) == hana::nothing
35 );
b32b8144
FG
36
37
38 BOOST_HANA_RUNTIME_CHECK(
39 hana::all_of(hana::accessors<Person>(), [&](auto a) {
40 return hana::second(a)(john) == hana::second(a)(john);
41 })
42 );
43
44 // the above is equivalent to:
45 BOOST_HANA_RUNTIME_CHECK(hana::equal(john, john));
7c673cae 46}