porymap/include/lib/qstringhash.h

21 lines
504 B
C
Raw Normal View History

2020-09-13 23:37:55 +01:00
#pragma once
#ifndef QSTRINGHASH_H
#define QSTRINGHASH_H
#include <QHash>
#include <QString>
#include <functional>
// This is a custom hash function for QString so it can be used as
// a key in a std::hash structure. Qt 5.14 added this function, so
// this file should only be included in earlier versions.
namespace std {
2021-02-18 00:20:14 +00:00
template <> struct hash<QString> {
std::size_t operator()(const QString& s) const noexcept {
2021-02-18 00:20:14 +00:00
return static_cast<size_t>(qHash(s));
}
2021-02-18 00:20:14 +00:00
};
}
#endif // QSTRINGHASH_H