AnyFunction.hpp
Based on std::function, but with a generic base class.
(Built from GenericFunction.h)
Note
Status: ALPHA
-
class BaseFunction
- #include <AnyFunction.hpp>
An BaseFunction object can be converted back into the derived type with the .Convert<return(args…)>() member function.
Subclassed by DerivedFunction< RETURN(PARAMS…)>
Public Functions
-
inline virtual ~BaseFunction()
-
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 BaseFunction into a derived Function.
-
template<typename T>
bool ConvertOK() Determine if this BaseFunction can be converted into a derived Function.
-
virtual Ptr<BaseFunction> Clone() = 0
-
inline virtual ~BaseFunction()
-
template<typename RETURN, typename ...PARAMS>
class DerivedFunction<RETURN(PARAMS...)> : public BaseFunction - #include <AnyFunction.hpp>
Specialized form for proper function types.
Public Functions
-
template<typename T>
inline DerivedFunction(T in_fun) Forward all args to std::function constructor…
-
inline virtual size_t NumArgs() const override
-
template<typename ...Ts>
inline RETURN operator()(Ts&&... args) Forward all args to std::function call.
-
inline virtual Ptr<BaseFunction> Clone() override
-
template<typename T>
-
class AnyFunction
- #include <AnyFunction.hpp>
AnyFunction manages the function pointers to be dynamically handled.
Public Functions
-
inline AnyFunction()
-
inline AnyFunction(const AnyFunction &other)
-
inline AnyFunction(AnyFunction &&other) noexcept
-
inline AnyFunction &operator=(const AnyFunction &other)
-
inline AnyFunction &operator=(AnyFunction &&other) noexcept
-
inline ~AnyFunction()
-
inline void Clear()
-
inline size_t NumArgs() const
-
inline Ptr<BaseFunction> CloneFunc() const
-
inline operator bool()
-
template<typename RETURN = void, typename ...Ts>
inline auto Call(Ts&&... args) Call this function with specific types; must be correct!
-
template<typename RETURN, typename ...Ts>
inline bool CallOK(Ts&&... args) Test if a function call will succeed before trying it.
-
template<typename RETURN, typename ...Ts>
inline bool CallTypeOK() Test if a function call will succeed before trying it, based only on types.
-
template<typename RETURN = void, 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>
inline auto Convert() Convert this BaseFunction into a derived Function.
-
template<typename T>
inline bool ConvertOK() Determine if this BaseFunction can be converted into a derived Function.
Private Functions
Private Members
-
Ptr<BaseFunction> fun = nullptr
-
inline AnyFunction()