From 64f0cc0d420c9be65ab75de9faead6dd606d8ca7 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 18 Jan 2023 17:16:19 +0200 Subject: [PATCH] BAN: fix Vector code one return value was missing and AddressOf functions were kinda ugly --- BAN/include/BAN/Vector.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/BAN/include/BAN/Vector.h b/BAN/include/BAN/Vector.h index 6cd321c09..5562962f3 100644 --- a/BAN/include/BAN/Vector.h +++ b/BAN/include/BAN/Vector.h @@ -106,9 +106,9 @@ namespace BAN size_type Capacity() const; private: - const T* AddressOf(size_type, uint8_t* = nullptr) const; - T* AddressOf(size_type, uint8_t* = nullptr); [[nodiscard]] ErrorOr EnsureCapasity(size_type); + const T* AddressOf(size_type, void* = nullptr) const; + T* AddressOf(size_type, void* = nullptr); private: uint8_t* m_data = nullptr; @@ -155,6 +155,8 @@ namespace BAN other.m_data = nullptr; other.m_capacity = 0; other.m_size = 0; + + return *this; } template @@ -403,19 +405,19 @@ namespace BAN } template - const T* Vector::AddressOf(size_type index, uint8_t* base) const + const T* Vector::AddressOf(size_type index, void* base) const { if (base == nullptr) base = m_data; - return (T*)(base + index * sizeof(T)); + return (T*)base + index; } template - T* Vector::AddressOf(size_type index, uint8_t* base) + T* Vector::AddressOf(size_type index, void* base) { if (base == nullptr) base = m_data; - return (T*)(base + index * sizeof(T)); + return (T*)base + index; } } \ No newline at end of file