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);
41 template <
class T1,
class T2>
class Pair :
public RelOP<Pair<T1, T2> >{
46 Pair(
bool commutative_ =
false) :
47 first(stlPair.first), second(stlPair.second), stlPair(), commutative(commutative_) {}
49 Pair(
const T1 &first,
const T2 &second,
bool commutative =
false) :
50 first(stlPair.first), second(stlPair.second), stlPair(first, second) {
52 this->commutative = commutative;
55 Pair(
const std::pair <T1, T2> &p,
bool commutative =
false) :
56 first(stlPair.first), second(stlPair.second), stlPair(p) {
58 this->commutative = commutative;
62 first(stlPair.first), second(stlPair.second), stlPair(other.stlPair) {
64 this->commutative = other.commutative;
67 std::pair<T1, T2> getStlPair()
const {
71 bool getCommutative()
const {
72 return this->commutative;
75 void setCommutative(
bool commutative) {
76 this->commutative = commutative;
80 this->stlPair = rhs.stlPair;
85 bool operator==(
const Pair &rhs)
const {
86 if(this->commutative || rhs.commutative) {
87 if((this->first == rhs.first && this->second == rhs.second) ||
88 (this->second == rhs.first && this->first == rhs.second))
93 return this->stlPair == rhs.stlPair;
97 bool operator<(
const Pair &rhs)
const {
98 if (this->commutative || rhs.commutative) {
99 if (this->first < this->second) {
100 if (rhs.first < rhs.second)
101 return this->first < rhs.first || (this->first == rhs.first && this->second < rhs.second);
103 return this->first < rhs.second || (this->first == rhs.second && this->second < rhs.first);
105 if (rhs.first < rhs.second)
106 return this->second < rhs.first || (this->second == rhs.first && this->first < rhs.second);
108 return this->second < rhs.second || (this->second == rhs.second && this->first < rhs.first);
111 return this->first < rhs.first || (this->first == rhs.first && this->second < rhs.second);
116 std::pair <T1, T2> stlPair;