DRXUtil/source/Utils.hpp
2024-04-02 17:51:50 +02:00

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);
}