PStack
2.0
Stack trace printer for MSVC and GCC binaries
|
Uniquely manage a single "handle" with (optimized for the default "deleter"). More...
#include <unique_handle.hpp>
Type Declarations | |
using | base = unique_handle_impl< T, default_close_handle< T >, kInvalidHandle > |
A convenient name for the base-class type. | |
using | safe_address_container = psystem::internal::managed_handle_proxy< handle_type, unique_handle< handle_type, deleter_type, kInvalidHandle > > |
A safe container for altering the handle by the address-of operator. | |
using | deleter_type = D |
The data-type of the clean-up facility. | |
using | handle_type = T |
The data-type of the handle being managed. | |
Construction / Destruction | |
unique_handle (handle_type hndl=kInvalidHandle) noexcept | |
Construct an instance to manage a handle. More... | |
unique_handle (unique_handle &&other) noexcept | |
Transfer ownership of a handle from another unique_handle. More... | |
~unique_handle () noexcept | |
Destroy this container, freeing the handle managed within. More... | |
Operator Overloads | |
unique_handle & | operator= (unique_handle &&o) noexcept |
Transfer ownership of a handle into this instance. More... | |
safe_address_container | operator& () noexcept |
Allow safe alteration of the handle by routines that return data by C-style output parameters. More... | |
Public Interface | |
void | reset (handle_type hndl=kInvalidHandle) noexcept |
Assign a new handle to be managed by this instance. More... | |
void | swap (unique_handle &o) noexcept |
Swap ownership of two unique_handle instances. More... | |
Additional Inherited Members | |
Public Types inherited from psystem::unique_handle_impl< T, default_close_handle< T >, kInvalidHandle > | |
using | deleter_type = default_close_handle< T > |
The data-type of the clean-up facility. | |
using | handle_type = T |
The data-type of the handle being managed. | |
Public Member Functions inherited from psystem::unique_handle_impl< T, default_close_handle< T >, kInvalidHandle > | |
unique_handle_impl (unique_handle_impl const &)=delete | |
Disable copying because it will likely be deleted twice. | |
unique_handle_impl & | operator= (unique_handle_impl &)=delete |
Disable copy-assignment to prevent double-frees. | |
handle_type | get () const noexcept |
Access the handle contained in this object. More... | |
handle_type | release () noexcept |
Release the handle from being managed by this class. More... | |
operator bool () const noexcept | |
Determines the validity of this instance. More... | |
Static Public Member Functions inherited from psystem::stack_allocated | |
static void | operator delete (void *)=delete |
Individual object deletion. | |
static void | operator delete[] (void *)=delete |
Array of type object deletion. | |
static void * | operator new (size_t)=delete |
Individual object allocation. | |
static void * | operator new[] (size_t)=delete |
Array of type allocation. | |
Uniquely manage a single "handle" with (optimized for the default "deleter").
See the discussion in the unspecialized psystem::unique_handle for the full rationale behind this class template. Essentially, this class exists to optimize away the runtime storage for a deleter that we know how to use. Naturally, this causes the API to remove deleter-specific items like unique_handle::get_deleter().
|
inlineexplicitnoexcept |
Construct an instance to manage a handle.
Construction always succeeds, as exceptions are not allowed. If no parameter is specified, this constructs an instance that does not (initially) own an handle.
[in] | hndl | The handle (or invalid handle value) that this instance will manage. |
|
inlinenoexcept |
Transfer ownership of a handle from another unique_handle.
std::unique_ptr
in that it does not allow the transfer of related handle types. Often, handles are convertable types (void*
to void*
or long
to long
) that are merely obscured via a typedef. Transferring ownership of different handle types would also require changing the type of the deleter_type
and the value of invalid_handle_value
.[in,out] | other | The unique_handle from which we're moving data. |
|
inlinenoexcept |
Destroy this container, freeing the handle managed within.
If the handle is invalid_handle_value
, this method does not call the deleter. The deleter contained within this instance will also be destroyed.
|
inlinenoexcept |
Allow safe alteration of the handle by routines that return data by C-style output parameters.
|
inlinenoexcept |
Transfer ownership of a handle into this instance.
std::unique_ptr
in that it does not allow the transfer of related handle types. Often, handles are convertable types (void*
to void*
or long
to long
) that are merely obscured via a typedef. Transferring ownership of different handle types would also require changing the type of the deleter_type
and the value of invalid_handle_value
.[in,out] | o | The unique_handle from which we're moving data. |
this
, after the assignment.
|
inlinenoexcept |
Assign a new handle to be managed by this instance.
If there was a valid handle managed previously by this unique_handle instance, its resources will be cleaned up prior to assigning the new handle. If the new handle equals (==
) the old handle, this method does nothing.
If no parameters are specified, this resets the unique_handle to the "invalid" state.
[in] | hndl | The new handle to manage. It need not be "valid." |
|
inlinenoexcept |
Swap ownership of two unique_handle instances.
[in,out] | o | The unique_handle instance that will swap handle data with this instance. |