Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1751)

Unified Diff: base/values.h

Issue 2771923005: Implement comparison operators for base::Value (Closed)
Patch Set: Declare Operators out of line and update tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/values.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.h
diff --git a/base/values.h b/base/values.h
index f74f543280e97b0372aa6b68e16f334796f3fbba..95d5d1c2baa280ed470f51ddcfab63af8788cc4b 100644
--- a/base/values.h
+++ b/base/values.h
@@ -161,11 +161,24 @@ class BASE_EXPORT Value {
// Preferred version of DeepCopy. TODO(estade): remove the above.
std::unique_ptr<Value> CreateDeepCopy() const;
+ // Comparison operators so that Values can easily be used with standard
+ // library algorithms and associative containers.
+ BASE_EXPORT friend bool operator==(const Value& lhs, const Value& rhs);
+ BASE_EXPORT friend bool operator!=(const Value& lhs, const Value& rhs);
+ BASE_EXPORT friend bool operator<(const Value& lhs, const Value& rhs);
+ BASE_EXPORT friend bool operator>(const Value& lhs, const Value& rhs);
+ BASE_EXPORT friend bool operator<=(const Value& lhs, const Value& rhs);
+ BASE_EXPORT friend bool operator>=(const Value& lhs, const Value& rhs);
+
// Compares if two Value objects have equal contents.
+ // DEPRECATED, use operator==(const Value& lhs, const Value& rhs) instead.
+ // TODO(crbug.com/646113): Delete this and migrate callsites.
bool Equals(const Value* other) const;
// Compares if two Value objects have equal contents. Can handle NULLs.
// NULLs are considered equal but different from Value::CreateNullValue().
+ // DEPRECATED, use operator==(const Value& lhs, const Value& rhs) instead.
+ // TODO(crbug.com/646113): Delete this and migrate callsites.
static bool Equals(const Value* a, const Value* b);
protected:
« no previous file with comments | « no previous file | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698