summaryrefslogtreecommitdiff
path: root/AK/Iterator.h
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-06-08 17:54:06 +0430
committerAndreas Kling <kling@serenityos.org>2021-06-08 19:14:24 +0200
commit3d94b5051d8a783858cde04eb4d2e1ecf63ac180 (patch)
treeb5248245957e652408beba570bfe8dd248d0d5da /AK/Iterator.h
parent48195b7c30c30c17b34666657475eb0c9d24ed2d (diff)
downloadserenity-3d94b5051d8a783858cde04eb4d2e1ecf63ac180.zip
AK: Make Vector capable of holding reference types
This commit makes it possible to instantiate `Vector<T&>` and use it to store references to `T` in a vector. All non-pointer observers are made to return the reference, and the pointer observers simply yield the underlying pointer. Note that the 'find_*' methods act on the values and not the pointers that are stored in the vector. This commit also makes errors in various vector methods much more readable by directly using requires-clauses on them. And finally, it should be noted that Vector cannot hold temporaries :^)
Diffstat (limited to 'AK/Iterator.h')
-rw-r--r--AK/Iterator.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/AK/Iterator.h b/AK/Iterator.h
index db0c9890c2..bf45c03862 100644
--- a/AK/Iterator.h
+++ b/AK/Iterator.h
@@ -55,8 +55,8 @@ public:
ALWAYS_INLINE constexpr const ValueType& operator*() const { return m_container[m_index]; }
ALWAYS_INLINE constexpr ValueType& operator*() { return m_container[m_index]; }
- constexpr const ValueType* operator->() const { return &m_container[m_index]; }
- constexpr ValueType* operator->() { return &m_container[m_index]; }
+ constexpr auto operator->() const { return &m_container[m_index]; }
+ constexpr auto operator->() { return &m_container[m_index]; }
SimpleIterator& operator=(const SimpleIterator& other)
{