-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathtemplate.cc
67 lines (58 loc) · 1.45 KB
/
template.cc
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
void print(std::ostream& out) { out << std::endl; }
template <typename T, typename T2>
void printOne(std::ostream& out, const std::pair<T, T2>& a) {
out << "{" << a.first << ", " << a.second << "}";
}
template <typename T>
void printOne(std::ostream& out, const T& a) {
out << a;
}
template <typename T>
void printOne(std::ostream& out, const std::vector<T>& a) {
out << "{";
for (int i = 0; i < a.size(); i++) {
if (i) out << ", ";
printOne(out, a[i]);
}
out << "}";
}
template <typename T>
void printOne(std::ostream& out, const std::deque<T>& a) {
out << "{";
for (int i = 0; i < a.size(); i++) {
if (i) out << ", ";
printOne(out, a[i]);
}
out << "}";
}
template <typename T>
void printOne(std::ostream& out, const std::set<T>& a) {
out << "{";
for (auto it : a) {
printOne(out, it);
out << ",";
}
out << "}";
}
template <typename T, typename V>
void printOne(std::ostream& out, const std::map<T, V>& a) {
out << "{";
for (auto [key, val] : a) {
out << "["; printOne(out, key); out << " = "; printOne(out, val); out << "],";
}
out << "}";
}
template <typename T, typename... Tail>
void print(std::ostream& out, const T& first, const Tail... tail) {
printOne(out, first);
if (sizeof...(tail) != 0) {
out << ", ";
}
print(out, tail...);
}
#ifdef LOCAL_CP
#define debug(...) \
std::cerr << "[DEBUG] [" << #__VA_ARGS__ << "] = ", print(std::cerr, __VA_ARGS__)
#else
#define debug(...) 0
#endif