diff --git a/TODO b/TODO index f6e09dccf..45ec72938 100644 --- a/TODO +++ b/TODO @@ -36,4 +36,4 @@ TODO: * improve non-const allow cast with in-place switch * meta fixed_size could return the size directly if present * setup testbed workflow on the CI and review build process for testbed (i.e. tests first due to SDL) -* type() -> info() for consistency (poly, sparse_set) +* type() -> info() for consistency (sparse_set) diff --git a/src/entt/poly/poly.hpp b/src/entt/poly/poly.hpp index 397cd6ad1..089d88e67 100644 --- a/src/entt/poly/poly.hpp +++ b/src/entt/poly/poly.hpp @@ -223,13 +223,18 @@ public: : basic_poly{std::in_place_type>>, std::forward(value)} {} /** - * @brief Returns the object type if any, `type_id()` otherwise. - * @return The object type if any, `type_id()` otherwise. + * @brief Returns the object type info if any, `type_id()` otherwise. + * @return The object type info if any, `type_id()` otherwise. */ - [[nodiscard]] const type_info &type() const noexcept { + [[nodiscard]] const type_info &info() const noexcept { return storage.info(); } + /*! @copydoc info */ + [[deprecated("use ::info instead")]] [[nodiscard]] const type_info &type() const noexcept { + return info(); + } + /** * @brief Returns an opaque pointer to the contained instance. * @return An opaque pointer the contained instance, if any. diff --git a/test/entt/poly/poly.cpp b/test/entt/poly/poly.cpp index 6ef48cb09..c8827ba09 100644 --- a/test/entt/poly/poly.cpp +++ b/test/entt/poly/poly.cpp @@ -236,9 +236,9 @@ TYPED_TEST(Poly, Functionalities) { ASSERT_TRUE(alias); ASSERT_TRUE(value); - ASSERT_EQ(empty.type(), entt::type_id()); + ASSERT_EQ(empty.info(), entt::type_id()); ASSERT_EQ(in_place.type(), entt::type_id()); - ASSERT_EQ(alias.type(), entt::type_id()); + ASSERT_EQ(alias.info(), entt::type_id()); ASSERT_EQ(value.type(), entt::type_id()); ASSERT_EQ(alias.data(), &instance); @@ -251,7 +251,7 @@ TYPED_TEST(Poly, Functionalities) { ASSERT_TRUE(empty); ASSERT_NE(empty.data(), nullptr); ASSERT_NE(std::as_const(empty).data(), nullptr); - ASSERT_EQ(empty.type(), entt::type_id()); + ASSERT_EQ(empty.info(), entt::type_id()); ASSERT_EQ(empty->get(), 0); empty.template emplace(3); @@ -265,7 +265,7 @@ TYPED_TEST(Poly, Functionalities) { ASSERT_NE(ref.data(), nullptr); ASSERT_EQ(ref.data(), in_place.data()); ASSERT_EQ(std::as_const(ref).data(), std::as_const(in_place).data()); - ASSERT_EQ(ref.type(), entt::type_id()); + ASSERT_EQ(ref.info(), entt::type_id()); ASSERT_EQ(ref->get(), 3); poly_type null{}; @@ -288,7 +288,7 @@ TYPED_TEST(Poly, Functionalities) { move.reset(); ASSERT_FALSE(move); - ASSERT_EQ(move.type(), entt::type_id()); + ASSERT_EQ(move.info(), entt::type_id()); } TYPED_TEST(Poly, Owned) {