mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-29 08:34:39 +08:00
change mutable if_contains to modify_if
This commit is contained in:
Vendored
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user