30 template<
typename TYPE,
typename DERIVED,
typename DELETER>
40 using autoPtr<TYPE, DERIVED, DELETER>::operator==;
41 using autoPtr<TYPE, DERIVED, DELETER>::operator!=;
49 template<
typename O_DERIVED>
58 template<
typename O_DERIVED>
65 [[nodiscard]] std::string
className()
const override;
72 [[nodiscard]] std::string
toString(
bool enter)
const override;
80 template<
typename TYPE,
typename DELETER = deleter<TYPE>>
83 template<
typename TYPE,
typename DELETER = deleter<TYPE>>
99 template<
typename TYPE,
typename DELETER>
101 friend class weakPtr<TYPE, DELETER>;
160 template <typename T, typename DEL, typename... Args>
163 template <typename T, typename DEL, typename... Args>
178 template<typename TYPE, typename DELETER>
300 [[nodiscard]] std::string
className()
const override;
326 template <
typename T,
typename DEL = deleter<T>,
typename... Args>
345 template <
typename T,
typename DEL = deleter<T[]>,
typename... Args>
352 template<
typename TYPE,
typename DERIVED,
typename DELETER>
356 template<
typename TYPE,
typename DERIVED,
typename DELETER>
357 template<
typename O_DERIVED>
359 return this->get() == other.
get();
362 template<
typename TYPE,
typename DERIVED,
typename DELETER>
363 template<
typename O_DERIVED>
365 return this->get() != other.
get();
368 template<
typename TYPE,
typename DERIVED,
typename DELETER>
373 template<
typename TYPE,
typename DERIVED,
typename DELETER>
375 std::stringstream ss;
376 ss << this->className() <<
"(";
378 ss <<
"strong ref: " << this->strongRefs() <<
", " <<
"weak ref: " << this->weakRefs();
385 template<
typename TYPE,
typename DELETER>
391 template<
typename TYPE,
typename DELETER>
396 template<
typename TYPE,
typename DELETER>
398 if (
this == &other || *
this == other)
401 this->removeStrongRef();
404 this->addStrongRef();
408 template<
typename TYPE,
typename DELETER>
410 this->operator=(std::move(other));
413 template<
typename TYPE,
typename DELETER>
415 this->removeStrongRef();
418 this->addStrongRef();
421 template<
typename TYPE,
typename DELETER>
423 if (
this == &other || *
this == other)
426 this->removeStrongRef();
428 this->ref_count = other.ref_count;
430 other.addStrongRef();
434 template<
typename TYPE,
typename DELETER>
439 template<
typename TYPE,
typename DELETER>
441 this->removeStrongRef();
444 template<
typename T,
typename DEL,
typename ... Args>
449 template<
typename T,
typename DEL,
typename ... Args>
454 strong_ptr[i] = T(std::forward<Args>(args)...);
459 template<
typename TYPE,
typename DELETER>
465 template<
typename TYPE,
typename DELETER>
471 template<
typename TYPE,
typename DELETER>
476 this->removeWeakRef();
483 template<
typename TYPE,
typename DELETER>
489 template<
typename TYPE,
typename DELETER>
491 if (
this == &other || *
this == other)
494 this->removeWeakRef();
501 template<
typename TYPE,
typename DELETER>
503 this->operator=(std::move(other));
506 template<
typename TYPE,
typename DELETER>
508 if (
this == &other || *
this == other)
511 this->removeWeakRef();
513 this->ref_count = other.ref_count;
519 template<
typename TYPE,
typename DELETER>
522 if (!this->expired()){
531 template<
typename TYPE,
typename DELETER>
533 return this->lock().operator*();
536 template<
typename TYPE,
typename DELETER>
538 return this->lock().operator->();
541 template<
typename TYPE,
typename DELETER>
543 return this->lock().operator[](index);
546 template<
typename TYPE,
typename DELETER>
548 return this->lock().operator*();
551 template<
typename TYPE,
typename DELETER>
553 return this->lock().operator->();
556 template<
typename TYPE,
typename DELETER>
558 return this->lock().operator[](index);
561 template<
typename TYPE,
typename DELETER>
566 template<
typename TYPE,
typename DELETER>
568 this->removeWeakRef();
Base class for reference-counted smart pointers.
Base smart pointer with reference counting.
Definition autoPtr.h:41
static refCount< TYPE, DELETER > * newRefCount(TYPE *p=nullptr)
Create new reference counter.
Definition autoPtr.h:386
void removeStrongRef()
Decrement strong reference count.
Definition autoPtr.h:360
virtual const TYPE & operator[](u_integer index) const
Const array access operator.
Definition autoPtr.h:450
void addStrongRef()
Increment strong reference count.
Definition autoPtr.h:350
void addWeakRef()
Increment weak reference count.
Definition autoPtr.h:355
void clean() noexcept
Cleanup resources when expired.
Definition autoPtr.h:376
friend bool operator!=(const autoPtr< T, DER, DEL > &ptr, const std::nullptr_t &null)
Inequality comparison with nullptr.
refCount< TYPE, DELETER > * ref_count
Reference counter object.
Definition autoPtr.h:43
virtual const TYPE & operator*() const
Const dereference operator.
Definition autoPtr.h:433
const TYPE * get() const
Get managed pointer const version.
Definition autoPtr.h:417
virtual const TYPE * operator->() const
Const member access operator.
Definition autoPtr.h:442
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.
Base class for reference-counted pointers.
Definition refCntPtr.h:31
std::string className() const override
Get class identifier.
Definition refCntPtr.h:369
std::string toString(bool enter) const override
Formatted string with reference info.
Definition refCntPtr.h:374
bool operator!=(const refCntPtr< TYPE, O_DERIVED, DELETER > &other) const
Inequality comparison operator.
Definition refCntPtr.h:364
bool operator==(const refCntPtr< TYPE, O_DERIVED, DELETER > &other) const
Equality comparison operator.
Definition refCntPtr.h:358
~refCntPtr() override=default
Default destructor of refCntPtr.
refCntPtr(TYPE *p=std::nullptr_t{})
Construct from raw pointer.
Definition refCntPtr.h:353
Shared ownership smart pointer with strong references.
Definition refCntPtr.h:100
strongPtr(strongPtr &&other) noexcept
Move constructor transfers ownership.
Definition refCntPtr.h:409
void reset() noexcept
Resets the smart pointer and releases the managed object.
Definition refCntPtr.h:414
std::string className() const override
Get class identifier.
Definition refCntPtr.h:435
friend strongPtr< T, DEL > makeStrongPtr(Args &&... args)
Creates a new strongPtr managing a shared object.
Definition refCntPtr.h:445
strongPtr & operator=(const strongPtr &other)
Copy assignment shares ownership.
Definition refCntPtr.h:397
strongPtr(TYPE *p=std::nullptr_t{})
Construct from raw pointer.
Definition refCntPtr.h:386
friend strongPtr< T, DEL > makeStrongPtrArray(u_integer size, Args &&... args)
Creates a new strongPtr managing a shared array.
Definition refCntPtr.h:450
~strongPtr() override
Destructor decreases strong references count.
Definition refCntPtr.h:440
strongPtr(const strongPtr &other)
Copy constructor shares ownership.
Definition refCntPtr.h:392
Non-owning reference to shared resource.
Definition refCntPtr.h:179
const TYPE & operator*() const override
Const dereference via temporary strong reference.
Definition refCntPtr.h:532
std::string className() const override
Get class type identifier.
Definition refCntPtr.h:562
strongPtr< TYPE, DELETER > lock() const
Attempt to acquire ownership.
Definition refCntPtr.h:520
weakPtr & operator=(const strongPtr< TYPE, DELETER > &other)
Assign observation from strongPtr.
Definition refCntPtr.h:472
~weakPtr() override
Destructor releases weak reference.
Definition refCntPtr.h:567
const TYPE & operator[](u_integer index) const override
Const array element access via temporary strong reference.
Definition refCntPtr.h:542
const TYPE * operator->() const override
Const member access via temporary strong reference.
Definition refCntPtr.h:537
weakPtr()
Initialize empty weak reference.
Definition refCntPtr.h:460
Default deleters for resource management.
Main namespace for the project Original.
Definition algorithms.h:21
std::uint32_t u_integer
32-bit unsigned integer type for sizes and indexes
Definition config.h:43
strongPtr< T, DEL > makeStrongPtrArray(u_integer size, Args &&... args)
Creates a new strongPtr managing a shared array.
Definition refCntPtr.h:450
strongPtr< T, DEL > makeStrongPtr(Args &&... args)
Creates a new strongPtr managing a shared object.
Definition refCntPtr.h:445