ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
original::ownerPtr< TYPE, DELETER > Class Template Referencefinal

Unique ownership smart pointer with move semantics. More...

#include <ownerPtr.h>

Inheritance diagram for original::ownerPtr< TYPE, DELETER >:
Inheritance graph
Collaboration diagram for original::ownerPtr< TYPE, DELETER >:
Collaboration graph

Public Member Functions

 ownerPtr (TYPE *p=std::nullptr_t{})
 Construct from raw pointer.
 
 ownerPtr (const ownerPtr &other)=delete
 Copy construction prohibited.
 
ownerPtroperator= (const ownerPtr &other)=delete
 Copy assignment prohibited.
 
 ownerPtr (ownerPtr &&other) noexcept
 Move constructor.
 
ownerPtroperator= (ownerPtr &&other) noexcept
 Move assignment operator.
 
template<typename U , typename DEL = DELETER::template rebound_deleter<U>>
ownerPtr< U, DELstaticCastMoveTo ()
 Performs static cast and transfers ownership.
 
template<typename U , typename DEL = DELETER::template rebound_deleter<U>>
ownerPtr< U, DELdynamicCastMoveTo ()
 Performs dynamic cast and transfers ownership.
 
template<typename U , typename DEL = DELETER::template rebound_deleter<U>>
ownerPtr< U, DELconstCastMoveTo ()
 Performs const cast and transfers ownership.
 
TYPEunlock ()
 Release ownership of managed object.
 
std::string className () const override
 Get class name identifier.
 
 ~ownerPtr () override
 Destructor releases owned resources.
 
- Public Member Functions inherited from original::autoPtr< TYPE, DERIVED, DELETER >
u_integer strongRefs () const
 Get strong reference count.
 
u_integer weakRefs () const
 Get weak reference count.
 
bool exist () const
 Check active ownership.
 
bool expired () const
 Check resource validity.
 
 operator bool () const
 Boolean conversion operator.
 
bool operator! () const
 Logical NOT operator.
 
const TYPEget () const
 Get managed pointer const version.
 
TYPEget ()
 Get managed pointer.
 
virtual const TYPEoperator* () const
 Const dereference operator.
 
virtual const TYPEoperator-> () const
 Const member access operator.
 
virtual const TYPEoperator[] (u_integer index) const
 Const array access operator.
 
virtual TYPEoperator* ()
 Mutable dereference operator.
 
virtual TYPEoperator-> ()
 Mutable member access operator.
 
virtual TYPEoperator[] (u_integer index)
 Mutable array access operator.
 
void swap (autoPtr &other) noexcept
 Swaps the reference counters between two autoPtr instances.
 
integer compareTo (const autoPtr &other) const override
 Compare reference counters.
 
std::string toString (bool enter) const override
 String representation formatter.
 
u_integer toHash () const noexcept override
 Compute hash value for the pointer.
 
bool equals (const autoPtr &other) const noexcept override
 Equality comparison.
 
 ~autoPtr () override
 Destructor triggers reference cleanup.
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const chartoCString (bool enter) const
 Direct C-string access with formatting control.
 
template<typename TYPE >
auto formatString (const TYPE &t) -> std::string
 
template<typename TYPE >
auto formatCString (const TYPE &t) -> const char *
 
template<typename TYPE >
auto formatEnum (const TYPE &t) -> std::string
 
template<typename TYPE >
auto formatString (TYPE *const &ptr) -> std::string
 
- Public Member Functions inherited from original::comparable< autoPtr< TYPE, DERIVED, DELETER > >
bool operator== (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is less than another.
 
bool operator> (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const autoPtr< TYPE, DERIVED, DELETER > &other) const
 Checks if the current object is greater than or equal to another.
 
virtual ~comparable ()=default
 Virtual destructor for proper cleanup of derived objects.
 
- Public Member Functions inherited from original::hashable< autoPtr< TYPE, DERIVED, DELETER > >
virtual bool equals (const autoPtr< TYPE, DERIVED, DELETER > &other) const noexcept
 Compares two objects for equality.
 
virtual ~hashable ()=0
 Virtual destructor.
 

Friends

template<typename T , typename DEL , typename... Args>
ownerPtr< T, DELmakeOwnerPtr (Args &&... args)
 Creates a new ownerPtr managing a dynamically allocated object.
 
template<typename T , typename DEL , typename... Args>
ownerPtr< T, DELmakeOwnerPtrArray (u_integer size, Args &&... args)
 Creates a new ownerPtr managing a dynamically allocated array.
 

Additional Inherited Members

- Static Public Member Functions inherited from original::printable
template<typename TYPE >
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion with type-specific formatting.
 
template<Printable TYPE>
static std::string formatString (const TYPE &t)
 Specialization for types deriving from printable.
 
template<EnumType TYPE>
static std::string formatString (const TYPE &t)
 Specialization for enum types with type-safe formatting.
 
template<typename TYPE >
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting with null safety.
 
template<typename TYPE >
static const charformatCString (const TYPE &t)
 C-string cache for temporary usage with static storage.
 
template<typename TYPE >
static std::string formatEnum (const TYPE &t)
 Enum formatting utility with underlying value extraction.
 
template<>
auto formatString (const char &t) -> std::string
 
template<>
auto formatString (const bool &t) -> std::string
 
template<>
auto formatString (const char *const &ptr) -> std::string
 
- Protected Member Functions inherited from original::autoPtr< TYPE, DERIVED, DELETER >
 autoPtr (TYPE *p)
 Construct from raw pointer.
 
void addStrongRef () const
 Increment strong reference count.
 
void addWeakRef () const
 Increment weak reference count.
 
void removeStrongRef () const
 Decrement strong reference count.
 
void removeWeakRef () const
 Decrement weak reference count.
 
TYPEreleasePtr () noexcept
 Release ownership of the managed pointer.
 
void destroyRefCnt () noexcept
 Destroy reference counter.
 
void clean () noexcept
 Cleanup resources when expired.
 
- Static Protected Member Functions inherited from original::autoPtr< TYPE, DERIVED, DELETER >
static refCount< TYPE, DELETER > * newRefCount (TYPE *p=nullptr)
 Create new reference counter.
 
- Protected Attributes inherited from original::autoPtr< TYPE, DERIVED, DELETER >
atomic< refCountBase * > ref_count
 Reference counter object.
 
TYPEalias_ptr
 Aliased pointer for type casting scenarios.
 

Detailed Description

template<typename TYPE, typename DELETER = deleter<TYPE>>
class original::ownerPtr< TYPE, DELETER >

Unique ownership smart pointer with move semantics.

Template Parameters
TYPEManaged object type
DELETERDeletion policy type (default: deleter<TYPE>)

Key features:

Examples
/home/runner/work/original/original/src/core/singleton.h, /home/runner/work/original/original/src/core/tuple.h, and /home/runner/work/original/original/src/core/vector.h.

Constructor & Destructor Documentation

◆ ownerPtr() [1/2]

template<typename TYPE , typename DELETER >
original::ownerPtr< TYPE, DELETER >::ownerPtr ( TYPE p = std::nullptr_t{})
explicit

Construct from raw pointer.

Parameters
pPointer to take ownership of
Warning
Transfers ownership responsibility to ownerPtr

◆ ownerPtr() [2/2]

template<typename TYPE , typename DELETER >
original::ownerPtr< TYPE, DELETER >::ownerPtr ( ownerPtr< TYPE, DELETER > &&  other)
noexcept

Move constructor.

Parameters
otherSource ownerPtr to transfer ownership from
Postcondition
other becomes empty

Member Function Documentation

◆ className()

template<typename TYPE , typename DELETER >
std::string original::ownerPtr< TYPE, DELETER >::className ( ) const
overridevirtual

Get class name identifier.

Returns
Class name of ownerPtr

Reimplemented from original::autoPtr< TYPE, DERIVED, DELETER >.

◆ constCastMoveTo()

template<typename TYPE , typename DELETER >
template<typename U , typename DEL >
ownerPtr< U, DEL > original::ownerPtr< TYPE, DELETER >::constCastMoveTo ( )

Performs const cast and transfers ownership.

Template Parameters
UTarget type for const cast
DELRebound deleter type for target type
Returns
ownerPtr<U, DEL> with ownership transferred
Note
Uses const_cast for type conversion

◆ dynamicCastMoveTo()

template<typename TYPE , typename DELETER >
template<typename U , typename DEL >
ownerPtr< U, DEL > original::ownerPtr< TYPE, DELETER >::dynamicCastMoveTo ( )

Performs dynamic cast and transfers ownership.

Template Parameters
UTarget type for dynamic cast
DELRebound deleter type for target type
Returns
ownerPtr<U, DEL> with ownership transferred if cast succeeds, empty ownerPtr otherwise
Note
Uses dynamic_cast for type conversion, returns empty pointer if cast fails

◆ operator=()

template<typename TYPE , typename DELETER >
ownerPtr< TYPE, DELETER > & original::ownerPtr< TYPE, DELETER >::operator= ( ownerPtr< TYPE, DELETER > &&  other)
noexcept

Move assignment operator.

Parameters
otherSource ownerPtr to transfer ownership from
Returns
Reference to this ownerPtr
Postcondition
other becomes empty

◆ staticCastMoveTo()

template<typename TYPE , typename DELETER >
template<typename U , typename DEL >
ownerPtr< U, DEL > original::ownerPtr< TYPE, DELETER >::staticCastMoveTo ( )

Performs static cast and transfers ownership.

Template Parameters
UTarget type for static cast
DELRebound deleter type for target type
Returns
ownerPtr<U, DEL> with ownership transferred
Note
Uses static_cast for type conversion

◆ unlock()

template<typename TYPE , typename DELETER >
TYPE * original::ownerPtr< TYPE, DELETER >::unlock ( )

Release ownership of managed object.

Returns
Raw pointer to released resource
Postcondition
ownerPtr no longer manages the resource
Warning
Caller assumes ownership responsibility

Friends And Related Symbol Documentation

◆ makeOwnerPtr

template<typename TYPE , typename DELETER = deleter<TYPE>>
template<typename T , typename DEL , typename... Args>
ownerPtr< T, DEL > makeOwnerPtr ( Args &&...  args)
friend

Creates a new ownerPtr managing a dynamically allocated object.

Template Parameters
TType of object to create and manage
DELDeleter policy type (default: deleter<T>)
ArgsArgument types for object construction
Parameters
argsArguments to forward to T's constructor
Returns
ownerPtr<T, DEL> owning the newly created object
Note
Provides exception-safe object creation
Warning
The returned ownerPtr has exclusive ownership of the object
// Create an ownerPtr managing a new MyClass constructed with args
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37

◆ makeOwnerPtrArray

template<typename TYPE , typename DELETER = deleter<TYPE>>
template<typename T , typename DEL , typename... Args>
ownerPtr< T, DEL > makeOwnerPtrArray ( u_integer  size,
Args &&...  args 
)
friend

Creates a new ownerPtr managing a dynamically allocated array.

Template Parameters
TType of array elements to create
DELDeleter policy type (default: deleter<T[]>)
ArgsArgument types for array element initialization
Parameters
sizeNumber of elements in the array
argsArguments to forward to each element's constructor
Returns
ownerPtr<T, DEL> owning the newly created array
Note
Provides exception-safe array creation
Warning
The returned ownerPtr has exclusive ownership of the array
// Create an ownerPtr managing a new MyClass[10] array

The documentation for this class was generated from the following file: