diff --git a/include/boost/coroutine2/detail/pull_coroutine.hpp b/include/boost/coroutine2/detail/pull_coroutine.hpp index 32cd68e..928a477 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.hpp +++ b/include/boost/coroutine2/detail/pull_coroutine.hpp @@ -56,8 +56,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap( cb_, other.cb_); return * this; } @@ -168,8 +167,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap( cb_, other.cb_); return * this; } @@ -278,8 +276,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap( cb_, other.cb_); return * this; } diff --git a/include/boost/coroutine2/detail/push_coroutine.hpp b/include/boost/coroutine2/detail/push_coroutine.hpp index d152be2..e68c880 100644 --- a/include/boost/coroutine2/detail/push_coroutine.hpp +++ b/include/boost/coroutine2/detail/push_coroutine.hpp @@ -54,8 +54,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap( cb_, other.cb_); return * this; } @@ -134,8 +133,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap( cb_, other.cb_); return * this; } @@ -212,8 +210,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap( cb_, other.cb_); return * this; }