Repository navigation
Expand file tree
/
Copy pathpair.hpp
More file actions
102 lines (92 loc) · 3 KB
/
Copy pathpair.hpp
File metadata and controls
102 lines (92 loc) · 3 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
92
93
94
95
96
97
98
99
100
101
102
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pair.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ahkecha <ahkecha@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/24 14:48:10 by ahkecha #+# #+# */
/* Updated: 2023/01/31 15:55:07 by ahkecha ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __PAIR_H__
#define __PAIR_H__
#include <utility>
namespace ft {
template <
class T1,
class T2>
struct pair
{
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair();
template <class U, class V>
pair(const pair<U, V> &pr);
pair(const first_type &a, const second_type &b);
pair &operator=(const pair &pr);
};
template <class T1, class T2>
pair<T1, T2>::pair() { }
template <class T1, class T2>
template <class U, class V>
pair<T1, T2>::pair(const pair<U, V> &pr)
: first(pr.first)
, second(pr.second)
{
}
template <class T1, class T2>
pair<T1, T2>::pair(const first_type &a, const second_type &b)
: first(a)
, second(b)
{
}
template <class T1, class T2>
pair<T1, T2> &pair<T1, T2>::operator=(const pair &pr)
{
first = pr.first;
second = pr.second;
return (*this);
}
template <class T1, class T2>
pair<T1, T2> make_pair(T1 x, T2 y) { return (pair<T1, T2>(x, y)); }
template <class T1, class T2>
inline bool
operator==(const pair<T1, T2>& __x, const pair<T1, T2>& __y)
{
return (__x.first == __y.first and __x.second == __y.second);
}
template <class T1, class T2>
inline bool
operator!=(const pair<T1,T2>& __x, const pair<T1,T2>& __y)
{
return !(__x == __y);
}
template <class T1, class 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 <class T1, class T2>
inline bool
operator> (const pair<T1,T2>& __x, const pair<T1,T2>& __y)
{
return __y < __x;
}
template <class T1, class T2>
inline bool
operator>=(const pair<T1,T2>& __x, const pair<T1,T2>& __y)
{
return !(__x < __y);
}
template <class T1, class T2>
inline bool
operator<=(const pair<T1,T2>& __x, const pair<T1,T2>& __y)
{
return !(__y < __x);
}
}
#endif // __PAIR_H__