72 template <CAdoptTag TAdoptTag>
80 requires std::convertible_to<TT*, T*>
86 requires std::convertible_to<TT*, T*>
100 requires std::convertible_to<TT*, T*>
108 requires std::convertible_to<TT*, T*>
116 template <CAdoptTag TAdoptTag = SharedIntrusiveAdoptIncrementStrongTag>
150 operator->() const noexcept;
153 operator
bool() const noexcept;
166 [[nodiscard]]
std::
size_t
169 template <class TT, class... Args>
245 requires std::convertible_to<TT*, T*>
304 static_assert(
alignof(T) >= 2,
"Bad alignment: Combo pointer requires low bit to be zero");
312 requires std::convertible_to<TT*, T*>
318 requires std::convertible_to<TT*, T*>
326 requires std::convertible_to<TT*, T*>
331 requires std::convertible_to<TT*, T*>
349 operator bool() const noexcept;
366 [[nodiscard]]
std::
size_t
443template <
class TT,
class... Args>
452 "SharedIntrusive constructor should not throw or this can leak "
470template <
class T,
class... A>
477template <
class T,
class TT>
484template <
class T,
class TT>
A shared intrusive pointer class that supports weak pointers.
SharedIntrusive(DynamicCastTagSharedIntrusive, SharedIntrusive< TT > const &rhs)
Create a new SharedIntrusive by dynamically casting the pointer controlled by the rhs param.
SHAMapTreeNode * unsafeGetRawPtr() const
SharedIntrusive & operator=(SharedIntrusive< TT > const &rhs)
std::size_t useCount() const
SHAMapTreeNode * get() const
bool operator==(std::nullptr_t) const
SharedIntrusive(SharedIntrusive< TT > const &rhs)
SharedIntrusive(StaticCastTagSharedIntrusive, SharedIntrusive< TT > const &rhs)
Create a new SharedIntrusive by statically casting the pointer controlled by the rhs param.
void unsafeSetRawPtr(SHAMapTreeNode *p)
SharedIntrusive()=default
SharedIntrusive(DynamicCastTagSharedIntrusive, SharedIntrusive< TT > &&rhs)
Create a new SharedIntrusive by dynamically casting the pointer controlled by the rhs param.
SHAMapTreeNode * unsafeExchange(SHAMapTreeNode *p)
friend class SharedWeakUnion
SharedIntrusive(StaticCastTagSharedIntrusive, SharedIntrusive< TT > &&rhs)
Create a new SharedIntrusive by statically casting the pointer controlled by the rhs param.
void adopt(T *p)
Adopt the raw pointer.
SharedIntrusive & operator=(SharedIntrusive &&rhs)
void unsafeReleaseAndStore(SHAMapTreeNode *next)
friend class SharedIntrusive
SharedIntrusive(SharedIntrusive< TT > &&rhs)
friend class WeakIntrusive
SharedIntrusive(SharedIntrusive const &rhs)
SharedIntrusive(T *p, TAdoptTag) noexcept
friend SharedIntrusive< TT > makeSharedIntrusive(Args &&... args)
bool operator!=(std::nullptr_t) const
SharedIntrusive & operator=(SharedIntrusive< TT > &&rhs)
SharedIntrusive & operator=(SharedIntrusive const &rhs)
T & operator*() const noexcept
SharedIntrusive(SharedIntrusive &&rhs)
A combination of a strong and a weak intrusive pointer stored in the space of a single pointer.
void unsafeSetRawPtr(std::nullptr_t)
Set the raw pointer and tag bit to all zeros (strong null pointer).
SharedWeakUnion(SharedIntrusive< TT > const &rhs)
SharedWeakUnion(SharedWeakUnion const &rhs)
static constexpr std::uintptr_t kPtrMask
bool expired() const
Return true if there is a non-zero strong count.
SharedWeakUnion(SharedWeakUnion &&rhs)
SharedWeakUnion(SharedIntrusive< TT > &&rhs)
void reset()
Set the pointer to null, decrement the appropriate ref count, and run the appropriate release action.
static constexpr std::uintptr_t kTagMask
void unsafeSetRawPtr(T *p, RefStrength rs)
Set the raw pointer and tag bit directly.
T * unsafeGetRawPtr() const
Return the raw pointer held by this object.
T * get() const
If this is a strong pointer, return the raw pointer.
SharedWeakUnion & operator=(SharedIntrusive< TT > const &rhs)
bool convertToStrong()
If this is a weak pointer, attempt to convert it to a strong pointer.
SharedIntrusive< T > lock() const
If this is a strong pointer, return the strong pointer.
SharedWeakUnion & operator=(SharedIntrusive< TT > &&rhs)
SharedWeakUnion & operator=(SharedWeakUnion const &rhs)
void unsafeReleaseNoStore()
Decrement the appropriate ref count, and run the appropriate release action.
SharedWeakUnion()=default
bool convertToWeak()
If this is a strong pointer, attempt to convert it to a weak pointer.
bool isStrong() const
Return true is this represents a strong pointer.
std::size_t useCount() const
If this is a strong pointer, return the strong count.
bool isWeak() const
Return true is this represents a weak pointer.
SharedIntrusive< T > getStrong() const
Return a strong pointer if this is already a strong pointer (i.e.
A weak intrusive pointer class for the SharedIntrusive pointer class.
WeakIntrusive(SharedIntrusive< T > const &&rhs)=delete
void unsafeReleaseNoStore()
Decrement the weak count.
WeakIntrusive(WeakIntrusive const &rhs)
void adopt(T *ptr)
Adopt the raw pointer and increment the weak count.
WeakIntrusive(SharedIntrusive< T > const &rhs)
SharedIntrusive< T > lock() const
Get a strong pointer from the weak pointer, if possible.
WeakIntrusive & operator=(SharedIntrusive< TT > const &rhs)
WeakIntrusive & operator=(WeakIntrusive const &)=delete
bool expired() const
Return true if the strong count is zero.
WeakIntrusive(WeakIntrusive &&rhs)
void reset()
Set the pointer to null and decrement the weak count.
SharedWeakUnion< T > SharedWeakUnionPtr
SharedPtr< T > dynamicPointerCast(TT const &v)
SharedPtr< T > staticPointerCast(TT const &v)
SharedIntrusive< T > SharedPtr
WeakIntrusive< T > WeakPtr
SharedPtr< T > makeShared(A &&... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
SharedIntrusive< TT > makeSharedIntrusive(Args &&... args)
Create a shared intrusive pointer.
When creating or adopting a raw pointer, controls whether the strong count is incremented or not.
When creating or adopting a raw pointer, controls whether the strong count is incremented or not.