summaryrefslogtreecommitdiff
path: root/src/mbgl/util/hash.hpp
blob: 89aba00f72f8797c892c49314567589deef6fb3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include <mbgl/util/ignore.hpp>

#include <functional>

namespace mbgl {
namespace util {

template <class T>
void hash_combine(std::size_t& seed, const T& v) {
    seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}

template <class... Args>
std::size_t hash(Args&&... args) {
    std::size_t seed = 0;
    ignore({ (hash_combine(seed, args), 0)... });
    return seed;
}

} // namespace util
} // namespace mbgl