Parcourir la source

meta: avoid warnings for unused variables

Michele Caini il y a 5 ans
Parent
commit
707574e294
2 fichiers modifiés avec 14 ajouts et 9 suppressions
  1. 1 1
      TODO
  2. 13 8
      src/entt/meta/meta.hpp

+ 1 - 1
TODO

@@ -18,7 +18,7 @@
   - ...
 
 WIP:
-* HP: test, enable warnings for unused variables
+* HP: paginate pools
 * HP: headless (sparse set only) view
 * HP: pass the registry to pools, basic poly storage should have only component member
 * HP: make view pack work also with groups, make packs input iterator only, add view adapter for external sources

+ 13 - 8
src/entt/meta/meta.hpp

@@ -1051,7 +1051,7 @@ private:
 
 /*! @brief Opaque wrapper for meta types. */
 class meta_type {
-    bool can_cast_or_convert(const meta_type type, const type_info info) const ENTT_NOEXCEPT {
+    static bool can_cast_or_convert(const meta_type type, const type_info info) ENTT_NOEXCEPT {
         for(auto curr: type.conv()) {
             if(curr.type().info() == info) {
                 return true;
@@ -1067,6 +1067,17 @@ class meta_type {
         return false;
     }
 
+    template<typename... Args, auto... Index>
+    [[nodiscard]] static const internal::meta_ctor_node * ctor(const internal::meta_ctor_node * const curr, std::index_sequence<Index...>) {
+        for(const auto &candidate: internal::meta_range{curr}) {
+            if(candidate.size == sizeof...(Args) && ([](auto *from, auto *to) { return from->info == to->info || can_cast_or_convert(from, to->info); }(internal::meta_info<Args>::resolve(), candidate.arg(Index)) && ...)) {
+                return &candidate;
+            }
+        }
+
+        return nullptr;
+    }
+
 public:
     /*! @brief Node type. */
     using node_type = internal::meta_type_node;
@@ -1318,13 +1329,7 @@ public:
      */
     template<typename... Args>
     [[nodiscard]] meta_ctor ctor() const {
-        for(const auto &candidate: internal::meta_range{node->ctor}) {
-            if(size_type index{}; candidate.size == sizeof...(Args) && ([this](auto *from, auto *to) { return from->info == to->info || can_cast_or_convert(from, to->info); }(internal::meta_info<Args>::resolve(), candidate.arg(index++)) && ...)) {
-                return &candidate;
-            }
-        }
-
-        return nullptr;
+        return ctor<Args...>(node->ctor, std::make_index_sequence<sizeof...(Args)>{});
     }
 
     /**