summaryrefslogtreecommitdiff
path: root/AK/NonnullPtrVector.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-19 19:04:52 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-19 19:04:52 +0200
commita5cdd0afa5e0737aa63291f9513470650cf60e11 (patch)
treefe549106bcca24847111becb0ebfbec41952db9d /AK/NonnullPtrVector.h
parent179158bc974d97c3f007824cb85c2b539ec18b66 (diff)
downloadserenity-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.h3
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); }