registry: assert on user entity storage - close #1143
This commit is contained in:
@@ -244,6 +244,7 @@ class basic_registry {
|
||||
static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Non-decayed types not allowed");
|
||||
|
||||
if constexpr(std::is_same_v<Type, entity_type>) {
|
||||
ENTT_ASSERT(id == type_hash<Type>::value(), "User entity storage not allowed");
|
||||
return entities;
|
||||
} else {
|
||||
auto &cpool = pools[id];
|
||||
@@ -272,6 +273,7 @@ class basic_registry {
|
||||
static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Non-decayed types not allowed");
|
||||
|
||||
if constexpr(std::is_same_v<Type, entity_type>) {
|
||||
ENTT_ASSERT(id == type_hash<Type>::value(), "User entity storage not allowed");
|
||||
return &entities;
|
||||
} else {
|
||||
if(const auto it = pools.find(id); it != pools.cend()) {
|
||||
|
||||
@@ -525,6 +525,9 @@ ENTT_DEBUG_TEST(RegistryDeathTest, Storage) {
|
||||
|
||||
ASSERT_DEATH(registry.storage<int>("other"_hs), "");
|
||||
ASSERT_DEATH(std::as_const(registry).storage<int>("other"_hs), "");
|
||||
|
||||
ASSERT_DEATH(registry.storage<entt::entity>("other"_hs), "");
|
||||
ASSERT_DEATH(std::as_const(registry).storage<entt::entity>("other"_hs), "");
|
||||
}
|
||||
|
||||
TEST(Registry, Identifiers) {
|
||||
|
||||
Reference in New Issue
Block a user