#include <unique_ptr.h>
Public Types | |
using | pointer = typename Base::element_type * |
using | element_type = typename Base::element_type |
Public Member Functions | |
constexpr | UniquePtr () noexcept |
constexpr | UniquePtr (std::nullptr_t) noexcept |
template<typename U > | |
UniquePtr (UniquePtr< U > &&other) noexcept | |
~UniquePtr () | |
Frees any currently-held value. | |
template<typename U > | |
UniquePtr & | operator= (UniquePtr< U > &&other) noexcept |
UniquePtr & | operator= (std::nullptr_t) noexcept |
size_t | size () const |
Deallocator * | deallocator () const |
Returns a pointer to the object that can destroy the value. | |
element_type * | Release () noexcept |
void | Reset () noexcept |
void | Swap (UniquePtr &other) |
Swaps the managed pointer and deallocator of this and another object. | |
template<typename U > | |
UniquePtr< T > & | operator= (UniquePtr< U > &&other) noexcept |
Friends | |
class | Deallocator |
TODO(b/326509341): Remove when downstream consumers migrate. | |
A std::unique_ptr<T>
-like type that integrates with pw::Deallocator
.
This is a RAII smart pointer that deallocates any memory it points to when it goes out of scope.
Its most notable difference from std::unique_ptr<T>
is that it cannot be constructed from a T*
. Use Allocator::MakeUnique<T>(...)
instead.
T | The type being pointed to. This may be an array type, e.g. pw::UniquePtr<T[]> . |
TODO(b/399441816): This class should be marked final, but at least one downstream has extended it. Resolve and mark final.
|
inlineconstexprnoexcept |
Creates an empty (nullptr
) instance.
NOTE: Instances of this type are most commonly constructed using Allocator::MakeUnique
.
|
inlineconstexprnoexcept |
Creates an empty (nullptr
) instance.
NOTE: Instances of this type are most commonly constructed using Allocator::MakeUnique
.
|
inlinenoexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Releases a value from the UniquePtr
without destructing or deallocating it.
After this call, the object will have an "empty" (nullptr
) value.
|
noexcept |
Destroys 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.
|
inline |
Returns the number of elements allocated.
This will fail to compile if it is called on a non-array type UniquePtr.