Index: tools/gn/label_ptr.h |
diff --git a/tools/gn/label_ptr.h b/tools/gn/label_ptr.h |
index f2519d30953ab4c045c05667fb3f85cbc0df0a1f..771b14ba3fce1a767a6d8405433d32afb8c7a405 100644 |
--- a/tools/gn/label_ptr.h |
+++ b/tools/gn/label_ptr.h |
@@ -7,7 +7,11 @@ |
#include <functional> |
+#include "tools/gn/label.h" |
+ |
+class Config; |
class ParseNode; |
+class Target; |
// Structure that holds a labeled "thing". This is used for various places |
// where we need to store lists of targets or configs. We sometimes populate |
@@ -80,4 +84,37 @@ struct LabelPtrLabelLess : public std::binary_function<LabelPtrPair<T>, |
} |
}; |
+// Default comparison operators ----------------------------------------------- |
+// |
+// The default hash and comparison operators operate on the label, which should |
+// always be valid, whereas the pointer is sometimes null. |
+ |
+template<typename T> inline bool operator==(const LabelPtrPair<T>& a, |
+ const LabelPtrPair<T>& b) { |
+ return a.label == b.label; |
+} |
+ |
+template<typename T> inline bool operator<(const LabelPtrPair<T>& a, |
+ const LabelPtrPair<T>& b) { |
+ return a.label < b.label; |
+} |
+ |
+namespace BASE_HASH_NAMESPACE { |
+ |
+#if defined(COMPILER_GCC) |
+template<typename T> struct hash< LabelPtrPair<T> > { |
+ std::size_t operator()(const LabelPtrPair<T>& v) const { |
+ BASE_HASH_NAMESPACE::hash<Label> h; |
+ return h(v.label); |
+ } |
+}; |
+#elif defined(COMPILER_MSVC) |
+template<typename T> |
+inline size_t hash_value(const LabelPtrPair<T>& v) { |
+ return BASE_HASH_NAMESPACE::hash_value(v.label); |
+} |
+#endif // COMPILER... |
+ |
+} // namespace BASE_HASH_NAMESPACE |
+ |
#endif // TOOLS_GN_LABEL_PTR_H_ |