Przeglądaj źródła

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

main
offa 6 lat temu
rodzic
commit
f64754c57d
2 zmienionych plików z 18 dodań i 8 usunięć
  1. +10
    -0
      include/detail/wrapper.h
  2. +8
    -8
      include/unique_resource.h

+ 10
- 0
include/detail/wrapper.h Wyświetl plik

@@ -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 Wyświetl plik

@@ -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);
}
}


Ładowanie…
Anuluj
Zapisz