5 #ifndef FML__INTERNALS_UTILS_H 6 #define FML__INTERNALS_UTILS_H 19 std::string format(
const char *fmt, ...)
25 const auto r = std::vsnprintf(buf,
sizeof buf, fmt, args);
36 std::string s(len,
'\0');
38 std::vsnprintf(s.data(), len+1, fmt, args);
45 inline void log(
const char *fmt, ...)
49 vfprintf(stdout, fmt, args);
53 inline void warn(
const char *fmt, ...)
57 vfprintf(stderr, fmt, args);
61 inline void oom(
const char *fmt, ...)
63 throw std::bad_alloc();
66 inline void error(
const char *fmt, ...)
68 throw std::runtime_error(
"invalid dimensions");