-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpair.hpp
More file actions
54 lines (50 loc) · 2.33 KB
/
pair.hpp
File metadata and controls
54 lines (50 loc) · 2.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pair.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smia <smia@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/11 22:42:12 by smia #+# #+# */
/* Updated: 2022/12/29 09:36:32 by smia ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
namespace ft {
template <class T1, class T2> struct pair {
T1 first;
T2 second;
typedef T1 first_type;
typedef T2 second_type;
pair() : first(first_type()), second(second_type()) {}
template<class U, class V> pair (const pair<U,V>& pr) : first(pr.first), second(pr.second) {}
pair (const first_type& a, const second_type& b) : first(a) , second(b) {}
pair& operator= (const pair& pr)
{
first = pr.first;
second = pr.second;
return *this;
}
};
template< class T1, class T2 > ft::pair<T1, T2> make_pair( T1 t, T2 u ) {
return ft::pair<T1 , T2>(t, u);
}
template <class T1, class T2> bool operator== (const ft::pair<T1,T2>& lhs, const ft::pair<T1,T2>& rhs) {
return lhs.first == rhs.first && lhs.second == rhs.second;
}
template <class T1, class T2> bool operator!= (const ft::pair<T1,T2>& lhs, const ft::pair<T1,T2>& rhs) {
return !(lhs == rhs);
}
template <class T1, class T2> bool operator< (const ft::pair<T1,T2>& lhs, const ft::pair<T1,T2>& rhs) {
return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second < rhs.second);
}
template <class T1, class T2> bool operator<= (const ft::pair<T1,T2>& lhs, const ft::pair<T1,T2>& rhs) {
return !(rhs < lhs);
}
template <class T1, class T2> bool operator> (const ft::pair<T1,T2>& lhs, const ft::pair<T1,T2>& rhs) {
return rhs < lhs;
}
template <class T1, class T2> bool operator>= (const ft::pair<T1,T2>& lhs, const ft::pair<T1,T2>& rhs) {
return !(lhs < rhs);
}
}