Make a single if_contains function to simplify the interface

This commit is contained in:
Brian McKinnon
2020-05-03 10:32:36 -05:00
parent fa7a5cc444
commit a1349d2b65
3 changed files with 3 additions and 22 deletions
-7
View File
@@ -14,19 +14,12 @@ TEST(THIS_TEST_NAME, ThreadSafeContains) {
// Test that the nodes have the proper API.
ThisMap<int, int> m = { {1, 7}, {2, 9} };
auto val = 0;
EXPECT_TRUE(m.if_contains(1, val));
EXPECT_EQ(val, 7);
EXPECT_FALSE(m.if_contains(3, val));
#if __cplusplus > 199711L
auto func = [&val](int& v) { val = v; };
EXPECT_TRUE(m.if_contains(2, func));
EXPECT_EQ(val, 9);
EXPECT_FALSE(m.if_contains(3, func));
#endif
}
} // namespace