From 5ed69edb7e942d0d6bfedddc86ebe901e1d06b97 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 25 Feb 2020 20:54:58 +0100 Subject: [PATCH] IntrusivePtr: overload std::swap() --- src/IntrusivePtr.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/IntrusivePtr.h b/src/IntrusivePtr.h index 35a3195546..1b75bc2751 100644 --- a/src/IntrusivePtr.h +++ b/src/IntrusivePtr.h @@ -118,6 +118,12 @@ public: std::swap(ptr_, other.ptr_); } + friend void swap(IntrusivePtr& a, IntrusivePtr &b) noexcept + { + using std::swap; + swap(a.ptr_, b.ptr_); + } + /** * Detaches an object from the automated lifetime management and sets this * intrusive pointer to @c nullptr.