| 19 | // |
| 20 | template<typename ... Args> |
| 21 | std::string string_format(char const* format = nullptr, Args ... args) |
| 22 | { |
| 23 | if (format == nullptr) |
| 24 | { |
| 25 | return std::string(); |
| 26 | } |
| 27 | |
| 28 | size_t size = snprintf(nullptr, 0, format, args ...) + 1; // Extra space for '\0' |
| 29 | std::unique_ptr<char[]> buf(new char[size]); |
| 30 | snprintf(buf.get(), size, format, args ...); |
| 31 | return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside |
| 32 | } |
| 33 | |
| 34 | |
| 35 | } // namespace core |
nothing calls this directly
no outgoing calls
no test coverage detected