mirror of
https://github.com/wiiu-env/ScreenshotWUPS.git
synced 2024-11-17 20:59:15 +01:00
15 lines
510 B
C++
15 lines
510 B
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
template<typename... Args>
|
|
std::string string_format(const std::string &format, Args... args) {
|
|
int size_s = std::snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0'
|
|
auto size = static_cast<size_t>(size_s);
|
|
auto buf = std::make_unique<char[]>(size);
|
|
std::snprintf(buf.get(), size, format.c_str(), args...);
|
|
return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside
|
|
}
|