7 Jan
2015
7 Jan
'15
9:41 a.m.
On January 7, 2015 3:41:04 AM EST, Eelis
Boost.Variant provides access through get() and visitors, but in C++11 we can do so much better! :)
For a boost::variant, the attached small utility function match() lets you write:
match(v, [](A & a){ cout << "it's a A!"; } [](B & b){ cout << "oh, a B!"; } [](C & c){ cout << "ah yes, a C!"; });
Return values are supported. I think this really belongs in Boost. It makes variants much more usable.
That looks nice, but I don't see how it will work for, say, variant