PHash.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PGuid.h>
17 #include <PString.h>
18 
19 
20 PAPILLON_BEGIN_NAMESPACE
21 
25 inline std::size_t hash_value(papillon::PGuid const& guid)
26 {
27  return static_cast<std::size_t>(guid.GetHashCode());
28 }
29 
33 inline std::size_t hash_value(papillon::PString const& s)
34 {
35  return static_cast<std::size_t>(s.GetHashCode());
36 }
37 
38 PAPILLON_END_NAMESPACE
39 
40 
41 namespace std
42 {
46  template <>
47  struct hash<papillon::PGuid>
48  {
49  size_t operator()(const papillon::PGuid& guid) const
50  {
51  return static_cast<std::size_t>(guid.GetHashCode());
52  }
53  };
54 
58  template <>
59  struct hash<papillon::PString>
60  {
61  size_t operator()(const papillon::PString& s) const
62  {
63  return static_cast<std::size_t>(s.GetHashCode());
64  }
65  };
66 }
size_t operator()(const papillon::PString &s) const
Definition: PHash.h:61
The PString class provides an Unicode character strings.
Definition: PString.h:37
Class PGuid: an immutable Globally Unique Identifier (GUID).
size_t operator()(const papillon::PGuid &guid) const
Definition: PHash.h:49
PAPILLON_BEGIN_NAMESPACE std::size_t hash_value(papillon::PGuid const &guid)
Computes hash value for PGuid objects (compatible with boost::unordered_map).
Definition: PHash.h:25
STL namespace.
Class PString: an unicode character strings (use copy-on-write idiom).
The PGuid class represents a Globally Unique Identifier (GUID); PGuid instances are immutable (thread...
Definition: PGuid.h:28