ORIGINAL
Loading...
Searching...
No Matches
original::comparable< DERIVED > Class Template Referenceabstract

Base class for comparable objects. More...

#include <comparable.h>

Collaboration diagram for original::comparable< DERIVED >:
Collaboration graph

Public Member Functions

virtual integer compareTo (const DERIVED &other) const =0
 Compares the current object with another of the same type.
 
bool operator== (const DERIVED &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const DERIVED &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const DERIVED &other) const
 Checks if the current object is less than another.
 
bool operator> (const DERIVED &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const DERIVED &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const DERIVED &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.
 

Friends

template<typename EXTENDED>
std::strong_ordering operator<=> (const EXTENDED &lc, const EXTENDED &rc)
 Three-way comparison operator (<=>), returns an ordered comparison result.
 

Detailed Description

template<typename DERIVED>
class original::comparable< DERIVED >

Base class for comparable objects.

Template Parameters
DERIVEDThe type of the derived class.

This class defines a compareTo() method that must be implemented by derived classes to compare their instances. It also provides common comparison operators (==, !=, <, >, <=, >=) based on the compareTo() method.

Derived classes are expected to override compareTo() to return:

  • A negative value if the current object is less than the other.
  • Zero if the current object is equal to the other.
  • A positive value if the current object is greater than the other.

Member Function Documentation

◆ compareTo()

template<typename DERIVED>
virtual integer original::comparable< DERIVED >::compareTo ( const DERIVED & other) const
pure virtual

Compares the current object with another of the same type.

Parameters
otherThe object to compare against.
Returns
A negative value if less than, zero if equal, and positive if greater than.

Implemented in original::containerAdapter< TYPE, SERIAL, ALLOC >, original::couple< F_TYPE, S_TYPE >, and original::iterator< TYPE >.

◆ operator!=()

template<typename DERIVED>
auto original::comparable< DERIVED >::operator!= ( const DERIVED & other) const

Checks if the current object is not equal to another.

Parameters
otherThe object to compare against.
Returns
True if not equal, otherwise false.

◆ operator<()

template<typename DERIVED>
auto original::comparable< DERIVED >::operator< ( const DERIVED & other) const

Checks if the current object is less than another.

Parameters
otherThe object to compare against.
Returns
True if less than, otherwise false.

◆ operator<=()

template<typename DERIVED>
auto original::comparable< DERIVED >::operator<= ( const DERIVED & other) const

Checks if the current object is less than or equal to another.

Parameters
otherThe object to compare against.
Returns
True if less than or equal, otherwise false.

◆ operator==()

template<typename DERIVED>
auto original::comparable< DERIVED >::operator== ( const DERIVED & other) const

Checks if the current object is equal to another.

Parameters
otherThe object to compare against.
Returns
True if equal, otherwise false.

◆ operator>()

template<typename DERIVED>
auto original::comparable< DERIVED >::operator> ( const DERIVED & other) const

Checks if the current object is greater than another.

Parameters
otherThe object to compare against.
Returns
True if greater than, otherwise false.

◆ operator>=()

template<typename DERIVED>
auto original::comparable< DERIVED >::operator>= ( const DERIVED & other) const

Checks if the current object is greater than or equal to another.

Parameters
otherThe object to compare against.
Returns
True if greater than or equal, otherwise false.

Friends And Related Symbol Documentation

◆ operator<=>

template<typename DERIVED>
template<typename EXTENDED>
std::strong_ordering operator<=> ( const EXTENDED & lc,
const EXTENDED & rc )
friend

Three-way comparison operator (<=>), returns an ordered comparison result.

This operator is implemented by invoking the compareTo() method of the comparable object. The result type is std::strong_ordering, indicating strong ordering semantics. Defined as a friend function to enable symmetric argument handling.

Template Parameters
EXTENDEDThe actual derived type using CRTP pattern.
Parameters
lcLeft-hand side comparable object
rcRight-hand side comparable object
Returns
std::strong_ordering
  • std::strong_ordering::less if lhs < rhs
  • std::strong_ordering::equal if lhs == rhs
  • std::strong_ordering::greater if lhs > rhs

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