The power of C++17.
C++17: The two line visitor explained
by Marius Elvert
From the article:
If you have ever used an “idiomatic” C++ variant datatype like Boost.Variant or the new C++17 std::variant, you probably wished you could assemble a visitor to dispatch on the type by assembling a couple of lambda expressions like this:
auto my_visitor = visitor{ [&](int value) { /* ... */ }, [&](std::string const& value) { /* ... */ }, };
Add a Comment
Comments are closed.