mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
Improve assignment operators for IntrusivePtr
Fixes Coverity finding 1367523 (Missing move assignment operator).
This commit is contained in:
parent
9fbbcaad8f
commit
2f19c89189
1 changed files with 18 additions and 1 deletions
|
@ -137,12 +137,29 @@ public:
|
||||||
return std::exchange(ptr_, nullptr);
|
return std::exchange(ptr_, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr& operator=(IntrusivePtr other) noexcept
|
IntrusivePtr& operator=(const IntrusivePtr& other) noexcept
|
||||||
|
{
|
||||||
|
IntrusivePtr tmp{other};
|
||||||
|
swap(tmp);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntrusivePtr& operator=(IntrusivePtr&& other) noexcept
|
||||||
{
|
{
|
||||||
swap(other);
|
swap(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntrusivePtr& operator=(std::nullptr_t) noexcept
|
||||||
|
{
|
||||||
|
if ( ptr_ )
|
||||||
|
{
|
||||||
|
Unref(ptr_);
|
||||||
|
ptr_ = nullptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
pointer get() const noexcept
|
pointer get() const noexcept
|
||||||
{
|
{
|
||||||
return ptr_;
|
return ptr_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue