From 5a7b4a65a1d93744e4a5e6cc6df4244f61b81f68 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Tue, 14 Jan 2025 18:17:54 -0500 Subject: chore: fix compiler warnings + extra includes --- src/dynamic-array.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/dynamic-array.hpp') diff --git a/src/dynamic-array.hpp b/src/dynamic-array.hpp index 06479db..900a684 100644 --- a/src/dynamic-array.hpp +++ b/src/dynamic-array.hpp @@ -28,16 +28,16 @@ struct DynArray: DynArrayBase { DynArray &operator=(const DynArray &other); DynArray &operator=(DynArray &&other); ~DynArray(); - T &operator[](std::size_t index); + T &operator[](int64_t index); T *GetPtr(); - const int64_t Count(); + int64_t Count() const; bool Has(const T &val); template int64_t FindFirstIndex(bool fn(const T&, const T2&), const T2 &val); T& Push(); void Push(const T &val); T Pop(); - void Remove(std::size_t index, int64_t count = 1); + void Remove(int64_t index, int64_t count = 1); void Reserve(int64_t count); void Resize(int64_t count); protected: @@ -115,10 +115,10 @@ template inline DynArray::~DynArray() { DynArrayDestroy(this); } -template inline T &DynArray::operator[](std::size_t index) { +template inline T &DynArray::operator[](int64_t index) { assert(index < this->elementCount && "Invalid DynArray[] index - out of bounds"); assert(index < this->reservedCount && "Invalid DynArray[] index - out of reserved bounds"); - assert(index < 0xF000000000000000 && "Invalid DynArray[] index - unlikely value"); + assert(index >= 0 && "Invalid DynArray[] index - unlikely value"); return *reinterpret_cast((this->ptr + (sizeof(T) * index))); } @@ -126,7 +126,7 @@ template inline T *DynArray::GetPtr() { return reinterpret_cast(reinterpret_cast(this->ptr)); } -template inline const int64_t DynArray::Count() { +template inline int64_t DynArray::Count() const { return this->elementCount; } @@ -180,7 +180,7 @@ template inline T DynArray::Pop() { return *reinterpret_cast((this->ptr + (sizeof(T) * this->elementCount))); } -template inline void DynArray::Remove(std::size_t index, int64_t count) { +template inline void DynArray::Remove(int64_t index, int64_t count) { assert(index <= this->elementCount && "Invalid DynArray::Remove() - Out of bounds"); int64_t moveCount = (this->elementCount - index - count); assert(moveCount >= 0 && "Invalid DynArray::Remove() - Removing too many elements"); -- cgit v1.2.3