template<class T>
using refcnt_ptr = intrusive_shared_ptr<T, typename T::refcnt_ptr_traits>;
refcnt_ptr
is a specialization of intrusive_shared_ptr
for a common case where you fully control the pointee's class and can provide traits as a nested type named refcnt_ptr_traits
.
A ref_counted
base class provides such an implementation so you can easily use ref_counted
derived classes with refcnt_ptr
.
template<class T> constexpr refcnt_ptr<T> refcnt_retain(T * ptr) noexcept
. Createsrefcnt_ptr
from a raw pointer and increments the reference count.template<class T> constexpr refcnt_ptr<T> refcnt_attach(T * ptr) noexcept
. Createsrefcnt_ptr
from a raw pointer without incrementing the reference count.template<class T, class... Args> refcnt_ptr<T> make_refcnt(Args &&... args)
. A convenience function that creates an instance ofT
vianew
and forwards the arguments to its constructor. Equivalent torefcnt_attach(new T(args))
.template<class T> refcnt_ptr<typename T::weak_value_type> weak_cast(const refcnt_ptr<T> & src)
and
template<class T> refcnt_ptr<const typename T::weak_value_type> weak_cast(const refcnt_ptr<const T> & src)
.
IfT
provides a type calledweak_value_type
and a methodget_weak_ptr()
it is assumed to support weak references. These functions provide a convenient "cast" conversion from a strong to a weak pointer wrapping the call toget_weak_ptr()
.template<class T> refcnt_ptr<typename T::strong_value_type> strong_cast(const refcnt_ptr<T> & src) noexcept
and
template<class T> refcnt_ptr<const typename T::strong_value_type> strong_cast(const refcnt_ptr<const T> & src) noexcept
IfT
provides a type calledstrong_value_type
and a methodlock()
it is assumed to be a weak reference. These functions provide a convenient "cast" conversion from a weak to a strong pointer wrapping the call tolock()
.