7template <
typename... Args>
9 int size_s = std::snprintf(
nullptr, 0, format.c_str(), args...) +
12 throw std::runtime_error(
"Error during formatting.");
14 auto size =
static_cast<size_t>(size_s);
15 std::unique_ptr<char[]> buf(
new char[size]);
16 std::snprintf(buf.get(), size, format.c_str(), args...);
17 return std::string(buf.get(),
18 buf.get() + size - 1);
std::string string_format(const std::string &format, Args... args)
Definition: util.hpp:8