13 RelOP() : derived(*static_cast<const D*>(
this)) {}
14 bool operator!=(
const D &rhs)
const {
15 return !(derived == rhs);
18 bool operator<=(
const D &rhs)
const {
19 return derived < rhs || derived == rhs;
22 bool operator>(
const D &rhs)
const {
23 return !(derived < rhs) && !(derived == rhs);
26 bool operator>=(
const D &rhs)
const {
27 return !(derived > rhs);
42 template <
class T1,
class T2>
class Pair :
public RelOP<Pair<T1, T2> >{
47 Pair(
bool commutative_ =
false) :
48 first(stlPair.first), second(stlPair.second), stlPair(),
49 commutative(commutative_) {}
51 Pair(
const T1 &first_,
const T2 &second_,
bool commutative_ =
false) :
52 first(stlPair.first), second(stlPair.second), stlPair(first_, second_),
53 commutative(commutative_) {}
55 Pair(
const std::pair <T1, T2> &p,
bool commutative_ =
false) :
56 first(stlPair.first), second(stlPair.second), stlPair(p),
57 commutative(commutative_) {}
60 first(stlPair.first), second(stlPair.second), stlPair(other.stlPair),
61 commutative(other.commutative) {}
63 std::pair<T1, T2> getStlPair()
const {
67 bool getCommutative()
const {
68 return this->commutative;
71 void setCommutative(
bool commutative_) {
72 this->commutative = commutative_;
76 this->stlPair = rhs.stlPair;
81 bool operator==(
const Pair &rhs)
const {
82 if(this->commutative || rhs.commutative) {
83 if((this->first == rhs.first && this->second == rhs.second) ||
84 (this->second == rhs.first && this->first == rhs.second))
89 return this->stlPair == rhs.stlPair;
95 bool operator<(
const Pair &rhs)
const {
96 if (this->commutative || rhs.commutative) {
97 if (this->first < this->second) {
98 if (rhs.first < rhs.second)
99 return this->first < rhs.first || (this->first == rhs.first && this->second < rhs.second);
101 return this->first < rhs.second || (this->first == rhs.second && this->second < rhs.first);
103 if (rhs.first < rhs.second)
104 return this->second < rhs.first || (this->second == rhs.first && this->first < rhs.second);
106 return this->second < rhs.second || (this->second == rhs.second && this->first < rhs.first);
109 return this->first < rhs.first || (this->first == rhs.first && this->second < rhs.second);
114 std::pair <T1, T2> stlPair;