Michele Caini 5 лет назад
Родитель
Сommit
89d7c7e572
2 измененных файлов с 9 добавлено и 1 удалено
  1. 8 0
      src/entt/entity/handle.hpp
  2. 1 1
      test/entt/entity/handle.cpp

+ 8 - 0
src/entt/entity/handle.hpp

@@ -46,6 +46,14 @@ struct basic_handle {
         return *this;
     }
 
+    /**
+     * @brief Assigns the null object to a handle.
+     * @return This handle.
+     */
+    basic_handle & operator=(null_t) ENTT_NOEXCEPT {
+        return (*this = static_cast<entity_type>(null));
+    }
+
     /**
      * @brief Constructs a const handle from a non-const one.
      * @return A const handle referring to the same entity.

+ 1 - 1
test/entt/entity/handle.cpp

@@ -39,7 +39,7 @@ TEST(BasicHandle, Construction) {
     static_assert(std::is_same_v<entt::registry &, decltype(handle.registry())>);
     static_assert(std::is_same_v<const entt::registry &, decltype(chandle.registry())>);
 
-    handle = static_cast<entt::entity>(entt::null);
+    handle = entt::null;
 
     ASSERT_TRUE(entt::null == handle.entity());
     ASSERT_NE(entity, handle);