Skip to content
Snippets Groups Projects
Commit f8892ec7 authored by Florian Fischer's avatar Florian Fischer
Browse files

[Debug] return std::string instead of lambda from EMPER_BUILD_STR

This seams more intuitive. A macro called EMPER_BUILD_STR actually returning
a string and not a lambda which when called returns the built string.
parent 88acaaa7
No related branches found
No related tags found
No related merge requests found
......@@ -18,10 +18,10 @@
// The lamda should be fairly cheap/free because it will be inlined.
// The use of a lambda here is the ISO C++ equivalent to GCC statement expressions.
// NOLINTNEXTLINE(bugprone-macro-parentheses)
#define EMPER_BUILD_STR(x) [&]() -> std::string {std::stringstream sst; sst << x; return sst.str(); }
#define EMPER_BUILD_STR(x) [&]() -> std::string {std::stringstream sst; sst << x; return sst.str(); }()
// NOLINTNEXTLINE(bugprone-macro-parentheses)
#define LOG(level, x, log_func) do { if constexpr (level <= EMPER_LOG_LEVEL) { log_func(EMPER_BUILD_STR(x)()); } } while (false)
#define LOG(level, x, log_func) do { if constexpr (level <= EMPER_LOG_LEVEL) { log_func(EMPER_BUILD_STR(x)); } } while (false)
// NOLINTNEXTLINE(bugprone-macro-parentheses)
#define DBG(x) LOG(Debug, x, emper_log_no_prefix);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment