From 031789eeb226b2b559f0edbaf28ed5bebc6ddff4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 10 Dec 2025 10:05:53 +0100 Subject: chore: new `InitializerList` API. Signed-off-by: Amlal El Mahrouss --- src/kernel/NeKit/Function.h | 18 +++++++----------- src/kernel/NeKit/InitializerList.h | 18 +++++++++--------- 2 files changed, 16 insertions(+), 20 deletions(-) (limited to 'src/kernel/NeKit') diff --git a/src/kernel/NeKit/Function.h b/src/kernel/NeKit/Function.h index 1ceda345..2889e055 100644 --- a/src/kernel/NeKit/Function.h +++ b/src/kernel/NeKit/Function.h @@ -16,28 +16,24 @@ namespace Kernel { template class Function final { public: - Function() = default; - - public: - explicit Function(T (*Fn)(Args... args)) : fFn(Fn) {} - + Function() = delete; + Function(nullPtr) = delete; ~Function() = default; - Function& operator=(const Function&) = default; - Function(const Function&) = default; + explicit Function(T (*Fn)(Args... args)) : fFn(Fn) { MUST_PASS(fFn); } + + Function& operator=(const Function&) = delete; + Function(const Function&) = delete; - template T operator()(Args&&... args) { return fFn(args...); } - template T Call(Args&&... args) { return fFn(args...); } - operator bool() { return fFn; } - + explicit operator bool() { return fFn; } bool operator!() { return !fFn; } private: diff --git a/src/kernel/NeKit/InitializerList.h b/src/kernel/NeKit/InitializerList.h index 158b88ed..dc33d8eb 100644 --- a/src/kernel/NeKit/InitializerList.h +++ b/src/kernel/NeKit/InitializerList.h @@ -7,9 +7,10 @@ #pragma once #include +#include namespace Kernel { -template +template class InitializerList final { public: explicit InitializerList(const T* list) { @@ -22,21 +23,20 @@ class InitializerList final { ~InitializerList() = default; - InitializerList& operator=(const InitializerList&) = default; - InitializerList(const InitializerList&) = default; + InitializerList& operator=(const InitializerList&) = delete; + InitializerList(const InitializerList&) = delete; T* begin() { return fList; } - T* operator->() { return fList; } - T* operator*() { return fList; } T* end() { return fList + N; } constexpr SizeT size() const { return N; } + + T* operator->() { return fList; } + T* operator*() { return fList; } private: T fList[N]; }; -template -inline InitializerList make_list(ValueType& val) { - return InitializerList{val}; -} +template +using ErrorOrList = ErrorOr>; } // namespace Kernel -- cgit v1.2.3