diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2025-01-24 10:38:36 +0100 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2025-01-24 10:38:36 +0100 |
| commit | 7b4bd3577a31d0f0adc7371840642791ae1567f4 (patch) | |
| tree | 1a8afc973aaa739d0d763315cad2fd376d1cea9c /dev/Kernel/NewKit/Function.h | |
ADD: Open version, with important changes kept out.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/NewKit/Function.h')
| -rw-r--r-- | dev/Kernel/NewKit/Function.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/dev/Kernel/NewKit/Function.h b/dev/Kernel/NewKit/Function.h new file mode 100644 index 00000000..9fa218af --- /dev/null +++ b/dev/Kernel/NewKit/Function.h @@ -0,0 +1,53 @@ +#ifndef _INC_FUNCTION_H__ +#define _INC_FUNCTION_H__ + +#include <NewKit/Defines.h> + +namespace Kernel +{ + template <typename T, typename... Args> + 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 <typename... XArgs> + T operator()(Args... args) + { + return fFn(args...); + } + + template <typename... XArgs> + 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_H__ |
