summaryrefslogtreecommitdiff
path: root/src/utils/cpp/hash_combine.hpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-02-22 17:03:21 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-02-22 17:03:21 +0100
commit619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 (patch)
tree01868de723cb82c86842f33743fa7b14e24c1fa3 /src/utils/cpp/hash_combine.hpp
downloadjustbuild-619def44c1cca9f3cdf63544d5f24f2c7a7d9b77.tar.gz
Initial self-hosting commit
This is the initial version of our tool that is able to build itself. In can be bootstrapped by ./bin/bootstrap.py Co-authored-by: Oliver Reiche <oliver.reiche@huawei.com> Co-authored-by: Victor Moreno <victor.moreno1@huawei.com>
Diffstat (limited to 'src/utils/cpp/hash_combine.hpp')
-rw-r--r--src/utils/cpp/hash_combine.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/utils/cpp/hash_combine.hpp b/src/utils/cpp/hash_combine.hpp
new file mode 100644
index 00000000..65c0c8ad
--- /dev/null
+++ b/src/utils/cpp/hash_combine.hpp
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_SRC_UTILS_CPP_HASH_COMBINE_HPP
+#define INCLUDED_SRC_UTILS_CPP_HASH_COMBINE_HPP
+
+#include "gsl-lite/gsl-lite.hpp"
+
+// Taken from Boost, as hash_combine did not yet make it to STL.
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0814r0.pdf
+template <class T>
+inline auto hash_combine(gsl::not_null<std::size_t*> const& seed, T const& v)
+ -> void {
+ *seed ^=
+ std::hash<T>{}(v) + 0x9e3779b9 + (*seed << 6) + (*seed >> 2); // NOLINT
+}
+
+#endif