handle: better API

This commit is contained in:
Michele Caini
2020-07-06 09:39:23 +02:00
parent 75b19230eb
commit 89d7c7e572
2 changed files with 9 additions and 1 deletions

View File

@@ -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.

View File

@@ -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);