|
Pigweed
|
#include <unique_ptr.h>
Public Types | |
| using | Base = ::pw::allocator::internal::BaseUniquePtr |
Public Member Functions | |
| constexpr | UniquePtr () |
| constexpr | UniquePtr (std::nullptr_t) |
| template<typename U > | |
| UniquePtr (UniquePtr< U > &&other) noexcept | |
| UniquePtr (const UniquePtr &)=delete | |
| UniquePtr & | operator= (const UniquePtr &)=delete |
| template<typename U > | |
| UniquePtr & | operator= (UniquePtr< U > &&other) noexcept |
| UniquePtr & | operator= (std::nullptr_t) |
| ~UniquePtr () | |
| Destructs and deallocates any currently-held value. | |
| Deallocator * | deallocator () const |
| Returns a pointer to the object that can destroy the value. | |
| T * | Release () |
| void | Reset () |
| operator bool () const =delete | |
| bool | operator== (std::nullptr_t) const |
Returns whether this UniquePtr is in an "empty" (nullptr) state. | |
| bool | operator!= (std::nullptr_t) const |
| T * | get () |
| Returns the underlying (possibly null) pointer. | |
| const T * | get () const |
| Returns the underlying (possibly null) pointer. | |
| T * | operator-> () |
| const T * | operator-> () const |
| T & | operator* () |
| const T & | operator* () const |
| UniquePtr (PrivateConstructorType, T *value, Deallocator *deallocator) | |
Friends | |
| template<typename U > | |
| class | UniquePtr |
| class | Deallocator |
| TODO(b/326509341): Remove when downstream consumers migrate. | |
Additional Inherited Members | |
Protected Types inherited from pw::allocator::internal::BaseUniquePtr | |
| using | Capability = ::pw::allocator::Capability |
Static Protected Member Functions inherited from pw::allocator::internal::BaseUniquePtr | |
| static bool | HasCapability (Deallocator *deallocator, Capability capability) |
| static void | Deallocate (Deallocator *deallocator, void *ptr) |
An RAII pointer to a value of type T stored in memory provided by a Deallocator.
This is analogous to std::unique_ptr, but includes a few differences in order to support Deallocator and encourage safe usage. Most notably, UniquePtr<T> cannot be constructed from a T*.
|
inlineconstexpr |
Creates an empty (nullptr) instance.
NOTE: Instances of this type are most commonly constructed using Deallocator::MakeUnique.
|
inlineconstexpr |
Creates an empty (nullptr) instance.
NOTE: Instances of this type are most commonly constructed using Deallocator::MakeUnique.
|
inlinenoexcept |
|
inline |
Private constructor that is public only for use with emplace and other in-place construction functions.
Constructs a UniquePtr from an already-allocated value.
NOTE: Instances of this type are most commonly constructed using Deallocator::MakeUnique.
|
explicitdelete |
operator bool is not provided in order to ensure that there is no confusion surrounding if (foo) vs. if (*foo).
nullptr checking should instead use if (foo == nullptr).
|
inline |
Returns whether this UniquePtr is not in an "empty" (nullptr) state.
|
inline |
Returns a reference to any underlying value.
The behavior of this operation is undefined if this UniquePtr is in an "empty" (nullptr) state.
|
inline |
Permits accesses to members of T via my_unique_ptr->Member.
The behavior of this operation is undefined if this UniquePtr is in an "empty" (nullptr) state.
|
inline |
|
inlinenoexcept |
Move-assigns a UniquePtr<T> from a UniquePtr<U>.
This operation destructs and deallocates any value currently stored in this.
This allows not only pure move assignment where T == U, but also converting assignment where T is a base class of U, like UniquePtr<Base> base = deallocator.MakeUnique<Child>();.
|
inline |
Releases a value from the UniquePtr without destructing or deallocating it.
After this call, the object will have an "empty" (nullptr) value.
|
inline |
Destructs and deallocates any currently-held value.
After this function returns, this UniquePtr will be in an "empty" (nullptr) state until a new value is assigned.