diff --git a/Source/Core/Common/Functional.h b/Source/Core/Common/Functional.h index cdb44ebb0c0..7f96664041b 100644 --- a/Source/Core/Common/Functional.h +++ b/Source/Core/Common/Functional.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include @@ -51,4 +52,17 @@ private: std::unique_ptr m_ptr; }; +// A functor type with an invocable non-type template parameter. +// e.g. Providing a function pointer will create a functor type that invokes said function. +// It allows using function pointers in contexts that expect a type, e.g. as a "deleter". +template +struct InvokerOf +{ + template + constexpr auto operator()(Args... args) const + { + return std::invoke(Invocable, std::forward(args)...); + } +}; + } // namespace Common