summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_retain_ptr.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/cfx_retain_ptr.h')
-rw-r--r--core/fxcrt/cfx_retain_ptr.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/fxcrt/cfx_retain_ptr.h b/core/fxcrt/cfx_retain_ptr.h
index 1b137d4974..f70faf1464 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(); }