From fc67c4af554189c941c811486a0b2b21aa3f54ea Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 23 May 2025 04:07:12 +0200 Subject: feat!(kernel): Rename NewKit to NeKit. Signed-off-by: Amlal El Mahrouss --- dev/kernel/NeKit/Function.h | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 dev/kernel/NeKit/Function.h (limited to 'dev/kernel/NeKit/Function.h') diff --git a/dev/kernel/NeKit/Function.h b/dev/kernel/NeKit/Function.h new file mode 100644 index 00000000..e5d56cee --- /dev/null +++ b/dev/kernel/NeKit/Function.h @@ -0,0 +1,51 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + + +#ifndef _INC_FUNCTION_H_ +#define _INC_FUNCTION_H_ + +#include +#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); +}; + +template +using FunctionOr = ErrorOr>; +} // namespace Kernel + +#endif // !_INC_FUNCTION_H__ -- cgit v1.2.3