From 25fc71ff92e8fb940377b4f4a513d535e2eb040f Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 12 Jun 2016 11:49:05 +0800 Subject: Resolve - Fix variable scoping --- src/include/debug.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/include/debug.hpp') diff --git a/src/include/debug.hpp b/src/include/debug.hpp index 7e68bbfa..af8dcf10 100644 --- a/src/include/debug.hpp +++ b/src/include/debug.hpp @@ -49,6 +49,17 @@ public: TraceLog(const char* tag); ~TraceLog(); }; + +struct FmtLambda +{ + ::std::function m_cb; + friend ::std::ostream& operator<<(::std::ostream& os, const FmtLambda& x) { + x.m_cb(os); + return os; + } +}; +#define FMT_CB(os, ...) ::FmtLambda { [&](auto& os) { __VA_ARGS__ } } + #define TRACE_FUNCTION TraceLog _tf_(__func__) #define TRACE_FUNCTION_F(ss) TraceLog _tf_(__func__, FMT(ss)) #define TRACE_FUNCTION_FR(ss,ss2) TraceLog _tf_(__func__, FMT(ss), [&](::std::ostream&__os){ __os << ss2;}) -- cgit v1.2.3