From 5339d016c07bf717ee388f4feb73544087324af0 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 6 Jan 2024 09:14:11 +0100 Subject: git: port from mercurial repo. Signed-off-by: Amlal El Mahrouss --- NewKit/Function.hpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 NewKit/Function.hpp (limited to 'NewKit/Function.hpp') diff --git a/NewKit/Function.hpp b/NewKit/Function.hpp new file mode 100644 index 00000000..772755e1 --- /dev/null +++ b/NewKit/Function.hpp @@ -0,0 +1,49 @@ +#ifndef _INC_FUNCTION_HPP__ +#define _INC_FUNCTION_HPP__ + +#include + +namespace hCore +{ + template + class Function final + { + public: + Function() = default; + + public: + explicit Function(T (*Fn)(Args... args)) + : m_Fn(Fn) + {} + + ~Function() = default; + + Function &operator=(const Function &) = default; + Function(const Function &) = default; + + template T operator()(Args... args) + { + return m_Fn(args...); + } + + template T Call(Args... args) + { + return m_Fn(args...); + } + + operator bool() + { + return m_Fn; + } + bool operator!() + { + return !m_Fn; + } + + private: + T (*m_Fn)(Args... args); + + }; +} // namespace hCore + +#endif // !_INC_FUNCTION_HPP__ -- cgit v1.2.3