diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 09:04:13 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 09:04:13 +0100 |
| commit | ed6d2f6007b572b907e3cb11b4303c13d1572c9c (patch) | |
| tree | 47f177336db980a138a91a2fb109db8f1a65086c /src/kernel/NeKit/InitializerList.h | |
| parent | 3a5c7473910156051951f8ec98488a6c91a3eabd (diff) | |
chore: specification updates and patches on the DDK, new source `ddk_c++.cc`.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/kernel/NeKit/InitializerList.h')
| -rw-r--r-- | src/kernel/NeKit/InitializerList.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/kernel/NeKit/InitializerList.h b/src/kernel/NeKit/InitializerList.h index d918ba85..46639d4d 100644 --- a/src/kernel/NeKit/InitializerList.h +++ b/src/kernel/NeKit/InitializerList.h @@ -1,19 +1,23 @@ /* ======================================== - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once +#ifndef __NE_KIT_INIT_LIST_H__ +#define __NE_KIT_INIT_LIST_H__ #include <NeKit/Config.h> #include <NeKit/ErrorOr.h> namespace Kernel { -template <class T, SizeT N> + // \brief Initalizer List object for containers. +template <class Type, SizeT N> class InitializerList final { public: - explicit InitializerList(const T* list) { + InitializerList() = delete; + + explicit InitializerList(const Type* list) { if constexpr (N > 0) { for (auto i = 0UL; i < N; ++i) { fList[i] = list[i]; @@ -26,17 +30,20 @@ class InitializerList final { InitializerList& operator=(const InitializerList&) = delete; InitializerList(const InitializerList&) = delete; - T* begin() { return fList; } - T* end() { return fList + N; } + Type* begin() { return fList; } + Type* end() { return fList + N; } + constexpr SizeT size() const { return N; } - T* operator->() { return fList; } - T* operator*() { return fList; } + Type* operator->() { return this->begin(); } + Type* operator*() { return this->begin(); } private: - T fList[N]; + Type fList[N]; }; template <class T, SizeT N> using ErrorOrList = ErrorOr<InitializerList<T, N>>; } // namespace Kernel + +#endif |
