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

Unified Diff: core/fxcrt/cfx_retain_ptr.h

Issue 2616683002: Add missing operator<() to CFX_RetainPtr (Closed)
Patch Set: Created 3 years, 11 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 | core/fxcrt/cfx_retain_ptr_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcrt/cfx_retain_ptr.h
diff --git a/core/fxcrt/cfx_retain_ptr.h b/core/fxcrt/cfx_retain_ptr.h
index 1b137d4974fb71317ad05e0e750f5b11d4f53a40..f70faf14645e74fc37d7d07357c8aec67a668ed7 100644
--- a/core/fxcrt/cfx_retain_ptr.h
+++ b/core/fxcrt/cfx_retain_ptr.h
@@ -5,11 +5,13 @@
#ifndef CORE_FXCRT_CFX_RETAIN_PTR_H_
#define CORE_FXCRT_CFX_RETAIN_PTR_H_
+#include <functional>
#include <memory>
#include <utility>
#include "core/fxcrt/fx_memory.h"
+// Analogous to base's scoped_refptr.
template <class T>
class CFX_RetainPtr {
public:
@@ -50,9 +52,12 @@ class CFX_RetainPtr {
bool operator==(const CFX_RetainPtr& that) const {
return Get() == that.Get();
}
-
bool operator!=(const CFX_RetainPtr& that) const { return !(*this == that); }
+ bool operator<(const CFX_RetainPtr& that) const {
+ return std::less<T*>()(Get(), that.Get());
+ }
+
explicit operator bool() const { return !!m_pObj; }
T& operator*() const { return *m_pObj.get(); }
T* operator->() const { return m_pObj.get(); }
« no previous file with comments | « no previous file | core/fxcrt/cfx_retain_ptr_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698