diff --git a/paddle/fluid/string/printf.h b/paddle/fluid/string/printf.h index e0f6202506868fd0dcbe93297785682edbcfe792..65dec970debf8859b113374aebbe161b27010214 100644 --- a/paddle/fluid/string/printf.h +++ b/paddle/fluid/string/printf.h @@ -84,7 +84,16 @@ void Fprintf(std::ostream& out, const char* fmt, const Args&... args) { } template -std::string Sprintf(const char* fmt = "", const Args&... args) { +std::string Sprintf(const Args&... args) { + if (0u == sizeof...(args)) { + Sprintf("", args); + } + + return Sprintf(args, args); +} + +template +std::string Sprintf(const char* fmt, const Args&... args) { std::ostringstream oss; Fprintf(oss, fmt, args...); return oss.str();