4.6.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 may still be null because a unique pointer must track its ownership status. Make sure not to access such pointers.
Public Types | |
using | element_type = Type |
using | pointer = element_type * |
using | deleter_type = Deleter |
Public Member Functions | |
unique_ptr (pointer) noexcept | |
Constructs a unique_ptr from a pointer. This pointer should not be equal to nullptr. | |
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. | |
unique_ptr (std::unique_ptr< Type > &&) noexcept | |
For implementation purposes only. | |
using fcppt::unique_ptr< Type, Deleter >::deleter_type = Deleter |
using fcppt::unique_ptr< Type, Deleter >::element_type = Type |
using fcppt::unique_ptr< Type, Deleter >::pointer = element_type * |
|
explicitnoexcept |
Constructs a unique_ptr from a pointer. This pointer should not be equal to nullptr.
|
noexcept |
fcppt::unique_ptr< Type, Deleter >::~unique_ptr | ( | ) |
|
explicitnoexcept |
For implementation purposes only.
|
nodiscardnoexcept |
|
nodiscardnoexcept |
|
nodiscardnoexcept |
|
noexcept |
|
nodiscardnoexcept |
Releases ownerhsip.
This can be used to move the pointer to another class that takes over ownership. Use this with extreme caution.