diff --git a/io/debug.h b/io/debug.h index 9641c2f..358e8d7 100644 --- a/io/debug.h +++ b/io/debug.h @@ -3,19 +3,25 @@ #include #include -struct X { -#ifdef LOG_DEBUG - X() { if(false) std::cout.setstate(std::ios_base::failbit); } - ~X() { if(false) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } } -#else - X() { std::cout.setstate(std::ios_base::failbit); } - ~X() { std::cout.clear(); } -#endif +struct print { + print() { if(false) std::cout.setstate(std::ios_base::failbit); } + ~print() { if(false) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } } +}; + +struct noprint { + noprint() { if(true) std::cout.setstate(std::ios_base::failbit); } + ~noprint() { if(true) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } } }; -#define DEBUG (X(), std::cout << "DEBUG[" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ") -#define WARN (X(), std::cout << "WARN [" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ") + +#ifdef LOG_DEBUG + #define DEBUG (print(), std::cout << "DEBUG[" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ") + #define WARN (print(), std::cout << "WARN [" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ") +#else + #define DEBUG (noprint(), std::cout << "") + #define WARN (noprint(), std::cout << "") +#endif #ifdef LOG_DEBUG #define STEP \