-
Notifications
You must be signed in to change notification settings - Fork 0
/
pair.hpp
88 lines (71 loc) · 2.45 KB
/
pair.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pair.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariahi <ariahi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/24 18:41:03 by ariahi #+# #+# */
/* Updated: 2023/02/12 17:17:05 by ariahi ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PAIR_HPP
#define PAIR_HPP
namespace ft
{
template<class T1, class T2>
struct pair
{
typedef T1 first_T;
typedef T2 second_T;
first_T first;
second_T second;
pair() : first(), second() {}
template<class A, class B>
pair(const pair<A,B>& other) : first(other.first), second(other.second) {}
pair(const first_T &a, const second_T &b) : first(a), second(b) {}
pair& operator=(const pair &other)
{
first = other.first;
second = other.second;
return (*this);
}
~pair() {}
};
template<class T1, class T2>
bool operator==(const pair<T1, T2> &first, const pair<T1, T2> &second)
{
return (first.first == second.first && first.second == second.second);
}
template<class T1, class T2>
bool operator!=(const pair<T1, T2> &first, const pair<T1, T2> &second)
{
return (!first == second);
}
template<class T1, class T2>
bool operator<(const pair<T1, T2> &first, const pair<T1, T2> &second)
{
return (first.first < second.first || (!(second.first < first.first) && first.second < second.second));
}
template<class T1, class T2>
bool operator>(const pair<T1, T2> &first, const pair<T1, T2> &second)
{
return (second < first);
}
template<class T1, class T2>
bool operator>=(const pair<T1, T2> &first, const pair<T1, T2> &second)
{
return !(first < second);
}
template<class T1, class T2>
bool operator<=(const pair<T1, T2> &first, const pair<T1, T2> &second)
{
return !(second < first);
}
template<class T1, class T2>
pair<T1, T2> make_pair(T1 first, T2 second)
{
return (pair<T1, T2> (first, second));
}
} // namespace ft
#endif