entity: review of entt_traits<T>::to_type

This commit is contained in:
Michele Caini
2021-05-25 12:45:51 +02:00
parent 3e7dc7af29
commit ea614a0f3f
2 changed files with 2 additions and 1 deletions

View File

@@ -120,7 +120,7 @@ public:
* @return A properly constructed identifier.
*/
[[nodiscard]] static constexpr auto to_type(const entity_type entity, const version_type version = {}) {
return Type{entity | (version << traits_type::entity_shift)};
return Type{(entity & traits_type::entity_mask) | (version << traits_type::entity_shift)};
}
};

View File

@@ -23,6 +23,7 @@ TEST(Entity, Traits) {
ASSERT_EQ(traits_type::to_type(traits_type::to_entity(entity), traits_type::to_version(entity)), entity);
ASSERT_EQ(traits_type::to_type(traits_type::to_entity(other), traits_type::to_version(other)), other);
ASSERT_NE(traits_type::to_type(traits_type::to_integral(entity)), entity);
}
TEST(Entity, Null) {