rk3399_arm_lvds/packages/common.pkg/include/stringex.hpp

11 lines
370 B
C++
Raw Permalink Normal View History

2024-03-05 03:46:18 +00:00
#pragma once
#include <string>
#include <memory>
template<typename ... Args>
std::string string_format(const std::string& format, Args ... args) {
size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1;
std::unique_ptr<char[]> buf(new char[size]);
snprintf(buf.get(), size, format.c_str(), args ...);
return std::string(buf.get(), buf.get() + size - 1);
}