-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.hpp
53 lines (42 loc) · 1.22 KB
/
utility.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
namespace ft {
template <class T1, class T2>
struct pair {
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair() : first(T1()), second(T2()) {}
pair(const T1 &x, const T2 &y) : first(x), second(y) {}
template <class U, class V>
pair(const pair<U, V> &p) : first(p.first), second(p.second) {}
};
template <class T1, class T2>
bool operator==(const pair<T1, T2> &x, const pair<T1, T2> &y) {
return x.first == y.first && x.second == y.second;
}
template <class T1, class T2>
bool operator!=(const pair<T1, T2> &x, const pair<T1, T2> &y) {
return !(x == y);
}
template <class T1, class T2>
bool operator<(const pair<T1, T2> &x, const pair<T1, T2> &y) {
return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
}
template <class T1, class T2>
bool operator>(const pair<T1, T2> &x, const pair<T1, T2> &y) {
return y < x;
}
template <class T1, class T2>
bool operator<=(const pair<T1, T2> &x, const pair<T1, T2> &y) {
return !(y < x);
}
template <class T1, class T2>
bool operator>=(const pair<T1, T2> &x, const pair<T1, T2> &y) {
return !(x < y);
}
template <class T1, class T2>
pair<T1, T2> make_pair(T1 x, T2 y) {
return pair<T1, T2>(x, y);
}
} // namespace ft