From f3d931aa7cfaf96baef8383b59a8938779541ee7 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Thu, 15 Aug 2024 18:35:34 +0200 Subject: [IMP] Moved source code into dev/ folder. Signed-off-by: Amlal EL Mahrouss --- dev/Kernel/NewKit/Function.hxx | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dev/Kernel/NewKit/Function.hxx (limited to 'dev/Kernel/NewKit/Function.hxx') diff --git a/dev/Kernel/NewKit/Function.hxx b/dev/Kernel/NewKit/Function.hxx new file mode 100644 index 00000000..e54ff456 --- /dev/null +++ b/dev/Kernel/NewKit/Function.hxx @@ -0,0 +1,53 @@ +#ifndef _INC_FUNCTION_HPP__ +#define _INC_FUNCTION_HPP__ + +#include + +namespace Kernel +{ + template + class Function final + { + public: + Function() = default; + + public: + explicit Function(T (*Fn)(Args... args)) + : fFn(Fn) + { + } + + ~Function() = default; + + Function& operator=(const Function&) = default; + Function(const Function&) = default; + + template + T operator()(Args... args) + { + return fFn(args...); + } + + template + T Call(Args... args) + { + return fFn(args...); + } + + operator bool() + { + return fFn; + } + + bool operator!() + { + return !fFn; + } + + private: + T(*fFn) + (Args... args); + }; +} // namespace Kernel + +#endif // !_INC_FUNCTION_HPP__ -- cgit v1.2.3