12 #ifndef ZEROERR_DISABLE_DBG_MARCO
13 #define dbg(...) zeroerr::DebugExpr(__FILE__, __LINE__, __func__, #__VA_ARGS__, __VA_ARGS__)
15 #define dbg(...) (__VA_ARGS__)
20 template <
class T1,
class... T>
34 template <
typename... Args>
36 return std::get<
sizeof...(Args) - 1>(std::tie(args...));
44 template <
typename... T>
45 auto DebugExpr(
const char* file,
unsigned line,
const char* func,
const char* exprs, T... t) ->
46 typename last<T...>::type {
47 std::string fileName(file);
48 auto p = fileName.find_last_of(
'/');
49 if (p != std::string::npos) fileName = fileName.substr(p + 1);
51 std::cerr <<
Dim <<
"[" << fileName <<
":" << line <<
" " << func <<
"] " <<
Reset;
57 std::string typenames[] = {print.
type(t)...};
58 for (
unsigned i = 0; i <
sizeof...(T); ++i) {
59 if (i != 0) std::cerr <<
", ";
60 std::cerr << typenames[i];
62 std::cerr <<
Reset <<
")" << std::endl;
#define ZEROERR_SUPPRESS_COMMON_WARNINGS_POP
Definition: config.h:265
#define ZEROERR_SUPPRESS_COMMON_WARNINGS_PUSH
Definition: config.h:218
Definition: benchmark.cpp:17
const char * FgCyan
Definition: color.cpp:48
auto DebugExpr(const char *file, unsigned line, const char *func, const char *exprs, T... t) -> typename last< T... >::type
DebugExpr is a function to print any type of variable with its type name. It is used by dbg macro.
Definition: dbg.h:45
const char * Dim
Definition: color.cpp:36
const char * FgGreen
Definition: color.cpp:44
auto get_last(Args &&... args) -> typename last< Args... >::type
get_last is a function to get the last argument of a variadic template. It is used by DebugExpr.
Definition: dbg.h:35
const char * Reset
Definition: color.cpp:34
A functor class Printer for printing a value of any type.
Definition: print.h:80
static std::string type(const T &t)
Definition: print.h:131
const char * line_break
Definition: print.h:125
T1 type
Definition: dbg.h:27
typename last< T... >::type type
Definition: dbg.h:22