#pragma once #include #include #ifdef DEBUG #define __FILENAME__ (\ __builtin_strrchr(__FILE__, '/') ? \ __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) #define npdebug_prep(); { \ std::cerr << "[" << __FILENAME__ \ << ":" << __LINE__ \ << ", " << __func__ \ << "] " ; \ } #define npdebug(...); { \ npdebug_prep(); \ np::va_debug(__VA_ARGS__); \ } namespace np { template inline void va_debug(Args&... args) { (std::cerr << ... << args) << std::endl; } template void range_debug(const T& t) { range_debug("", t); } template void range_debug(const std::string& msg, const T& t) { std::string out; for (auto elem : t) out += elem += ", "; npdebug(msg, out); } template T inspect(const T& t) { npdebug(t); return t; } template T inspect(const std::string& msg, const T& t) { npdebug(msg, t); return t; } } #else #define npdebug(...) {} namespace np { template inline void va_debug(Args&... args) {} template inline void range_debug(const T& t) {} template inline void range_debug(const std::string& msg, const T& t) {} template T inspect(const T& t) { return t; } template T inspect(const std::string& msg, const T& t) { return t; } } #endif