registry: extended checks to support swap-only entity storage types

This commit is contained in:
Michele Caini
2023-01-24 17:34:46 +01:00
parent 7be8d83278
commit 4747c9a4c8

View File

@@ -320,7 +320,7 @@ class basic_registry {
cpool->bind(forward_as_any(*this));
}
ENTT_ASSERT(cpool->type() == type_id<Type>(), "Unexpected type");
ENTT_ASSERT((cpool->type() == type_id<std::conditional_t<std::is_same_v<Type, entity_type>, void, Type>>()), "Unexpected type");
return static_cast<storage_for_type<Type> &>(*cpool);
}
@@ -329,7 +329,7 @@ class basic_registry {
static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Non-decayed types not allowed");
if(const auto it = pools.first().find(id); it != pools.first().cend()) {
ENTT_ASSERT(it->second->type() == type_id<Type>(), "Unexpected type");
ENTT_ASSERT((it->second->type() == type_id<std::conditional_t<std::is_same_v<Type, entity_type>, void, Type>>()), "Unexpected type");
return static_cast<const storage_for_type<Type> &>(*it->second);
}