16#ifdef __cpp_impl_three_way_comparison
21#include "libcopp/utils/config/libcopp_build_features.h"
25LIBCOPP_COPP_NAMESPACE_BEGIN
45 virtual
void dispose() noexcept = 0;
48 virtual
void destroy() noexcept = 0;
51 LIBCOPP_COPP_API static
void throw_bad_weak_ptr();
55 if (!add_ref_nothrow()) {
62 if (use_count_ == 0) {
72 if (--use_count_ == 0) {
74 if (--weak_count_ == 0) {
85 if (--weak_count_ == 0) {
111 using alloc_type = ::std::allocator<nostd::remove_cv_t<T>>;
112 using alloc_traits = ::std::allocator_traits<alloc_type>;
114 if (
nullptr != ptr_) {
115 alloc_traits::destroy(alloc,
const_cast<nostd::remove_cv_t<T>*
>(ptr_));
116 alloc_traits::deallocate(alloc,
const_cast<nostd::remove_cv_t<T>*
>(ptr_), 1);
122 using alloc_type = ::std::allocator<__rc_ptr_counted_data_default<T>>;
140 template <
class... Args>
142 using alloc_type = ::std::allocator<nostd::remove_cv_t<T>>;
143 using alloc_traits = ::std::allocator_traits<alloc_type>;
145 alloc_traits::construct(alloc,
const_cast<nostd::remove_cv_t<T>*
>(ptr()), std::forward<Args>(args)...);
149 using alloc_type = ::std::allocator<nostd::remove_cv_t<T>>;
150 using alloc_traits = ::std::allocator_traits<alloc_type>;
152 alloc_traits::destroy(alloc,
const_cast<nostd::remove_cv_t<T>*
>(ptr()));
156 using alloc_type = ::std::allocator<__rc_ptr_counted_data_inplace<T>>;
157 using alloc_traits = ::std::allocator_traits<alloc_type>;
160 alloc_traits::destroy(alloc,
this);
163 inline T*
ptr() noexcept {
return reinterpret_cast<T*
>(addr()); }
166 inline void*
addr() {
return reinterpret_cast<void*
>(&storage_); }
168 nostd::aligned_storage_t<
sizeof(T),
alignof(T)>
storage_;
177template <
class T,
class Alloc>
180 template <
class AllocInput,
class... Args>
183 using alloc_type_a = typename ::std::allocator_traits<Alloc>::template rebind_alloc<Alloc>;
184 using alloc_traits_a = ::std::allocator_traits<alloc_type_a>;
186 alloc_traits_a::construct(aa, alloc_ptr(), std::forward<AllocInput>(a));
189#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
192 using alloc_traits_v = ::std::allocator_traits<Alloc>;
193 alloc_traits_v::construct(*alloc_ptr(),
const_cast<nostd::remove_cv_t<T>*
>(value_ptr()),
194 std::forward<Args>(args)...);
195#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
197 alloc_traits_a::destroy(aa, alloc_ptr());
204 using alloc_traits_v = ::std::allocator_traits<Alloc>;
205 alloc_traits_v::destroy(*alloc_ptr(),
const_cast<nostd::remove_cv_t<T>*
>(value_ptr()));
209 using alloc_type_self =
210 typename ::std::allocator_traits<Alloc>::template rebind_alloc<__rc_ptr_counted_data_inplace_alloc<T, Alloc>>;
211 using alloc_traits_self = ::std::allocator_traits<alloc_type_self>;
213#if defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
214# if (__GNUC__ * 100 + __GNUC_MINOR__ * 10) >= 460
215# pragma GCC diagnostic push
217# pragma GCC diagnostic ignored "-Wuninitialized"
218#elif defined(__clang__) || defined(__apple_build_version__)
219# pragma clang diagnostic push
220# pragma clang diagnostic ignored "-Wuninitialized"
224 using alloc_type_a = typename ::std::allocator_traits<Alloc>::template rebind_alloc<Alloc>;
225 using alloc_traits_a = ::std::allocator_traits<alloc_type_a>;
227 alloc_traits_a::destroy(aa, alloc_ptr());
232 alloc_traits_self::destroy(as,
this);
234#if defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
235# if (__GNUC__ * 100 + __GNUC_MINOR__ * 10) >= 460
236# pragma GCC diagnostic pop
238#elif defined(__clang__) || defined(__apple_build_version__)
239# pragma clang diagnostic pop
243 inline T*
value_ptr() noexcept {
return reinterpret_cast<T*
>(value_addr()); }
244 inline Alloc*
alloc_ptr() noexcept {
return reinterpret_cast<Alloc*
>(alloc_addr()); }
247 inline void*
value_addr() {
return reinterpret_cast<void*
>(&storage_); }
248 inline void*
alloc_addr() {
return reinterpret_cast<void*
>(&alloc_); }
250 nostd::aligned_storage_t<
sizeof(T),
alignof(T)>
storage_;
251 nostd::aligned_storage_t<
sizeof(Alloc),
alignof(Alloc)>
alloc_;
258template <
class T,
class Deleter>
261 template <
class DeleterInput>
263 : ptr_(p), deleter_(std::forward<DeleterInput>(d)) {}
265 void dispose() noexcept
override { deleter_(ptr_); }
268 using alloc_type = ::std::allocator<__rc_ptr_counted_data_with_deleter<T, Deleter>>;
269 using alloc_traits = ::std::allocator_traits<alloc_type>;
274 alloc_traits::destroy(alloc,
this);
286template <
class T,
class Deleter,
class Alloc>
290 template <
class DeleterInput,
class AllocInput>
292 : ptr_(p), deleter_(std::forward<DeleterInput>(d)), alloc_(std::forward<AllocInput>(a)) {}
294 void dispose() noexcept
override { deleter_(ptr_); }
297 using alloc_type = typename ::std::allocator_traits<Alloc>::template rebind_alloc<
299 using alloc_traits = ::std::allocator_traits<alloc_type>;
300 alloc_type alloc{alloc_};
304 alloc_traits::destroy(alloc,
this);
342 using alloc_type = ::std::allocator<__rc_ptr_counted_data_default<Y>>;
343 using alloc_traits = ::std::allocator_traits<alloc_type>;
346#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
349 alloc_traits::construct(alloc, guard.get(), p);
353#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
355 using alloc_type_y = ::std::allocator<nostd::remove_cv_t<Y>>;
356 using alloc_traits_y = ::std::allocator_traits<alloc_type_y>;
357 alloc_type_y alloc_y;
360 alloc_traits_y::destroy(alloc_y, p);
361 alloc_traits_y::deallocate(alloc_y,
const_cast<nostd::remove_cv_t<Y>*
>(p), 1);
368 template <
class Y,
class Deleter,
class =
typename __not_alloc_shared_tag<nostd::remove_cvref_t<Deleter>>::type>
370 using alloc_type = ::std::allocator<__rc_ptr_counted_data_with_deleter<Y, nostd::remove_cvref_t<Deleter>>>;
371 using alloc_traits = ::std::allocator_traits<alloc_type>;
374#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
377 alloc_traits::construct(alloc, guard.get(), p, std::forward<Deleter>(d));
380#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
388 template <
class Y,
class Deleter,
class Alloc,
389 class =
typename __not_alloc_shared_tag<nostd::remove_cvref_t<Deleter>>::type>
391 using origin_alloc_traits = ::std::allocator_traits<nostd::remove_cvref_t<Alloc>>;
392 using alloc_type =
typename origin_alloc_traits::template rebind_alloc<
394 using alloc_traits = ::std::allocator_traits<alloc_type>;
397#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
400 alloc_traits::construct(alloc, guard.get(), p, std::forward<Deleter>(d), std::forward<Alloc>(a));
403#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
411 template <
class... Args>
413 using alloc_type = ::std::allocator<__rc_ptr_counted_data_inplace<T>>;
414 using alloc_traits = ::std::allocator_traits<alloc_type>;
418#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
421 alloc_traits::construct(alloc, guard.get(), std::forward<Args>(args)...);
423 __p = guard.get()->ptr();
425#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
432 template <
class Alloc,
class... Args>
434 using origin_alloc_traits = ::std::allocator_traits<nostd::remove_cvref_t<Alloc>>;
436 using alloc_type =
typename origin_alloc_traits::template rebind_alloc<
438 using alloc_traits = ::std::allocator_traits<alloc_type>;
442#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
445 alloc_traits::construct(alloc, guard.get(), std::forward<Alloc>(a), std::forward<Args>(args)...);
447 __p = guard.get()->value_ptr();
449#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
456 template <
class UT,
class UDeleter>
458 if (r.get() ==
nullptr) {
462 using alloc_type = ::std::allocator<__rc_ptr_counted_data_with_deleter<UT, nostd::remove_cvref_t<UDeleter>>>;
463 using alloc_traits = ::std::allocator_traits<alloc_type>;
467#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
470 alloc_traits::construct(alloc, guard.get(), r.get(), std::forward<UDeleter>(r.get_deleter()));
475#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
487 if (
nullptr != pi_) {
493 if (
nullptr != pi_) {
502 if (
nullptr != pi_) {
517 if (
nullptr != pi_) {
520 if (
nullptr != origin_pi) {
533 if (
nullptr != origin_pi) {
553 inline std::size_t
use_count() const noexcept {
return (
nullptr != pi_) ? pi_->use_count() : 0; }
571 if (
nullptr != pi_) {
577 if (
nullptr != pi_) {
583 if (
nullptr != pi_) {
592 if (
nullptr != pi_) {
606 if (
nullptr != pi_) {
610 if (
nullptr != origin_pi) {
623 if (
nullptr != origin_pi) {
643 inline std::size_t
use_count() const noexcept {
return (
nullptr != pi_) ? pi_->use_count() : 0; }
664 : pi_(w.ref_counter()) {
665 if (
nullptr != pi_ && !pi_->add_ref_nothrow()) {
673template <class T, bool = std::is_array<T>::value,
bool = std::is_void<T>::value>
680#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
681 if (
nullptr == ret) {
682 __rc_ptr_counted_data_base::throw_bad_weak_ptr();
690#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
691 if (
nullptr == ret) {
692 __rc_ptr_counted_data_base::throw_bad_weak_ptr();
712#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
713 if (
nullptr == ret) {
714 __rc_ptr_counted_data_base::throw_bad_weak_ptr();
731#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
732 if (
nullptr == ret) {
733 __rc_ptr_counted_data_base::throw_bad_weak_ptr();
748template <
class T1,
class T2,
class T3>
752 if (
nullptr != __p) {
758template <
class T1,
class T2,
class T3,
size_t T3SIZE>
761 if (
nullptr != __p) {
762 for (
auto& p : *__p) {
763 p->__internal_weak_assign(
const_cast<T2*
>(__py), *__n);
772struct __sp_any_pointer {
774 __sp_any_pointer(T*) {}
803 constexpr strong_rc_ptr(std::nullptr_t) noexcept : ptr_(
nullptr), ref_counter_() {}
807 : ptr_(ptr), ref_counter_(ptr) {
808 static_assert(!std::is_void<Y>::value,
"incomplete type");
809 static_assert(
sizeof(Y) > 0,
"incomplete type");
813 template <
class Y,
class Deleter>
818 template <
class Y,
class Deleter,
class Alloc>
823 template <
class Deleter>
824 strong_rc_ptr(std::nullptr_t ptr, Deleter d) : ptr_(ptr), ref_counter_(ptr,
std::move(d)) {}
826 template <
class Y,
class Deleter,
class Alloc>
827 strong_rc_ptr(std::nullptr_t ptr, Deleter d, Alloc a) : ptr_(ptr), ref_counter_(ptr,
std::move(d),
std::move(a)) {}
834 ref_counter_.swap(other.ref_counter_);
835 other.ptr_ =
nullptr;
840 : ptr_(ptr), ref_counter_(other.ref_counter_) {}
844 ref_counter_.swap(other.ref_counter_);
845 other.ptr_ =
nullptr;
849 : ptr_(nullptr), ref_counter_(other.ref_counter_) {
854 : ptr_(
nullptr), ref_counter_(other.ref_counter_, std::nothrow) {
855 ptr_ = other.use_count() > 0 ? other.ptr_ :
nullptr;
860 : ptr_(nullptr), ref_counter_(other.ref_counter_) {
864 template <
class Y,
class Deleter>
866 : ptr_(other.get()), ref_counter_() {
876 template <
class... Args>
878 : ptr_(nullptr), ref_counter_(ptr_, __tag,
std::forward<Args>(args)...) {
887 template <
class... Args>
889 : ptr_(nullptr), ref_counter_(ptr_, __tag,
std::forward<Args>(args)...) {
898 ref_counter_.
swap(other.ref_counter_);
899 other.ptr_ =
nullptr;
910 ref_counter_ = other.ref_counter_;
920 template <
class Y,
class Deleter>
929 inline void reset(Y* ptr)
noexcept {
930 if (ptr_ == ptr && ptr !=
nullptr) {
937 template <
class Y,
class Deleter>
938 inline void reset(Y* ptr, Deleter d)
noexcept {
938 inline void reset(Y* ptr, Deleter d)
noexcept {
…}
942 template <
class Y,
class Deleter,
class Alloc>
943 inline void reset(Y* ptr, Deleter d, Alloc a)
noexcept {
943 inline void reset(Y* ptr, Deleter d, Alloc a)
noexcept {
…}
949 ref_counter_.swap(other.ref_counter_);
954 inline std::size_t
use_count() const noexcept {
return ref_counter_.use_count(); }
956 inline bool unique() const noexcept {
return ref_counter_.use_count() == 1; }
958 inline explicit operator bool() const noexcept {
return nullptr != get(); }
962 return std::less<__rc_ptr_counted_data_base*>()(ref_counter_.ref_counter(), r.ref_counter_.ref_counter());
967 return std::less<__rc_ptr_counted_data_base*>()(ref_counter_.ref_counter(), r.ref_counter_.ref_counter());
972 return ref_counter_.ref_counter() == r.ref_counter_.ref_counter();
977 return ref_counter_.ref_counter() == r.ref_counter_.ref_counter();
981 return std::hash<__rc_ptr_counted_data_base*>()(ref_counter_.ref_counter());
996template <
class T1,
class T2>
998 return l.get() == r.get();
1006template <class T1, class T2, bool = std::is_convertible<T1*, T2*>::value || std::is_convertible<T2*, T1*>::value>
1009template <
class T1,
class T2>
1017template <
class T1,
class T2>
1026#ifdef __cpp_impl_three_way_comparison
1027template <
class T1,
class T2>
1028LIBCOPP_COPP_API_HEAD_ONLY
inline std::strong_ordering operator<=>(
const strong_rc_ptr<T1>& l,
1035LIBCOPP_COPP_API_HEAD_ONLY
inline std::strong_ordering operator<=>(
const strong_rc_ptr<T1>& l,
1036 ::std::nullptr_t)
noexcept {
1037 return l.get() <=>
static_cast<T1*
>(
nullptr);
1046template <
class T1,
class T2>
1048 return l.get() != r.get();
1053 return l.get() !=
nullptr;
1058 return r.get() !=
nullptr;
1061template <
class T1,
class T2>
1070 return std::less<T1>()(l.get(),
nullptr);
1075 return std::less<T1>()(
nullptr, r.get());
1078template <
class T1,
class T2>
1087 return std::greater<T1>()(l.get(),
nullptr);
1092 return std::greater<T1>()(
nullptr, r.get());
1095template <
class T1,
class T2>
1102 return !(
nullptr < l);
1107 return !(r <
nullptr);
1110template <
class T1,
class T2>
1117 return !(
nullptr > l);
1122 return !(r >
nullptr);
1130template <
typename T>
1143 : ptr_(other.ptr_), ref_counter_(std::move(other.ref_counter_)) {
1144 other.ptr_ =
nullptr;
1154 : ptr_(other.ptr_), ref_counter_(other.ref_counter_) {}
1158 ptr_ = other.lock().get();
1163 other.ptr_ =
nullptr;
1168 ptr_ = other.
lock().get();
1169 ref_counter_ = other.ref_counter_;
1190 ref_counter_.swap(r.ref_counter_);
1193 inline std::size_t
use_count() const noexcept {
return ref_counter_.use_count(); }
1195 inline bool expired() const noexcept {
return ref_counter_.use_count() == 0; }
1201 return std::less<__rc_ptr_counted_data_base*>()(ref_counter_.ref_counter(), r.ref_counter_.ref_counter());
1206 return std::less<__rc_ptr_counted_data_base*>()(ref_counter_.ref_counter(), r.ref_counter_.ref_counter());
1211 return ref_counter_.ref_counter() == r.ref_counter_.ref_counter();
1216 return ref_counter_.ref_counter() == r.ref_counter_.ref_counter();
1220 return std::hash<__rc_ptr_counted_data_base*>()(ref_counter_.ref_counter());
1229 if (use_count() == 0) {
1251#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
1252 if (
this != result.
get()) {
1262#if defined(LIBCOPP_MACRO_ENABLE_EXCEPTION) && LIBCOPP_MACRO_ENABLE_EXCEPTION
1263 if (
this != result.
get()) {
1299template <
class T,
class... TArgs>
1308template <
class T,
class... TArgs>
1318template <
class T,
class Alloc,
class... TArgs>
1329template <
class T,
class Alloc,
class... TArgs>
1340template <
class T,
class Y>
1350template <
class T,
class Y>
1355#if defined(LIBCOPP_MACRO_ENABLE_RTTI) && LIBCOPP_MACRO_ENABLE_RTTI
1361template <
class T,
class Y>
1362strong_rc_ptr<T> dynamic_pointer_cast(
const strong_rc_ptr<Y>& r)
noexcept {
1368LIBCOPP_COPP_NAMESPACE_END
1377LIBCOPP_COPP_API_HEAD_ONLY
void swap(LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr<T>& a,
1378 LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr<T>& b)
noexcept {
1377LIBCOPP_COPP_API_HEAD_ONLY
void swap(LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr<T>& a, {
…}
1389 std::size_t
operator()(
const LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr<T>& s)
const noexcept {
1390 return std::hash<T*>()(s.get());
1389 std::size_t
operator()(
const LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr<T>& s)
const noexcept {
…}
1399template <
class CharT,
class TraitT,
class T>
1400LIBCOPP_COPP_API_HEAD_ONLY
inline std::basic_ostream<CharT, TraitT>&
operator<<(
1401 std::basic_ostream<CharT, TraitT>& __os,
const LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr<T>& __p) {
1400LIBCOPP_COPP_API_HEAD_ONLY
inline std::basic_ostream<CharT, TraitT>&
operator<<( {
…}
1407LIBCOPP_COPP_NAMESPACE_BEGIN
1421template <compat_strong_ptr_mode>
1435 template <
class Y,
class... ArgsT>
1437 return memory::make_strong_rc<Y>(std::forward<ArgsT>(args)...);
1440 template <
class Y,
class Alloc,
class... TArgs>
1442 return memory::allocate_strong_rc<Y>(alloc, std::forward<TArgs>(args)...);
1445 template <
class Y,
class F>
1447 return memory::static_pointer_cast<Y>(std::forward<F>(f));
1450 template <
class Y,
class F>
1452 return memory::const_pointer_cast<Y>(std::forward<F>(f));
1455#if defined(LIBCOPP_MACRO_ENABLE_RTTI) && LIBCOPP_MACRO_ENABLE_RTTI
1456 template <
class Y,
class F>
1458 return memory::dynamic_pointer_cast<Y>(std::forward<F>(f));
1474 template <
class Y,
class... ArgsT>
1480 return std::make_shared<Y>(std::forward<ArgsT>(args)...);
1485 template <
class Y,
class Alloc,
class... TArgs>
1491 return std::allocate_shared<Y>(alloc, std::forward<TArgs>(args)...);
1496 template <
class Y,
class F>
1498 return std::static_pointer_cast<Y>(std::forward<F>(f));
1501 template <
class Y,
class F>
1503 return std::const_pointer_cast<Y>(std::forward<F>(f));
1506#if defined(LIBCOPP_MACRO_ENABLE_RTTI) && LIBCOPP_MACRO_ENABLE_RTTI
1507 template <
class Y,
class F>
1508 static inline std::shared_ptr<Y> dynamic_pointer_cast(F&& f) {
1509 return std::dynamic_pointer_cast<Y>(std::forward<F>(f));
1518template <
class T, compat_strong_ptr_mode PtrMode>
1525LIBCOPP_COPP_NAMESPACE_END
LIBCOPP_UTIL_FORCEINLINE bool add_ref_nothrow() noexcept
__rc_ptr_counted_data_base & operator=(const __rc_ptr_counted_data_base &)=delete
__rc_ptr_counted_data_base(const __rc_ptr_counted_data_base &)=delete
static LIBCOPP_COPP_API void throw_bad_weak_ptr()
LIBCOPP_UTIL_FORCEINLINE void weak_release() noexcept
LIBCOPP_UTIL_FORCEINLINE void weak_add_ref() noexcept
constexpr __rc_ptr_counted_data_base() noexcept
LIBCOPP_UTIL_FORCEINLINE void add_ref()
LIBCOPP_UTIL_FORCEINLINE std::size_t use_count() const noexcept
LIBCOPP_UTIL_FORCEINLINE void release() noexcept
Template class definition for reference-counted.
void dispose() noexcept override
void destroy() noexcept override
__rc_ptr_counted_data_default(T *p) noexcept
Template class definition for reference-counted with allocator.(inplacement)
void dispose() noexcept override
Alloc * alloc_ptr() noexcept
nostd::aligned_storage_t< sizeof(T), alignof(T)> storage_
nostd::aligned_storage_t< sizeof(Alloc), alignof(Alloc)> alloc_
__rc_ptr_counted_data_inplace_alloc(AllocInput &&a, Args &&... args)
void destroy() noexcept override
Template class definition for reference-counted.(inplacement)
nostd::aligned_storage_t< sizeof(T), alignof(T)> storage_
void dispose() noexcept override
__rc_ptr_counted_data_inplace(Args &&... args)
void destroy() noexcept override
Template class definition for reference-counted with deletor and allocator.
__rc_ptr_counted_data_with_deleter_allocator(T *p, DeleterInput &&d, AllocInput &&a) noexcept
void destroy() noexcept override
void dispose() noexcept override
Template class definition for reference-counted with deletor.
void destroy() noexcept override
void dispose() noexcept override
__rc_ptr_counted_data_with_deleter(T *p, DeleterInput &&d) noexcept
__strong_rc_counter(Y *p, Deleter &&d)
__strong_rc_counter & operator=(const __strong_rc_counter &r) noexcept
void swap(__strong_rc_counter &r) noexcept
__strong_rc_counter(std::unique_ptr< UT, UDeleter > &&r)
__rc_ptr_counted_data_base * ref_counter() const noexcept
__strong_rc_counter(__strong_rc_counter< Y > &&r) noexcept
__rc_ptr_counted_data_base * pi_
__strong_rc_counter(const __weak_rc_counter< T > &w, std::nothrow_t) noexcept
friend class LIBCOPP_COPP_API_HEAD_ONLY __strong_rc_counter
__strong_rc_counter(const __strong_rc_counter< Y > &r) noexcept
__strong_rc_counter(__strong_rc_counter &&r) noexcept
std::size_t use_count() const noexcept
__strong_rc_counter(const __strong_rc_counter &r) noexcept
__strong_rc_counter & operator=(__strong_rc_counter &&r) noexcept
__strong_rc_counter(T *&__p, __strong_rc_default_alloc_shared_tag< T >, Args &&... args)
__strong_rc_counter(const __weak_rc_counter< T > &w)
__strong_rc_counter(Y *p, Deleter &&d, Alloc &&a)
__strong_rc_counter(Y *p)
constexpr __strong_rc_counter() noexcept
__strong_rc_counter(T *&__p, __strong_rc_with_alloc_shared_tag< T >, Alloc &&a, Args &&... args)
void swap(__strong_rc_counter< Y > &r) noexcept
void swap(__weak_rc_counter< Y > &r) noexcept
__weak_rc_counter(__weak_rc_counter< Y > &&r) noexcept
__weak_rc_counter & operator=(__weak_rc_counter &&r) noexcept
__weak_rc_counter(const __weak_rc_counter &r) noexcept
__weak_rc_counter(const __strong_rc_counter< Y > &other) noexcept
constexpr __weak_rc_counter() noexcept
__weak_rc_counter(const __weak_rc_counter< Y > &r) noexcept
std::size_t use_count() const noexcept
__rc_ptr_counted_data_base * pi_
__weak_rc_counter(__weak_rc_counter &&r) noexcept
__weak_rc_counter & operator=(const __weak_rc_counter &r) noexcept
void swap(__weak_rc_counter &r) noexcept
__rc_ptr_counted_data_base * ref_counter() const noexcept
strong_rc_ptr< T > shared_from_this()
weak_rc_ptr< T > weak_from_this()
enable_shared_rc_from_this()=default
weak_rc_ptr< T > weak_this_
enable_shared_rc_from_this & operator=(const enable_shared_rc_from_this &)=default
strong_rc_ptr< const T > shared_from_this() const
weak_rc_ptr< const T > weak_from_this() const
~enable_shared_rc_from_this()=default
void __internal_weak_assign(T *__p, const __strong_rc_counter< Y > &__n) const noexcept
enable_shared_rc_from_this(const enable_shared_rc_from_this &)=default
element_type * operator->() const noexcept
element_type * get() const noexcept
element_type & operator[](std::ptrdiff_t __i) const noexcept
element_type * get() const noexcept
nostd::remove_extent_t< T > element_type
Base class to mantain all shared APIs.
element_type & operator*() const noexcept
element_type * operator->() const noexcept
element_type * get() const noexcept
A std::shared_ptr replacement that is more lightweight and do not use atomic operation for reference ...
strong_rc_ptr(const weak_rc_ptr< T > &other)
strong_rc_ptr & operator=(strong_rc_ptr< Y > &&other) noexcept
strong_rc_ptr(strong_rc_ptr< Y > &&other, element_type *ptr) noexcept
strong_rc_ptr & operator=(std::unique_ptr< Y, Deleter > &&other)
constexpr strong_rc_ptr(std::nullptr_t) noexcept
void absl_nullability_compatible
strong_rc_ptr(std::unique_ptr< Y, Deleter > &&other)
bool owner_equal(weak_rc_ptr< Y > const &r) const noexcept
void reset(Y *ptr, Deleter d) noexcept
strong_rc_ptr(const weak_rc_ptr< T > &other, std::nothrow_t) noexcept
bool unique() const noexcept
__strong_rc_counter< element_type > ref_counter_
void nullability_compatible_type
strong_rc_ptr(const weak_rc_ptr< Y > &other)
bool owner_before(strong_rc_ptr< Y > const &r) const noexcept
~strong_rc_ptr() noexcept=default
strong_rc_ptr(__strong_rc_with_alloc_shared_tag< T > __tag, Args &&... args)
This is a special constructor for make_strong_rc/allocate_strong_rc.
strong_rc_ptr(strong_rc_ptr< Y > &&other) noexcept
strong_rc_ptr(std::nullptr_t ptr, Deleter d, Alloc a)
strong_rc_ptr & operator=(strong_rc_ptr &&other) noexcept
element_type * get() const noexcept
strong_rc_ptr(Y *ptr, Deleter d, Alloc a)
void swap(strong_rc_ptr &other) noexcept
bool owner_before(weak_rc_ptr< Y > const &r) const noexcept
strong_rc_ptr(const strong_rc_ptr< Y > &other, element_type *ptr) noexcept
strong_rc_ptr & operator=(const strong_rc_ptr< Y > &other) noexcept
void reset(Y *ptr, Deleter d, Alloc a) noexcept
bool owner_equal(strong_rc_ptr< Y > const &r) const noexcept
std::size_t owner_hash() const noexcept
void reset(Y *ptr) noexcept
strong_rc_ptr(Y *ptr) noexcept
constexpr strong_rc_ptr() noexcept
strong_rc_ptr(__strong_rc_default_alloc_shared_tag< T > __tag, Args &&... args)
This is a special constructor for make_strong_rc/allocate_strong_rc.
strong_rc_ptr(const strong_rc_ptr< Y > &other) noexcept
strong_rc_ptr(Y *ptr, Deleter d)
std::size_t use_count() const noexcept
strong_rc_ptr(std::nullptr_t ptr, Deleter d)
nostd::remove_extent_t< T > element_type
A std::weak_ptr replacement that is more lightweight and do not use atomic operation for reference co...
bool owner_before(strong_rc_ptr< Y > const &r) const noexcept
bool expired() const noexcept
nostd::remove_extent_t< T > element_type
void swap(weak_rc_ptr &r) noexcept
weak_rc_ptr(weak_rc_ptr &&other) noexcept
constexpr weak_rc_ptr() noexcept
weak_rc_ptr & operator=(const strong_rc_ptr< Y > &other) noexcept
bool owner_equal(weak_rc_ptr< Y > const &r) const noexcept
weak_rc_ptr & operator=(weak_rc_ptr< Y > &&other) noexcept
weak_rc_ptr(const weak_rc_ptr &) noexcept=default
weak_rc_ptr(const weak_rc_ptr< Y > &other) noexcept
weak_rc_ptr & operator=(weak_rc_ptr &&other) noexcept
std::size_t owner_hash() const noexcept
void assign(element_type *__ptr, const __strong_rc_counter< T > &__refcount) noexcept
bool owner_equal(strong_rc_ptr< Y > const &r) const noexcept
__weak_rc_counter< T > ref_counter_
weak_rc_ptr & operator=(const weak_rc_ptr< Y > &other) noexcept
weak_rc_ptr & operator=(const weak_rc_ptr &) noexcept=default
weak_rc_ptr(const strong_rc_ptr< Y > &other) noexcept
weak_rc_ptr(weak_rc_ptr< Y > &&other) noexcept
bool owner_before(weak_rc_ptr< Y > const &r) const noexcept
strong_rc_ptr< T > lock() const noexcept
std::size_t use_count() const noexcept
#define LIBCOPP_UTIL_SYMBOL_VISIBLE
#define LIBCOPP_UTIL_FORCEINLINE
#define LIBCOPP_UTIL_ATTRIBUTE_UNINITIALIZED
intrusive_ptr< T > const_pointer_cast(intrusive_ptr< U > const &p)
struct LIBCOPP_COPP_API_HEAD_ONLY compat_strong_ptr_function_trait
Helper trait class to switch between strong_rc_ptr and std::shared_ptr.
LIBCOPP_COPP_API_HEAD_ONLY void __enable_shared_from_this_with(const __strong_rc_counter< T1 > *__n, const T2 *__py, const enable_shared_rc_from_this< T3 > *__p)
A helper class that used to inject datas for classes that inherit enable_shared_rc_from_this.
bool operator==(intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) noexcept
bool operator<(intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) noexcept
bool operator>(intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) noexcept
LIBCOPP_UTIL_SYMBOL_VISIBLE allocated_ptr< Alloc > allocate_guarded(Alloc &a)
Allocate space for a single object using a.
intrusive_ptr< T > static_pointer_cast(intrusive_ptr< U > const &p)
bool operator<=(intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) noexcept
compat_strong_ptr_mode
Helper class to switch between strong_rc_ptr and std::shared_ptr.
bool operator!=(intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) noexcept
bool operator>=(intrusive_ptr< T > const &a, intrusive_ptr< U > const &b) noexcept
nostd::enable_if_t<!::std::is_array< T >::value, strong_rc_ptr< T > > allocate_strong_rc(const Alloc &alloc, TArgs &&... args)
A std::allocate_shared (C++20) replacement for strong_rc_ptr(non-array).
LIBCOPP_COPP_API_HEAD_ONLY void swap(LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr< T > &a, LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr< T > &b) noexcept
Support std::swap for strong_rc_ptr.
ostream & operator<<(ostream &os, const LIBCOPP_COPP_NAMESPACE_ID::gsl::not_null< T > &val)
nostd::common_type_t< left_type, right_type > common_type
Non-standard RAII type for managing pointers obtained from allocators.
static std::shared_ptr< Y > allocate_shared(const Alloc &alloc, TArgs &&... args)
static std::shared_ptr< Y > make_shared(ArgsT &&... args)
static std::shared_ptr< Y > static_pointer_cast(F &&f)
static std::shared_ptr< Y > const_pointer_cast(F &&f)
std::weak_ptr< Y > weak_ptr
std::enable_shared_from_this< Y > enable_shared_from_this
std::shared_ptr< Y > shared_ptr
static memory::strong_rc_ptr< Y > const_pointer_cast(F &&f)
static memory::strong_rc_ptr< Y > static_pointer_cast(F &&f)
static memory::strong_rc_ptr< Y > allocate_shared(const Alloc &alloc, TArgs &&... args)
static memory::strong_rc_ptr< Y > make_shared(ArgsT &&... args)
A simple helper trait class to switch between strong_rc_ptr and std::shared_ptr.
typename compat_strong_ptr_function_trait< PtrMode >::template shared_ptr< T > shared_ptr
typename compat_strong_ptr_function_trait< PtrMode >::template weak_ptr< T > weak_ptr
std::size_t operator()(const LIBCOPP_COPP_NAMESPACE_ID::memory::strong_rc_ptr< T > &s) const noexcept