From b9aa776e4a1ad1894debc8699049d6fb7ba34b18 Mon Sep 17 00:00:00 2001 From: Ilia Sharin Date: Sat, 23 Dec 2017 17:26:41 -0500 Subject: [PATCH] Added support for format specifier represented as string object --- tinyformat.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tinyformat.h b/tinyformat.h index cd40624..d9d0c6e 100644 --- a/tinyformat.h +++ b/tinyformat.h @@ -976,6 +976,16 @@ std::string format(const char* fmt, const Args&... args) return oss.str(); } +/// Format list of arguments according to the given format in a string object and return +/// the result as a string. +template +std::string format(const std::string& fmt, const Args&... args) +{ + std::ostringstream oss; + format(oss, fmt.c_str(), args...); + return oss.str(); +} + /// Format list of arguments to std::cout, according to the given format string template void printf(const char* fmt, const Args&... args)