15template<
class ...Args>
std::string string_format (
const char *format,
const Args &...args) __attribute__ ((__format__ (__printf__, 1, 0)));
19 locale_t saved_locale_ = {};
25 static locale_t posix_locale();
33 using StringFormatVariant::operator=;
34 void assign (
const char *s,
SL &h) { *
this = s; }
35 void assign (
const std::string &s,
SL &h) { *
this = s.c_str(); }
37 void assign (
const void *p,
SL &h) { *
this =
uint64_t (ptrdiff_t (p)); }
39 ::type assign (
const T &v,
SL &h) { *
this =
uint64_t (v); }
41 ::type assign (
const T &v,
SL &h) { *
this =
double (v); }
43 ::type assign (
const T &o,
SL &h) {
std::ostringstream s; s << o; h.push_back (s.
str()); *
this = h.back().c_str(); }
62template<
class ...Args> __attribute__ ((noinline))
std::string
65 constexpr size_t N =
sizeof... (Args);
69 (sfa[i++].assign (args, templist), ...);
70 return sfa[0].string_format_args (format, N, sfa);
Class to push the POSIX/C locale_t (UTF-8) for the scope of its lifetime.
The Anklang C++ API namespace.
std::string string_format(const char *format, const Args &...args) __attribute__((__format__(__printf__
Format a string similar to sprintf(3) with support for std::string and std::ostringstream convertible...