Pārlūkot izejas kodu

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.
creator1creeper1 3 gadi atpakaļ
vecāks
revīzija
4869dda79f
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 3 3
      AK/Iterator.h

+ 3 - 3
AK/Iterator.h

@@ -52,11 +52,11 @@ public:
         return SimpleIterator { m_container, m_index + 1 };
         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]; }
     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)
     SimpleIterator& operator=(const SimpleIterator& other)
     {
     {