diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2022-03-25 16:36:46 -0700 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2022-03-25 16:36:46 -0700 |
commit | 6d0bd1a5320e3103b10e5263732566c9d63981d9 (patch) | |
tree | 3e9a90618752a9c193527cea25c3f0246827089c /common/intrusive_ptr.h | |
parent | b80dc504958e116f40ac6e8ab827be57a30aa4b0 (diff) |
Simplify some move assignments
Diffstat (limited to 'common/intrusive_ptr.h')
-rw-r--r-- | common/intrusive_ptr.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/common/intrusive_ptr.h b/common/intrusive_ptr.h index 31afa70f..9e206a6b 100644 --- a/common/intrusive_ptr.h +++ b/common/intrusive_ptr.h @@ -62,6 +62,8 @@ public: intrusive_ptr& operator=(const intrusive_ptr &rhs) noexcept { + static_assert(noexcept(std::declval<T*>()->release()), "release must be noexcept"); + if(rhs.mPtr) rhs.mPtr->add_ref(); if(mPtr) mPtr->release(); mPtr = rhs.mPtr; @@ -71,10 +73,8 @@ public: { if(likely(&rhs != this)) { - if(mPtr) - mPtr->release(); - mPtr = rhs.mPtr; - rhs.mPtr = nullptr; + if(mPtr) mPtr->release(); + mPtr = std::exchange(rhs.mPtr, nullptr); } return *this; } |