From d48cbe75ef29a9c67c9d176bf58e56ea6448fb9e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 21 Oct 2024 20:23:36 +0200 Subject: IMP: Major refactor of header and source files extensions. Signed-off-by: Amlal El Mahrouss --- dev/zka/NewKit/Function.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dev/zka/NewKit/Function.h (limited to 'dev/zka/NewKit/Function.h') diff --git a/dev/zka/NewKit/Function.h b/dev/zka/NewKit/Function.h new file mode 100644 index 00000000..ae298db5 --- /dev/null +++ b/dev/zka/NewKit/Function.h @@ -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