Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Static Protected Member Functions | Friends | List of all members
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>

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. More...
 
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. More...
 

Friends

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

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 X in the type list should have the corresponding operator:

      bool operator<(const X&, const X& 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

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  }
Auxiliary class for a type holder.
Definition: JType.hh:19
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 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 Function Documentation

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  }
Auxiliary class for a type holder.
Definition: JType.hh:19
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 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  }
Auxiliary class for a type holder.
Definition: JType.hh:19
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 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  }
Auxiliary class for a type holder.
Definition: JType.hh:19
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 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  }
Auxiliary class for a type holder.
Definition: JType.hh:19
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 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  }
Auxiliary class for a type holder.
Definition: JType.hh:19
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 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  }
Auxiliary class for a type holder.
Definition: JType.hh:19
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.

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