-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpair.hpp
More file actions
91 lines (78 loc) · 2.28 KB
/
pair.hpp
File metadata and controls
91 lines (78 loc) · 2.28 KB
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
89
90
91
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pair.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: davidzh <davidzh@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/05/26 14:20:57 by tyamcha #+# #+# */
/* Updated: 2022/09/11 19:47:06 by davidzh ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PAIR_HPP
# define PAIR_HPP
namespace ft
{
template <typename T1, typename T2>
struct pair
{
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair (void)
: first(), second()
{}
pair (const T1& a, const T2& b)
: first(a), second(b)
{}
template <typename U1, typename U2>
pair (const pair<U1, U2>& p)
: first(p.first), second(p.second)
{}
};
template <typename T1, typename T2>
inline bool
operator== (const pair<T1, T2>& x, const pair<T1, T2>& y)
{
return (x.first == y.first && x.second == y.second);
}
template <typename T1, typename T2>
inline 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 <typename T1, typename T2>
inline bool
operator!= (const pair<T1, T2>& x, const pair<T1, T2>& y)
{
return (!(x == y));
}
template <typename T1, typename T2>
inline bool
operator> (const pair<T1, T2>& x, const pair<T1, T2>& y)
{
return (y < x);
}
template <typename T1, typename T2>
inline bool
operator<= (const pair<T1, T2>& x, const pair<T1, T2>& y)
{
return (!(y < x));
}
template <typename T1, typename T2>
inline bool
operator>= (const pair<T1, T2>& x, const pair<T1, T2>& y)
{
return (!(x < y));
}
template <typename T1, typename T2>
inline pair<T1, T2>
makepair(T1 x, T2 y)
{
return (pair<T1, T2>(x, y));
}
}
#endif