Преглед изворни кода

minor changes: make_index_sequence -> index_sequence_for

Michele Caini пре 6 година
родитељ
комит
0bdc5dfe95

+ 1 - 1
src/entt/core/ident.hpp

@@ -54,7 +54,7 @@ public:
 
     /*! @brief Statically generated unique identifier for the given type. */
     template<typename Type>
-    static constexpr identifier_type type = get<std::decay_t<Type>>(std::make_index_sequence<sizeof...(Types)>{});
+    static constexpr identifier_type type = get<std::decay_t<Type>>(std::index_sequence_for<Types...>{});
 };
 
 

+ 2 - 2
src/entt/entity/observer.hpp

@@ -287,7 +287,7 @@ public:
           release{},
           view{}
     {
-        connect<Matcher...>(reg, std::make_index_sequence<sizeof...(Matcher)>{});
+        connect<Matcher...>(reg, std::index_sequence_for<Matcher...>{});
     }
 
     /*! @brief Default destructor. */
@@ -313,7 +313,7 @@ public:
     template<typename... Matcher>
     void connect(basic_registry<entity_type> &reg, basic_collector<Matcher...>) {
         disconnect();
-        connect<Matcher...>(reg, std::make_index_sequence<sizeof...(Matcher)>{});
+        connect<Matcher...>(reg, std::index_sequence_for<Matcher...>{});
         target = &reg;
         view.reset();
     }

+ 1 - 1
src/entt/entity/snapshot.hpp

@@ -155,7 +155,7 @@ public:
      */
     template<typename... Component, typename Archive, typename It>
     const basic_snapshot & component(Archive &archive, It first, It last) const {
-        component<Component...>(archive, first, last, std::make_index_sequence<sizeof...(Component)>{});
+        component<Component...>(archive, first, last, std::index_sequence_for<Component...>{});
         return *this;
     }
 

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

@@ -1563,7 +1563,7 @@ public:
      */
     template<typename... Args>
     meta_ctor ctor() const ENTT_NOEXCEPT {
-        return ctor<Args...>(std::make_index_sequence<sizeof...(Args)>{}, node);
+        return ctor<Args...>(std::index_sequence_for<Args...>{}, node);
     }
 
     /**

+ 6 - 17
src/entt/signal/delegate.hpp

@@ -51,18 +51,10 @@ template<typename... Type>
 using to_function_pointer_t = decltype(internal::to_function_pointer(std::declval<Type>()...));
 
 
-template<typename>
-struct function_extent;
-
-
 template<typename Ret, typename... Args>
-struct function_extent<Ret(*)(Args...)> {
-    static constexpr auto value = sizeof...(Args);
-};
-
-
-template<typename Func>
-constexpr auto function_extent_v = function_extent<Func>::value;
+constexpr auto index_sequence_for(Ret(*)(Args...)) {
+    return std::index_sequence_for<Args...>{};
+}
 
 
 }
@@ -200,8 +192,7 @@ public:
      */
     template<auto Function>
     void connect() ENTT_NOEXCEPT {
-        constexpr auto extent = internal::function_extent_v<internal::to_function_pointer_t<decltype(Function)>>;
-        connect<Function>(std::make_index_sequence<extent>{});
+        connect<Function>(internal::index_sequence_for(internal::to_function_pointer_t<decltype(Function)>{}));
     }
 
     /**
@@ -221,8 +212,7 @@ public:
      */
     template<auto Candidate, typename Type>
     void connect(Type &value_or_instance) ENTT_NOEXCEPT {
-        constexpr auto extent = internal::function_extent_v<internal::to_function_pointer_t<decltype(Candidate), Type *>>;
-        connect<Candidate>(value_or_instance, std::make_index_sequence<extent>{});
+        connect<Candidate>(value_or_instance, internal::index_sequence_for(internal::to_function_pointer_t<decltype(Candidate), Type *>{}));
     }
 
     /**
@@ -242,8 +232,7 @@ public:
      */
     template<auto Candidate, typename Type>
     void connect(Type *value_or_instance) ENTT_NOEXCEPT {
-        constexpr auto extent = internal::function_extent_v<internal::to_function_pointer_t<decltype(Candidate), Type *>>;
-        connect<Candidate>(value_or_instance, std::make_index_sequence<extent>{});
+        connect<Candidate>(value_or_instance, internal::index_sequence_for(internal::to_function_pointer_t<decltype(Candidate), Type *>{}));
     }
 
     /**