Chapter 37. Constructing visitors for std::variants

#include <x/visitor.H>

struct one{};
struct two{};

void foo(const std::variant<one, two> &bar)
{
        std::visit( x::visitor{
            [](const one &o) {},
            [](const two &t) {}
        }, bar);
}

The x::visitor template constructs a callable object for passing to std::visit. The intended usage is to pass a variadic list of lambdas to the template, using uniform initialization syntax. This constructs a callable object that inherits all passed lambas, which then gets passed to std::visit.