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/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>
14 namespace hana = boost::hana;
18 // Unit test inspired by http://stackoverflow.com/q/32678647/627587
22 std::string get_name() const { return "louis"; }
25 namespace boost { namespace hana {
27 struct accessors_impl<Foo> {
29 return hana::make_tuple(
30 hana::make_pair(BOOST_HANA_STRING("get_name"), [](auto const& foo) {
31 return foo.get_name();
40 hana::for_each(foo, hana::fuse([](auto /*key*/, std::string const& name) {
41 BOOST_HANA_RUNTIME_CHECK(name == "louis");