• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(
__anon764774a20102(int i) 13     [](int i) { return i + 1; },
__anon764774a20202(std::string s) 14     [](std::string s) { return s + "d"; },
__anon764774a20302(double) 15     [](double) { BOOST_HANA_RUNTIME_CHECK(false && "never called"); }
16 );
17 
main()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 }
23