From 5339d016c07bf717ee388f4feb73544087324af0 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 6 Jan 2024 09:14:11 +0100 Subject: git: port from mercurial repo. Signed-off-by: Amlal El Mahrouss --- NewKit/Array.hpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 NewKit/Array.hpp (limited to 'NewKit/Array.hpp') diff --git a/NewKit/Array.hpp b/NewKit/Array.hpp new file mode 100644 index 00000000..6987ca72 --- /dev/null +++ b/NewKit/Array.hpp @@ -0,0 +1,61 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ +#pragma once + +#include +#include +#include + +namespace hCore +{ +template +class Array final +{ +public: + Array() {} + ~Array() {} + + Array &operator=(const Array &) = default; + Array(const Array &) = default; + + ErrorOr operator[](Size At) + { + if (At > N) + return {}; + + kcout << "Returning element\r\n"; + return ErrorOr(m_Array[At]); + } + + Boolean Empty() const + { + for (auto Val : m_Array) + { + if (Val) + return false; + } + + return true; + } + + const T *CData() + { + return m_Array; + } + + operator bool() + { + return !Empty(); + } + +private: + T m_Array[N]; + +}; +} // namespace hCore -- cgit v1.2.3