mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
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.
This commit is contained in:
parent
179158bc97
commit
a5cdd0afa5
1 changed files with 3 additions and 0 deletions
|
@ -33,6 +33,9 @@ public:
|
||||||
ConstIterator begin() const { return ConstIterator(*this, 0); }
|
ConstIterator begin() const { return ConstIterator(*this, 0); }
|
||||||
ConstIterator end() const { return ConstIterator(*this, size()); }
|
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); }
|
T& at(int index) { return *Base::at(index); }
|
||||||
const T& at(int index) const { return *Base::at(index); }
|
const T& at(int index) const { return *Base::at(index); }
|
||||||
T& operator[](int index) { return at(index); }
|
T& operator[](int index) { return at(index); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue