-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdebug.sublime-snippet
executable file
·59 lines (50 loc) · 1.41 KB
/
debug.sublime-snippet
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
<snippet>
<content><![CDATA[
string to_string(string s) {
return '"' + s + '"';
}
string to_string(const char* s) {
return to_string((string) s);
}
string to_string(bool b) {
return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#ifdef ABHI
#define line_debug(x) cerr << "[" << __LINE__ << "]: " << #x << "->" << to_string(x) << '\n';
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define line_debug(x) 42
#define debug(...) 42
#endif
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>debug</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.cpp, source.c++, source.c</scope>
<!-- Optional: Description to show in the menu -->
<description>My Code template for Debug</description>
</snippet>