GenericFunction.hpp
Based on std::function, but with a common base class.
- Todo:
Need to setup Call on GenericFunction to just take a function signature as a template argument, rather than listing all types.
Note
Status: ALPHA
-
class GenericFunction
- #include <GenericFunction.hpp>
The Function templated class behaves almost identically to std::function, but can be reduced to the GenericFunction base class which is NOT templated.
An GenericFunction object can be converted back into the derived type with the .Convert<return(args…)>() member function.
Subclassed by Function< RETURN(PARAMS…)>
Public Functions
-
inline virtual ~GenericFunction()
-
virtual size_t NumArgs() const = 0
-
template<typename RETURN, typename ...Ts>
auto Call(Ts&&... args) A generic form of the function call operator; use arg types to determine derived form.
-
template<typename RETURN, typename ...Ts>
bool CallOK(Ts&&...) Test if a function call will succeed before trying it.
-
template<typename RETURN, typename ...Ts>
bool CallTypeOK() Test if a function call will succeed before trying it, based only on types.
-
template<typename RETURN, typename ...Ts>
inline auto operator()(Ts&&... args) A generic form of the function call operator; use arg types to determine derived form.
-
template<typename T>
auto Convert() Convert this GenericFunction into a derived Function.
-
template<typename T>
bool ConvertOK() Determine if this GenericFunction can be converted into a derived Function.
-
inline virtual ~GenericFunction()
-
template<typename RETURN, typename ...PARAMS>
class Function<RETURN(PARAMS...)> : public GenericFunction - #include <GenericFunction.hpp>