OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TOOLS_GN_LABEL_PTR_H_ | 5 #ifndef TOOLS_GN_LABEL_PTR_H_ |
6 #define TOOLS_GN_LABEL_PTR_H_ | 6 #define TOOLS_GN_LABEL_PTR_H_ |
7 | 7 |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "tools/gn/label.h" | 10 #include "tools/gn/label.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return a.label == b.label; | 98 return a.label == b.label; |
99 } | 99 } |
100 | 100 |
101 template<typename T> inline bool operator<(const LabelPtrPair<T>& a, | 101 template<typename T> inline bool operator<(const LabelPtrPair<T>& a, |
102 const LabelPtrPair<T>& b) { | 102 const LabelPtrPair<T>& b) { |
103 return a.label < b.label; | 103 return a.label < b.label; |
104 } | 104 } |
105 | 105 |
106 namespace BASE_HASH_NAMESPACE { | 106 namespace BASE_HASH_NAMESPACE { |
107 | 107 |
108 #if defined(COMPILER_GCC) | |
109 template<typename T> struct hash< LabelPtrPair<T> > { | 108 template<typename T> struct hash< LabelPtrPair<T> > { |
110 std::size_t operator()(const LabelPtrPair<T>& v) const { | 109 std::size_t operator()(const LabelPtrPair<T>& v) const { |
111 BASE_HASH_NAMESPACE::hash<Label> h; | 110 BASE_HASH_NAMESPACE::hash<Label> h; |
112 return h(v.label); | 111 return h(v.label); |
113 } | 112 } |
114 }; | 113 }; |
115 #elif defined(COMPILER_MSVC) | |
116 template<typename T> | |
117 inline size_t hash_value(const LabelPtrPair<T>& v) { | |
118 return BASE_HASH_NAMESPACE::hash_value(v.label); | |
119 } | |
120 #endif // COMPILER... | |
121 | 114 |
122 } // namespace BASE_HASH_NAMESPACE | 115 } // namespace BASE_HASH_NAMESPACE |
123 | 116 |
124 #endif // TOOLS_GN_LABEL_PTR_H_ | 117 #endif // TOOLS_GN_LABEL_PTR_H_ |
OLD | NEW |