Euphoria
Main Page
Related Pages
Topics
Namespaces
Concepts
Classes
Files
File List
File Members
libs
core
src
eu
core
hash.h
Go to the documentation of this file.
1
#pragma once
2
3
namespace
eu::core
4
{
5
20
21
25
struct
HashCombiner
26
{
27
std::size_t
result
= 17;
28
37
template
<
typename
T>
38
HashCombiner
&
combine
(
const
T& t)
39
{
40
result
=
result
* 31 + std::hash<T>{}(t);
41
return
*
this
;
42
}
43
};
44
45
51
#define HASH_DEF_BEGIN(TYPE) \
52
template<> \
53
struct std::hash<TYPE> \
54
{ \
55
std::size_t operator()(const TYPE& x) const \
56
{ \
57
return eu::core::HashCombiner \
58
{ \
59
}
60
70
#define HASH_DEF(NAME) .combine(x.NAME)
71
79
#define HASH_DEF_END() \
80
.result; \
81
} \
82
} \
83
;
84
88
89
}
// namespace klotter
90
eu::core
Definition
color.h:4
eu::core::HashCombiner
A utility for combining hash values of multiple objects into a single hash value.
Definition
hash.h:26
eu::core::HashCombiner::result
std::size_t result
Definition
hash.h:27
eu::core::HashCombiner::combine
HashCombiner & combine(const T &t)
Combines the hash of the given object with the current result.
Definition
hash.h:38
Generated by
1.15.0