35 template<
typename TYPE,
typename DELETER>
65 template<
typename TYPE,
typename DERIVED,
typename DELETER>
67 public comparable<autoPtr<TYPE, DERIVED, DELETER>>,
68 public hashable<autoPtr<TYPE, DERIVED, DELETER>> {
69 template<
typename,
typename,
typename>
friend class autoPtr;
378 template <
typename,
typename,
typename>
442 template <
typename,
typename,
typename>
459 const void* getPtr()
const noexcept override;
466 void* getPtr()
noexcept override;
481 void destroyPtr()
noexcept override;
503 template<
typename TYPE,
typename DERIVED,
typename DELETER>
508template<
typename TYPE,
typename DERIVED,
typename DELETER>
512template<
typename TYPE,
typename DERIVED,
typename DELETER>
520template<
typename TYPE,
typename DERIVED,
typename DELETER>
528template<
typename TYPE,
typename DERIVED,
typename DELETER>
536template<
typename TYPE,
typename DERIVED,
typename DELETER>
544template <
typename TYPE,
typename DERIVED,
typename DELETER>
552template<
typename TYPE,
typename DERIVED,
typename DELETER>
556 this->ref_count =
nullptr;
560template<
typename TYPE,
typename DERIVED,
typename DELETER>
570 if (strong_refs == 0) {
574 if (strong_refs == 0 && weak_refs == 0) {
575 this->ref_count =
nullptr;
580template <
typename TYPE,
typename DERIVED,
typename DELETER>
586template<
typename TYPE,
typename DERIVED,
typename DELETER>
593template<
typename TYPE,
typename DERIVED,
typename DELETER>
600template<
typename TYPE,
typename DERIVED,
typename DELETER>
607template<
typename TYPE,
typename DERIVED,
typename DELETER>
611 return *
current->strong_refs == 0;
614template<
typename TYPE,
typename DERIVED,
typename DELETER>
618 if (*
current->strong_refs == 0)
return false;
619 const void* p =
current->getPtr();
620 return p !=
nullptr || this->alias_ptr !=
nullptr;
623template <
typename TYPE,
typename DERIVED,
typename DELETER>
625 return !this->
operator bool();
628template<
typename TYPE,
typename DERIVED,
typename DELETER>
633 if (this->alias_ptr) {
634 return this->alias_ptr;
640template<
typename TYPE,
typename DERIVED,
typename DELETER>
645 if (this->alias_ptr) {
646 return this->alias_ptr;
652template<
typename TYPE,
typename DERIVED,
typename DELETER>
654 const auto ptr = this->get();
660template<
typename TYPE,
typename DERIVED,
typename DELETER>
663 const auto ptr = this->get();
669template<
typename TYPE,
typename DERIVED,
typename DELETER>
671 const auto ptr = this->get();
677template<
typename TYPE,
typename DERIVED,
typename DELETER>
679 auto ptr = this->get();
685template<
typename TYPE,
typename DERIVED,
typename DELETER>
688 auto ptr = this->get();
694template<
typename TYPE,
typename DERIVED,
typename DELETER>
696 auto ptr = this->get();
702template<
typename TYPE,
typename DERIVED,
typename DELETER>
713template<
typename TYPE,
typename DERIVED,
typename DELETER>
718template<
typename TYPE,
typename DERIVED,
typename DELETER>
723template<
typename TYPE,
typename DERIVED,
typename DELETER>
725 std::stringstream
ss;
726 ss << this->className() <<
"(";
727 ss << formatString(this->get());
734template<
typename TYPE,
typename DERIVED,
typename DELETER>
739template<
typename TYPE,
typename DERIVED,
typename DELETER>
741 return *
this ==
other;
744template<
typename TYPE,
typename DERIVED,
typename DELETER>
749template<
typename T,
typename DER,
typename DEL>
751 return !ptr.operator
bool();
754template<
typename T,
typename DER,
typename DEL>
756 return ptr.operator
bool();
759template<
typename T,
typename DER,
typename DEL>
761 return !ptr.operator
bool();
764template<
typename T,
typename DER,
typename DEL>
766 return ptr.operator
bool();
771template<
typename TYPE,
typename DELETER>
775template <
typename TYPE,
typename DELETER>
781template <
typename TYPE,
typename DELETER>
784 if constexpr (std::is_const_v<TYPE>) {
785 return const_cast<std::remove_const_t<TYPE>*
>(this->ptr);
791template <
typename TYPE,
typename DELETER>
794 if constexpr (std::is_const_v<TYPE>) {
795 auto p =
const_cast<std::remove_const_t<TYPE>*
>(this->ptr);
805template<
typename TYPE,
typename DELETER>
807 TYPE* tmp = this->ptr;
812template<
typename TYPE,
typename DELETER>
817template <
typename TYPE,
typename DERIVED,
typename DELETER>
Base smart pointer with reference counting.
Definition autoPtr.h:68
void addWeakRef() const
Increment weak reference count.
Definition autoPtr.h:521
static refCount< TYPE, DELETER > * newRefCount(TYPE *p=nullptr)
Create new reference counter.
Definition autoPtr.h:581
integer compareTo(const autoPtr &other) const override
Compare reference counters.
Definition autoPtr.h:714
void destroyRefCnt() noexcept
Destroy reference counter.
Definition autoPtr.h:553
virtual const TYPE & operator[](u_integer index) const
Const array access operator.
Definition autoPtr.h:670
u_integer strongRefs() const
Get strong reference count.
Definition autoPtr.h:587
~autoPtr() override
Destructor triggers reference cleanup.
Definition autoPtr.h:745
bool exist() const
Check active ownership.
Definition autoPtr.h:601
void removeWeakRef() const
Decrement weak reference count.
Definition autoPtr.h:537
void addStrongRef() const
Increment strong reference count.
Definition autoPtr.h:513
TYPE * alias_ptr
Aliased pointer for type casting scenarios.
Definition autoPtr.h:72
bool equals(const autoPtr &other) const noexcept override
Equality comparison.
Definition autoPtr.h:740
TYPE * releasePtr() noexcept
Release ownership of the managed pointer.
Definition autoPtr.h:545
bool operator!() const
Logical NOT operator.
Definition autoPtr.h:624
std::string className() const override
Get class name string.
Definition autoPtr.h:719
atomic< refCountBase * > ref_count
Reference counter object.
Definition autoPtr.h:71
void removeStrongRef() const
Decrement strong reference count.
Definition autoPtr.h:529
void swap(autoPtr &other) noexcept
Swaps the reference counters between two autoPtr instances.
Definition autoPtr.h:703
u_integer toHash() const noexcept override
Compute hash value for the pointer.
Definition autoPtr.h:735
bool expired() const
Check resource validity.
Definition autoPtr.h:608
void clean() noexcept
Cleanup resources when expired.
Definition autoPtr.h:561
u_integer weakRefs() const
Get weak reference count.
Definition autoPtr.h:594
autoPtr(TYPE *p)
Construct from raw pointer.
Definition autoPtr.h:509
virtual const TYPE & operator*() const
Const dereference operator.
Definition autoPtr.h:653
std::string toString(bool enter) const override
String representation formatter.
Definition autoPtr.h:724
const TYPE * get() const
Get managed pointer const version.
Definition autoPtr.h:629
virtual const TYPE * operator->() const
Const member access operator.
Definition autoPtr.h:662
Base class for comparable objects.
Definition comparable.h:35
Default deletion policy for single objects.
Definition deleter.h:109
static u_integer hashFunc(const T &t) noexcept
Default hash function fallback.
Forward declaration of hashable interface template.
Definition hash.h:220
Exception for null pointer dereference attempts.
Definition error.h:245
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Base class providing polymorphic string conversion capabilities.
Definition printable.h:39
Base class for reference counting metadata.
Definition autoPtr.h:377
atomic< u_integer > strong_refs
Strong reference counter.
Definition autoPtr.h:382
virtual const void * getPtr() const noexcept=0
Get managed pointer (const version)
refCountBase()
Construct refCountBase object.
Definition autoPtr.h:769
atomic< u_integer > weak_refs
Weak reference counter.
Definition autoPtr.h:383
Reference counting metadata container.
Definition autoPtr.h:441
Interface for objects that can be compared.
Platform-independent type definitions and compiler/platform detection.
Custom exception classes and callback validation utilities.
std::uint32_t u_integer
32-bit unsigned integer type for sizes and indexes
Definition config.h:263
std::int64_t integer
64-bit signed integer type for arithmetic operations
Definition config.h:254
Provides a generic hashing utility and interface for hashable types.
Main namespace for the project Original.
Definition algorithms.h:21
bool operator!=(const autoPtr< T, DER, DEL > &ptr, const std::nullptr_t &null)
Inequality comparison with nullptr.
Definition autoPtr.h:755
bool operator==(const autoPtr< T, DER, DEL > &ptr, const std::nullptr_t &null)
Equality comparison with nullptr.
Definition autoPtr.h:750
Standard namespace extensions for original::alternative.
Definition allocator.h:351
void swap(original::objPoolAllocator< TYPE > &lhs, original::objPoolAllocator< TYPE > &rhs) noexcept
Specialization of std::swap for objPoolAllocator.
Definition allocator.h:635
Interface for polymorphic string formatting and output.