31 #ifndef _STRING_FORMAT_H_ 32 #define _STRING_FORMAT_H_ 44 template<
typename ... Args>
47 size_t size = snprintf(
nullptr, 0, format.c_str(), args ...) + 1;
48 std::unique_ptr<char[]> buf(
new char[size]);
49 snprintf(buf.get(), size, format.c_str(), args ...);
50 return std::string(buf.get(), buf.get() + size - 1);
55 #endif // _STRING_FORMAT_H_
std::string string_format(const std::string &format, Args ... args)