This is follow up on another question that I had a while ago boost variant simple call to common methods.
Thanks to the suggested idea there I can do
boost::apply_visitor([](auto const& obj) { obj.some_operation(); }, variant);
I extended the idea and now I have:
auto visitor = [](auto const& element) { return element->do_something(); };
as a global variable and the visiting it is simply:
boost::apply_visitor(visitor, variant);
My question is how I can extend this pattern if possible to be able to use it for lambdas that accept additional arguments. Say if I have:
auto visitor = [](auto const& element, int a) { return element->do_something(a); };
boost::apply_visitor(<some visitor magic with passing a>, variant);
Note that at the time the lambda is defined there is nothing to capture there.