diff --git a/CMakeLists.txt b/CMakeLists.txt index 74eb568..860ad94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,9 @@ if (PHMAP_BUILD_EXAMPLES) add_executable(ex_basic examples/basic.cc phmap.natvis) add_executable(ex_bench examples/bench.cc phmap.natvis) add_executable(ex_emplace examples/emplace.cc phmap.natvis) + if (MSVC) + add_executable(ex_lazy_emplace_l examples/lazy_emplace_l.cc phmap.natvis) + endif() add_executable(ex_serialize examples/serialize.cc phmap.natvis) target_include_directories(ex_serialize PUBLIC $) add_executable(ex_hash_std examples/hash_std.cc phmap.natvis) diff --git a/examples/lazy_emplace_l.cc b/examples/lazy_emplace_l.cc index 30a040f..beb5f2f 100644 --- a/examples/lazy_emplace_l.cc +++ b/examples/lazy_emplace_l.cc @@ -30,7 +30,7 @@ public: { int newIndex = -1; m_stringsMap.lazy_emplace_l(std::move(str), - [&](int& v) { newIndex = v; }, // called only when key was already present + [&](Map::value_type& p) { newIndex = p.second; }, // called only when key was already present [&](const Map::constructor& ctor) // construct value_type in place when key not present { newIndex = InterlockedIncrement(curIdx); ctor(std::move(str), newIndex); }); diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index 1803bdf..e56bed1 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -3276,10 +3276,10 @@ public: return false; } - // if map does not contains key, it is inserted and the mapped value is value-constructed - // with the provided arguments (if any), as with try_emplace. - // if map already contains key, then the lambda is called with the mapped value (under + // if map already contains key, the first lambda is called with the mapped value (under // write lock protection) and can update the mapped value. + // if map does not contains key, the second lambda is called and it should invoke the + // passed constructor to construct the value // returns true if key was not already present, false otherwise. // --------------------------------------------------------------------------------------- template