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 | |
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) { / * ... * / }
|
||||||||||
|
'!=' operation between this instance and rhs
|
|
||||||||||
|
'<' operation between this instance and rhs
|
|
||||||||||
|
'<=' operation between this instance and rhs
|
|
||||||||||
|
'==' operation between this instance and rhs
|
|
||||||||||
|
'>' operation between this instance and rhs
|
|
||||||||||
|
'>=' operation between this instance and rhs
|
1.3-rc2