本文整理汇总了C++中ContextMap::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextMap::Find方法的具体用法?C++ ContextMap::Find怎么用?C++ ContextMap::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextMap
的用法示例。
在下文中一共展示了ContextMap::Find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(ContextMapTest, AdjacentCleanupTest) {
ContextMap<string> mp;
std::weak_ptr<CoreContext> outerWeak;
std::weak_ptr<CoreContext> innerWeak;
// Add two contexts, and let one go out of scope
AutoCreateContext outer;
mp.Add("0", outer);
outerWeak = outer;
{
AutoCreateContext inner;
mp.Add("1", inner);
innerWeak = inner;
// Verify that we can find both contexts
std::shared_ptr<CoreContext> outerSearched = mp.Find("0");
ASSERT_TRUE(!!outerSearched.get()) << "Outer context just added, but couldn't be found";
std::shared_ptr<CoreContext> innerSearched = mp.Find("1");
ASSERT_TRUE(!!innerSearched.get()) << "Inner context just added, but couldn't be found";
}
// Inner should be 404 by now
ASSERT_TRUE(innerWeak.expired()) << "Unexpected outstanding reference to the inner context";
// Try to find the outer context. This should evict the inner context.
mp.Find("0");
ASSERT_EQ(1UL, mp.size()) << "Proximity eviction didn't function as expected";
}