diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-29 00:35:41 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-11-05 20:04:46 +0000 |
commit | 4fe253978dabe749effa982a4873e628a4641681 (patch) | |
tree | 768af37f72fa9236070110cf70bf07113554e7a5 /lib/stream_support.h | |
parent | Update operator<< for collections to work with ranges (diff) | |
download | ilt-4fe253978dabe749effa982a4873e628a4641681.tar.bz2 ilt-4fe253978dabe749effa982a4873e628a4641681.tar.xz ilt-4fe253978dabe749effa982a4873e628a4641681.zip |
Update CLOG to be implemented as a function
Forces capture of value before outputting anything
Diffstat (limited to 'lib/stream_support.h')
-rw-r--r-- | lib/stream_support.h | 13 |
1 files changed, 12 insertions, 1 deletions
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 <glm/glm.hpp> #include <iostream> #include <maths.h> +#include <source_location> #include <span> #include <sstream> #include <tuple> @@ -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<typename T> + 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) |