Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions cds/container/hopscotch_hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ namespace cds {
template <typename K>
bool contains(K const& key)
{
return get(key, [=](K const& one, K const& two) { return one != two; }) != NULL;
DATA data = get(key);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khizmax, почему-то не хочет компилировать на этом моменте, второй день понять не можем почему, есть идеи?
MSVC: d:\sources\libcds\cds\container\hopscotch_hashmap.h(128): error C2672: 'cds::container::hopscotch_hashmap<cds_test::striped_map_fixture::key_type,cds_test::striped_map_fixture::value_type>::get': no matching overloaded function found

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Во-первых, надо просто убрать = из [=], он тут не нужен:
return get(key, [](K const& one, K const& two) { return one != two; }) != nullptr;
Вторая причина - в template-параметре K функции: если этот тип отличен от template-параметра KEY класса, то конечно же такая лямбда не подойдет.

return data != NULL;
}

/// Checks whether the map contains \p key using \p pred predicate for searching
Expand Down Expand Up @@ -161,29 +162,29 @@ namespace cds {
{
DATA data = get(key, [=](K const& one, K const& two) { return one != two; });
f(data);
return *data != NULL;
return data != NULL;
}

template <typename K, typename Predicate>
bool find(K const& key, Predicate pred)
{
DATA data = get(key, pred);
return *data != NULL;
return data != NULL;
}

template <typename K>
bool find(K const& key)
{
DATA data = get(key, [=](K const& one, K const& two) { return one != two; });
return *data != NULL;
return data != NULL;
}

template <typename K, typename Predicate, typename Func>
bool find_with(K const& key, Predicate pred, Func f)
{
DATA data = get(key, [=](K const& one, K const& two) { return one != two; });
f(data);
return *data != NULL;
return data != NULL;
}

/// For key \p key inserts data of type \ref value_type constructed with <tt>std::forward<Args>(args)...</tt>
Expand Down