Kaynağa Gözat

view/group: make range return types explicit in preparation for faster/unsafe reverse iterators

Michele Caini 5 yıl önce
ebeveyn
işleme
a53f0900bd
2 değiştirilmiş dosya ile 16 ekleme ve 8 silme
  1. 8 4
      src/entt/entity/group.hpp
  2. 8 4
      src/entt/entity/view.hpp

+ 8 - 4
src/entt/entity/group.hpp

@@ -130,7 +130,9 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> {
         {}
 
     public:
-        [[nodiscard]] auto begin() const ENTT_NOEXCEPT {
+        using iterator = range_iterator;
+
+        [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
             return range_iterator{handler->begin(), std::tuple_cat([](auto *cpool) {
                 if constexpr(ENTT_IS_EMPTY(typename std::decay_t<decltype(*cpool)>::object_type)) {
                     return std::make_tuple();
@@ -140,7 +142,7 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> {
             }(std::get<pool_type<Get> *>(pools))...)};
         }
 
-        [[nodiscard]] auto end() const ENTT_NOEXCEPT {
+        [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
             return range_iterator{handler->end(), std::tuple_cat([](auto *cpool) {
                 if constexpr(ENTT_IS_EMPTY(typename std::decay_t<decltype(*cpool)>::object_type)) {
                     return std::make_tuple();
@@ -642,7 +644,9 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> {
         {}
 
     public:
-        [[nodiscard]] auto begin() const ENTT_NOEXCEPT {
+        using iterator = range_iterator;
+
+        [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
             return range_iterator{
                 std::get<0>(pools)->sparse_set<Entity>::end() - *length,
                 std::tuple_cat([length = *length](auto *cpool) {
@@ -662,7 +666,7 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> {
             };
         }
 
-        [[nodiscard]] auto end() const ENTT_NOEXCEPT {
+        [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
             return range_iterator{
                 std::get<0>(pools)->sparse_set<Entity>::end(),
                 std::tuple_cat([](auto *cpool) {

+ 8 - 4
src/entt/entity/view.hpp

@@ -208,7 +208,9 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
         {}
 
     public:
-        [[nodiscard]] auto begin() const ENTT_NOEXCEPT {
+        using iterator = range_iterator;
+
+        [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
             return range_iterator{first, std::tuple_cat([](auto *cpool) {
                 if constexpr(ENTT_IS_EMPTY(typename std::decay_t<decltype(*cpool)>::object_type)) {
                     return std::make_tuple();
@@ -218,7 +220,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> {
             }(std::get<pool_type<Component> *>(pools))...)};
         }
 
-        [[nodiscard]] auto end() const ENTT_NOEXCEPT {
+        [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
             return range_iterator{last, std::tuple_cat([](auto *cpool) {
                 if constexpr(ENTT_IS_EMPTY(typename std::decay_t<decltype(*cpool)>::object_type)) {
                     return std::make_tuple();
@@ -741,7 +743,9 @@ class basic_view<Entity, exclude_t<>, Component> {
         {}
 
     public:
-        [[nodiscard]] auto begin() const ENTT_NOEXCEPT {
+        using iterator = range_iterator;
+
+        [[nodiscard]] iterator begin() const ENTT_NOEXCEPT {
             if constexpr(ENTT_IS_EMPTY(Component)) {
                 return range_iterator{std::make_tuple(pool->sparse_set<entity_type>::begin())};
             } else {
@@ -749,7 +753,7 @@ class basic_view<Entity, exclude_t<>, Component> {
             }
         }
 
-        [[nodiscard]] auto end() const ENTT_NOEXCEPT {
+        [[nodiscard]] iterator end() const ENTT_NOEXCEPT {
             if constexpr(ENTT_IS_EMPTY(Component)) {
                 return range_iterator{std::make_tuple(pool->sparse_set<entity_type>::end())};
             } else {