33 std::is_nothrow_copy_constructible_v<Resource> &&
34 std::is_nothrow_swappable_v<Resource> &&
53 handle(Resource resource) noexcept : _resource(resource) { }
98 Resource
get() noexcept {
return _resource; }
106 const Resource
get() const noexcept {
return _resource; }
114 operator Resource() noexcept {
return _resource; }
122 operator const Resource() const noexcept {
return _resource; }
129 operator bool() const noexcept {
return Closed != _resource; }
138 Resource resource(Closed);
140 if (Closed != resource)
156 Resource resource = Closed;
An RAII handle type which owns an opaque resource of a specified type, and calls a designated functio...
Definition: handle.hpp:40
Resource release() noexcept
Releases (without closing) and returns the underlying resource.
Definition: handle.hpp:154
handle() noexcept
Constructs a handle which does not own a resource.
Definition: handle.hpp:46
handle & operator=(const handle &)=delete
handle(const handle &)=delete
handle(handle &&other) noexcept
Constructs a handle which takes ownership of a resource (if any) from another handle.
Definition: handle.hpp:64
const Resource get() const noexcept
Returns the resource (if any) owned by this handle.
Definition: handle.hpp:106
void close() noexcept
Closes the resource (if any) owned by this handle by calling CloseFunc.
Definition: handle.hpp:136
~handle() noexcept
Closes the resource (if any) owned by this handle.
Definition: handle.hpp:90
handle(Resource resource) noexcept
Constructs a handle which owns the specified resource.
Definition: handle.hpp:53
handle & operator=(handle &&other) noexcept
Releases the resource (if any) owned by this handle and takes ownership of a resource (if any) from a...
Definition: handle.hpp:76
Resource get() noexcept
Returns the resource (if any) owned by this handle.
Definition: handle.hpp:98
Definition: assert.hpp:13