summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-01-22 07:51:35 -0800
committerKonstantin Käfer <mail@kkaefer.com>2015-02-04 10:49:06 +0100
commit78376acea78056d9c20cc39bf98323adeedd22aa (patch)
tree2c17f9bd90e3a7f5d8a31d1b1eefc32b1c060030
parent92a7f73bbe10f817d5c2d607ba07fc69b859593b (diff)
downloadqtlocation-mapboxgl-78376acea78056d9c20cc39bf98323adeedd22aa.tar.gz
don't override std::hash
-rw-r--r--include/mbgl/storage/default/default_file_source.hpp2
-rw-r--r--include/mbgl/storage/resource.hpp14
2 files changed, 6 insertions, 10 deletions
diff --git a/include/mbgl/storage/default/default_file_source.hpp b/include/mbgl/storage/default/default_file_source.hpp
index 189ff7b9ee..21048e99e5 100644
--- a/include/mbgl/storage/default/default_file_source.hpp
+++ b/include/mbgl/storage/default/default_file_source.hpp
@@ -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;
diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp
index e499f84a28..cfd52caa75 100644
--- a/include/mbgl/storage/resource.hpp
+++ b/include/mbgl/storage/resource.hpp
@@ -21,17 +21,13 @@ struct Resource {
inline bool operator==(const Resource &res) const {
return kind == res.kind && url == res.url;
}
-};
-
-}
-// Specialize std::hash for use in std::unordered_map
-namespace std {
+ struct Hash {
+ std::size_t operator()(Resource const& r) const {
+ return std::hash<std::string>()(r.url) ^ (std::hash<uint8_t>()(r.kind) << 1);
+ }
+ };
-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);
- }
};
}