summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libadhocutil/compileTimeFormatter.h8
-rw-r--r--libadhocutil/unittests/testCompileTimeFormatter.cpp8
2 files changed, 8 insertions, 8 deletions
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h
index 2fc193e..35dffde 100644
--- a/libadhocutil/compileTimeFormatter.h
+++ b/libadhocutil/compileTimeFormatter.h
@@ -190,11 +190,11 @@ namespace AdHoc {
// As far as I know, only clang/llvm version 5+ can compile this
// so long as std=c++17
#if __clang_major__ >= 5 && __cplusplus >= 201703
-#define scprintf(strm, fmt, ...) \
- ([&strm]() -> decltype(strm) & { \
- static constexpr const char * const __FMT = fmt; \
+#define scprintf(strmp, fmt, ...) \
+ ([](decltype(strmp) & strm) -> auto & { \
+ static constexpr auto __FMT = fmt; \
return ::AdHoc::Formatter<__FMT>::write(strm, __VA_ARGS__); \
- }())
+ }(strmp))
#endif
#endif
diff --git a/libadhocutil/unittests/testCompileTimeFormatter.cpp b/libadhocutil/unittests/testCompileTimeFormatter.cpp
index b966078..9bb81f6 100644
--- a/libadhocutil/unittests/testCompileTimeFormatter.cpp
+++ b/libadhocutil/unittests/testCompileTimeFormatter.cpp
@@ -450,10 +450,10 @@ BOOST_AUTO_TEST_CASE(smartptr)
#ifdef scprintf
BOOST_AUTO_TEST_CASE(scprintf)
{
- std::stringstream str;
- auto & strret = scprintf(str, "Some literal format string (%d, %c).", 0, 'f');
- BOOST_CHECK_EQUAL(&str, &strret); // We got back our original stream
- BOOST_CHECK_EQUAL(str.str(), "Some literal format string (0, f).");
+ auto str = std::make_unique<std::stringstream>();
+ auto & strret = scprintf(*str, "Some literal format string (%d, %c).", 0, 'f');
+ BOOST_CHECK_EQUAL(str.get(), &strret); // We got back our original stream
+ BOOST_CHECK_EQUAL(str->str(), "Some literal format string (0, f).");
}
#endif