diff --git a/TODO b/TODO index 95be9ca4b..31ae45089 100644 --- a/TODO +++ b/TODO @@ -25,5 +25,6 @@ - ::group improve, reduce code * Mission: get rid of named types + - make family-like fallback for type_info::id work across boundaries - update doc: dispatcher, emitter, registry, meta, across boundaries - review and suppress warnings, if any diff --git a/src/entt/core/type_info.hpp b/src/entt/core/type_info.hpp index 49df2b22e..63ee8a627 100644 --- a/src/entt/core/type_info.hpp +++ b/src/entt/core/type_info.hpp @@ -15,22 +15,53 @@ namespace entt { */ template struct type_info { -#if defined _MSC_VER /** * @brief Returns the numeric representation of a given type. * @return The numeric representation of the given type. */ +#if defined _MSC_VER static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT { return entt::hashed_string{__FUNCSIG__}; } #elif defined __GNUC__ - /** - * @brief Returns the numeric representation of a given type. - * @return The numeric representation of the given type. - */ static constexpr ENTT_ID_TYPE id() ENTT_NOEXCEPT { return entt::hashed_string{__PRETTY_FUNCTION__}; } +#else + static ENTT_ID_TYPE id() ENTT_NOEXCEPT; +}; + + +/** + * @cond TURN_OFF_DOXYGEN + * Internal details not to be documented. + */ + + +namespace internal { + + +struct type_id_generator { + static ENTT_ID_TYPE next() ENTT_NOEXCEPT { + static ENTT_ID_TYPE value{}; + return value++; + } +}; + + +} + + +/** + * Internal details not to be documented. + * @endcond TURN_OFF_DOXYGEN + */ + + +template +ENTT_ID_TYPE type_info::id() ENTT_NOEXCEPT { + static const ENTT_ID_TYPE value = internal::type_id_generator::next(); + return value; #endif };