Function type_id

Summary

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

(1) template <typename Type>
    const type_info & type_id()

(2) template <typename Type>
    const type_info & type_id(Type &&)

Function overload

Synopsis

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

template <typename Type>
const type_info & type_id()

Description

Returns the type info object associated to a given type.

The returned element refers to an object with static storage duration.
The type doesn't need to be a complete type. If the type is a reference, the result refers to the referenced type. In all cases, top-level cv-qualifiers are ignored.

Template Parameters

Type - Type for which to generate a type info object.

Returns
A reference to a properly initialized type info object.

Mentioned in

Source

Lines 256-264 in src/entt/core/type_info.hpp.

template<typename Type>
[[nodiscard]] const type_info &type_id() ENTT_NOEXCEPT {
    if constexpr(std::is_same_v<Type, std::remove_cv_t<std::remove_reference_t<Type>>>) {
        static type_info instance{std::in_place_type<Type>};
        return instance;
    } else {
        return type_id<std::remove_cv_t<std::remove_reference_t<Type>>>();
    }
}

Synopsis

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

template <typename Type>
const type_info & type_id(Type &&)

Description

Returns the type info object associated to a given type.

The returned element refers to an object with static storage duration.
The type doesn't need to be a complete type. If the type is a reference, the result refers to the referenced type. In all cases, top-level cv-qualifiers are ignored.

Template Parameters

Type - Type for which to generate a type info object.

Returns
A reference to a properly initialized type info object.

Mentioned in

Source

Lines 267-270 in src/entt/core/type_info.hpp.

template<typename Type>
[[nodiscard]] const type_info &type_id(Type &&) ENTT_NOEXCEPT {
    return type_id<std::remove_cv_t<std::remove_reference_t<Type>>>();
}





Add Discussion

Log in to comment