Debugging in C++ Hi everyone.
This is my template for debugging in C++. I was inspired by Tourist's [source code](https://codeforces.me/contest/1110/submission/49588803) and modified it to my style. Here is it:
<spoiler summary="Template">
~~~~~
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.seco...
Debugging in C++, (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef ONLINE_JUDGE #define debug
(x...) cerr, = {'x', 0.5}; string d = "This is a string"; pair > e = {1, {2, 3}}; debug(a, b, , 3, 1, 1, 2}; vector > f = {{1, 2, 3}}; debug(d, e, f);, Basically, the debug works with collections types which you can iterate by `for
(auto i: a)`. So, Hi everyone. This is my template for debugging in C++. I was inspired by
Tourist's [source code, Note: I haven't tried the debug with other complex data types nested in
collection types., Note: You should only debug a pair of simple data types. For example, the debug
won't work if one, This is my template for debugging in C++. I was inspired by Tourist's [source
code](https, To debug, just type: `debug(x, y, z...)`. It requires C++ 11 or above., You can use the template and change it's style to what you want. Hope it would
help youdebug in C, ["string 1"] = 1; c["string 2"] = 2; debug(a, b, c);, int b = 1; float c = 2.5; long long d = LLONG_MAX; char e = 'e'; debug(a, b, c,
d, e);, ~~~~ int a = 1; int b = 2; debug(a + b, a * b, a / b, a - b, a / (float)b,
2019, 2019 - 1);, ~~~~~ bool a = true; debug(a);
Full text and comments »