-
Notifications
You must be signed in to change notification settings - Fork 0
/
pair.hpp
41 lines (33 loc) · 982 Bytes
/
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
#ifndef PAIR_HPP
# define PAIR_HPP
namespace ft
{
template <class T1, class T2>
struct pair
{
typedef T1 first_type;
typedef T2 second_type;
first_type first;
second_type second;
pair(void): first(), second() {};
template <class U, class V>
pair(pair<U, V> const& pr): first(pr.first), second(pr.second) {};
pair(const first_type& a, const second_type& b): first(a), second(b) {};
pair& operator=(pair const& pr)
{ first = pr.first; second = pr.second; return (*this); };
};
template <class T1, class T2>
bool operator==(pair<T1, T2> const& lhs, pair<T1, T2> const& rhs)
{
return (lhs.first == rhs.first && lhs.second == rhs.second);
};
template <class T1, class T2>
bool operator<(const pair<T1, T2>& lhs, const pair<T1, T2>& rhs)
{
return (lhs.first < rhs.first || (!(rhs.first < lhs.first) && lhs.second < rhs.second));
};
template <class T1, class T2>
pair<T1, T2> make_pair(T1 x, T2 y)
{ return (pair<T1, T2>(x, y)); };
}
#endif