Skip to content

Commit 5116841

Browse files
Copilotskypjack
andauthored
Cover context lookup across TU keys
Co-authored-by: skypjack <1812216+skypjack@users.noreply.github.com>
1 parent b3fb347 commit 5116841

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎test/entt/entity/registry.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,9 +2372,12 @@ TEST_F(Registry, ContextTypeMatchingAcrossTranslationUnits) {
23722372
entt::registry registry{};
23732373
auto *const expected = test::registry_context_insert(registry);
23742374
const auto *const value = registry.ctx().find<test::registry_context_type *>();
2375+
const auto *const hinted = registry.ctx().find<test::registry_context_type *>(0u);
23752376

23762377
ASSERT_NE(value, nullptr);
23772378
ASSERT_EQ(*value, expected);
2379+
ASSERT_NE(hinted, nullptr);
2380+
ASSERT_EQ(*hinted, expected);
23782381
}
23792382

23802383
TEST_F(Registry, ContextHint) {

‎test/entt/entity/registry_context.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ registry_context_value<Type>::registry_context_value() = default;
77

88
template<typename Type>
99
registry_context_value<Type> *registry_context_value<Type>::insert(entt::registry &registry) {
10-
registry.ctx().emplace<registry_context_value<Type> *>(this);
10+
auto &ctx = registry.ctx();
11+
ctx.emplace<registry_context_value<Type> *>(this);
12+
ctx.emplace_as<registry_context_value<Type> *>(0u, this);
1113
return this;
1214
}
1315

0 commit comments

Comments
 (0)