]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/functional/overload_linearly.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_linearly.hpp>
9 namespace hana
= boost::hana
;
12 auto f
= hana::overload_linearly(
13 [](int i
) { return i
+ 1; },
14 [](std::string s
) { return s
+ "d"; },
15 [](double) { BOOST_HANA_RUNTIME_CHECK(false && "never called"); }
19 BOOST_HANA_RUNTIME_CHECK(f(1) == 2);
20 BOOST_HANA_RUNTIME_CHECK(f("abc") == "abcd");
21 BOOST_HANA_RUNTIME_CHECK(f(2.2) == static_cast<int>(2.2) + 1);