summaryrefslogtreecommitdiff
path: root/src/mbgl/util
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-10-18 17:57:04 +0200
committerKonstantin Käfer <mail@kkaefer.com>2018-10-23 12:23:40 +0200
commit70d5972e104aac91f4198540d4af14562e92d555 (patch)
tree83e92385784d2c89df052690cd3a15ad1ca3eb01 /src/mbgl/util
parent282c71e8e9a8ec9c2eab612f2e60a71b15d24c8a (diff)
downloadqtlocation-mapboxgl-70d5972e104aac91f4198540d4af14562e92d555.tar.gz
[core] don't use <boost/functional/hash.hpp> to avoid <locale> include
Diffstat (limited to 'src/mbgl/util')
-rw-r--r--src/mbgl/util/font_stack.cpp8
-rw-r--r--src/mbgl/util/hash.hpp23
2 files changed, 29 insertions, 2 deletions
diff --git a/src/mbgl/util/font_stack.cpp b/src/mbgl/util/font_stack.cpp
index fb1b716fb6..4093a21793 100644
--- a/src/mbgl/util/font_stack.cpp
+++ b/src/mbgl/util/font_stack.cpp
@@ -1,8 +1,8 @@
#include <mbgl/util/font_stack.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/style/layers/symbol_layer_impl.hpp>
+#include <mbgl/util/hash.hpp>
-#include <boost/functional/hash.hpp>
#include <boost/algorithm/string/join.hpp>
namespace mbgl {
@@ -14,7 +14,11 @@ std::string fontStackToString(const FontStack& fontStack) {
}
FontStackHash FontStackHasher::operator()(const FontStack& fontStack) const {
- return boost::hash_range(fontStack.begin(), fontStack.end());
+ std::size_t seed = 0;
+ for (const auto& font : fontStack) {
+ util::hash_combine(seed, font);
+ }
+ return seed;
}
std::set<FontStack> fontStacks(const std::vector<Immutable<style::Layer::Impl>>& layers) {
diff --git a/src/mbgl/util/hash.hpp b/src/mbgl/util/hash.hpp
new file mode 100644
index 0000000000..987a8bd8dc
--- /dev/null
+++ b/src/mbgl/util/hash.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <mbgl/util/ignore.hpp>
+
+#include <functional>
+
+namespace mbgl {
+namespace util {
+
+template <class T>
+inline void hash_combine(std::size_t& seed, const T& v) {
+ seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
+}
+
+template <class... Args>
+inline std::size_t hash(Args&&... args) {
+ std::size_t seed = 0;
+ ignore({ (hash_combine(seed, args), 0)... });
+ return seed;
+}
+
+} // namespace util
+} // namespace mbgl