diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-09-04 22:19:30 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-09-04 22:23:31 +0100 |
commit | 6cf08f40dc2564bf35144f3c1c40a7994915e02e (patch) | |
tree | 4f9e7821d7c6161038efc5a49ca40454032ba666 | |
parent | scprintf macro with non-variable (diff) | |
download | libadhocutil-6cf08f40dc2564bf35144f3c1c40a7994915e02e.tar.bz2 libadhocutil-6cf08f40dc2564bf35144f3c1c40a7994915e02e.tar.xz libadhocutil-6cf08f40dc2564bf35144f3c1c40a7994915e02e.zip |
Support scprintf macro for format string with no args
-rw-r--r-- | libadhocutil/compileTimeFormatter.h | 2 | ||||
-rw-r--r-- | libadhocutil/unittests/testCompileTimeFormatter.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h index 35dffde..5f0237e 100644 --- a/libadhocutil/compileTimeFormatter.h +++ b/libadhocutil/compileTimeFormatter.h @@ -193,7 +193,7 @@ namespace AdHoc { #define scprintf(strmp, fmt, ...) \ ([](decltype(strmp) & strm) -> auto & { \ static constexpr auto __FMT = fmt; \ - return ::AdHoc::Formatter<__FMT>::write(strm, __VA_ARGS__); \ + return ::AdHoc::Formatter<__FMT>::write(strm, ##__VA_ARGS__); \ }(strmp)) #endif diff --git a/libadhocutil/unittests/testCompileTimeFormatter.cpp b/libadhocutil/unittests/testCompileTimeFormatter.cpp index 9bb81f6..37d1947 100644 --- a/libadhocutil/unittests/testCompileTimeFormatter.cpp +++ b/libadhocutil/unittests/testCompileTimeFormatter.cpp @@ -454,6 +454,7 @@ BOOST_AUTO_TEST_CASE(scprintf) 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)."); + scprintf(*str, "Some literal format string, no args."); } #endif |