Lunchbox  1.16.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
hash.h
1 
2 /* Copyright (c) 2005-2017, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
18 #ifndef LUNCHBOX_HASH_H
19 #define LUNCHBOX_HASH_H
20 
21 #include <lunchbox/refPtr.h>
22 
23 #include <unordered_map>
24 
25 namespace lunchbox
26 {
28 template <class K, class T>
29 class PtrHash : public std::unordered_map<K, T, std::hash<const void*> >
30 {
31 };
32 
33 template <typename T>
34 struct hashRefPtr
35 {
36  size_t operator()(RefPtr<T> key) const
37  {
38  return std::hash<const void*>()(key.get());
39  }
40 };
41 
43 template <class K, class T>
44 class RefPtrHash : public std::unordered_map<RefPtr<K>, T, hashRefPtr<K> >
45 {
46 };
47 }
48 #endif // LUNCHBOX_HASH_H
A hash for pointer keys.
Definition: hash.h:29
A hash for RefPtr keys.
Definition: hash.h:44
Abstraction layer and common utilities for multi-threaded programming.
Definition: algorithm.h:29
A smart reference pointer, aka boost::intrusive_ptr.
Definition: refPtr.h:40