Commit 33fb91d9 authored by Joe Romano's avatar Joe Romano Committed by Facebook Github Bot

Add docs to insert_or_assign re: inconsistency with std::map interface

Summary:
`ConcurrentHashMap::insert_or_assign` does not follow the interface for `std::map::insert_or_assign`.  Making this clear for future users to avoid confusion.

Code:
```
int main(int argc, char** argv) {
  folly::ConcurrentHashMap<int, std::string> map;
  std::cout << "Insertion took place?: " << map.insert_or_assign(1, "hey").second << std::endl;
  std::cout << "Insertion took place?: "
<< map.insert_or_assign(0, "wow").second << std::endl;
  std::cout << "Insertion took place?: "
<< map.insert_or_assign(1, "wow").second << std::endl;
}
```

Output:
```
Insertion took place?: 1
Insertion took place?: 1
Insertion took place?: 1
```

Also see: https://github.com/facebook/folly/blob/master/folly/concurrency/test/ConcurrentHashMapTest.cpp#L86-L87

Reviewed By: magedm

Differential Revision: D16967939

fbshipit-source-id: ce0d32813371b31a94e14e404665d4fb2e7ffdfe
parent 1a0ddc9c
......@@ -319,6 +319,11 @@ class ConcurrentHashMap {
return res;
}
/*
* The bool component will always be true if the map has been updated via
* either insertion or assignment. Note that this is different from the
* std::map::insert_or_assign interface.
*/
template <typename Key, typename Value>
std::pair<ConstIterator, bool> insert_or_assign(Key&& k, Value&& v) {
auto segment = pickSegment(k);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment