-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutility.hpp
70 lines (59 loc) · 2.19 KB
/
utility.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utility.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aisraely <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/30 14:59:18 by aisraely #+# #+# */
/* Updated: 2021/12/30 14:59:18 by aisraely ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef UTILITY_HPP
# define UTILITY_HPP
# include <sstream>
# include <exception>
# include <cstddef>
# include <climits>
# include "pair.hpp"
#define SSTR(x) static_cast<std::ostringstream&> \
((std::ostringstream() << std::dec << x)).str()
namespace ft
{
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>
bool operator==(const ft::pair<T1, T2> &lhs, const ft::pair<T1, T2> &rhs)
{
return (lhs.first == rhs.first and 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 or (!(rhs.first < lhs.first) and 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));
}
#endif