don't override std::hash

This commit is contained in:
Konstantin Käfer
2015-01-22 07:51:35 -08:00
committed by Konstantin Käfer
parent 92a7f73bbe
commit 78376acea7
2 changed files with 6 additions and 10 deletions

View File

@@ -47,7 +47,7 @@ private:
SharedRequestBase *find(const Resource &resource);
std::unordered_map<Resource, SharedRequestBase *> pending;
std::unordered_map<Resource, SharedRequestBase *, Resource::Hash> pending;
uv_loop_t *loop = nullptr;
FileCache *cache = nullptr;

View File

@@ -21,17 +21,13 @@ struct Resource {
inline bool operator==(const Resource &res) const {
return kind == res.kind && url == res.url;
}
};
}
struct Hash {
std::size_t operator()(Resource const& r) const {
return std::hash<std::string>()(r.url) ^ (std::hash<uint8_t>()(r.kind) << 1);
}
};
// Specialize std::hash for use in std::unordered_map
namespace std {
template<> struct hash<mbgl::Resource> {
std::size_t operator()(mbgl::Resource const& r) const {
return std::hash<std::string>()(r.url) ^ (std::hash<uint8_t>()(r.kind) << 1);
}
};
}