| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 { | 89 { |
| 90 other.mPointer = nullptr; | 90 other.mPointer = nullptr; |
| 91 } | 91 } |
| 92 | 92 |
| 93 ~intrusive_ptr() | 93 ~intrusive_ptr() |
| 94 { | 94 { |
| 95 if (mPointer) | 95 if (mPointer) |
| 96 mPointer->ReleaseRef(); | 96 mPointer->ReleaseRef(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 intrusive_ptr& operator=(intrusive_ptr& other) | 99 intrusive_ptr& operator=(const intrusive_ptr& other) |
|
hub
2017/09/27 17:30:03
it should be const & here.
| |
| 100 { | 100 { |
| 101 intrusive_ptr(other).swap(*this); | 101 if (this != &other) |
|
hub
2017/09/27 17:30:03
we shall insure that the self assignment is a noop
| |
| 102 intrusive_ptr(other).swap(*this); | |
| 102 return *this; | 103 return *this; |
| 103 } | 104 } |
| 104 | 105 |
| 105 intrusive_ptr& operator=(intrusive_ptr&& other) | 106 intrusive_ptr& operator=(intrusive_ptr&& other) |
| 106 { | 107 { |
| 107 intrusive_ptr(std::move(other)).swap(*this); | 108 if (this != &other) |
|
hub
2017/09/27 17:30:03
same here.
| |
| 109 intrusive_ptr(std::move(other)).swap(*this); | |
| 108 return *this; | 110 return *this; |
| 109 } | 111 } |
| 110 | 112 |
| 111 intrusive_ptr& operator=(T* other) | 113 intrusive_ptr& operator=(T* other) |
| 112 { | 114 { |
| 113 intrusive_ptr(other).swap(*this); | 115 intrusive_ptr(other).swap(*this); |
| 114 return *this; | 116 return *this; |
| 115 } | 117 } |
| 116 | 118 |
| 117 void reset() | 119 void reset() |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 inline bool operator==(const T* a, const intrusive_ptr<U>& b) | 210 inline bool operator==(const T* a, const intrusive_ptr<U>& b) |
| 209 { | 211 { |
| 210 return a == b.get(); | 212 return a == b.get(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 template<typename T, typename U> | 215 template<typename T, typename U> |
| 214 inline bool operator!=(const T* a, intrusive_ptr<U> const& b) | 216 inline bool operator!=(const T* a, intrusive_ptr<U> const& b) |
| 215 { | 217 { |
| 216 return a != b.get(); | 218 return a != b.get(); |
| 217 } | 219 } |
| OLD | NEW |