win32/file: add move operators

This commit is contained in:
Danny Robson 2019-03-27 19:08:42 +11:00
parent 5fa4704456
commit 332d28614b
2 changed files with 15 additions and 0 deletions

View File

@ -15,6 +15,12 @@ using cruft::win32::file;
///////////////////////////////////////////////////////////////////////////////
file::file ()
: m_handle (INVALID_HANDLE_VALUE)
{ ; }
//-----------------------------------------------------------------------------
file::file (std::filesystem::path const &src, DWORD access, DWORD share, DWORD create, DWORD flags)
: m_handle (
error::try_call (
@ -43,6 +49,14 @@ file::file (handle &&src) noexcept
{ ; }
//-----------------------------------------------------------------------------
file& file::operator= (file &&rhs) noexcept
{
std::swap (m_handle, rhs.m_handle);
return *this;
}
//-----------------------------------------------------------------------------
file::file (posix::fd &&src)
: file (handle (std::move (src)))

View File

@ -18,6 +18,7 @@
namespace cruft::win32 {
class file {
public:
explicit file ();
file (std::filesystem::path const &, DWORD access, DWORD share, DWORD create, DWORD flags);
explicit file (handle&&) noexcept;
explicit file (posix::fd&&);