summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libadhocutil/compileTimeFormatter.h10
-rw-r--r--libadhocutil/unittests/testCompileTimeFormatter.cpp5
2 files changed, 10 insertions, 5 deletions
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h
index 8a92094..aeff488 100644
--- a/libadhocutil/compileTimeFormatter.h
+++ b/libadhocutil/compileTimeFormatter.h
@@ -176,20 +176,20 @@ namespace AdHoc {
static std::string get(const Pn & ... pn)
{
std::stringstream s;
- run(Parser<S, 0, 0, *S>::parse(), s, pn...);
- return s.str();
+ return run(Parser<S, 0, 0, *S>::parse(), s, pn...).str();
}
template<typename stream, typename ... Pn>
- static void write(stream & s, const Pn & ... pn)
+ static stream & write(stream & s, const Pn & ... pn)
{
- run(Parser<S, 0, 0, *S>::parse(), s, pn...);
+ return run(Parser<S, 0, 0, *S>::parse(), s, pn...);
}
template<typename stream, char...ssn, template<bool, char...> class ParserBuffer, typename ... Pn>
- static void run(const ParserBuffer<false, ssn...> &, stream & s, const Pn & ... pn)
+ static stream & run(const ParserBuffer<false, ssn...> &, stream & s, const Pn & ... pn)
{
StreamWriter<S, 0, stream, ssn...>::write(s, pn...);
+ return s;
}
};
}
diff --git a/libadhocutil/unittests/testCompileTimeFormatter.cpp b/libadhocutil/unittests/testCompileTimeFormatter.cpp
index 0f021e5..df0d93c 100644
--- a/libadhocutil/unittests/testCompileTimeFormatter.cpp
+++ b/libadhocutil/unittests/testCompileTimeFormatter.cpp
@@ -117,6 +117,11 @@ BOOST_AUTO_TEST_CASE ( singleInt )
BOOST_REQUIRE_EQUAL(this->str(), "single 32.");
}
+BOOST_AUTO_TEST_CASE ( singleIntReturn )
+{
+ BOOST_REQUIRE_EQUAL(Formatter<formatStringSingle>::write(*this, 32).str(), "single 32.");
+}
+
BOOST_AUTO_TEST_CASE ( singleDouble )
{
Formatter<formatStringSingle>::write(*this, 3.14);