Struct type_hash

Synopsis

#include <src/entt/core/type_info.hpp>

template<typename Type, typename = void>
struct type_hash final

Description

Type hash.

Template Parameters

Type - Type for which to generate a hash value.

Mentioned in

Methods

valueReturns the numeric representation of a given type.

Source

Lines 76-98 in src/entt/core/type_info.hpp.

template<typename Type, typename = void>
struct type_hash final {
    /**
     * @brief Returns the numeric representation of a given type.
     * @return The numeric representation of the given type.
     */
#if defined ENTT_PRETTY_FUNCTION_CONSTEXPR
    [[nodiscard]] static constexpr id_type value() ENTT_NOEXCEPT {
        constexpr auto stripped = internal::type_name<Type>();
        constexpr auto value = hashed_string::value(stripped.data(), stripped.size());
        return value;
    }
#elif defined ENTT_PRETTY_FUNCTION
    [[nodiscard]] static id_type value() ENTT_NOEXCEPT {
        static const auto value = [](const auto stripped) { return hashed_string::value(stripped.data(), stripped.size()); }(internal::type_name<Type>());
        return value;
    }
#else
    [[nodiscard]] static id_type value() ENTT_NOEXCEPT {
        return type_seq<Type>::value();
    }
#endif
};





Add Discussion

Log in to comment