From 81c6d8e98ee240874ea36a85be6e7f4c05e15ff4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 20 Feb 2021 17:39:58 +0100 Subject: [PATCH] AK: Make Nonnull*PtrVector use size_t for indexes This was weird. It turns out these class were using int indexes and sizes despite being derived from Vector which uses size_t. Make the universe right again by using size_t here as well. --- AK/Forward.h | 4 ++-- AK/NonnullOwnPtrVector.h | 2 +- AK/NonnullPtrVector.h | 18 +++++++++--------- AK/NonnullRefPtrVector.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/AK/Forward.h b/AK/Forward.h index c15a275e9e..2135a48836 100644 --- a/AK/Forward.h +++ b/AK/Forward.h @@ -108,10 +108,10 @@ class NonnullRefPtr; template class NonnullOwnPtr; -template +template class NonnullRefPtrVector; -template +template class NonnullOwnPtrVector; template diff --git a/AK/NonnullOwnPtrVector.h b/AK/NonnullOwnPtrVector.h index f42487e33e..374fbfe367 100644 --- a/AK/NonnullOwnPtrVector.h +++ b/AK/NonnullOwnPtrVector.h @@ -31,7 +31,7 @@ namespace AK { -template +template class NonnullOwnPtrVector : public NonnullPtrVector, inline_capacity> { }; diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 7abbc26829..812bdc8a4e 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2021, Andreas Kling * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ namespace AK { -template +template class NonnullPtrVector : public Vector { using T = typename PtrType::ElementType; using Base = Vector; @@ -60,13 +60,13 @@ public: ALWAYS_INLINE constexpr ConstIterator end() const { return ConstIterator::end(*this); } ALWAYS_INLINE constexpr Iterator end() { return Iterator::end(*this); } - ALWAYS_INLINE PtrType& ptr_at(int index) { return Base::at(index); } - ALWAYS_INLINE const PtrType& ptr_at(int index) const { return Base::at(index); } + ALWAYS_INLINE PtrType& ptr_at(size_t index) { return Base::at(index); } + ALWAYS_INLINE const PtrType& ptr_at(size_t index) const { return Base::at(index); } - ALWAYS_INLINE T& at(int index) { return *Base::at(index); } - ALWAYS_INLINE const T& at(int index) const { return *Base::at(index); } - ALWAYS_INLINE T& operator[](int index) { return at(index); } - ALWAYS_INLINE const T& operator[](int index) const { return at(index); } + ALWAYS_INLINE T& at(size_t index) { return *Base::at(index); } + ALWAYS_INLINE const T& at(size_t index) const { return *Base::at(index); } + ALWAYS_INLINE T& operator[](size_t index) { return at(index); } + ALWAYS_INLINE const T& operator[](size_t index) const { return at(index); } ALWAYS_INLINE T& first() { return at(0); } ALWAYS_INLINE const T& first() const { return at(0); } ALWAYS_INLINE T& last() { return at(size() - 1); } @@ -76,7 +76,7 @@ private: // NOTE: You can't use resize() on a NonnullFooPtrVector since making the vector // bigger would require being able to default-construct NonnullFooPtrs. // Instead, use shrink(new_size). - void resize(int) = delete; + void resize(size_t) = delete; }; } diff --git a/AK/NonnullRefPtrVector.h b/AK/NonnullRefPtrVector.h index 1842099be3..c7bb530efe 100644 --- a/AK/NonnullRefPtrVector.h +++ b/AK/NonnullRefPtrVector.h @@ -31,7 +31,7 @@ namespace AK { -template +template class NonnullRefPtrVector : public NonnullPtrVector, inline_capacity> { };