summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common_funcs.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index ed20c3629..7a8dd39a0 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -4,6 +4,9 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <cstddef>
8#include <functional>
9
7#include "common_types.h" 10#include "common_types.h"
8 11
9#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 12#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
@@ -95,3 +98,18 @@ inline u64 _rotr64(u64 x, unsigned int shift){
95// This function might change the error code. 98// This function might change the error code.
96// Defined in Misc.cpp. 99// Defined in Misc.cpp.
97const char* GetLastErrorMsg(); 100const char* GetLastErrorMsg();
101
102template <typename T>
103inline std::size_t hash(const T& o) {
104 return std::hash<T>()(o);
105}
106
107template <typename T>
108inline std::size_t combine_hash(const T& o) {
109 return hash(o);
110}
111
112template <typename T, typename... Args>
113inline std::size_t combine_hash(const T& o, const Args&... args) {
114 return hash(o) * 3 + combine_hash(args...);
115}