Просмотр исходного кода

meta: keep supporting invalid types

skypjack 5 месяцев назад
Родитель
Сommit
c239821d12
2 измененных файлов с 3 добавлено и 3 удалено
  1. 2 2
      src/entt/meta/meta.hpp
  2. 1 1
      test/entt/meta/meta_type.cpp

+ 2 - 2
src/entt/meta/meta.hpp

@@ -1085,7 +1085,7 @@ private:
 /*! @brief Opaque wrapper for types. */
 class meta_type {
     [[nodiscard]] const auto &fetch_node() const {
-        return (node == nullptr) ? *(node = &internal::resolve<void>(internal::meta_context::from(*ctx))) : *node;
+        return (node == nullptr) ? internal::resolve<void>(internal::meta_context::from(*ctx)) : *node;
     }
 
     template<typename Func>
@@ -1521,7 +1521,7 @@ public:
      * @brief Returns true if an object is valid, false otherwise.
      * @return True if the object is valid, false otherwise.
      */
-    [[deprecated("empty meta types are never invalid, and they match void instead")]] [[nodiscard]] explicit operator bool() const noexcept {
+    [[nodiscard]] explicit operator bool() const noexcept {
         return (node != nullptr);
     }
 

+ 1 - 1
test/entt/meta/meta_type.cpp

@@ -232,7 +232,7 @@ TEST_F(MetaType, SafeWhenEmpty) {
     ASSERT_EQ(type.template_type(), type);
     ASSERT_EQ(type.template_arg(0u), type);
     ASSERT_EQ(type.template_arg(1u), type);
-    ASSERT_TRUE(type.can_cast(type));
+    ASSERT_FALSE(type.can_cast(type));
     ASSERT_TRUE(type.can_cast(entt::resolve<void>()));
     ASSERT_TRUE(type.can_convert(type));
     ASSERT_TRUE(type.can_convert(entt::resolve<void>()));