registry: context .clear() function - close #1262
This commit is contained in:
@@ -164,6 +164,10 @@ public:
|
||||
explicit registry_context(const allocator_type &allocator)
|
||||
: ctx{allocator} {}
|
||||
|
||||
void clear() noexcept {
|
||||
ctx.clear();
|
||||
}
|
||||
|
||||
template<typename Type, typename... Args>
|
||||
Type &emplace_as(const id_type id, Args &&...args) {
|
||||
return any_cast<Type &>(ctx.try_emplace(id, std::in_place_type<Type>, std::forward<Args>(args)...).first->second);
|
||||
|
||||
@@ -2353,6 +2353,14 @@ TEST(Registry, Context) {
|
||||
ASSERT_EQ(ctx.find<const int>(), cctx.find<int>());
|
||||
ASSERT_EQ(ctx.get<int>(), cctx.get<const int>());
|
||||
ASSERT_EQ(ctx.get<int>(), 0);
|
||||
|
||||
ASSERT_TRUE(ctx.contains<char>());
|
||||
ASSERT_TRUE(ctx.contains<int>());
|
||||
|
||||
ctx.clear();
|
||||
|
||||
ASSERT_FALSE(ctx.contains<char>());
|
||||
ASSERT_FALSE(ctx.contains<int>());
|
||||
}
|
||||
|
||||
TEST(Registry, ContextHint) {
|
||||
|
||||
Reference in New Issue
Block a user