type_id: reduce the number of static variables due to type_id

This commit is contained in:
Michele Caini
2021-11-06 23:31:57 +01:00
parent 25977cc569
commit 0fa586a3d8

View File

@@ -254,8 +254,12 @@ private:
*/
template<typename Type>
[[nodiscard]] const type_info &type_id() ENTT_NOEXCEPT {
static type_info instance{std::in_place_type<std::remove_cv_t<std::remove_reference_t<Type>>>};
return instance;
if constexpr(std::is_same_v<Type, std::remove_cv_t<std::remove_reference_t<Type>>>) {
static type_info instance{std::in_place_type<std::remove_cv_t<std::remove_reference_t<Type>>>};
return instance;
} else {
return type_id<std::remove_cv_t<std::remove_reference_t<Type>>>();
}
}
} // namespace entt