36TEST(ContextTests, Builders) {
44 ParentCtx.
derive(ParentAndChildParam, 30).
derive(ChildParam, 40);
46 EXPECT_EQ(*ParentCtx.
get(ParentParam), 10);
47 EXPECT_EQ(*ParentCtx.
get(ParentAndChildParam), 20);
48 EXPECT_EQ(ParentCtx.
get(ChildParam),
nullptr);
50 EXPECT_EQ(*ChildCtx.
get(ParentParam), 10);
51 EXPECT_EQ(*ChildCtx.
get(ParentAndChildParam), 30);
52 EXPECT_EQ(*ChildCtx.
get(ChildParam), 40);
A context is an immutable container for per-request data that must be propagated through layers that ...
Context derive(const Key< Type > &Key, std::decay_t< Type > Value) const &
Derives a child context It is safe to move or destroy a parent context after calling derive().
const Type * get(const Key< Type > &Key) const
Get data stored for a typed Key.
static Context empty()
Returns an empty root context that contains no data.