ORIGINAL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
original::couple< F_TYPE, S_TYPE > Class Template Referencefinal

Container for two heterogeneous elements. More...

#include <couple.h>

Inheritance diagram for original::couple< F_TYPE, S_TYPE >:
Inheritance graph
Collaboration diagram for original::couple< F_TYPE, S_TYPE >:
Collaboration graph

Public Member Functions

 couple ()
 Default constructs both elements.
 
 couple (F_TYPE *first, S_TYPE *second)
 Constructs from pointer elements.
 
 couple (const F_TYPE &first, const S_TYPE &second)
 Constructs from element copies.
 
 couple (F_TYPE &&first, S_TYPE &&second)
 Constructs from rvalue references.
 
 couple (const couple &other)
 Copy constructor.
 
coupleoperator= (const couple &other)
 Copy assignment operator.
 
 couple (couple &&other) noexcept
 Move constructor.
 
coupleoperator= (couple &&other) noexcept
 Move assignment operator.
 
void swap (couple &other) noexcept
 Swaps the contents of this couple with another.
 
template<u_integer IDX>
autoget ()
 Element access template method (non-const version)
 
template<u_integer IDX>
const autoget () const
 Element access template method (const version)
 
template<u_integer IDX, typename T >
coupleset (const T &e)
 Element modification template method.
 
integer compareTo (const couple &other) const override
 Lexicographical comparison operation.
 
F_TYPEfirst ()
 Access first element.
 
S_TYPEsecond ()
 Access second element.
 
const F_TYPEfirst () const
 Access first element (const version)
 
const S_TYPEsecond () const
 Access second element (const version)
 
 ~couple () override
 Default destructor.
 
std::string className () const override
 Gets class name identifier.
 
std::string toString (bool enter) const override
 Formats pair elements as string.
 
template<original::u_integer IDX, typename T >
original::couple< F_TYPE, S_TYPE > & set (const T &e)
 
- 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< couple< F_TYPE, S_TYPE > >
bool operator== (const couple< F_TYPE, S_TYPE > &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const couple< F_TYPE, S_TYPE > &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const couple< F_TYPE, S_TYPE > &other) const
 Checks if the current object is less than another.
 
bool operator> (const couple< F_TYPE, S_TYPE > &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const couple< F_TYPE, S_TYPE > &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const couple< F_TYPE, S_TYPE > &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.
 

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
 

Detailed Description

template<typename F_TYPE, typename S_TYPE>
class original::couple< F_TYPE, S_TYPE >

Container for two heterogeneous elements.

Template Parameters
F_TYPEType of the first element
S_TYPEType of the second element

Stores a pair of elements with type safety. Provides:

Usage Examples

// Basic construction
// Element access
c1.first() = 100;
c1.second() = "world";
// Template-based element access
auto& first = c1.get<0>();
auto& second = c1.get<1>();
// Structured binding support
auto [x, y] = c1;
const TYPE * get() const
Get managed pointer const version.
Definition autoPtr.h:629
F_TYPE & first()
Access first element.
Definition couple.h:379
S_TYPE & second()
Access second element.
Definition couple.h:385
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37

Constructor & Destructor Documentation

◆ couple() [1/5]

original::couple< F_TYPE, S_TYPE >::couple ( F_TYPE first,
S_TYPE second 
)

Constructs from pointer elements.

Parameters
firstPointer to first element
secondPointer to second element

◆ couple() [2/5]

original::couple< F_TYPE, S_TYPE >::couple ( const F_TYPE first,
const S_TYPE second 
)

Constructs from element copies.

Parameters
firstFirst element to copy
secondSecond element to copy

◆ couple() [3/5]

original::couple< F_TYPE, S_TYPE >::couple ( F_TYPE &&  first,
S_TYPE &&  second 
)

Constructs from rvalue references.

Parameters
firstFirst element to move
secondSecond element to move

◆ couple() [4/5]

original::couple< F_TYPE, S_TYPE >::couple ( const couple< F_TYPE, S_TYPE > &  other)

Copy constructor.

Parameters
othercouple to copy from

◆ couple() [5/5]

original::couple< F_TYPE, S_TYPE >::couple ( couple< F_TYPE, S_TYPE > &&  other)
noexcept

Move constructor.

Parameters
othercouple to move from
Note
noexcept qualified for compatibility with STL containers

Member Function Documentation

◆ className()

auto original::couple< F_TYPE, S_TYPE >::className ( ) const
overridevirtual

Gets class name identifier.

Returns
"couple" string constant

Reimplemented from original::printable.

◆ compareTo()

auto original::couple< F_TYPE, S_TYPE >::compareTo ( const couple< F_TYPE, S_TYPE > &  other) const
overridevirtual

Lexicographical comparison operation.

Parameters
othercouple to compare with
Returns
integer Negative if less, positive if greater, zero if equal

Compares first elements first, then second elements if firsts are equal

Implements original::comparable< couple< F_TYPE, S_TYPE > >.

◆ first() [1/2]

Access first element.

Returns
Mutable reference to first element

◆ first() [2/2]

const F_TYPE & original::couple< F_TYPE, S_TYPE >::first ( ) const

Access first element (const version)

Returns
Mutable reference to first element

◆ get() [1/2]

Element access template method (non-const version)

Template Parameters
IDXelement index (0=1st element, 1=2nd element)
Returns
Reference to the corresponding element
Exceptions
outOfBoundErrorif IDX > 1
Note
For non-const objects, returns a mutable reference

◆ get() [2/2]

template<original::u_integer IDX>
const auto & original::couple< F_TYPE, S_TYPE >::get ( ) const

Element access template method (const version)

Template Parameters
IDXelement index (0=1st element, 1=2nd element)
Returns
Const reference to the corresponding element
Exceptions
outOfBoundErrorif IDX > 1
Note
For const objects, returns a read-only reference

◆ operator=() [1/2]

auto original::couple< F_TYPE, S_TYPE >::operator= ( const couple< F_TYPE, S_TYPE > &  other)

Copy assignment operator.

Parameters
othercouple to copy from
Returns
Reference to this object

◆ operator=() [2/2]

original::couple< F_TYPE, S_TYPE > & original::couple< F_TYPE, S_TYPE >::operator= ( couple< F_TYPE, S_TYPE > &&  other)
noexcept

Move assignment operator.

Parameters
othercouple to move from
Returns
Reference to this object
Note
noexcept qualified for compatibility with STL containers

◆ second() [1/2]

Access second element.

Returns
Mutable reference to second element

◆ second() [2/2]

const S_TYPE & original::couple< F_TYPE, S_TYPE >::second ( ) const

Access second element (const version)

Returns
Mutable reference to second element

◆ set()

template<u_integer IDX, typename T >
couple & original::couple< F_TYPE, S_TYPE >::set ( const T &  e)

Element modification template method.

Template Parameters
IDXelement index (0=1st element, 1=2nd element)
TElement type (auto-derivation)
Parameters
enew element value
Returns
Reference to this object for method chaining
Exceptions
valueErrorif type conversion fails

◆ swap()

void original::couple< F_TYPE, S_TYPE >::swap ( couple< F_TYPE, S_TYPE > &  other)
noexcept

Swaps the contents of this couple with another.

Parameters
otherThe couple to swap with

◆ toString()

auto original::couple< F_TYPE, S_TYPE >::toString ( bool  enter) const
overridevirtual

Formats pair elements as string.

Parameters
enterAdd newline at end if true
Returns
Formatted string "(first: value, second: value)"

Reimplemented from original::printable.


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