#pragma once
|
|
#include "gp/algorithm/move.hpp"
|
|
|
|
namespace gp{
|
|
template<typename T1, typename T2>
|
|
struct pair{
|
|
T1 first;
|
|
T2 second;
|
|
|
|
pair() : first(), second() {}
|
|
|
|
pair(const T1& a, const T2& b) : first(a), second(b) {}
|
|
|
|
pair(pair&& v)
|
|
: first(gp::move(v.first))
|
|
, second(gp::move(v.second))
|
|
{}
|
|
|
|
template<typename U1, typename U2>
|
|
pair(U1&& a, U2&& b)
|
|
: first(gp::forward<U1>(a))
|
|
, second(gp::forward<U2>(b))
|
|
{}
|
|
|
|
template<typename U1, typename U2>
|
|
pair(pair<U1, U2>&& v)
|
|
: first(gp::move(v.first))
|
|
, second(gp::move(v.second))
|
|
{}
|
|
|
|
pair& operator=(pair&& v)
|
|
{
|
|
first = gp::move(v.first);
|
|
second = gp::move(v.second);
|
|
return *this;
|
|
}
|
|
|
|
bool operator==(const pair& rhs) {
|
|
return first == rhs.first and second == rhs.second;
|
|
}
|
|
|
|
bool operator!=(const pair& rhs) {
|
|
return first != rhs.first or second != rhs.second;
|
|
}
|
|
|
|
bool operator<=(const pair& rhs) {
|
|
if(first > rhs.first) {
|
|
return false;
|
|
} else if(first == rhs.first) {
|
|
return second <= rhs.second;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool operator>=(const pair& rhs) {
|
|
if(first < rhs.first) {
|
|
return false;
|
|
} else if(first == rhs.first) {
|
|
return second >= rhs.second;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool operator<(const pair& rhs) {
|
|
return !(*this >= rhs);
|
|
}
|
|
|
|
bool operator>(const pair& rhs) {
|
|
return !(*this <= rhs);
|
|
}
|
|
};
|
|
}
|