Pigweed
C/C++ API Reference
|
Public Types | |
using | element_type = typename Base::element_type |
using | weak_type = WeakPtr< T > |
Public Member Functions | |
~SharedPtr () | |
Releases any currently-held value. | |
constexpr | SharedPtr () noexcept=default |
constexpr | SharedPtr (std::nullptr_t) noexcept |
constexpr | SharedPtr (const SharedPtr &other) noexcept |
Copy-constructs a SharedPtr<T> from a SharedPtr<T> . | |
template<typename U > | |
constexpr | SharedPtr (const SharedPtr< U > &other) noexcept |
template<typename U > | |
SharedPtr (SharedPtr< U > &&other) noexcept | |
constexpr SharedPtr & | operator= (const SharedPtr &other) noexcept |
template<typename U > | |
constexpr SharedPtr & | operator= (const SharedPtr< U > &other) noexcept |
template<typename U > | |
SharedPtr & | operator= (SharedPtr< U > &&other) noexcept |
SharedPtr & | operator= (std::nullptr_t) noexcept |
size_t | size () const |
int32_t | use_count () const |
void | reset () noexcept |
void | swap (SharedPtr &other) noexcept |
Swaps the managed pointer and deallocator of this and another object. | |
template<typename PtrType > | |
bool | owner_before (const PtrType &other) const noexcept |
template<typename... Args> | |
SharedPtr< T > | Create (Allocator *allocator, Args &&... args) |
template<typename U > | |
constexpr SharedPtr< T > & | operator= (const SharedPtr< U > &other) noexcept |
template<typename U > | |
SharedPtr< T > & | operator= (SharedPtr< U > &&other) noexcept |
Friends | |
class | Allocator |
template<typename > | |
class | WeakPtr |
template<MultiBufProperty... > | |
class | BasicMultiBuf |
A std::shared_ptr<T>
-like type that integrates with pw::Allocator
.
This is a RAII smart pointer that deallocates any memory it points to when every pointer to the same object has gone out of scope.
Notable differences from std::shared_ptr<T>
include:
T*
. Use Allocator::MakeShared<T>(...)
instead.SharedPtr
from a UniquePtr
is not supported, as the shared pointer control block must be allocated inline.T | The type being pointed to. This may be an array type, e.g. pw::SharedPtr<T[]> . |
|
constexprdefaultnoexcept |
Creates an empty (nullptr
) instance.
NOTE: Instances of this type are most commonly constructed using Allocator::MakeShared
.
|
inlineconstexprnoexcept |
Creates an empty (nullptr
) instance.
NOTE: Instances of this type are most commonly constructed using Allocator::MakeShared
.
|
inlineconstexprnoexcept |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
|
constexprnoexcept |
|
noexcept |
|
noexcept |
Sets this ManagedPtr
to null, releasing any currently-held value.
After this function returns, this ManagedPtr
will be in an "empty" (nullptr
) state until a new value is assigned.
|
inlinenoexcept |
Checks whether this
precedes other
based on an ordering of their control blocks.
|
noexcept |
Resets this object to an empty state.
If this was the last shared pointer to the associated object, it is destroyed. If this is the last shared or weak pointer associated with the control block, it is deallocated.
|
inline |
Returns the number of elements allocated.
This will fail to compile if it is called on a non-array type SharedPtr.
|
inline |
Returns the number of shared pointers to the associated object, or 0 if this object is empty.