10#include <cosmos/formatting.hxx>
16 COSMOS_FORMAT_PRINTF(1, 0)
17std::
string sprintf_v(const
char *fmt, va_list orig_args) {
28 va_copy(varargs, orig_args);
30 written = vsnprintf(&ret[0], ret.size() + 1, fmt, varargs);
37 }
else if (
static_cast<size_t>(written) <= ret.size()) {
57std::string sprintf(
const char *fmt, ...) {
59 va_start(varargs, fmt);
60 const auto ret = sprintf_v(fmt, varargs);
67template <
typename NUM>
69 const auto orig_flags = o.flags();
70 const auto orig_fill = o.fill();
72 static_assert(std::is_integral_v<NUM>,
"template type needs to be an integral integer type");
79 o << fmtnum.basePrefix();
80 o << std::setw(fmtnum.width());
97#if SIZE_MAX != UINT_MAX