mirror of
https://github.com/GaryOderNichts/DRXUtil.git
synced 2024-10-31 22:55:09 +01:00
23 lines
464 B
C++
23 lines
464 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
|
|
namespace Utils
|
|
{
|
|
|
|
template<typename ...Args>
|
|
std::string sprintf(const std::string& format, Args ...args)
|
|
{
|
|
int size = std::snprintf(nullptr, 0, format.c_str(), args ...) + 1;
|
|
|
|
std::unique_ptr<char[]> buf(new char[size]);
|
|
std::snprintf(buf.get(), size, format.c_str(), args ...);
|
|
|
|
return std::string(buf.get(), buf.get() + size - 1);
|
|
}
|
|
|
|
std::string ToHexString(const void* data, size_t size);
|
|
|
|
}
|