Simple-Utility v2.3.1
|
This type models some kind of std::optional
behaviour but resets itself on move operations.
More...
#include <unique_handle.hpp>
Public Types | |
using | value_type = T |
Type of the stored value. | |
using | delete_action_type = TDeleteAction |
Type of the used delete action. | |
Public Member Functions | |
constexpr | unique_handle () noexcept=default |
Default constructor. The value will be in an uninitialized stated and the delete action gets default constructed. | |
constexpr | ~unique_handle () noexcept |
Destruct. Does invoke the delete action if the value is in an initialized state. | |
SL_UNIQUE_HANDLE_FULL_CONSTEXPR | unique_handle (unique_handle &&other) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_copy_constructible_v< TDeleteAction >) |
Move constructor, which relocates the ownership of the value to the target and resets the source. Delete actions will be copied. | |
SL_UNIQUE_HANDLE_FULL_CONSTEXPR unique_handle & | operator= (unique_handle &&other) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_move_assignable_v< T > &&std::is_nothrow_copy_constructible_v< TDeleteAction > &&std::is_nothrow_copy_assignable_v< TDeleteAction >) |
Move assignment, which relocates the ownership of the value to the target and resets the source. Delete actions will be copied. | |
constexpr void | swap (unique_handle &other) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_swappable_v< T > &&std::is_nothrow_move_constructible_v< TDeleteAction > &&std::is_nothrow_swappable_v< TDeleteAction >) |
Swaps the target and the source in a more efficient way. | |
unique_handle (const unique_handle &)=delete | |
Explicitly deleted copy constructor. | |
unique_handle & | operator= (const unique_handle &)=delete |
Explicitly deleted copy assignment. | |
constexpr | unique_handle (nullhandle_t, const delete_action_type &deleteAction=delete_action_type()) noexcept |
Explicitly does not initialize the value. This overload is mainly used for convenience when returning a nullhandle. | |
SL_UNIQUE_HANDLE_FULL_CONSTEXPR unique_handle & | operator= (nullhandle_t) noexcept |
Explicitly resets the value and invokes the delete action if value was initialized. | |
constexpr | unique_handle (const delete_action_type &deleteAction) noexcept |
Constructor overload for explicitly providing a delete action. | |
template<concepts::initializes< T > T2> requires concepts::not_same_as<std::remove_cvref_t<T2>, unique_handle> && concepts::not_same_as<std::remove_cvref_t<T2>, nullhandle_t> | |
!std ::convertible_to< T2 &&, T > constexpr | unique_handle (T2 &&value, const delete_action_type &deleteAction=delete_action_type{}) |
Constructor overload for initializing the value. | |
template<concepts::assignable_to< T & > T2> requires concepts::not_same_as<std::remove_cvref_t<T2>, unique_handle> && concepts::not_same_as<std::remove_cvref_t<T2>, nullhandle_t> && concepts::initializes<std::remove_cvref_t<T2>, T> | |
constexpr unique_handle & | operator= (T2 &&value) |
Assignment operator overload for assigning the value. | |
template<class... TArgs> requires std::constructible_from<T, TArgs...> | |
constexpr | unique_handle (std::in_place_t, TArgs &&... args) |
Constructor overload for directly initializing the value with a set of arguments. | |
template<class... TArgs> requires std::constructible_from<T, TArgs...> | |
constexpr | unique_handle (std::in_place_t, const delete_action_type &deleteAction, TArgs &&... args) |
Constructor overload for directly initializing the value with a set of arguments and also initializing the delete action. | |
template<class... TArgs> requires std::constructible_from<T, TArgs...> | |
SL_UNIQUE_HANDLE_FULL_CONSTEXPR void | emplace (TArgs &&... args) |
Constructor overload for directly initializing the value with a set of arguments. | |
SL_UNIQUE_HANDLE_FULL_CONSTEXPR void | reset () noexcept |
Resets the value and invokes the delete action if value was initialized. | |
constexpr const T & | raw () const |
Immutable access to the value. No checks will be performed. | |
constexpr const T & | operator* () const noexcept |
Immutable access to the value. No checks will be performed. | |
constexpr const T * | operator-> () const noexcept |
Immutable access to the value. No checks will be performed. | |
constexpr | operator bool () const noexcept |
Checks whether the value is initialized. | |
constexpr bool | is_valid () const noexcept |
Checks whether the value is initialized. | |
constexpr const delete_action_type & | delete_action () const noexcept |
Immutable access to the delete action. | |
template<std::equality_comparable_with< T > T2, class TOtherDeleteAction > | |
constexpr bool | operator== (const unique_handle< T2, TOtherDeleteAction > &other) const |
Equality-comparison operator overload between two unique_handles. operator != is implicitly defined. | |
template<std::three_way_comparable_with< T > T2, class TOtherDeleteAction > | |
constexpr std::compare_three_way_result_t< T, T2 > | operator<=> (const unique_handle< T2, TOtherDeleteAction > &other) const |
Three-way-comparison operator overload between two unique_handles. | |
template<class T2 > requires concepts::not_same_as<std::remove_cvref_t<T2>, unique_handle> && std::three_way_comparable_with<T, T2> | |
constexpr std::compare_three_way_result_t< T, T2 > | operator<=> (const T2 &other) const |
Three-way-comparison operator overload for comparison between a unique_handle and a value. | |
template<class T2 > requires concepts::not_same_as<std::remove_cvref_t<T2>, unique_handle> && std::equality_comparable_with<T, T2> | |
constexpr bool | operator== (const T2 &other) const |
Equality-comparison operator overload for comparison between a unique_handle and a value. operator != is implicitly defined. | |
constexpr bool | operator== (nullhandle_t) const noexcept |
Equality-comparison operator overload for comparison of unique_handle and nullhandle_t. | |
constexpr std::strong_ordering | operator<=> (nullhandle_t) const noexcept |
Three-way-comparison operator overload for comparison of unique_handle and nullhandle_t. | |
Friends | |
template<value T2, delete_action_for< T2 > TOtherDeleteAction> | |
class | unique_handle |
Related Functions | |
(Note that these are not member functions.) | |
template<class T , class TDeleteAction > | |
unique_handle (T, TDeleteAction) -> unique_handle< detail::type_t< detail::value_validator< T > >, detail::type_t< detail::delete_action_validator< T, TDeleteAction > > > | |
Deduction guide for unique_handle class. | |
template<class T > | |
unique_handle (T) -> unique_handle< T > | |
Deduction guide for unique_handle class. | |
This type models some kind of std::optional
behaviour but resets itself on move operations.
For more details and information about related components go to unique_handle group page.
T | The type of the stored value |
TDeleteAction | Type of the used delete action |
using sl::unique_handle< T, TDeleteAction >::delete_action_type = TDeleteAction |
Type of the used delete action.
using sl::unique_handle< T, TDeleteAction >::value_type = T |
Type of the stored value.
|
constexprdefaultnoexcept |
Default constructor. The value will be in an uninitialized stated and the delete action gets default constructed.
|
inlineconstexprnoexcept |
Destruct. Does invoke the delete action if the value is in an initialized state.
|
inlinenoexcept |
Move constructor, which relocates the ownership of the value to the target and resets the source. Delete actions will be copied.
other | The source object which will lose ownership, if it has any. |
|
delete |
Explicitly deleted copy constructor.
|
inlineconstexprnoexcept |
Explicitly does not initialize the value. This overload is mainly used for convenience when returning a nullhandle.
deleteAction | The provided delete action object |
|
inlineconstexprnoexcept |
Constructor overload for explicitly providing a delete action.
deleteAction | The provided delete action object |
|
inlineexplicitconstexpr |
Constructor overload for initializing the value.
T2 | Type of the provided value. Must be convertible to T . |
value | Used object to initialize the value |
deleteAction | The provided delete action object |
|
inlineexplicitconstexpr |
Constructor overload for directly initializing the value with a set of arguments.
TArgs | Type of the provided arguments. |
args | Used arguments to initialize the value |
|
inlineexplicitconstexpr |
Constructor overload for directly initializing the value with a set of arguments and also initializing the delete action.
TArgs | Type of the provided arguments. |
deleteAction | The provided delete action object |
args | Used arguments to initialize the value |
|
inlineconstexprnoexcept |
Immutable access to the delete action.
|
inline |
Constructor overload for directly initializing the value with a set of arguments.
TArgs | Type of the provided arguments. |
args | Used arguments to initialize the value |
|
inlineconstexprnoexcept |
Checks whether the value is initialized.
|
inlineexplicitconstexprnoexcept |
Checks whether the value is initialized.
|
inlineconstexprnoexcept |
Immutable access to the value. No checks will be performed.
|
inlineconstexprnoexcept |
Immutable access to the value. No checks will be performed.
|
inlineconstexpr |
Three-way-comparison operator overload for comparison between a unique_handle and a value.
T2 | Type of right-hand-side. Must be three-way-comparable to T |
other | The object to compare with |
|
inlineconstexpr |
Three-way-comparison operator overload between two unique_handles.
T2 | Other value type. |
TOtherDeleteAction | Other delete action type. |
other | The object to compare with |
is_valid()
.
|
inlineconstexprnoexcept |
Three-way-comparison operator overload for comparison of unique_handle and nullhandle_t.
std::strong_ordering::equal
if handle's value is uninitialized, otherwise std::strong_ordering::greater
.
|
delete |
Explicitly deleted copy assignment.
|
inlinenoexcept |
Explicitly resets the value and invokes the delete action if value was initialized.
|
inlineconstexpr |
Assignment operator overload for assigning the value.
T2 | Type of the provided value. Must be convertible to T . |
value | Used object to assign the value |
|
inlinenoexcept |
Move assignment, which relocates the ownership of the value to the target and resets the source. Delete actions will be copied.
other | The source object which will lose ownership, if it has any. |
|
inlineconstexpr |
Equality-comparison operator overload for comparison between a unique_handle and a value. operator != is implicitly defined.
T2 | Type of right-hand-side. Must be equality-comparable to T |
other | The object to compare with |
true
if handle is valid and value compares equal equal to rhs. Otherwise false
.
|
inlineconstexpr |
Equality-comparison operator overload between two unique_handles. operator != is implicitly defined.
T2 | Other value type. |
TOtherDeleteAction | Other delete action type. |
other | The unique_handle to compare with |
false
is returned.
|
inlineconstexprnoexcept |
Equality-comparison operator overload for comparison of unique_handle and nullhandle_t.
|
inlineconstexpr |
Immutable access to the value. No checks will be performed.
Throws | bad_handle_access if value is uninitialized. |
|
inlinenoexcept |
Resets the value and invokes the delete action if value was initialized.
|
inlineconstexprnoexcept |
Swaps the target and the source in a more efficient way.
other | The source object |
|
friend |