registry: ::storage(id) returns a pointer rather than an utterly annoying iterator
This commit is contained in:
@@ -43,8 +43,8 @@ TEST(Example, EntityCopy) {
|
||||
TEST(Example, DifferentRegistryTypes) {
|
||||
using namespace entt::literals;
|
||||
|
||||
entt::basic_registry<entt::entity> registry{};
|
||||
entt::basic_registry<my_entity> other{};
|
||||
entt::basic_registry<entt::entity> src{};
|
||||
entt::basic_registry<my_entity> dst{};
|
||||
|
||||
/*
|
||||
TODO These are currently needed to ensure that the source and
|
||||
@@ -56,23 +56,23 @@ TEST(Example, DifferentRegistryTypes) {
|
||||
lines should be removed when a fix is properly landed.
|
||||
https://github.com/skypjack/entt/issues/827
|
||||
*/
|
||||
static_cast<void>(registry.storage<double>());
|
||||
static_cast<void>(other.storage<int>());
|
||||
static_cast<void>(src.storage<double>());
|
||||
static_cast<void>(dst.storage<int>());
|
||||
|
||||
const auto src = registry.create();
|
||||
const auto dst = other.create();
|
||||
const auto entity = src.create();
|
||||
const auto copy = dst.create();
|
||||
|
||||
registry.emplace<int>(src, 42);
|
||||
registry.emplace<char>(src, 'c');
|
||||
src.emplace<int>(entity, 42);
|
||||
src.emplace<char>(entity, 'c');
|
||||
|
||||
for(auto [id, storage]: registry.storage()) {
|
||||
if(auto it = other.storage(id); it != other.storage().end() && storage.contains(src)) {
|
||||
it->second.emplace(dst, storage.get(src));
|
||||
for(auto [id, storage]: src.storage()) {
|
||||
if(auto *other = dst.storage(id); other && storage.contains(entity)) {
|
||||
other->emplace(copy, storage.get(entity));
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_TRUE((registry.all_of<int, char>(src)));
|
||||
ASSERT_FALSE(other.all_of<char>(dst));
|
||||
ASSERT_TRUE(other.all_of<int>(dst));
|
||||
ASSERT_EQ(other.get<int>(dst), 42);
|
||||
ASSERT_TRUE((src.all_of<int, char>(entity)));
|
||||
ASSERT_FALSE(dst.all_of<char>(copy));
|
||||
ASSERT_TRUE(dst.all_of<int>(copy));
|
||||
ASSERT_EQ(dst.get<int>(copy), 42);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user