]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/functional/overload.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / functional / overload.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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.hpp>
7
8#include <iostream>
9#include <string>
10namespace hana = boost::hana;
11
12
13auto on_string = [](std::string const& s) {
14 std::cout << "matched std::string: " << s << std::endl;
15 return s;
16};
17
18auto on_int = [](int i) {
19 std::cout << "matched int: " << i << std::endl;
20 return i;
21};
22
23auto f = hana::overload(on_int, on_string);
24
25int main() {
26 // prints "matched int: 1"
27 BOOST_HANA_RUNTIME_CHECK(f(1) == 1);
28
29 // prints "matched std::string: abcdef"
30 BOOST_HANA_RUNTIME_CHECK(f("abcdef") == std::string{"abcdef"});
31}