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)