My personal stance and I what I use on projects is something a little different and I try to evangelize: Make an overloads template that just works with apply_visitor or an apply_visitor like function:
apply_visitor( overloads( [](A & a){ cout << "it's a A!"; } [](B & b){ cout << "oh, a B!"; } [](C & c){ cout << "ah yes, a C!"; } [](auto & d){ cout << "a default!"; } ),
v
);
I use syntax like this:
case_<void>(v)(
[](A & a){ cout << "it's a A!"; }
[](B & b){ cout << "oh, a B!"; }
[](C & c){ cout << "ah yes, a C!"; }
[](auto & d){ cout << "a default!"; }
);
Which I think is a little neater. You can implement this in C++14 with Fit
like this:
template