PStack  2.0
Stack trace printer for MSVC and GCC binaries
unique_handle.hpp File Reference

Declare an RAII container for system API handles (psystem::unique_handle). More...

Include dependency graph for unique_handle.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  psystem::unique_handle_impl< T, D, kInvalidHandle >
 Base unique_handle functionality common to all template specializations. More...
 
class  psystem::unique_handle< T, D, kInvalidHandle >
 Uniquely manage a single "handle". More...
 
class  psystem::unique_handle< T, default_close_handle< T >, kInvalidHandle >
 Uniquely manage a single "handle" with (optimized for the default "deleter"). More...
 
struct  std::hash< psystem::unique_handle< T, D, kInvalidHandle > >
 Forward the hash functor along to the underlying handle type for psystem::unique_handle. More...
 

Namespaces

 psystem
 Contains the process examination "system" and basic frameworks.
 

Functions

template<typename T , typename D , T kInvalidHandle>
void std::swap (psystem::unique_handle< T, D, kInvalidHandle > &o1, psystem::unique_handle< T, D, kInvalidHandle > &o2) noexcept
 Delegate std::swap calls for unique_handle to the member function. More...
 
template<typename T , typename D , T kInvalidHandle>
bool operator== (psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
 Test for equality of two handles. More...
 
template<typename T , typename D , T kInvalidHandle>
bool operator!= (psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
 Test for inequality of two handles. More...
 
template<typename T , typename D , T kInvalidHandle>
bool operator< (psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
 Test if the first handle is less than the second. More...
 
template<typename T , typename D , T kInvalidHandle>
bool operator<= (psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
 Test if the first handle is less than or equal to the second. More...
 
template<typename T , typename D , T kInvalidHandle>
bool operator> (psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
 Test if the first handle is greater than the second. More...
 
template<typename T , typename D , T kInvalidHandle>
bool operator>= (psystem::unique_handle< T, D, kInvalidHandle > const &h1, psystem::unique_handle< T, D, kInvalidHandle > const &h2) noexcept
 Test if the first handle is greater than or equal to the second. More...
 

Detailed Description

Declare an RAII container for system API handles (psystem::unique_handle).

Note
There are no comparison operators for unique_handle to simple handle types for a few reasons. First, it is difficult challenging (not impossible) to decide on a type for the unmanaged handle because handles are generally pointers or even integers that have been given another name via typedef. They may also be forward declarations of a type as well. The second reason is that many handle types will conflict with the bool operator—the expression "unique_handle(hndl) == hndl" may first convert the unique_handle to a bool, then use a simple equality operator that compares POD integers, or it call the operator== that takes unique_handle and the handle type. There is ambiguity. We will therefore not defined these operators, and only compare unique_handle to unique_handle.
Author
Matt Bisson
Date
5 August, 2014
Since
PSystem 2.0
Version
PSystem 2.0

Function Documentation

template<typename T , typename D , T kInvalidHandle>
bool operator!= ( psystem::unique_handle< T, D, kInvalidHandle > const &  h1,
psystem::unique_handle< T, D, kInvalidHandle > const &  h2 
)
inlinenoexcept

Test for inequality of two handles.

This ignores any deleter instance in the unique_handle.

Inequality is defined in terms of operator=().

Template Parameters
TThe handle type.
DThe deleter type.
kInvalidHandleThe value of an "invalid" handle.
Parameters
[in]h1The first unique_handle to compare.
[in]h2The second unique_handle to compare.
Returns
The value of the comparison.
template<typename T , typename D , T kInvalidHandle>
bool operator< ( psystem::unique_handle< T, D, kInvalidHandle > const &  h1,
psystem::unique_handle< T, D, kInvalidHandle > const &  h2 
)
inlinenoexcept

Test if the first handle is less than the second.

This ignores any deleter instance in the unique_handle.

This comparison is defined in terms of std::less.

Template Parameters
TThe handle type.
DThe deleter type.
kInvalidHandleThe value of an "invalid" handle.
Parameters
[in]h1The first unique_handle to compare.
[in]h2The second unique_handle to compare.
Returns
The value of the comparison.
template<typename T , typename D , T kInvalidHandle>
bool operator<= ( psystem::unique_handle< T, D, kInvalidHandle > const &  h1,
psystem::unique_handle< T, D, kInvalidHandle > const &  h2 
)
inlinenoexcept

Test if the first handle is less than or equal to the second.

This ignores any deleter instance in the unique_handle.

This comparison is defined in terms of operator<()

Template Parameters
TThe handle type.
DThe deleter type.
kInvalidHandleThe value of an "invalid" handle.
Parameters
[in]h1The first unique_handle to compare.
[in]h2The second unique_handle to compare.
Returns
The value of the comparison.
template<typename T , typename D , T kInvalidHandle>
bool operator== ( psystem::unique_handle< T, D, kInvalidHandle > const &  h1,
psystem::unique_handle< T, D, kInvalidHandle > const &  h2 
)
inlinenoexcept

Test for equality of two handles.

This ignores any deleter instance in the unique_handle.

Template Parameters
TThe handle type.
DThe deleter type.
kInvalidHandleThe value of an "invalid" handle.
Parameters
[in]h1The first unique_handle to compare.
[in]h2The second unique_handle to compare.
Returns
The value of the comparison.
template<typename T , typename D , T kInvalidHandle>
bool operator> ( psystem::unique_handle< T, D, kInvalidHandle > const &  h1,
psystem::unique_handle< T, D, kInvalidHandle > const &  h2 
)
inlinenoexcept

Test if the first handle is greater than the second.

This ignores any deleter instance in the unique_handle.

This comparison is defined in terms of operator<()

Template Parameters
TThe handle type.
DThe deleter type.
kInvalidHandleThe value of an "invalid" handle.
Parameters
[in]h1The first unique_handle to compare.
[in]h2The second unique_handle to compare.
Returns
The value of the comparison.
template<typename T , typename D , T kInvalidHandle>
bool operator>= ( psystem::unique_handle< T, D, kInvalidHandle > const &  h1,
psystem::unique_handle< T, D, kInvalidHandle > const &  h2 
)
inlinenoexcept

Test if the first handle is greater than or equal to the second.

This ignores any deleter instance in the unique_handle.

This comparison is defined in terms of operator<()

Template Parameters
TThe handle type.
DThe deleter type.
kInvalidHandleThe value of an "invalid" handle.
Parameters
[in]h1The first unique_handle to compare.
[in]h2The second unique_handle to compare.
Returns
The value of the comparison.