Selaa lähdekoodia

Move-Assignment implemented as specified (#63).

main
offa 7 vuotta sitten
vanhempi
commit
71b79880e9
1 muutettua tiedostoa jossa 17 lisäystä ja 2 poistoa
  1. +17
    -2
      include/unique_resource.h

+ 17
- 2
include/unique_resource.h Näytä tiedosto

@@ -234,8 +234,23 @@ namespace sr
if( this != &other )
{
reset();
m_resource = std::move(other.m_resource);
m_deleter = std::move(other.m_deleter);

if( std::is_nothrow_move_assignable<R>::value == true )
{
m_deleter.reset(forward_if_nothrow_move_constructible(other.m_deleter.get()));
m_resource.reset(std::forward<RR>(other.m_resource.get()));
}
else if( std::is_nothrow_move_assignable<D>::value == true )
{
m_resource.reset(forward_if_nothrow_move_constructible(other.m_resource.get()));
m_deleter.reset(std::forward<DD>(other.m_deleter.get()));
}
else
{
m_resource = other.m_resource;
m_deleter = other.m_deleter;
}

m_execute_on_destruction = std::exchange(other.m_execute_on_destruction, false);
}
return *this;

Loading…
Peruuta
Tallenna