From 4869dda79f699d76922e90f1cacbcc6b242b4062 Mon Sep 17 00:00:00 2001 From: creator1creeper1 Date: Sat, 8 Jan 2022 23:00:35 +0100 Subject: 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. --- AK/Iterator.h | 6 +++--- 1 file 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) { -- cgit v1.2.3