]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/functional/overload_linearly.cpp
update sources to v12.2.3
[ceph.git] / 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)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/functional/overload_linearly.hpp>
7
8 #include <string>
9 namespace hana = boost::hana;
10
11
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"); }
16 );
17
18 int main() {
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);
22 }