printf.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. // Formatting library for C++ - legacy printf implementation
  2. //
  3. // Copyright (c) 2012 - 2016, Victor Zverovich
  4. // All rights reserved.
  5. //
  6. // For the license information refer to format.h.
  7. #ifndef FMT_PRINTF_H_
  8. #define FMT_PRINTF_H_
  9. #ifndef FMT_MODULE
  10. # include <algorithm> // std::max
  11. # include <limits> // std::numeric_limits
  12. #endif
  13. #include "format.h"
  14. FMT_BEGIN_NAMESPACE
  15. FMT_BEGIN_EXPORT
  16. template <typename T> struct printf_formatter {
  17. printf_formatter() = delete;
  18. };
  19. template <typename Char> class basic_printf_context {
  20. private:
  21. basic_appender<Char> out_;
  22. basic_format_args<basic_printf_context> args_;
  23. static_assert(std::is_same<Char, char>::value ||
  24. std::is_same<Char, wchar_t>::value,
  25. "Unsupported code unit type.");
  26. public:
  27. using char_type = Char;
  28. using parse_context_type = basic_format_parse_context<Char>;
  29. template <typename T> using formatter_type = printf_formatter<T>;
  30. /// Constructs a `printf_context` object. References to the arguments are
  31. /// stored in the context object so make sure they have appropriate lifetimes.
  32. basic_printf_context(basic_appender<Char> out,
  33. basic_format_args<basic_printf_context> args)
  34. : out_(out), args_(args) {}
  35. auto out() -> basic_appender<Char> { return out_; }
  36. void advance_to(basic_appender<Char>) {}
  37. auto locale() -> detail::locale_ref { return {}; }
  38. auto arg(int id) const -> basic_format_arg<basic_printf_context> {
  39. return args_.get(id);
  40. }
  41. };
  42. namespace detail {
  43. // Checks if a value fits in int - used to avoid warnings about comparing
  44. // signed and unsigned integers.
  45. template <bool IsSigned> struct int_checker {
  46. template <typename T> static auto fits_in_int(T value) -> bool {
  47. unsigned max = to_unsigned(max_value<int>());
  48. return value <= max;
  49. }
  50. static auto fits_in_int(bool) -> bool { return true; }
  51. };
  52. template <> struct int_checker<true> {
  53. template <typename T> static auto fits_in_int(T value) -> bool {
  54. return value >= (std::numeric_limits<int>::min)() &&
  55. value <= max_value<int>();
  56. }
  57. static auto fits_in_int(int) -> bool { return true; }
  58. };
  59. struct printf_precision_handler {
  60. template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
  61. auto operator()(T value) -> int {
  62. if (!int_checker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
  63. report_error("number is too big");
  64. return (std::max)(static_cast<int>(value), 0);
  65. }
  66. template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
  67. auto operator()(T) -> int {
  68. report_error("precision is not integer");
  69. return 0;
  70. }
  71. };
  72. // An argument visitor that returns true iff arg is a zero integer.
  73. struct is_zero_int {
  74. template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
  75. auto operator()(T value) -> bool {
  76. return value == 0;
  77. }
  78. template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
  79. auto operator()(T) -> bool {
  80. return false;
  81. }
  82. };
  83. template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
  84. template <> struct make_unsigned_or_bool<bool> {
  85. using type = bool;
  86. };
  87. template <typename T, typename Context> class arg_converter {
  88. private:
  89. using char_type = typename Context::char_type;
  90. basic_format_arg<Context>& arg_;
  91. char_type type_;
  92. public:
  93. arg_converter(basic_format_arg<Context>& arg, char_type type)
  94. : arg_(arg), type_(type) {}
  95. void operator()(bool value) {
  96. if (type_ != 's') operator()<bool>(value);
  97. }
  98. template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
  99. void operator()(U value) {
  100. bool is_signed = type_ == 'd' || type_ == 'i';
  101. using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
  102. if (const_check(sizeof(target_type) <= sizeof(int))) {
  103. // Extra casts are used to silence warnings.
  104. if (is_signed) {
  105. auto n = static_cast<int>(static_cast<target_type>(value));
  106. arg_ = detail::make_arg<Context>(n);
  107. } else {
  108. using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
  109. auto n = static_cast<unsigned>(static_cast<unsigned_type>(value));
  110. arg_ = detail::make_arg<Context>(n);
  111. }
  112. } else {
  113. if (is_signed) {
  114. // glibc's printf doesn't sign extend arguments of smaller types:
  115. // std::printf("%lld", -42); // prints "4294967254"
  116. // but we don't have to do the same because it's a UB.
  117. auto n = static_cast<long long>(value);
  118. arg_ = detail::make_arg<Context>(n);
  119. } else {
  120. auto n = static_cast<typename make_unsigned_or_bool<U>::type>(value);
  121. arg_ = detail::make_arg<Context>(n);
  122. }
  123. }
  124. }
  125. template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
  126. void operator()(U) {} // No conversion needed for non-integral types.
  127. };
  128. // Converts an integer argument to T for printf, if T is an integral type.
  129. // If T is void, the argument is converted to corresponding signed or unsigned
  130. // type depending on the type specifier: 'd' and 'i' - signed, other -
  131. // unsigned).
  132. template <typename T, typename Context, typename Char>
  133. void convert_arg(basic_format_arg<Context>& arg, Char type) {
  134. arg.visit(arg_converter<T, Context>(arg, type));
  135. }
  136. // Converts an integer argument to char for printf.
  137. template <typename Context> class char_converter {
  138. private:
  139. basic_format_arg<Context>& arg_;
  140. public:
  141. explicit char_converter(basic_format_arg<Context>& arg) : arg_(arg) {}
  142. template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
  143. void operator()(T value) {
  144. auto c = static_cast<typename Context::char_type>(value);
  145. arg_ = detail::make_arg<Context>(c);
  146. }
  147. template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
  148. void operator()(T) {} // No conversion needed for non-integral types.
  149. };
  150. // An argument visitor that return a pointer to a C string if argument is a
  151. // string or null otherwise.
  152. template <typename Char> struct get_cstring {
  153. template <typename T> auto operator()(T) -> const Char* { return nullptr; }
  154. auto operator()(const Char* s) -> const Char* { return s; }
  155. };
  156. // Checks if an argument is a valid printf width specifier and sets
  157. // left alignment if it is negative.
  158. class printf_width_handler {
  159. private:
  160. format_specs& specs_;
  161. public:
  162. explicit printf_width_handler(format_specs& specs) : specs_(specs) {}
  163. template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
  164. auto operator()(T value) -> unsigned {
  165. auto width = static_cast<uint32_or_64_or_128_t<T>>(value);
  166. if (detail::is_negative(value)) {
  167. specs_.align = align::left;
  168. width = 0 - width;
  169. }
  170. unsigned int_max = to_unsigned(max_value<int>());
  171. if (width > int_max) report_error("number is too big");
  172. return static_cast<unsigned>(width);
  173. }
  174. template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
  175. auto operator()(T) -> unsigned {
  176. report_error("width is not integer");
  177. return 0;
  178. }
  179. };
  180. // Workaround for a bug with the XL compiler when initializing
  181. // printf_arg_formatter's base class.
  182. template <typename Char>
  183. auto make_arg_formatter(basic_appender<Char> iter, format_specs& s)
  184. -> arg_formatter<Char> {
  185. return {iter, s, locale_ref()};
  186. }
  187. // The `printf` argument formatter.
  188. template <typename Char>
  189. class printf_arg_formatter : public arg_formatter<Char> {
  190. private:
  191. using base = arg_formatter<Char>;
  192. using context_type = basic_printf_context<Char>;
  193. context_type& context_;
  194. void write_null_pointer(bool is_string = false) {
  195. auto s = this->specs;
  196. s.type = presentation_type::none;
  197. write_bytes<Char>(this->out, is_string ? "(null)" : "(nil)", s);
  198. }
  199. public:
  200. printf_arg_formatter(basic_appender<Char> iter, format_specs& s,
  201. context_type& ctx)
  202. : base(make_arg_formatter(iter, s)), context_(ctx) {}
  203. void operator()(monostate value) { base::operator()(value); }
  204. template <typename T, FMT_ENABLE_IF(detail::is_integral<T>::value)>
  205. void operator()(T value) {
  206. // MSVC2013 fails to compile separate overloads for bool and Char so use
  207. // std::is_same instead.
  208. if (!std::is_same<T, Char>::value) {
  209. base::operator()(value);
  210. return;
  211. }
  212. format_specs s = this->specs;
  213. if (s.type != presentation_type::none && s.type != presentation_type::chr) {
  214. return (*this)(static_cast<int>(value));
  215. }
  216. s.sign = sign::none;
  217. s.alt = false;
  218. s.fill = ' '; // Ignore '0' flag for char types.
  219. // align::numeric needs to be overwritten here since the '0' flag is
  220. // ignored for non-numeric types
  221. if (s.align == align::none || s.align == align::numeric)
  222. s.align = align::right;
  223. write<Char>(this->out, static_cast<Char>(value), s);
  224. }
  225. template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
  226. void operator()(T value) {
  227. base::operator()(value);
  228. }
  229. void operator()(const char* value) {
  230. if (value)
  231. base::operator()(value);
  232. else
  233. write_null_pointer(this->specs.type != presentation_type::pointer);
  234. }
  235. void operator()(const wchar_t* value) {
  236. if (value)
  237. base::operator()(value);
  238. else
  239. write_null_pointer(this->specs.type != presentation_type::pointer);
  240. }
  241. void operator()(basic_string_view<Char> value) { base::operator()(value); }
  242. void operator()(const void* value) {
  243. if (value)
  244. base::operator()(value);
  245. else
  246. write_null_pointer();
  247. }
  248. void operator()(typename basic_format_arg<context_type>::handle handle) {
  249. auto parse_ctx = basic_format_parse_context<Char>({});
  250. handle.format(parse_ctx, context_);
  251. }
  252. };
  253. template <typename Char>
  254. void parse_flags(format_specs& specs, const Char*& it, const Char* end) {
  255. for (; it != end; ++it) {
  256. switch (*it) {
  257. case '-':
  258. specs.align = align::left;
  259. break;
  260. case '+':
  261. specs.sign = sign::plus;
  262. break;
  263. case '0':
  264. specs.fill = '0';
  265. break;
  266. case ' ':
  267. if (specs.sign != sign::plus) specs.sign = sign::space;
  268. break;
  269. case '#':
  270. specs.alt = true;
  271. break;
  272. default:
  273. return;
  274. }
  275. }
  276. }
  277. template <typename Char, typename GetArg>
  278. auto parse_header(const Char*& it, const Char* end, format_specs& specs,
  279. GetArg get_arg) -> int {
  280. int arg_index = -1;
  281. Char c = *it;
  282. if (c >= '0' && c <= '9') {
  283. // Parse an argument index (if followed by '$') or a width possibly
  284. // preceded with '0' flag(s).
  285. int value = parse_nonnegative_int(it, end, -1);
  286. if (it != end && *it == '$') { // value is an argument index
  287. ++it;
  288. arg_index = value != -1 ? value : max_value<int>();
  289. } else {
  290. if (c == '0') specs.fill = '0';
  291. if (value != 0) {
  292. // Nonzero value means that we parsed width and don't need to
  293. // parse it or flags again, so return now.
  294. if (value == -1) report_error("number is too big");
  295. specs.width = value;
  296. return arg_index;
  297. }
  298. }
  299. }
  300. parse_flags(specs, it, end);
  301. // Parse width.
  302. if (it != end) {
  303. if (*it >= '0' && *it <= '9') {
  304. specs.width = parse_nonnegative_int(it, end, -1);
  305. if (specs.width == -1) report_error("number is too big");
  306. } else if (*it == '*') {
  307. ++it;
  308. specs.width = static_cast<int>(
  309. get_arg(-1).visit(detail::printf_width_handler(specs)));
  310. }
  311. }
  312. return arg_index;
  313. }
  314. inline auto parse_printf_presentation_type(char c, type t, bool& upper)
  315. -> presentation_type {
  316. using pt = presentation_type;
  317. constexpr auto integral_set = sint_set | uint_set | bool_set | char_set;
  318. switch (c) {
  319. case 'd':
  320. return in(t, integral_set) ? pt::dec : pt::none;
  321. case 'o':
  322. return in(t, integral_set) ? pt::oct : pt::none;
  323. case 'X':
  324. upper = true;
  325. FMT_FALLTHROUGH;
  326. case 'x':
  327. return in(t, integral_set) ? pt::hex : pt::none;
  328. case 'E':
  329. upper = true;
  330. FMT_FALLTHROUGH;
  331. case 'e':
  332. return in(t, float_set) ? pt::exp : pt::none;
  333. case 'F':
  334. upper = true;
  335. FMT_FALLTHROUGH;
  336. case 'f':
  337. return in(t, float_set) ? pt::fixed : pt::none;
  338. case 'G':
  339. upper = true;
  340. FMT_FALLTHROUGH;
  341. case 'g':
  342. return in(t, float_set) ? pt::general : pt::none;
  343. case 'A':
  344. upper = true;
  345. FMT_FALLTHROUGH;
  346. case 'a':
  347. return in(t, float_set) ? pt::hexfloat : pt::none;
  348. case 'c':
  349. return in(t, integral_set) ? pt::chr : pt::none;
  350. case 's':
  351. return in(t, string_set | cstring_set) ? pt::string : pt::none;
  352. case 'p':
  353. return in(t, pointer_set | cstring_set) ? pt::pointer : pt::none;
  354. default:
  355. return pt::none;
  356. }
  357. }
  358. template <typename Char, typename Context>
  359. void vprintf(buffer<Char>& buf, basic_string_view<Char> format,
  360. basic_format_args<Context> args) {
  361. using iterator = basic_appender<Char>;
  362. auto out = iterator(buf);
  363. auto context = basic_printf_context<Char>(out, args);
  364. auto parse_ctx = basic_format_parse_context<Char>(format);
  365. // Returns the argument with specified index or, if arg_index is -1, the next
  366. // argument.
  367. auto get_arg = [&](int arg_index) {
  368. if (arg_index < 0)
  369. arg_index = parse_ctx.next_arg_id();
  370. else
  371. parse_ctx.check_arg_id(--arg_index);
  372. return detail::get_arg(context, arg_index);
  373. };
  374. const Char* start = parse_ctx.begin();
  375. const Char* end = parse_ctx.end();
  376. auto it = start;
  377. while (it != end) {
  378. if (!find<false, Char>(it, end, '%', it)) {
  379. it = end; // find leaves it == nullptr if it doesn't find '%'.
  380. break;
  381. }
  382. Char c = *it++;
  383. if (it != end && *it == c) {
  384. write(out, basic_string_view<Char>(start, to_unsigned(it - start)));
  385. start = ++it;
  386. continue;
  387. }
  388. write(out, basic_string_view<Char>(start, to_unsigned(it - 1 - start)));
  389. auto specs = format_specs();
  390. specs.align = align::right;
  391. // Parse argument index, flags and width.
  392. int arg_index = parse_header(it, end, specs, get_arg);
  393. if (arg_index == 0) report_error("argument not found");
  394. // Parse precision.
  395. if (it != end && *it == '.') {
  396. ++it;
  397. c = it != end ? *it : 0;
  398. if ('0' <= c && c <= '9') {
  399. specs.precision = parse_nonnegative_int(it, end, 0);
  400. } else if (c == '*') {
  401. ++it;
  402. specs.precision =
  403. static_cast<int>(get_arg(-1).visit(printf_precision_handler()));
  404. } else {
  405. specs.precision = 0;
  406. }
  407. }
  408. auto arg = get_arg(arg_index);
  409. // For d, i, o, u, x, and X conversion specifiers, if a precision is
  410. // specified, the '0' flag is ignored
  411. if (specs.precision >= 0 && arg.is_integral()) {
  412. // Ignore '0' for non-numeric types or if '-' present.
  413. specs.fill = ' ';
  414. }
  415. if (specs.precision >= 0 && arg.type() == type::cstring_type) {
  416. auto str = arg.visit(get_cstring<Char>());
  417. auto str_end = str + specs.precision;
  418. auto nul = std::find(str, str_end, Char());
  419. auto sv = basic_string_view<Char>(
  420. str, to_unsigned(nul != str_end ? nul - str : specs.precision));
  421. arg = make_arg<basic_printf_context<Char>>(sv);
  422. }
  423. if (specs.alt && arg.visit(is_zero_int())) specs.alt = false;
  424. if (specs.fill.template get<Char>() == '0') {
  425. if (arg.is_arithmetic() && specs.align != align::left)
  426. specs.align = align::numeric;
  427. else
  428. specs.fill = ' '; // Ignore '0' flag for non-numeric types or if '-'
  429. // flag is also present.
  430. }
  431. // Parse length and convert the argument to the required type.
  432. c = it != end ? *it++ : 0;
  433. Char t = it != end ? *it : 0;
  434. switch (c) {
  435. case 'h':
  436. if (t == 'h') {
  437. ++it;
  438. t = it != end ? *it : 0;
  439. convert_arg<signed char>(arg, t);
  440. } else {
  441. convert_arg<short>(arg, t);
  442. }
  443. break;
  444. case 'l':
  445. if (t == 'l') {
  446. ++it;
  447. t = it != end ? *it : 0;
  448. convert_arg<long long>(arg, t);
  449. } else {
  450. convert_arg<long>(arg, t);
  451. }
  452. break;
  453. case 'j':
  454. convert_arg<intmax_t>(arg, t);
  455. break;
  456. case 'z':
  457. convert_arg<size_t>(arg, t);
  458. break;
  459. case 't':
  460. convert_arg<std::ptrdiff_t>(arg, t);
  461. break;
  462. case 'L':
  463. // printf produces garbage when 'L' is omitted for long double, no
  464. // need to do the same.
  465. break;
  466. default:
  467. --it;
  468. convert_arg<void>(arg, c);
  469. }
  470. // Parse type.
  471. if (it == end) report_error("invalid format string");
  472. char type = static_cast<char>(*it++);
  473. if (arg.is_integral()) {
  474. // Normalize type.
  475. switch (type) {
  476. case 'i':
  477. case 'u':
  478. type = 'd';
  479. break;
  480. case 'c':
  481. arg.visit(char_converter<basic_printf_context<Char>>(arg));
  482. break;
  483. }
  484. }
  485. bool upper = false;
  486. specs.type = parse_printf_presentation_type(type, arg.type(), upper);
  487. if (specs.type == presentation_type::none)
  488. report_error("invalid format specifier");
  489. specs.upper = upper;
  490. start = it;
  491. // Format argument.
  492. arg.visit(printf_arg_formatter<Char>(out, specs, context));
  493. }
  494. write(out, basic_string_view<Char>(start, to_unsigned(it - start)));
  495. }
  496. } // namespace detail
  497. using printf_context = basic_printf_context<char>;
  498. using wprintf_context = basic_printf_context<wchar_t>;
  499. using printf_args = basic_format_args<printf_context>;
  500. using wprintf_args = basic_format_args<wprintf_context>;
  501. /// Constructs an `format_arg_store` object that contains references to
  502. /// arguments and can be implicitly converted to `printf_args`.
  503. template <typename Char = char, typename... T>
  504. inline auto make_printf_args(T&... args)
  505. -> decltype(fmt::make_format_args<basic_printf_context<Char>>(args...)) {
  506. return fmt::make_format_args<basic_printf_context<Char>>(args...);
  507. }
  508. template <typename Char> struct vprintf_args {
  509. using type = basic_format_args<basic_printf_context<Char>>;
  510. };
  511. template <typename Char>
  512. inline auto vsprintf(basic_string_view<Char> fmt,
  513. typename vprintf_args<Char>::type args)
  514. -> std::basic_string<Char> {
  515. auto buf = basic_memory_buffer<Char>();
  516. detail::vprintf(buf, fmt, args);
  517. return to_string(buf);
  518. }
  519. /**
  520. * Formats `args` according to specifications in `fmt` and returns the result
  521. * as as string.
  522. *
  523. * **Example**:
  524. *
  525. * std::string message = fmt::sprintf("The answer is %d", 42);
  526. */
  527. template <typename S, typename... T, typename Char = char_t<S>>
  528. inline auto sprintf(const S& fmt, const T&... args) -> std::basic_string<Char> {
  529. return vsprintf(detail::to_string_view(fmt),
  530. fmt::make_format_args<basic_printf_context<Char>>(args...));
  531. }
  532. template <typename Char>
  533. inline auto vfprintf(std::FILE* f, basic_string_view<Char> fmt,
  534. typename vprintf_args<Char>::type args) -> int {
  535. auto buf = basic_memory_buffer<Char>();
  536. detail::vprintf(buf, fmt, args);
  537. size_t size = buf.size();
  538. return std::fwrite(buf.data(), sizeof(Char), size, f) < size
  539. ? -1
  540. : static_cast<int>(size);
  541. }
  542. /**
  543. * Formats `args` according to specifications in `fmt` and writes the output
  544. * to `f`.
  545. *
  546. * **Example**:
  547. *
  548. * fmt::fprintf(stderr, "Don't %s!", "panic");
  549. */
  550. template <typename S, typename... T, typename Char = char_t<S>>
  551. inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
  552. return vfprintf(f, detail::to_string_view(fmt),
  553. make_printf_args<Char>(args...));
  554. }
  555. template <typename Char>
  556. FMT_DEPRECATED inline auto vprintf(basic_string_view<Char> fmt,
  557. typename vprintf_args<Char>::type args)
  558. -> int {
  559. return vfprintf(stdout, fmt, args);
  560. }
  561. /**
  562. * Formats `args` according to specifications in `fmt` and writes the output
  563. * to `stdout`.
  564. *
  565. * **Example**:
  566. *
  567. * fmt::printf("Elapsed time: %.2f seconds", 1.23);
  568. */
  569. template <typename... T>
  570. inline auto printf(string_view fmt, const T&... args) -> int {
  571. return vfprintf(stdout, fmt, make_printf_args(args...));
  572. }
  573. template <typename... T>
  574. FMT_DEPRECATED inline auto printf(basic_string_view<wchar_t> fmt,
  575. const T&... args) -> int {
  576. return vfprintf(stdout, fmt, make_printf_args<wchar_t>(args...));
  577. }
  578. FMT_END_EXPORT
  579. FMT_END_NAMESPACE
  580. #endif // FMT_PRINTF_H_