diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-08-19 19:04:52 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-19 19:04:52 +0200 |
commit | a5cdd0afa5e0737aa63291f9513470650cf60e11 (patch) | |
tree | fe549106bcca24847111becb0ebfbec41952db9d /AK/NonnullPtrVector.h | |
parent | 179158bc974d97c3f007824cb85c2b539ec18b66 (diff) | |
download | serenity-a5cdd0afa5e0737aa63291f9513470650cf60e11.zip |
NonnullPtrVector: Add ptr_at() getters for accessing the NonnullPtr
Normally you want to access the T&, but sometimes you need to grab at
the NonnullPtr, for example when moving it out of the Vector before
a call to remove(). This is generally a weird pattern, but I don't have
a better solution at the moment.
Diffstat (limited to 'AK/NonnullPtrVector.h')
-rw-r--r-- | AK/NonnullPtrVector.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/AK/NonnullPtrVector.h b/AK/NonnullPtrVector.h index 2cc7147c4a..9e274169b5 100644 --- a/AK/NonnullPtrVector.h +++ b/AK/NonnullPtrVector.h @@ -33,6 +33,9 @@ public: ConstIterator begin() const { return ConstIterator(*this, 0); } ConstIterator end() const { return ConstIterator(*this, size()); } + PtrType& ptr_at(int index) { return Base::at(index); } + const PtrType& ptr_at(int index) const { return Base::at(index); } + T& at(int index) { return *Base::at(index); } const T& at(int index) const { return *Base::at(index); } T& operator[](int index) { return at(index); } |