Просмотр исходного кода

meta no longer uses named types

Michele Caini 6 лет назад
Родитель
Сommit
5be1bf7d82
2 измененных файлов с 8 добавлено и 36 удалено
  1. 7 27
      src/entt/meta/factory.hpp
  2. 1 9
      src/entt/meta/meta.hpp

+ 7 - 27
src/entt/meta/factory.hpp

@@ -381,7 +381,13 @@ class meta_factory<Type> {
         return node && (node->identifier == identifier || duplicate(identifier, node->next));
     }
 
-    auto record(const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT {
+public:
+    /**
+     * @brief Extends a meta type by assigning it an identifier.
+     * @param identifier Unique identifier.
+     * @return An extended meta factory for the given type.
+     */
+    auto type(const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT {
         auto * const node = internal::meta_info<Type>::resolve();
 
         ENTT_ASSERT(!duplicate(identifier, *internal::meta_info<>::global));
@@ -393,32 +399,6 @@ class meta_factory<Type> {
         return meta_factory<Type, Type>{&node->prop};
     }
 
-public:
-    /**
-     * @brief Extends a meta type by assigning it an identifier.
-     *
-     * This function is intended only for unnamed types.
-     *
-     * @param identifier Unique identifier.
-     * @return An extended meta factory for the given type.
-     */
-    auto type(const ENTT_ID_TYPE identifier) ENTT_NOEXCEPT {
-        static_assert(!is_named_type_v<Type>);
-        return record(identifier);
-    }
-
-    /**
-     * @brief Extends a meta type by assigning it an identifier.
-     *
-     * This function is intended only for named types
-     *
-     * @return An extended meta factory for the given type.
-     */
-    auto type() ENTT_NOEXCEPT {
-        static_assert(is_named_type_v<Type>);
-        return record(named_type_traits_t<Type>::value);
-    }
-
     /**
      * @brief Assigns a meta base to a meta type.
      *

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

@@ -264,15 +264,7 @@ struct meta_node<Type> {
             }
         };
 
-        if constexpr(is_named_type_v<Type>) {
-            auto *candidate = internal::find_if([](const auto *curr) {
-                return curr->identifier == named_type_traits_v<Type>;
-            }, *meta_node<>::global);
-
-            return candidate ? candidate : &node;
-        } else {
-            return &node;
-        }
+        return &node;
     }
 };