3.0.0
|
|
Freundlich's C++ toolkit |
A simpler unique_ptr that shouldn't be used as a null pointer.
std::unique_ptr
can easily be used as a null pointer because it has a default constructor and also a reset function. Null pointers should always be handled by optional references instead (see fcppt.optional). While it is not possible to completely forbid unique pointers that are null, this class makes it harder to do so. Unique pointers that have been moved from are still null because a unique pointer must track its ownership status. Make sure not to access such pointers.
Public Types | |
typedef Type | element_type |
typedef element_type * | pointer |
typedef Deleter | deleter_type |
Public Member Functions | |
unique_ptr (pointer) noexcept | |
unique_ptr (unique_ptr &&) noexcept | |
unique_ptr & | operator= (unique_ptr &&) noexcept |
~unique_ptr () | |
std::add_lvalue_reference_t< Type > | operator* () const noexcept |
pointer | operator-> () const noexcept |
pointer | get_pointer () const noexcept |
pointer | release_ownership () noexcept |
Releases ownerhsip. More... | |
typedef Deleter fcppt::unique_ptr< Type, Deleter >::deleter_type |
typedef Type fcppt::unique_ptr< Type, Deleter >::element_type |
typedef element_type* fcppt::unique_ptr< Type, Deleter >::pointer |
|
explicitnoexcept |
|
noexcept |
fcppt::unique_ptr< Type, Deleter >::~unique_ptr | ( | ) |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Releases ownerhsip.
This can be used to move the pointer to another class that takes over ownership. Use this with extreme caution.