Browse Source

Handling of self move assignment.

main
offa 7 years ago
parent
commit
526a869cfb
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      include/unique_resource.h

+ 7
- 4
include/unique_resource.h View File

@@ -178,10 +178,13 @@ namespace sr
>
unique_resource& operator=(unique_resource&& other)
{
reset();
m_resource = std::forward<RR>(other.m_resource);
m_deleter = std::forward<DD>(other.m_deleter);
m_execute_on_destruction = std::exchange(other.m_execute_on_destruction, false);
if( this != &other )
{
reset();
m_resource = std::forward<RR>(other.m_resource);
m_deleter = std::forward<DD>(other.m_deleter);
m_execute_on_destruction = std::exchange(other.m_execute_on_destruction, false);
}
return *this;
}


Loading…
Cancel
Save