-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.h
More file actions
36 lines (34 loc) · 1.19 KB
/
debug.h
File metadata and controls
36 lines (34 loc) · 1.19 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
#include <bits/stdc++.h>
using namespace std;
// For pair
template<typename A, typename B>
ostream& operator<<(ostream &os, const pair<A, B> &p) {
return os << '(' << p.first << ", " << p.second << ')';
}
// For containers (vector, set, map, deque, string, etc.)
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type>
ostream& operator<<(ostream &os, const T_container &v) {
os << '{';
string sep;
for (const T &x : v) os << sep << x, sep = ", ";
return os << '}' /*<< '\n'*/ ;
}
// map<int, container<pair>>> // not that necessary
template<typename K, typename V>
ostream& operator<<(ostream& os, const map<K, V>& m) {
os << '{';
string sep;
for (const auto& [key, val] : m) os << sep << key << ": " << val, sep = ", ";
return os << '}';
}
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
cerr << ' ' << H;
dbg_out(T...);
}
#ifdef WOOF_
#define dbg(...) cerr << '[' << __LINE__ << "] (" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif