Skip to content

Commit

Permalink
Update debug.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
OmeletWithoutEgg committed Oct 14, 2023
1 parent c506dcc commit 6faadd6
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions codes/Basic/debug.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#ifdef local
#define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
template <typename ...T>
void debug_(const char *s, T ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int cnt = sizeof...(T);
(..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
#define debug(a...) \
cerr<<"\e[1;32m("#a") = ("<<debug_(a)<<")\e[0m\n"
#define orange(a...) \
orange_("\e[1;32m[ "#a" ] = [ ", a, " ]\e[0m\n")
template <typename T>
string debug_(T t) { return to_string(t); }
template <typename U, typename ...V>
string debug_(U u, V ...v) {
return to_string(u) + ", " + debug_(v...);
}
template <typename I>
void orange_(const char *s, I L, I R) {
cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L)
cerr << (f++ ? ", " : "") << *L;
cerr << " ]\e[0m\n";
void orange_(string pre, I L, I R, string post) {
cerr << pre;
copy(L, R, ostream_iterator<decltype(*L)>(cerr, ", "));
cerr << post;
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

0 comments on commit 6faadd6

Please sign in to comment.