This talk will present a class template that behaves almost like
any_invocable, but lacks one of its key restrictions: having just one overload of
std::function is an excellent tool for interface design. It encapsulates almost any object that is invocable the right way.
any_invocable is an even better tool. It can encapsulate some types that
std::function can't — the ones that are move-only. Unfortunately, it is still invocable in just one way. You get one list of argument types and that's what you must pass.
What if the object you want to pass is invocable in more than one way? What if it's
operator() is a template that you will instantiate with N different types? What if it is a variadic template to which you will pass 0-N arguments? What if you use tag dispatch to do N different things?
If you want these things, as well as the type erasure offered by
std::function and the move-only support offered by
unique_pseudofunction is the class for you.
Follow the path Filipp took towards realizing that
unique_pseudofunction is the solution to most problems. We'll break this down into the following steps:
- building a simple non-generic
- making it generic;
- adding a small buffer optimization;
- extending it to support more than one overload of
We will also look in close detail at several problems solved along the way, and several others that are still unsolved. This talk involves small amounts of C++17 and large amounts of template metaprogramming, function references, and type erasure.