]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/struct/searchable.cpp
ce25f182b89a0f638c07afefb025362eabfc00c7
[ceph.git] / ceph / src / boost / libs / hana / example / struct / searchable.cpp
1 // Copyright Louis Dionne 2013-2016
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/define_struct.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/find.hpp>
9 #include <boost/hana/optional.hpp>
10 #include <boost/hana/string.hpp>
11
12 #include <string>
13 namespace hana = boost::hana;
14
15
16 struct Person {
17 BOOST_HANA_DEFINE_STRUCT(Person,
18 (std::string, name),
19 (unsigned short, age)
20 );
21 };
22
23 int main() {
24 Person john{"John", 30};
25
26 BOOST_HANA_RUNTIME_CHECK(
27 hana::find(john, BOOST_HANA_STRING("name")) == hana::just("John")
28 );
29
30 BOOST_HANA_CONSTANT_CHECK(
31 hana::find(john, BOOST_HANA_STRING("foobar")) == hana::nothing
32 );
33 }