-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.hpp
More file actions
49 lines (41 loc) · 959 Bytes
/
Copy pathdebug.hpp
File metadata and controls
49 lines (41 loc) · 959 Bytes
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
#ifndef DEBUG_HPP
#define DEBUG_HPP
#include <iostream>
#include <utility>
#include <vector>
template <class T>
void _print(const T& x) {
std::cerr << x;
}
template <class A, class B>
void _print(const std::pair<A, B>& p) {
std::cerr << '(';
_print(p.first);
std::cerr << ", ";
_print(p.second);
std::cerr << ')';
}
template <class T>
void _print(const std::vector<T>& v) {
std::cerr << '[';
for (int i = 0; i < static_cast<int>(v.size()); i++) {
if (i) std::cerr << ", ";
_print(v[i]);
}
std::cerr << ']';
}
inline void dbg_out() {
std::cerr << '\n';
}
template <class T, class... Args>
void dbg_out(const T& x, const Args&... args) {
_print(x);
if constexpr (sizeof...(args)) {
std::cerr << ", ";
dbg_out(args...);
} else {
std::cerr << '\n';
}
}
#define dbg(...) std::cerr << __LINE__ << ": [" << #__VA_ARGS__ << "] = ", dbg_out(__VA_ARGS__)
#endif