change mutable if_contains to modify_if

This commit is contained in:
greg
2020-08-07 13:10:31 -04:00
parent 7bbf9dc041
commit 17f9048990
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -3438,7 +3438,7 @@ public:
}
template <class K = key_type, class F>
bool if_contains(const key_arg<K>& key, F&& f) {
bool modify_if(const key_arg<K>& key, F&& f) {
#if __cplusplus >= 201703L
static_assert(std::is_invocable<F, mapped_type&>::value);
#endif
+3 -1
View File
@@ -23,8 +23,10 @@ TEST(THIS_TEST_NAME, ThreadSafeContains) {
EXPECT_FALSE(m.if_contains(3, get_value));
auto set_value = [&val](int& v) { v = 11; };
EXPECT_TRUE(m.if_contains(2, set_value));
EXPECT_TRUE(m. modify_if(2, set_value));
EXPECT_EQ(m[2], 11);
EXPECT_FALSE(m.modify_if(3, set_value));
}
} // namespace