Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

sword::Comparable< T > Class Template Reference

Mixin Inheritance base class for ordering elements. More...


Public Methods

bool operator< (const Comparable< T > &rhs) const
 '<' operation between this instance and rhs

bool operator<= (const Comparable< T > &rhs) const
 '<=' operation between this instance and rhs

bool operator> (const Comparable< T > &rhs) const
 '>' operation between this instance and rhs

bool operator>= (const Comparable< T > &rhs) const
 '>=' operation between this instance and rhs

bool operator== (const Comparable< T > &rhs) const
 '==' operation between this instance and rhs

bool operator!= (const Comparable< T > &rhs) const
 '!=' operation between this instance and rhs


Detailed Description

template<class T>
class sword::Comparable< T >

Mixin Inheritance base class for ordering elements.

This class can be used in mixin inheritance in order to quickly add an order relationship on instances of another class 'A'. The class 'A' must implement a 'compare' static method with this signature:

   // returns <0 if lhs <  rhs
   // returns  0 if lhs == rhs
   // returns >0 if lhs >  rhs
   static int compare(const A &lhs, const A &rhs);
  

You just have your 'A' class inherit from 'Comparable' and you automatically get the full set of ordering operators on your 'A' instances:

  class A : public Comparable<A> {
  public:
    ...
    static int compare(const A &lhs, const A &rhs);
  };

  A a1; A a2;
  ...
  if (a1 < a2) { / * ... * / }
  


Member Function Documentation

template<class T>
bool sword::Comparable< T >::operator!= const Comparable< T > &    rhs const
 

'!=' operation between this instance and rhs

template<class T>
bool sword::Comparable< T >::operator< const Comparable< T > &    rhs const
 

'<' operation between this instance and rhs

template<class T>
bool sword::Comparable< T >::operator<= const Comparable< T > &    rhs const
 

'<=' operation between this instance and rhs

template<class T>
bool sword::Comparable< T >::operator== const Comparable< T > &    rhs const
 

'==' operation between this instance and rhs

template<class T>
bool sword::Comparable< T >::operator> const Comparable< T > &    rhs const
 

'>' operation between this instance and rhs

template<class T>
bool sword::Comparable< T >::operator>= const Comparable< T > &    rhs const
 

'>=' operation between this instance and rhs


Generated on Tue Dec 23 20:08:57 2003 for SWORD by doxygen1.3-rc2