aboutsummaryrefslogtreecommitdiff
path: root/libbutl/win32-utility.ixx
blob: 403d9863471c84dc12c0dd9abd02dae7a3bf2bb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 ();
    }
  }
}