Explorar o código

meta: constrain iterator types

skypjack hai 1 mes
pai
achega
d447f8c14a
Modificáronse 2 ficheiros con 5 adicións e 3 borrados
  1. 3 2
      src/entt/meta/meta.hpp
  2. 2 1
      src/entt/meta/range.hpp

+ 3 - 2
src/entt/meta/meta.hpp

@@ -2,6 +2,7 @@
 #define ENTT_META_META_HPP
 
 #include <array>
+#include <concepts>
 #include <cstddef>
 #include <iterator>
 #include <memory>
@@ -1623,7 +1624,7 @@ public:
 
     meta_iterator() = default;
 
-    template<typename It>
+    template<std::bidirectional_iterator It>
     meta_iterator(const meta_ctx &area, It iter) noexcept
         : ctx{&area},
           vtable{&basic_vtable<It>},
@@ -1704,7 +1705,7 @@ public:
 
     meta_iterator() = default;
 
-    template<bool KeyOnly, typename It>
+    template<bool KeyOnly, std::forward_iterator It>
     meta_iterator(const meta_ctx &area, std::bool_constant<KeyOnly>, It iter) noexcept
         : ctx{&area},
           vtable{&basic_vtable<KeyOnly, It>},

+ 2 - 1
src/entt/meta/range.hpp

@@ -2,6 +2,7 @@
 #define ENTT_META_RANGE_HPP
 
 #include <compare>
+#include <concepts>
 #include <cstddef>
 #include <iterator>
 #include <utility>
@@ -112,7 +113,7 @@ private:
  * @tparam Type Type of meta objects returned.
  * @tparam It Type of forward iterator.
  */
-template<typename Type, typename It>
+template<typename Type, std::forward_iterator It>
 using meta_range = iterable_adaptor<internal::meta_range_iterator<Type, It>>;
 
 } // namespace entt