diff options
Diffstat (limited to 'libbutl/win32-utility.ixx')
-rw-r--r-- | libbutl/win32-utility.ixx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libbutl/win32-utility.ixx b/libbutl/win32-utility.ixx new file mode 100644 index 0000000..403d986 --- /dev/null +++ b/libbutl/win32-utility.ixx @@ -0,0 +1,32 @@ +// file : libbutl/win32-utility.ixx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +namespace butl +{ + namespace win32 + { + inline void auto_handle:: + reset (HANDLE h) noexcept + { + // Don't check for an error as not much we can do here. + // + if (handle_ != INVALID_HANDLE_VALUE) + CloseHandle (handle_); + + handle_ = h; + } + + inline auto_handle& auto_handle:: + operator= (auto_handle&& h) noexcept + { + reset (h.release ()); + return *this; + } + + inline auto_handle:: + ~auto_handle () noexcept + { + reset (); + } + } +} |