Boost logo

Boost :

Subject: Re: [boost] An open typeswitch using lambdas
From: Evgeny Panasyuk (evgeny.panasyuk_at_[hidden])
Date: 2013-11-29 15:43:02


29.11.2013 22:31, Sumant Tambe:
> template <class Poly>
> void test_poly(Poly& p)
> {
> match(p)(
> [](int i) { std::cout << "int = " << i << "\n"; },
> [](double d) { std::cout << "double = " << d << "\n"; },
> [](const std::string &s) { std::cout << "string = " << s << "\n"; },
> [](std::ostream &o) { std::cout << "found ostream" << "\n"; }
> );
> }
>

Just for your information, there is Boost.Functional/OverloadedFunction
library -
http://www.boost.org/doc/libs/1_55_0/libs/functional/overloaded_function/doc/html/index.html

It has make_overloaded_function template function
http://www.boost.org/doc/libs/1_55_0/libs/functional/overloaded_function/doc/html/boost/make_overloaded_function.html
- which is somewhat similar (not sure if it provides required typedef
for result_type).

-- 
Evgeny Panasyuk

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk