From 4fe253978dabe749effa982a4873e628a4641681 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 29 Oct 2024 00:35:41 +0000 Subject: Update CLOG to be implemented as a function Forces capture of value before outputting anything --- lib/stream_support.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/stream_support.h b/lib/stream_support.h index 423c7d4..f21622a 100644 --- a/lib/stream_support.h +++ b/lib/stream_support.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -92,4 +93,14 @@ streamed_string(const T & v) return std::move(ss).str(); } -#define CLOG(x) std::cerr << __LINE__ << " : " #x " : " << x << "\n"; +namespace { + template + void + clogImpl(const T & value, const std::string_view name, + const std::source_location loc = std::source_location::current()) + { + std::cerr << loc.line() << " : " << name << " : " << value << "\n"; + } +} + +#define CLOG(x) clogImpl(x, #x) -- cgit v1.2.3