win32/handle: add move operators

This commit is contained in:
Danny Robson 2019-03-27 19:07:51 +11:00
parent a69ec062f1
commit 5fa4704456
2 changed files with 19 additions and 9 deletions

View File

@ -17,14 +17,6 @@ handle::handle (HANDLE &&h):
{ ; }
//-----------------------------------------------------------------------------
handle::handle (handle &&rhs):
m_native (rhs.m_native)
{
rhs.m_native = nullptr;
}
//-----------------------------------------------------------------------------
handle::handle (posix::fd &&rhs):
m_native (reinterpret_cast<HANDLE> (_get_osfhandle (rhs.release ())))
@ -33,6 +25,22 @@ handle::handle (posix::fd &&rhs):
}
//-----------------------------------------------------------------------------
handle::handle (cruft::win32::handle &&rhs) noexcept
: handle ()
{
std::swap (m_native, rhs.m_native);
}
//-----------------------------------------------------------------------------
handle& handle::operator= (handle &&rhs) noexcept
{
std::swap (m_native, rhs.m_native);
return *this;
}
//-----------------------------------------------------------------------------
handle::~handle ()
{

View File

@ -17,7 +17,9 @@ namespace cruft::win32 {
handle ();
explicit handle (posix::fd&&);
explicit handle (HANDLE&&);
handle (handle&&);
handle (handle&&) noexcept;
handle& operator= (handle&&) noexcept;
handle (const handle&) = delete;
handle& operator= (handle const&) = delete;