Overte C++ Documentation
UUIDHasher.h
1 //
2 // UUIDHasher.h
3 // libraries/networking/src
4 //
5 // Created by Stephen Birarda on 2014-11-05.
6 // Copyright 2014 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_UUIDHasher_h
13 #define hifi_UUIDHasher_h
14 
15 #include <QUuid>
16 
17 // uses the same hashing performed by Qt
18 // https://qt.gitorious.org/qt/qtbase/source/73ef64fb5fabb60101a3cac6e43f0c5bb2298000:src/corelib/plugin/quuid.cpp
19 
20 class UUIDHasher {
21 public:
22  size_t operator()(const QUuid& uuid) const {
23  return qHash(uuid);
24  }
25 };
26 
27 namespace std {
28  template <> struct hash<QUuid> {
29  size_t operator()(const QUuid& uuid) const {
30  return qHash(uuid);
31  }
32  };
33 }
34 
35 #endif // hifi_UUIDHasher_h