This PR adds the OverloadSet variadic class template and a make_overload_set() helper function to create objects of this type. Such a type is recommended for use with std::visit by Bjarne Stroustrup in "A Tour of C++" where he writes that "[t]he overloaded class is necessary and strangely enough, not standard". Well, at least we should have it. :)
I think we should squeeze this in as patch release 2.9.2. Yes, we enhance the API, but since this is header-only stuff, users can safely ignore it.
[why]
Without C++17, we do not have "if constexpr". This can make it hard to
construct a suitable visitor function for gul14::visit(). The
alternative to using "if constexpr" is constructing an overload set of
functions.
[how]
Provide a variadic class template OverloadSet that inherits from an
arbitrary number of function objects (typically lambdas) and imports
their definitions of operator() into an overload set for its own
operator(). Because constructing such an OverloadSet object manually is
almost impossible without C++17's advanced template argument deduction,
we also provide a helper function make_overload_set() to take care of
that.
This PR adds the
OverloadSet
variadic class template and amake_overload_set()
helper function to create objects of this type. Such a type is recommended for use withstd::visit
by Bjarne Stroustrup in "A Tour of C++" where he writes that "[t]he overloaded class is necessary and strangely enough, not standard". Well, at least we should have it. :)I think we should squeeze this in as patch release 2.9.2. Yes, we enhance the API, but since this is header-only stuff, users can safely ignore it.
[why]
Without C++17, we do not have "if constexpr". This can make it hard to construct a suitable visitor function for gul14::visit(). The alternative to using "if constexpr" is constructing an overload set of functions.
[how]
Provide a variadic class template OverloadSet that inherits from an arbitrary number of function objects (typically lambdas) and imports their definitions of operator() into an overload set for its own operator(). Because constructing such an OverloadSet object manually is almost impossible without C++17's advanced template argument deduction, we also provide a helper function make_overload_set() to take care of that.