5#ifndef GEMMI_SPRINTF_HPP_
6#define GEMMI_SPRINTF_HPP_
10# if __has_include(<charconv>) && !(defined(_MSVC_LANG) && _MSVC_LANG < 201703L)
15#if __cpp_lib_to_chars < 201611L
24#if (defined(__GNUC__) && !defined(__MINGW32__)) || defined(__clang__)
25# define GEMMI_ATTRIBUTE_FORMAT(fmt,va) __attribute__((format(printf,fmt,va)))
27# define GEMMI_ATTRIBUTE_FORMAT(fmt,va)
39 return std::string(buf, len > 0 ? len : 0);
45 return std::string(buf, len > 0 ? len : 0);
50 static_assert(
Prec >= 0 &&
Prec < 7,
"unsupported precision");
54 return std::string(buf, len > 0 ? len : 0);
59#if __cpp_lib_to_chars >= 201611L
60 auto result = std::to_chars(first,
last-1, value);
65 return std::min(first + n,
last - 1);
69#if __cpp_lib_to_chars >= 201611L
70 auto result = std::to_chars(first,
last-1, value);
75 return std::min(first + n,
last - 1);
char * to_chars_z(char *first, char *last, int value)
zero-terminated to_chars()
GEMMI_DLL int GEMMI_DLL int sprintf_z(char *buf, char const *fmt,...) GEMMI_ATTRIBUTE_FORMAT(2
stb_sprintf in gemmi namespace
GEMMI_DLL int GEMMI_DLL int std::string to_str(double d)
GEMMI_DLL int snprintf_z(char *buf, int count, char const *fmt,...) GEMMI_ATTRIBUTE_FORMAT(3
stb_snprintf in gemmi namespace - like snprintf, but ignores locale and is always zero-terminated (he...
std::string to_str_prec(double d)
#define GEMMI_ATTRIBUTE_FORMAT(fmt, va)