I am trying to use an std::array as a key for a QHash class:
QHash<std::array<char, 6>, QString> _hash;
As required, I have overloaded a qHash function:
inline uint qHash(const std::array<char, 6> &key, uint seed)
{
return ::qHashBits(key.data(), key.size(), seed);
}
An == operator is supported by std::array itself.
But when compiling I get the error "no matching function for call to qHash(const std::array<char, 6>&)
".
The same situation is with std::tuple. Although std::pair works fine. So do regular structs.
What am I doing wrong?
UPD
I tried also one-argument form of qHash:
inline uint qHash(const std::array<char, 6> &key)
{
return ::qHashBits(key.data(), key.size(), 0);
}
Exactly the same result.
UPD2
Here is an example main.cpp file. No other code in the project.
#include <array>
#include <QHash>
static QHash<std::array<char, 6>, QString> hashByArray;
uint qHash(const std::array<char, 6>& key)
{
return 0;
}
int main(int argc, char *argv[])
{
hashByArray.insert({ 0, 0, 0, 0, 0, 0 }, "Hello");
return 0;
}