Cachemere
Modular Caching Library for C++
include
cachemere
hash.h
1
#ifndef CACHEMERE_HASH_H
2
#define CACHEMERE_HASH_H
3
4
#include <cstdint>
5
6
namespace
cachemere
{
7
11
template
<
typename
Key,
typename
KeyHash,
typename
... Tail>
struct
MultiHash
;
12
13
// Base case.
14
template
<
typename
Key,
typename
KeyHash>
struct
MultiHash
<Key, KeyHash> {
15
// Declare this type as transparent - this is needed for abseil maps to support heterogeneous lookup.
16
using
is_transparent = void;
17
18
size_t
operator()(
const
Key& key)
const
19
{
20
return
m_hash(key);
21
}
22
23
private
:
24
KeyHash m_hash;
25
};
26
27
// Recursive case.
28
template
<
typename
Key,
typename
KeyHash,
typename
... Tail>
struct
MultiHash
:
public
MultiHash
<Key, KeyHash>,
public
MultiHash
<Tail...> {
29
// Declare this type as transparent - this is needed for abseil maps to support heterogeneous lookup.
30
using
is_transparent = void;
31
32
// Need to bring back operator() declarations from parent types, so they can all be considered as overloads.
33
using
MultiHash<Key, KeyHash>::operator
();
34
using
MultiHash<Tail...>:: operator
();
35
};
36
37
}
// namespace cachemere
38
39
#endif // CACHEMERE_HASH_H
cachemere::MultiHash
Allows combining hashers for multiple types into a single hashing object.
Definition:
hash.h:11
cachemere
Root namespace.
Definition:
cache.h:35
Generated by
1.8.17