File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,10 @@ class observable_unique_ptr_base {
292292 /* * \param other The other pointer to swap with
293293 */
294294 void swap (observable_unique_ptr_base& other) noexcept {
295+ if (&other == this ) {
296+ return ;
297+ }
298+
295299 using std::swap;
296300 swap (block, other.block );
297301 swap (ptr_deleter, other.ptr_deleter );
@@ -973,6 +977,10 @@ class observer_ptr {
973977 /* * \param value The existing weak pointer to copy
974978 */
975979 observer_ptr& operator =(const observer_ptr& value) noexcept {
980+ if (&value == this ) {
981+ return *this ;
982+ }
983+
976984 if (data) {
977985 pop_ref_ ();
978986 }
@@ -993,6 +1001,10 @@ class observer_ptr {
9931001 */
9941002 template <typename U, typename enable = std::enable_if_t <std::is_convertible_v<U*, T*>>>
9951003 observer_ptr& operator =(const observer_ptr<U>& value) noexcept {
1004+ if (&value == this ) {
1005+ return *this ;
1006+ }
1007+
9961008 if (data) {
9971009 pop_ref_ ();
9981010 }
@@ -1114,6 +1126,10 @@ class observer_ptr {
11141126 /* * \param other The other pointer to swap with
11151127 */
11161128 void swap (observer_ptr& other) noexcept {
1129+ if (&other == this ) {
1130+ return ;
1131+ }
1132+
11171133 using std::swap;
11181134 swap (block, other.block );
11191135 swap (data, other.data );
You can’t perform that action at this time.
0 commit comments