diff options
author | John Hodge <tpg@mutabah.net> | 2016-06-12 11:49:05 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-06-12 11:49:05 +0800 |
commit | 25fc71ff92e8fb940377b4f4a513d535e2eb040f (patch) | |
tree | 501c8b5a596689c0bd09d40e08a0cec3e5108dda /src/include/debug.hpp | |
parent | 1c3f5cd57013c067cfea41f26c28f93b451b6b84 (diff) | |
download | mrust-25fc71ff92e8fb940377b4f4a513d535e2eb040f.tar.gz |
Resolve - Fix variable scoping
Diffstat (limited to 'src/include/debug.hpp')
-rw-r--r-- | src/include/debug.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
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<void(::std::ostream&)> 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;}) |