Fix WaitFreeHashMap::get_pointer.

This commit is contained in:
levlam 2022-08-04 22:40:22 +03:00
parent ecfd1dacd3
commit 9e4ae8997b
2 changed files with 5 additions and 5 deletions

View File

@ -76,8 +76,8 @@ class WaitFreeHashMap {
} }
// specialization for WaitFreeHashMap<..., unique_ptr<T>> // specialization for WaitFreeHashMap<..., unique_ptr<T>>
template <typename ReturnT = decltype(ValueT().get())> template <class T = ValueT>
ReturnT get_pointer(const KeyT &key) { typename T::element_type *get_pointer(const KeyT &key) {
auto &storage = get_storage(key); auto &storage = get_storage(key);
auto it = storage.find(key); auto it = storage.find(key);
if (it == storage.end()) { if (it == storage.end()) {
@ -86,8 +86,8 @@ class WaitFreeHashMap {
return it->second.get(); return it->second.get();
} }
template <typename ReturnT = decltype(static_cast<const ValueT &>(ValueT()).get())> template <class T = ValueT>
ReturnT get_pointer(const KeyT &key) const { const typename T::element_type *get_pointer(const KeyT &key) const {
auto &storage = get_storage(key); auto &storage = get_storage(key);
auto it = storage.find(key); auto it = storage.find(key);
if (it == storage.end()) { if (it == storage.end()) {

View File

@ -38,7 +38,7 @@ TEST(WaitFreeHashMap, stress_test) {
result -= key * 101; result -= key * 101;
result -= value; result -= value;
}); });
ASSERT_EQ(0, result); ASSERT_EQ(0u, result);
} }
}; };