-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy patheasy_compare.cpp
More file actions
49 lines (41 loc) · 1.43 KB
/
easy_compare.cpp
File metadata and controls
49 lines (41 loc) · 1.43 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
#include <stdexcept>
#include <tuple>
struct Date
{
unsigned year;
unsigned month;
unsigned day;
};
struct StudentInfo
{
size_t id;
char mark;
int score;
unsigned course;
Date birth_date;
};
bool operator<(const Date &s1, const Date &s2)
{
return std::tie(s1.year, s1.month, s1.day) < std::tie(s2.year, s2.month, s2.day);
}
bool operator==(const Date &s1, const Date &s2)
{
return std::tie(s1.year, s1.month, s1.day) == std::tie(s2.year, s2.month, s2.day);
}
bool operator==(const StudentInfo &s1, const StudentInfo &s2)
{
return std::tie(s1.mark, s1.score) == std::tie(s2.mark, s2.score);
}
bool operator<(const StudentInfo &s1, const StudentInfo &s2)
{
return std::tie(s2.mark, s1.score, s2.course, s1.birth_date) <
std::tie(s1.mark, s2.score, s1.course, s2.birth_date);
}
bool operator!=(const StudentInfo &s1, const StudentInfo &s2) { return !(s1 == s2); }
bool operator>(const StudentInfo &s1, const StudentInfo &s2) { return s2 < s1; }
bool operator<=(const StudentInfo &s1, const StudentInfo &s2) { return !(s2 < s1); }
bool operator>=(const StudentInfo &s1, const StudentInfo &s2) { return !(s1 < s2); }
bool operator!=(const Date &d1, const Date &d2) { return !(d1 == d2); }
bool operator>(const Date &d1, const Date &d2) { return d2 < d1; }
bool operator<=(const Date &d1, const Date &d2) { return !(d2 < d1); }
bool operator>=(const Date &d1, const Date &d2) { return !(d1 < d2); }