summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-10-29 00:35:41 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-10-29 00:35:41 +0000
commitbb94eb2ac87274319875f8938407dd0a3ffc9ca4 (patch)
tree768af37f72fa9236070110cf70bf07113554e7a5 /lib
parentUpdate operator<< for collections to work with ranges (diff)
downloadilt-bb94eb2ac87274319875f8938407dd0a3ffc9ca4.tar.bz2
ilt-bb94eb2ac87274319875f8938407dd0a3ffc9ca4.tar.xz
ilt-bb94eb2ac87274319875f8938407dd0a3ffc9ca4.zip
Update CLOG to be implemented as a function
Forces capture of value before outputting anything
Diffstat (limited to 'lib')
-rw-r--r--lib/stream_support.h13
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)