From 9e68eb4d2c9e9d24998f70f703c4d0f10263ec6b Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 5 Apr 2022 08:50:08 +0200 Subject: [PATCH] type_id: type_info from variable --- src/entt/core/type_info.hpp | 6 ++++++ test/entt/core/type_info.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/entt/core/type_info.hpp b/src/entt/core/type_info.hpp index 827bbb1eb..0b0fbf94c 100644 --- a/src/entt/core/type_info.hpp +++ b/src/entt/core/type_info.hpp @@ -262,6 +262,12 @@ template } } +/*! @copydoc type_id */ +template +[[nodiscard]] const type_info &type_id(Type &&) ENTT_NOEXCEPT { + return type_id>>(); +} + } // namespace entt #endif diff --git a/test/entt/core/type_info.cpp b/test/entt/core/type_info.cpp index 9f165a524..3d51e70cc 100644 --- a/test/entt/core/type_info.cpp +++ b/test/entt/core/type_info.cpp @@ -48,6 +48,11 @@ TEST(TypeInfo, Functionalities) { static_assert(std::is_copy_assignable_v); static_assert(std::is_move_assignable_v); + const int value = 42; + + ASSERT_EQ(entt::type_id(value), entt::type_id()); + ASSERT_EQ(entt::type_id(42), entt::type_id()); + ASSERT_EQ(entt::type_id(), entt::type_id()); ASSERT_EQ(entt::type_id(), entt::type_id()); ASSERT_EQ(entt::type_id(), entt::type_id());