Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JMultiComparable< JClass_t, JTypelist_t > Struct Template Reference

Template definition of auxiliary base class for composite data structures composed of base classes with comparisons capabilities. More...

#include <JMultiComparable.hh>

Inheritance diagram for JLANG::JMultiComparable< JClass_t, JTypelist_t >:
JACOUSTICS::JEKey JDATABASE::JDateAndTime_t JDATABASE::JDatim_t JDETECTOR::JPMTAddressTranslator JDETECTOR::JPMTChannel JDETECTOR::JPMTIdentifier JDATABASE::JDateAndTimeUS_t

Static Protected Member Functions

template<class JHead_t , class JTail_t >
static bool lt (const JClass_t &first, const JClass_t &second, const JType< JTypeList< JHead_t, JTail_t > > &type)
 Less than method for composite data types.
 
template<class JHead_t >
static bool lt (const JClass_t &first, const JClass_t &second, const JType< JTypeList< JHead_t, JNullType > > &type)
 Less than method for composite data types.
 

Friends

bool operator< (const JClass_t &first, const JClass_t &second)
 Less than operator.
 
bool operator> (const JClass_t &first, const JClass_t &second)
 Greater than operator.
 
bool operator<= (const JClass_t &first, const JClass_t &second)
 Less than or equal operator.
 
bool operator>= (const JClass_t &first, const JClass_t &second)
 Greater than or equal operator.
 
bool operator== (const JClass_t &first, const JClass_t &second)
 Equal operator.
 
bool operator!= (const JClass_t &first, const JClass_t &second)
 Not equal operator.
 

Detailed Description

template<class JClass_t, class JTypelist_t>
struct JLANG::JMultiComparable< JClass_t, JTypelist_t >

Template definition of auxiliary base class for composite data structures composed of base classes with comparisons capabilities.

Each data type T in the type list should have the corresponding operator:

      bool operator<(const T&, const T& second);

This class uses in-class friend operators (see Barton-Nackman trick).

This class implements the operators < > <= >= == != .

Definition at line 32 of file JMultiComparable.hh.

Member Function Documentation

◆ lt() [1/2]

template<class JClass_t , class JTypelist_t >
template<class JHead_t , class JTail_t >
static bool JLANG::JMultiComparable< JClass_t, JTypelist_t >::lt ( const JClass_t & first,
const JClass_t & second,
const JType< JTypeList< JHead_t, JTail_t > > & type )
inlinestaticprotected

Less than method for composite data types.

Parameters
firstfirst object
secondsecond object
typetype
Returns
true if first object is less than second object; else false

Definition at line 43 of file JMultiComparable.hh.

46 {
47 if (static_cast<const JHead_t&>(first) <
48 static_cast<const JHead_t&>(second))
49 return true;
50 else if (static_cast<const JHead_t&>(second) <
51 static_cast<const JHead_t&>(first))
52 return false;
53 else
54 return lt(first, second, JType<JTail_t>());
55 }
static bool lt(const JClass_t &first, const JClass_t &second, const JType< JTypeList< JHead_t, JTail_t > > &type)
Less than method for composite data types.

◆ lt() [2/2]

template<class JClass_t , class JTypelist_t >
template<class JHead_t >
static bool JLANG::JMultiComparable< JClass_t, JTypelist_t >::lt ( const JClass_t & first,
const JClass_t & second,
const JType< JTypeList< JHead_t, JNullType > > & type )
inlinestaticprotected

Less than method for composite data types.

Parameters
firstfirst object
secondsecond object
typetype
Returns
true if first object is less than second object; else false

Definition at line 67 of file JMultiComparable.hh.

70 {
71 return (static_cast<const JHead_t&>(first) <
72 static_cast<const JHead_t&>(second));
73 }

Friends And Related Symbol Documentation

◆ operator<

template<class JClass_t , class JTypelist_t >
bool operator< ( const JClass_t & first,
const JClass_t & second )
friend

Less than operator.

Parameters
firstfirst object
secondsecond object
Returns
true if first object is less than second object; else false

Definition at line 83 of file JMultiComparable.hh.

85 {
86 return lt(first, second, JType<JTypelist_t>());
87 }

◆ operator>

template<class JClass_t , class JTypelist_t >
bool operator> ( const JClass_t & first,
const JClass_t & second )
friend

Greater than operator.

Parameters
firstfirst object
secondsecond object
Returns
true if first object is greater than second object; else false

Definition at line 97 of file JMultiComparable.hh.

99 {
100 return lt(second, first, JType<JTypelist_t>());
101 }

◆ operator<=

template<class JClass_t , class JTypelist_t >
bool operator<= ( const JClass_t & first,
const JClass_t & second )
friend

Less than or equal operator.

Parameters
firstfirst object
secondsecond object
Returns
true if first object is less than or equal to second object; else false

Definition at line 111 of file JMultiComparable.hh.

113 {
114 return !lt(second, first, JType<JTypelist_t>());
115 }

◆ operator>=

template<class JClass_t , class JTypelist_t >
bool operator>= ( const JClass_t & first,
const JClass_t & second )
friend

Greater than or equal operator.

Parameters
firstfirst object
secondsecond object
Returns
true if first object is greater than or equal to second object; else false

Definition at line 125 of file JMultiComparable.hh.

127 {
128 return !lt(first, second, JType<JTypelist_t>());
129 }

◆ operator==

template<class JClass_t , class JTypelist_t >
bool operator== ( const JClass_t & first,
const JClass_t & second )
friend

Equal operator.

Parameters
firstfirst object
secondsecond object
Returns
true if two objects are equal; else false

Definition at line 139 of file JMultiComparable.hh.

141 {
142 return (!lt(first, second, JType<JTypelist_t>()) &&
143 !lt(second, first, JType<JTypelist_t>()));
144 }

◆ operator!=

template<class JClass_t , class JTypelist_t >
bool operator!= ( const JClass_t & first,
const JClass_t & second )
friend

Not equal operator.

Parameters
firstfirst object
secondsecond object
Returns
true if two objects are not equal; else false

Definition at line 154 of file JMultiComparable.hh.

156 {
157 return (lt(first, second, JType<JTypelist_t>()) ||
158 lt(second, first, JType<JTypelist_t>()));
159 }

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