38 template<
typename TYPE,
typename DERIVED,
typename DELETER>
40 template<
typename,
typename,
typename>
friend class refCntPtr;
49 using autoPtr<TYPE, DERIVED, DELETER>::operator==;
50 using autoPtr<TYPE, DERIVED, DELETER>::operator!=;
58 template<
typename O_DERIVED>
67 template<
typename O_DERIVED>
74 [[nodiscard]] std::string
className()
const override;
81 [[nodiscard]] std::string
toString(
bool enter)
const override;
89 template<
typename TYPE,
typename DELETER = deleter<TYPE>>
92 template<
typename TYPE,
typename DELETER = deleter<TYPE>>
107 template<
typename TYPE,
typename DELETER>
109 template<
typename,
typename>
friend class strongPtr;
110 template<
typename,
typename>
friend class weakPtr;
153 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<U>>
163 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<const U>>
173 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<U>>
183 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<const U>>
193 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<U>>
225 template <typename T, typename DEL, typename... Args>
228 template <typename T, typename DEL, typename... Args>
243 template<typename TYPE, typename DELETER>
245 template<
typename,
typename>
friend class weakPtr;
246 template<
typename,
typename>
friend class strongPtr;
326 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<U>>
336 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<const U>>
346 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<U>>
356 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<const U>>
366 template<
typename U,
typename DEL = DELETER::
template rebound_deleter<U>>
428 [[nodiscard]] std::string
className()
const override;
454 template <
typename T,
typename DEL = deleter<T>,
typename... Args>
473 template <
typename T,
typename DEL = deleter<T[]>,
typename... Args>
479 template<
typename TYPE,
typename DERIVED,
typename DELETER>
483 template<
typename TYPE,
typename DERIVED,
typename DELETER>
484 template<
typename O_DERIVED>
486 return this->get() == other.
get();
489 template<
typename TYPE,
typename DERIVED,
typename DELETER>
490 template<
typename O_DERIVED>
492 return this->get() != other.
get();
495 template<
typename TYPE,
typename DERIVED,
typename DELETER>
500 template<
typename TYPE,
typename DERIVED,
typename DELETER>
502 std::stringstream ss;
503 ss << this->className() <<
"(";
505 ss <<
"strong ref: " << this->strongRefs() <<
", " <<
"weak ref: " << this->weakRefs();
512 template <
typename TYPE,
typename DELETER>
522 template<
typename TYPE,
typename DELETER>
528 template<
typename TYPE,
typename DELETER>
533 template<
typename TYPE,
typename DELETER>
535 if (
this == &other || *
this == other)
538 this->removeStrongRef();
541 this->addStrongRef();
546 template<
typename TYPE,
typename DELETER>
548 this->operator=(std::move(other));
551 template <
typename TYPE,
typename DELETER>
552 template <
typename U,
typename DEL>
560 template <
typename TYPE,
typename DELETER>
561 template <
typename U,
typename DEL>
569 template <
typename TYPE,
typename DELETER>
570 template <
typename U,
typename DEL>
573 auto alias =
dynamic_cast<U*
>(this->get());
574 if (alias ==
nullptr) {
580 template <
typename TYPE,
typename DELETER>
581 template <
typename U,
typename DEL>
584 auto alias =
dynamic_cast<const U*
>(this->get());
585 if (alias ==
nullptr) {
591 template <
typename TYPE,
typename DELETER>
592 template <
typename U,
typename DEL>
595 auto alias =
const_cast<U*
>(this->get());
599 template<
typename TYPE,
typename DELETER>
601 this->removeStrongRef();
604 this->addStrongRef();
605 this->alias_ptr =
nullptr;
608 template<
typename TYPE,
typename DELETER>
610 if (
this == &other || *
this == other)
613 this->removeStrongRef();
615 this->ref_count = *other.ref_count;
617 other.addStrongRef();
618 this->alias_ptr = other.alias_ptr;
622 template<
typename TYPE,
typename DELETER>
627 template<
typename TYPE,
typename DELETER>
629 this->removeStrongRef();
632 template<
typename T,
typename DEL,
typename ... Args>
637 template<
typename T,
typename DEL,
typename ... Args>
642 strong_ptr[i] = T(std::forward<Args>(args)...);
647 template <
typename TYPE,
typename DELETER>
657 template<
typename TYPE,
typename DELETER>
663 template<
typename TYPE,
typename DELETER>
669 template<
typename TYPE,
typename DELETER>
674 this->removeWeakRef();
682 template<
typename TYPE,
typename DELETER>
688 template<
typename TYPE,
typename DELETER>
690 if (
this == &other || *
this == other)
693 this->removeWeakRef();
701 template<
typename TYPE,
typename DELETER>
703 this->operator=(std::move(other));
706 template<
typename TYPE,
typename DELETER>
708 if (
this == &other || *
this == other)
711 this->removeWeakRef();
713 this->ref_count = *other.ref_count;
716 this->alias_ptr = other.alias_ptr;
720 template <
typename TYPE,
typename DELETER>
721 template <
typename U,
typename DEL>
729 template <
typename TYPE,
typename DELETER>
730 template <
typename U,
typename DEL>
738 template <
typename TYPE,
typename DELETER>
739 template <
typename U,
typename DEL>
742 auto alias =
dynamic_cast<U*
>(this->get());
743 if (alias ==
nullptr) {
749 template <
typename TYPE,
typename DELETER>
750 template <
typename U,
typename DEL>
753 auto alias =
dynamic_cast<const U*
>(this->get());
754 if (alias ==
nullptr) {
760 template <
typename TYPE,
typename DELETER>
761 template <
typename U,
typename DEL>
764 auto alias =
const_cast<U*
>(this->get());
768 template<
typename TYPE,
typename DELETER>
771 if (!this->expired()){
781 template<
typename TYPE,
typename DELETER>
783 return this->lock().operator*();
786 template<
typename TYPE,
typename DELETER>
788 return this->lock().operator->();
791 template<
typename TYPE,
typename DELETER>
793 return this->lock().operator[](index);
796 template<
typename TYPE,
typename DELETER>
798 return this->lock().operator*();
801 template<
typename TYPE,
typename DELETER>
803 return this->lock().operator->();
806 template<
typename TYPE,
typename DELETER>
808 return this->lock().operator[](index);
811 template<
typename TYPE,
typename DELETER>
816 template<
typename TYPE,
typename DELETER>
818 this->removeWeakRef();
Base class for reference-counted smart pointers.
Base smart pointer with reference counting.
Definition autoPtr.h:57
void addWeakRef() const
Increment weak reference count.
Definition autoPtr.h:434
static refCount< TYPE, DELETER > * newRefCount(TYPE *p=nullptr)
Create new reference counter.
Definition autoPtr.h:494
virtual const TYPE & operator[](u_integer index) const
Const array access operator.
Definition autoPtr.h:583
void removeWeakRef() const
Decrement weak reference count.
Definition autoPtr.h:450
void addStrongRef() const
Increment strong reference count.
Definition autoPtr.h:426
TYPE * alias_ptr
Aliased pointer for type casting scenarios.
Definition autoPtr.h:61
atomic< refCountBase * > ref_count
Reference counter object.
Definition autoPtr.h:60
void removeStrongRef() const
Decrement strong reference count.
Definition autoPtr.h:442
void clean() noexcept
Cleanup resources when expired.
Definition autoPtr.h:474
friend bool operator!=(const autoPtr< T, DER, DEL > &ptr, const std::nullptr_t &null)
Inequality comparison with nullptr.
virtual const TYPE & operator*() const
Const dereference operator.
Definition autoPtr.h:566
const TYPE * get() const
Get managed pointer const version.
Definition autoPtr.h:542
virtual const TYPE * operator->() const
Const member access operator.
Definition autoPtr.h:575
friend bool operator==(const autoPtr< T, DER, DEL > &ptr, const std::nullptr_t &null)
Equality comparison with nullptr.
static std::string formatString(const TYPE &t)
Universal value-to-string conversion.
Definition printable.h:263
Base class for reference-counted pointers.
Definition refCntPtr.h:39
std::string className() const override
Get class identifier.
Definition refCntPtr.h:496
std::string toString(bool enter) const override
Formatted string with reference info.
Definition refCntPtr.h:501
bool operator!=(const refCntPtr< TYPE, O_DERIVED, DELETER > &other) const
Inequality comparison operator.
Definition refCntPtr.h:491
bool operator==(const refCntPtr< TYPE, O_DERIVED, DELETER > &other) const
Equality comparison operator.
Definition refCntPtr.h:485
~refCntPtr() override=default
Default destructor of refCntPtr.
refCntPtr(TYPE *p=std::nullptr_t{})
Construct from raw pointer.
Definition refCntPtr.h:480
Base class for reference counting metadata.
Definition autoPtr.h:339
Compile-time error triggering utility.
Definition error.h:112
Shared ownership smart pointer with strong references.
Definition refCntPtr.h:108
strongPtr(strongPtr &&other) noexcept
Move constructor transfers ownership.
Definition refCntPtr.h:547
void reset() noexcept
Resets the smart pointer and releases the managed object.
Definition refCntPtr.h:600
std::string className() const override
Get class identifier.
Definition refCntPtr.h:623
friend strongPtr< T, DEL > makeStrongPtr(Args &&... args)
Creates a new strongPtr managing a shared object.
Definition refCntPtr.h:633
strongPtr< const U, DEL > staticCastTo() const
Static cast to const pointer type.
Definition refCntPtr.h:562
strongPtr & operator=(const strongPtr &other)
Copy assignment shares ownership.
Definition refCntPtr.h:534
strongPtr< U, DEL > staticCastTo()
Static cast to different pointer type.
Definition refCntPtr.h:553
strongPtr(TYPE *p=std::nullptr_t{})
Construct from raw pointer.
Definition refCntPtr.h:523
strongPtr< const U, DEL > dynamicCastTo() const
Dynamic cast to const pointer type.
Definition refCntPtr.h:582
friend strongPtr< T, DEL > makeStrongPtrArray(u_integer size, Args &&... args)
Creates a new strongPtr managing a shared array.
Definition refCntPtr.h:638
~strongPtr() override
Destructor decreases strong references count.
Definition refCntPtr.h:628
strongPtr< U, DEL > constCastTo() const
Const cast to remove const qualifier.
Definition refCntPtr.h:593
strongPtr< U, DEL > dynamicCastTo()
Dynamic cast to different pointer type.
Definition refCntPtr.h:571
strongPtr(const strongPtr &other)
Copy constructor shares ownership.
Definition refCntPtr.h:529
Non-owning reference to shared resource.
Definition refCntPtr.h:244
const TYPE & operator*() const override
Const dereference via temporary strong reference.
Definition refCntPtr.h:782
weakPtr< U, DEL > staticCastTo()
Static cast to different pointer type.
Definition refCntPtr.h:722
std::string className() const override
Get class type identifier.
Definition refCntPtr.h:812
strongPtr< TYPE, DELETER > lock() const
Attempt to acquire ownership.
Definition refCntPtr.h:769
weakPtr< U, DEL > constCastTo() const
Const cast to remove const qualifier.
Definition refCntPtr.h:762
weakPtr & operator=(const strongPtr< TYPE, DELETER > &other)
Assign observation from strongPtr.
Definition refCntPtr.h:670
weakPtr< U, DEL > dynamicCastTo()
Dynamic cast to different pointer type.
Definition refCntPtr.h:740
~weakPtr() override
Destructor releases weak reference.
Definition refCntPtr.h:817
const TYPE & operator[](u_integer index) const override
Const array element access via temporary strong reference.
Definition refCntPtr.h:792
const TYPE * operator->() const override
Const member access via temporary strong reference.
Definition refCntPtr.h:787
Default deleters for resource management.
std::uint32_t u_integer
32-bit unsigned integer type for sizes and indexes
Definition config.h:263
Main namespace for the project Original.
Definition algorithms.h:21
strongPtr< T, DEL > makeStrongPtrArray(u_integer size, Args &&... args)
Creates a new strongPtr managing a shared array.
Definition refCntPtr.h:638
strongPtr< T, DEL > makeStrongPtr(Args &&... args)
Creates a new strongPtr managing a shared object.
Definition refCntPtr.h:633
Reference-counted smart pointer hierarchy.