Chromium Code Reviews| Index: base/scoped_nsobject.h |
| diff --git a/base/scoped_nsobject.h b/base/scoped_nsobject.h |
| index e673a60d5c3e1781fa830ffdfb22b3e25bca2ed8..1b40ade3e07a0c3c597047423b473b3b69db0841 100644 |
| --- a/base/scoped_nsobject.h |
| +++ b/base/scoped_nsobject.h |
| @@ -49,13 +49,8 @@ class scoped_nsobject { |
| object_ = object; |
| } |
| - bool operator==(NST* that) const { |
| - return object_ == that; |
| - } |
| - |
| - bool operator!=(NST* that) const { |
| - return object_ != that; |
| - } |
| + bool operator==(NST* that) const { return object_ == that; } |
| + bool operator!=(NST* that) const { return object_ != that; } |
| operator NST*() const { |
| return object_; |
| @@ -86,6 +81,23 @@ class scoped_nsobject { |
| DISALLOW_COPY_AND_ASSIGN(scoped_nsobject); |
| }; |
| +// Free functions |
| +template <class C> |
| +void swap(scoped_nsobject<C>& p1, scoped_nsobject<C>& p2) { |
|
Mark Mentovai
2010/09/21 18:40:01
What uses swap as a free guy?
|
| + p1.swap(p2); |
| +} |
| + |
| +template <class C> |
| +bool operator==(C* p1, const scoped_nsobject<C>& p2) { |
| + return p1 == p2.get(); |
| +} |
| + |
| +template <class C> |
| +bool operator!=(C* p1, const scoped_nsobject<C>& p2) { |
| + return p1 != p2.get(); |
| +} |
| + |
| + |
| // Specialization to make scoped_nsobject<id> work. |
| template<> |
| class scoped_nsobject<id> { |
| @@ -110,13 +122,8 @@ class scoped_nsobject<id> { |
| object_ = object; |
| } |
| - bool operator==(id that) const { |
| - return object_ == that; |
| - } |
| - |
| - bool operator!=(id that) const { |
| - return object_ != that; |
| - } |
| + bool operator==(id that) const { return object_ == that; } |
| + bool operator!=(id that) const { return object_ != that; } |
| operator id() const { |
| return object_; |