Browse Source

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

main
offa 6 years ago
parent
commit
f64754c57d
2 changed files with 18 additions and 8 deletions
  1. +10
    -0
      include/detail/wrapper.h
  2. +8
    -8
      include/unique_resource.h

+ 10
- 0
include/detail/wrapper.h View File

return m_value; 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))>) void reset(T&& newValue) noexcept(std::is_nothrow_assignable_v<T, decltype(std::move_if_noexcept(newValue))>)
{ {
m_value = std::forward<T>(newValue); m_value = std::forward<T>(newValue);
return m_value.get(); return m_value.get();
} }


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

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

+ 8
- 8
include/unique_resource.h View File

{ {
if constexpr( std::is_nothrow_move_assignable_v<DD> == true ) 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 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 else
{ {
if constexpr( std::is_nothrow_move_assignable_v<DD> == true ) 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 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…
Cancel
Save