Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / tools / gn / label_ptr.h
index f2519d3..771b14b 100644 (file)
@@ -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_