]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/concept/struct/member_function.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / concept / struct / member_function.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)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/for_each.hpp>
7 #include <boost/hana/fuse.hpp>
8 #include <boost/hana/fwd/accessors.hpp>
9 #include <boost/hana/pair.hpp>
10 #include <boost/hana/string.hpp>
11 #include <boost/hana/tuple.hpp>
12
13 #include <string>
14 namespace hana = boost::hana;
15
16
17 //
18 // Unit test inspired by http://stackoverflow.com/q/32678647/627587
19 //
20
21 struct Foo {
22 std::string get_name() const { return "louis"; }
23 };
24
25 namespace boost { namespace hana {
26 template <>
27 struct accessors_impl<Foo> {
28 static auto apply() {
29 return hana::make_tuple(
30 hana::make_pair(BOOST_HANA_STRING("get_name"), [](auto const& foo) {
31 return foo.get_name();
32 })
33 );
34 }
35 };
36 }}
37
38 int main() {
39 Foo foo;
40 hana::for_each(foo, hana::fuse([](auto /*key*/, std::string const& name) {
41 BOOST_HANA_RUNTIME_CHECK(name == "louis");
42 }));
43 }