Skip to content

Instantly share code, notes, and snippets.

@Genki-S
Last active August 29, 2015 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Genki-S/4afeae502d57dd1280ea to your computer and use it in GitHub Desktop.
Save Genki-S/4afeae502d57dd1280ea to your computer and use it in GitHub Desktop.
#define FOR(i, b, e) for (typeof(e) i = (b); i < (e); ++i)
// for arrays
#define arrsz(a) ( sizeof(a) / sizeof(a[0]) )
#define darr(a) if (opt_debug) { copy( (a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ") ); cerr << endl; }
#define darr2(a) if (opt_debug) { FOR(__i, 0, (arrsz(a))){ darr( (a)[__i] ); } }
// for vectors
#define ALL(a) (a).begin(), (a).end()
#define dvec(v) if (opt_debug) { copy( ALL(v), ostream_iterator<int>(cerr, " ") ); cerr << endl; }
#define dvec2(v) if (opt_debug) { FOR(__i, 0, v.size()){ dvec( (v)[__i] ); } }
bool opt_debug = true; // <= debug option flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment