diff options
author | creator1creeper1 <creator1creeper1@airmail.cc> | 2022-01-08 23:00:35 +0100 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-01-16 00:38:21 +0330 |
commit | 4869dda79f699d76922e90f1cacbcc6b242b4062 (patch) | |
tree | 40a58baa881e23a9ad2569768fa7ec8374fcc9a1 | |
parent | 6484d42933be767b9c071a080a8552b4a8fc3648 (diff) | |
download | serenity-4869dda79f699d76922e90f1cacbcc6b242b4062.zip |
AK: Explicitly name types in Iterator.h
In this particular case, auto is a footgun, because we are very
certain about the type that we want to return. const-correctness
could have been violated (as Vector did), because Iterator did not
enforce that the returned pointer was actually const if the Iterator
was an Iterator over a const container.
-rw-r--r-- | AK/Iterator.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/AK/Iterator.h b/AK/Iterator.h index bf45c03862..953c091967 100644 --- a/AK/Iterator.h +++ b/AK/Iterator.h @@ -52,11 +52,11 @@ public: return SimpleIterator { m_container, m_index + 1 }; } - ALWAYS_INLINE constexpr const ValueType& operator*() const { return m_container[m_index]; } + ALWAYS_INLINE constexpr ValueType const& operator*() const { return m_container[m_index]; } ALWAYS_INLINE 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]; } + ALWAYS_INLINE constexpr ValueType const* operator->() const { return &m_container[m_index]; } + ALWAYS_INLINE constexpr ValueType* operator->() { return &m_container[m_index]; } SimpleIterator& operator=(const SimpleIterator& other) { |