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

meta: shared meta_object<Type>::name()

skypjack 1 день назад
Родитель
Сommit
6bf9124e24
1 измененных файлов с 9 добавлено и 24 удалено
  1. 9 24
      src/entt/meta/meta.hpp

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

@@ -830,6 +830,15 @@ public:
         }
     }
 
+    /**
+     * @brief Returns the name assigned to a meta object, if any.
+     * @return The name assigned to the meta object, if any.
+     */
+    [[nodiscard]] stl::string_view name() const noexcept
+    requires requires(node_type elem) { elem.name; } {
+        return (node_or_assert().name == nullptr) ? stl::string_view{} : stl::string_view{node_or_assert().name};
+    }
+
     /**
      * @brief Returns user defined data for a given meta object.
      * @return User defined arbitrary data.
@@ -853,14 +862,6 @@ private:
 struct meta_data final: meta_object<internal::meta_data_node> {
     using meta_object::meta_object;
 
-    /**
-     * @brief Returns the name assigned to a data member, if any.
-     * @return The name assigned to the data member, if any.
-     */
-    [[nodiscard]] stl::string_view name() const noexcept {
-        return (node_or_assert().name == nullptr) ? stl::string_view{} : stl::string_view{node_or_assert().name};
-    }
-
     /**
      * @brief Returns the number of arguments of a data member's setter.
      * @return The number of arguments accepted by the data member's setter.
@@ -951,14 +952,6 @@ struct meta_data final: meta_object<internal::meta_data_node> {
 struct meta_func final: meta_object<internal::meta_func_node> {
     using meta_object::meta_object;
 
-    /**
-     * @brief Returns the name assigned to a member function, if any.
-     * @return The name assigned to the member function, if any.
-     */
-    [[nodiscard]] stl::string_view name() const noexcept {
-        return (node_or_assert().name == nullptr) ? stl::string_view{} : stl::string_view{node_or_assert().name};
-    }
-
     /**
      * @brief Returns the number of arguments accepted by a member function.
      * @return The number of arguments accepted by the member function.
@@ -1105,14 +1098,6 @@ public:
         return node_or_assert().alias;
     }
 
-    /**
-     * @brief Returns the name assigned to a type, if any.
-     * @return The name assigned to the type, if any.
-     */
-    [[nodiscard]] stl::string_view name() const noexcept {
-        return (node_or_assert().name == nullptr) ? stl::string_view{} : stl::string_view{node_or_assert().name};
-    }
-
     /**
      * @brief Returns the size of the underlying type if known.
      * @return The size of the underlying type if known, 0 otherwise.