You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error is no matching function for call to ‘swap( for both the hash and equality functions.
Replacing "google::dense_hash_map" by "std::unordered_map" makes the code compiles.
As it happen this is only annoying, not blocking. The "solution" is to std::function<size_t(size_t)> hash_fct instead of auto hash_fct. Also, replace decltype(hash_fct) by std::function<size_t(size_t)>. Of course do similarly for the equality test.
But that is annoying and maybe there is a better solution.
The text was updated successfully, but these errors were encountered:
The following code does not compile:
#include <sparsehash/dense_hash_map>
#include
int main(int argc, char* argv[])
{
auto hash_fct=[&](size_t eVal) -> size_t {
return std::hash<size_t>()(eVal % 128);
};
auto equal_fct=[&](size_t eVal1, size_t eVal2) -> bool {
return eVal1 == eVal2;
};
google::dense_hash_map<size_t, size_t, decltype(hash_fct), decltype(equal_fct)> V({}, hash_fct, equal_fct);
for (size_t i=0; i<10; i++) {
size_t& group = V[i];
}
}
Error is
no matching function for call to ‘swap(
for both the hash and equality functions.Replacing "google::dense_hash_map" by "std::unordered_map" makes the code compiles.
As it happen this is only annoying, not blocking. The "solution" is to
std::function<size_t(size_t)> hash_fct
instead ofauto hash_fct
. Also, replacedecltype(hash_fct)
bystd::function<size_t(size_t)>
. Of course do similarly for the equality test.But that is annoying and maybe there is a better solution.
The text was updated successfully, but these errors were encountered: