diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-11 17:48:17 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-11 17:48:17 +0100 |
| commit | e3b0df6ae2a5cd1f98400f671c374b5955bd0bcc (patch) | |
| tree | 1aa8346d564da8d08097dd4eec3b5216877b036c /src/kernel/NeKit/Function.h | |
| parent | 878919d80864301328f3e9c471fe2dce2a8ea61d (diff) | |
chore: kernel: specs fixes and kernel API impl improvements.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/kernel/NeKit/Function.h')
| -rw-r--r-- | src/kernel/NeKit/Function.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/kernel/NeKit/Function.h b/src/kernel/NeKit/Function.h index d32c0f46..77d9aa23 100644 --- a/src/kernel/NeKit/Function.h +++ b/src/kernel/NeKit/Function.h @@ -1,4 +1,4 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/nekernel-org/nekernel @@ -9,22 +9,21 @@ #include <NeKit/ErrorOr.h> namespace Kernel { -/// ================================================================================ -/// @brief Function wrapper class. -/// ================================================================================ + +/// @brief Function Pointer Container. template <typename T, typename... Args> class Function final { public: Function() = delete; Function(nullPtr) = delete; - ~Function() = default; - explicit Function(T (*Fn)(Args... args)) : fFn(Fn) { MUST_PASS(fFn); } + ~Function() = default; + Function(T (*Fn)(Args... args)) : fFn(Fn) { MUST_PASS(fFn); } Function& operator=(const Function&) = delete; Function(const Function&) = delete; - T operator()(Args&&... args) { return fFn(args...); } + T operator()(Args&&... args) { return fFn(forward<Args...>(args)...); } explicit operator bool() { return fFn; } bool operator!() { return !fFn; } @@ -35,6 +34,10 @@ class Function final { template <typename T, typename... Args> using FunctionOr = ErrorOr<Function<T, Args...>>; + +template <typename T, typename... Args> +using FunctionRef = Ref<Function<T, Args...>>; + } // namespace Kernel #endif |
