summaryrefslogtreecommitdiffhomepage
path: root/dev/Kernel/NewKit/Function.hxx
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-15 18:35:34 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-15 18:35:34 +0200
commitf3d931aa7cfaf96baef8383b59a8938779541ee7 (patch)
treefdb9fc51badb3dbd03e46ab0766a49d9522e13e2 /dev/Kernel/NewKit/Function.hxx
parent86640816e8b1d3595365f1fcc8a2a9e61fb40ff1 (diff)
[IMP] Moved source code into dev/ folder.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/NewKit/Function.hxx')
-rw-r--r--dev/Kernel/NewKit/Function.hxx53
1 files changed, 53 insertions, 0 deletions
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 <NewKit/Defines.hxx>
+
+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_HPP__