Selaa lähdekoodia

Move-Assignment operator updated to R8 specification (fixes #126).

main
offa 6 vuotta sitten
vanhempi
commit
f64754c57d
2 muutettua tiedostoa jossa 18 lisäystä ja 8 poistoa
  1. +10
    -0
      include/detail/wrapper.h
  2. +8
    -8
      include/unique_resource.h

+ 10
- 0
include/detail/wrapper.h Näytä tiedosto

@@ -48,6 +48,11 @@ namespace sr::detail
return m_value;
}

void reset(Wrapper<T>&& other) noexcept
{
m_value = std::move(other.m_value);
}

void reset(T&& newValue) noexcept(std::is_nothrow_assignable_v<T, decltype(std::move_if_noexcept(newValue))>)
{
m_value = std::forward<T>(newValue);
@@ -99,6 +104,11 @@ namespace sr::detail
return m_value.get();
}

void reset(Wrapper<T>&& other) noexcept
{
m_value = std::move(other.m_value);
}

void reset(T& newValue) noexcept
{
m_value = std::ref(newValue);

+ 8
- 8
include/unique_resource.h Näytä tiedosto

@@ -165,26 +165,26 @@ namespace sr
{
if constexpr( std::is_nothrow_move_assignable_v<DD> == true )
{
m_resource.reset(std::forward<RR>(other.m_resource.get()));
m_deleter.reset(std::forward<DD>(other.m_deleter.get()));
m_resource.reset(std::move(other.m_resource));
m_deleter.reset(std::move(other.m_deleter));
}
else
{
m_deleter.reset(other.m_deleter.get());
m_resource.reset(std::forward<RR>(other.m_resource.get()));
m_deleter.reset(other.m_deleter);
m_resource.reset(std::move(other.m_resource));
}
}
else
{
if constexpr( std::is_nothrow_move_assignable_v<DD> == true )
{
m_resource.reset(other.m_resource.get());
m_deleter.reset(std::forward<DD>(other.m_deleter.get()));
m_resource.reset(other.m_resource);
m_deleter.reset(std::move(other.m_deleter));
}
else
{
m_resource.reset(other.m_resource.get());
m_deleter.reset(other.m_deleter.get());
m_resource.reset(other.m_resource);
m_deleter.reset(other.m_deleter);
}
}


Loading…
Peruuta
Tallenna