An RAII handle type which owns an opaque resource of a specified type, and calls a designated function to close the resource upon destruction.
More...
|
| | handle () noexcept |
| | Constructs a handle which does not own a resource. More...
|
| |
| | handle (Resource resource) noexcept |
| | Constructs a handle which owns the specified resource. More...
|
| |
| | handle (const handle &)=delete |
| |
| handle & | operator= (const handle &)=delete |
| |
| | handle (handle &&other) noexcept |
| | Constructs a handle which takes ownership of a resource (if any) from another handle. More...
|
| |
| handle & | operator= (handle &&other) noexcept |
| | Releases the resource (if any) owned by this handle and takes ownership of a resource (if any) from another handle. More...
|
| |
| | ~handle () noexcept |
| | Closes the resource (if any) owned by this handle. More...
|
| |
| Resource | get () noexcept |
| | Returns the resource (if any) owned by this handle. More...
|
| |
| const Resource | get () const noexcept |
| | Returns the resource (if any) owned by this handle. More...
|
| |
| | operator Resource () noexcept |
| | Returns the resource (if any) owned by this handle. More...
|
| |
| | operator const Resource () const noexcept |
| | Returns the resource (if any) owned by this handle. More...
|
| |
| | operator bool () const noexcept |
| | Tests whether this handle owns a resource. More...
|
| |
| void | close () noexcept |
| | Closes the resource (if any) owned by this handle by calling CloseFunc. More...
|
| |
| Resource | release () noexcept |
| | Releases (without closing) and returns the underlying resource. More...
|
| |
An RAII handle type which owns an opaque resource of a specified type, and calls a designated function to close the resource upon destruction.
The type is moveable but not copyable, and provides semantics similar to std::unique_ptr. Most members are noexcept for underlying resource types which are nothrow-swappable and nothrow-copy-constructible.
- Template Parameters
-
| Resource | The type of the resource to own. This type must be nothrow-comparable, nothrow-copy-constructible and nothrow-swappable. |
| Closed | A special value which indicates a closed resource. |
| CloseFunc | A function which closes a resource. The function must not throw exceptions, and preferably should be marked nothrow. The function must either take no arguments or a single argument of type Resource. Any value returned by the function is ignored. |