|
|
@@ -927,6 +927,17 @@ struct meta_data {
|
|
|
return internal::meta_to_user_traits<Type>(node->traits);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Returns user defined data for a given meta object.
|
|
|
+ * @tparam Type The type to convert the user defined data to.
|
|
|
+ * @return User defined arbitrary data.
|
|
|
+ */
|
|
|
+ template<typename Type>
|
|
|
+ [[nodiscard]] const Type &custom() const noexcept {
|
|
|
+ ENTT_ASSERT(node->custom != nullptr, "Invalid user data");
|
|
|
+ return *std::static_pointer_cast<Type>(node->custom);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @brief Returns true if an object is valid, false otherwise.
|
|
|
* @return True if the object is valid, false otherwise.
|
|
|
@@ -1055,6 +1066,13 @@ struct meta_func {
|
|
|
return internal::meta_to_user_traits<Type>(node->traits);
|
|
|
}
|
|
|
|
|
|
+ /*! @copydoc meta_data::custom */
|
|
|
+ template<typename Type>
|
|
|
+ [[nodiscard]] const Type &custom() const noexcept {
|
|
|
+ ENTT_ASSERT(node->custom != nullptr, "Invalid user data");
|
|
|
+ return *std::static_pointer_cast<Type>(node->custom);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @brief Returns the next overload of a given function, if any.
|
|
|
* @return The next overload of the given function, if any.
|
|
|
@@ -1525,6 +1543,13 @@ public:
|
|
|
return internal::meta_to_user_traits<Type>(node.traits);
|
|
|
}
|
|
|
|
|
|
+ /*! @copydoc meta_data::custom */
|
|
|
+ template<typename Type>
|
|
|
+ [[nodiscard]] const Type &custom() const noexcept {
|
|
|
+ ENTT_ASSERT(node.custom != nullptr, "Invalid user data");
|
|
|
+ return *std::static_pointer_cast<Type>(node.custom);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @brief Returns true if an object is valid, false otherwise.
|
|
|
* @return True if the object is valid, false otherwise.
|