Przeglądaj źródła

slightly improved

Michele Caini 8 lat temu
rodzic
commit
3a265a53ad
2 zmienionych plików z 14 dodań i 13 usunięć
  1. 6 6
      src/component_pool.hpp
  2. 8 7
      src/registry.hpp

+ 6 - 6
src/component_pool.hpp

@@ -59,7 +59,7 @@ public:
         return direct.begin();
     }
 
-    const_iterator_type begin() const noexcept {
+    const_iterator_type cbegin() const noexcept {
         return direct.cbegin();
     }
 
@@ -67,7 +67,7 @@ public:
         return direct.end();
     }
 
-    const_iterator_type end() const noexcept {
+    const_iterator_type cend() const noexcept {
         return direct.cend();
     }
 
@@ -176,8 +176,8 @@ public:
     }
 
     template<typename Comp>
-    const_iterator_type begin() const noexcept {
-        return Pool<Comp>::begin();
+    const_iterator_type cbegin() const noexcept {
+        return Pool<Comp>::cbegin();
     }
 
     template<typename Comp>
@@ -186,8 +186,8 @@ public:
     }
 
     template<typename Comp>
-    const_iterator_type end() const noexcept {
-        return Pool<Comp>::end();
+    const_iterator_type cend() const noexcept {
+        return Pool<Comp>::cend();
     }
 
     template<typename Comp>

+ 8 - 7
src/registry.hpp

@@ -56,7 +56,8 @@ private:
         }
 
         ViewIterator & operator++() noexcept {
-            while(++begin != end && !valid());
+            ++begin;
+            while(begin != end && !valid()) { ++begin; }
             return *this;
         }
 
@@ -157,20 +158,20 @@ public:
         : pool{pool}
     {}
 
-    const_iterator_type begin() const noexcept {
-        return pool.template begin<Type>();
+    const_iterator_type cbegin() const noexcept {
+        return pool.template cbegin<Type>();
     }
 
     iterator_type begin() noexcept {
-        return const_cast<const View *>(this)->begin();
+        return pool.template begin<Type>();
     }
 
-    const_iterator_type end() const noexcept {
-        return pool.template end<Type>();
+    const_iterator_type cend() const noexcept {
+        return pool.template cend<Type>();
     }
 
     iterator_type end() noexcept {
-        return const_cast<const View *>(this)->end();
+        return pool.template end<Type>();
     }
 
     size_type size() const noexcept {