my debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
namespace /* debug */{ | |
#define DEBUG(...) do{cout<<#__VA_ARGS__<<" = "; debug(__VA_ARGS__);}while(0) //変数 | |
#define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "; debug(__VA_ARGS__);}while(0) //行数 | |
#define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = "; debug(__VA_ARGS__);}while(0) //変数, 行数 | |
template <class T> | |
void show(T &x){ | |
cout<<x<<" "; | |
} | |
template <class T> | |
void showendl(T &x){ | |
cout<<x<<endl; | |
} | |
template <class P, class Q> | |
void show(pair<P, Q> &x){ | |
cout<<"("<<x.first<<", "<<x.second<<") "; | |
} | |
template <class P, class Q> | |
void showendl(pair<P, Q> &x){ | |
cout<<"("<<x.first<<", "<<x.second<<")"<<endl; | |
} | |
template <class H> | |
void debug(H&& h){ | |
showendl(h); | |
} | |
template <class H, class... Ts> | |
void debug(H&& h, Ts&&... ts){ | |
show(h); | |
debug(forward<Ts>(ts)...); | |
} | |
template <class T> | |
void debug(vector<T> &vt){ | |
int i=0; | |
for(auto x: vt)++i!=vt.size() ? show(x) : showendl(x); | |
} | |
template <class T> | |
void debug(initializer_list<T> init){ | |
int i=0; | |
for(auto x: init)++i!=init.size() ? show(x) : showendl(x); | |
} | |
} | |
int main(){ | |
int a=1, b=10, c=-1; | |
double d=3.14, e=1.41; | |
string S = "hoge"; | |
debug(a); | |
DEBUG(99); | |
ldebug(d); | |
lDEBUG(S); | |
cout<<"//////////"<<endl; | |
debug(a,b,c); | |
DEBUG(d,e,S); | |
ldebug(a,d,S); | |
lDEBUG(b,c,e,"fuga"); | |
cout<<"//////////"<<endl; | |
debug({a,b,c}); | |
DEBUG({d,e,1.23}); | |
ldebug({a,b,99}); | |
lDEBUG({"piyo","nyo"}); | |
cout<<"//////////"<<endl; | |
vector<pair<int, double>> pid = {{a,d}, {c,e}}; | |
debug(pid); | |
DEBUG(pid); | |
ldebug(pid); | |
lDEBUG(pid); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
99 = 99 | |
[ 56] 3.14 | |
[ 57] S = hoge | |
////////// | |
1 10 -1 | |
d,e,S = 3.14 1.41 hoge | |
[ 63] 1 3.14 hoge | |
[ 64] b,c,e,"fuga" = 10 -1 1.41 fuga | |
////////// | |
1 10 -1 | |
{d,e,1.23} = 3.14 1.41 1.23 | |
[ 70] 1 10 99 | |
[ 71] {"piyo","nyo"} = piyo nyo | |
////////// | |
(1, 3.14) (-1, 1.41) | |
pid = (1, 3.14) (-1, 1.41) | |
[ 78] (1, 3.14) (-1, 1.41) | |
[ 79] pid = (1, 3.14) (-1, 1.41) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment