]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/functional/overload.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/assert.hpp>
6 #include <boost/hana/functional/overload.hpp>
10 namespace hana
= boost::hana
;
13 auto on_string
= [](std::string
const& s
) {
14 std::cout
<< "matched std::string: " << s
<< std::endl
;
18 auto on_int
= [](int i
) {
19 std::cout
<< "matched int: " << i
<< std::endl
;
23 auto f
= hana::overload(on_int
, on_string
);
26 // prints "matched int: 1"
27 BOOST_HANA_RUNTIME_CHECK(f(1) == 1);
29 // prints "matched std::string: abcdef"
30 BOOST_HANA_RUNTIME_CHECK(f("abcdef") == std::string
{"abcdef"});