spdlog
Loading...
Searching...
No Matches
printf.h
Go to the documentation of this file.
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
8#ifndef FMT_PRINTF_H_
9#define FMT_PRINTF_H_
10
11#include <algorithm> // std::max
12#include <limits> // std::numeric_limits
13#include <ostream>
14
15#include "format.h"
16
19
20template <typename T> struct printf_formatter { printf_formatter() = delete; };
21
22template <typename Char>
26
27template <typename OutputIt, typename Char> class basic_printf_context {
28 private:
29 OutputIt out_;
31
32 public:
33 using char_type = Char;
36 template <typename T> using formatter_type = printf_formatter<T>;
37
38 /**
39 \rst
40 Constructs a ``printf_context`` object. References to the arguments are
41 stored in the context object so make sure they have appropriate lifetimes.
42 \endrst
43 */
47
48 OutputIt out() { return out_; }
49 void advance_to(OutputIt it) { out_ = it; }
50
51 detail::locale_ref locale() { return {}; }
52
53 format_arg arg(int id) const { return args_.get(id); }
54
55 FMT_CONSTEXPR void on_error(const char* message) {
56 detail::error_handler().on_error(message);
57 }
58};
59
61
62// Checks if a value fits in int - used to avoid warnings about comparing
63// signed and unsigned integers.
64template <bool IsSigned> struct int_checker {
65 template <typename T> static bool fits_in_int(T value) {
66 unsigned max = max_value<int>();
67 return value <= max;
68 }
69 static bool fits_in_int(bool) { return true; }
70};
71
72template <> struct int_checker<true> {
73 template <typename T> static bool fits_in_int(T value) {
75 value <= max_value<int>();
76 }
77 static bool fits_in_int(int) { return true; }
78};
79
81 public:
82 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
85 FMT_THROW(format_error("number is too big"));
86 return (std::max)(static_cast<int>(value), 0);
87 }
88
89 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
91 FMT_THROW(format_error("precision is not integer"));
92 return 0;
93 }
94};
95
96// An argument visitor that returns true iff arg is a zero integer.
98 public:
99 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
101 return value == 0;
102 }
103
104 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
105 bool operator()(T) {
106 return false;
107 }
108};
109
110template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
111
112template <> struct make_unsigned_or_bool<bool> { using type = bool; };
113
114template <typename T, typename Context> class arg_converter {
115 private:
116 using char_type = typename Context::char_type;
117
120
121 public:
124
125 void operator()(bool value) {
126 if (type_ != 's') operator()<bool>(value);
127 }
128
129 template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
131 bool is_signed = type_ == 'd' || type_ == 'i';
132 using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
133 if (const_check(sizeof(target_type) <= sizeof(int))) {
134 // Extra casts are used to silence warnings.
135 if (is_signed) {
136 arg_ = detail::make_arg<Context>(
137 static_cast<int>(static_cast<target_type>(value)));
138 } else {
139 using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
140 arg_ = detail::make_arg<Context>(
141 static_cast<unsigned>(static_cast<unsigned_type>(value)));
142 }
143 } else {
144 if (is_signed) {
145 // glibc's printf doesn't sign extend arguments of smaller types:
146 // std::printf("%lld", -42); // prints "4294967254"
147 // but we don't have to do the same because it's a UB.
148 arg_ = detail::make_arg<Context>(static_cast<long long>(value));
149 } else {
150 arg_ = detail::make_arg<Context>(
151 static_cast<typename make_unsigned_or_bool<U>::type>(value));
152 }
153 }
154 }
155
156 template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
157 void operator()(U) {} // No conversion needed for non-integral types.
158};
159
160// Converts an integer argument to T for printf, if T is an integral type.
161// If T is void, the argument is converted to corresponding signed or unsigned
162// type depending on the type specifier: 'd' and 'i' - signed, other -
163// unsigned).
164template <typename T, typename Context, typename Char>
168
169// Converts an integer argument to char for printf.
170template <typename Context> class char_converter {
171 private:
173
174 public:
176
177 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
179 arg_ = detail::make_arg<Context>(
180 static_cast<typename Context::char_type>(value));
181 }
182
183 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
184 void operator()(T) {} // No conversion needed for non-integral types.
185};
186
187// An argument visitor that return a pointer to a C string if argument is a
188// string or null otherwise.
189template <typename Char> struct get_cstring {
190 template <typename T> const Char* operator()(T) { return nullptr; }
191 const Char* operator()(const Char* s) { return s; }
192};
193
194// Checks if an argument is a valid printf width specifier and sets
195// left alignment if it is negative.
196template <typename Char> class printf_width_handler {
197 private:
199
201
202 public:
203 explicit printf_width_handler(format_specs& specs) : specs_(specs) {}
204
205 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
206 unsigned operator()(T value) {
207 auto width = static_cast<uint32_or_64_or_128_t<T>>(value);
208 if (detail::is_negative(value)) {
209 specs_.align = align::left;
210 width = 0 - width;
211 }
212 unsigned int_max = max_value<int>();
213 if (width > int_max) FMT_THROW(format_error("number is too big"));
214 return static_cast<unsigned>(width);
215 }
216
217 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
218 unsigned operator()(T) {
219 FMT_THROW(format_error("width is not integer"));
220 return 0;
221 }
222};
223
224// The ``printf`` argument formatter.
225template <typename OutputIt, typename Char>
227 private:
231
233
234 OutputIt write_null_pointer(bool is_string = false) {
235 auto s = this->specs;
236 s.type = 0;
237 return write_bytes(this->out, is_string ? "(null)" : "(nil)", s);
238 }
239
240 public:
242 : base{iter, s, locale_ref()}, context_(ctx) {}
243
245
246 template <typename T, FMT_ENABLE_IF(detail::is_integral<T>::value)>
247 OutputIt operator()(T value) {
248 // MSVC2013 fails to compile separate overloads for bool and Char so use
249 // std::is_same instead.
251 format_specs fmt_specs = this->specs;
252 if (fmt_specs.type && fmt_specs.type != 'c')
253 return (*this)(static_cast<int>(value));
254 fmt_specs.sign = sign::none;
255 fmt_specs.alt = false;
256 fmt_specs.fill[0] = ' '; // Ignore '0' flag for char types.
257 // align::numeric needs to be overwritten here since the '0' flag is
258 // ignored for non-numeric types
259 if (fmt_specs.align == align::none || fmt_specs.align == align::numeric)
260 fmt_specs.align = align::right;
261 return write<Char>(this->out, static_cast<Char>(value), fmt_specs);
262 }
263 return base::operator()(value);
264 }
265
266 template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
267 OutputIt operator()(T value) {
268 return base::operator()(value);
269 }
270
271 /** Formats a null-terminated C string. */
272 OutputIt operator()(const char* value) {
273 if (value) return base::operator()(value);
274 return write_null_pointer(this->specs.type != 'p');
275 }
276
277 /** Formats a null-terminated wide C string. */
278 OutputIt operator()(const wchar_t* value) {
279 if (value) return base::operator()(value);
280 return write_null_pointer(this->specs.type != 'p');
281 }
282
286
287 /** Formats a pointer. */
288 OutputIt operator()(const void* value) {
290 }
291
292 /** Formats an argument of a custom (user-defined) type. */
294 auto parse_ctx =
296 handle.format(parse_ctx, context_);
297 return this->out;
298 }
299};
300
301template <typename Char>
302void parse_flags(basic_format_specs<Char>& specs, const Char*& it,
303 const Char* end) {
304 for (; it != end; ++it) {
305 switch (*it) {
306 case '-':
307 specs.align = align::left;
308 break;
309 case '+':
310 specs.sign = sign::plus;
311 break;
312 case '0':
313 specs.fill[0] = '0';
314 break;
315 case ' ':
316 if (specs.sign != sign::plus) {
317 specs.sign = sign::space;
318 }
319 break;
320 case '#':
321 specs.alt = true;
322 break;
323 default:
324 return;
325 }
326 }
327}
328
329template <typename Char, typename GetArg>
330int parse_header(const Char*& it, const Char* end,
331 basic_format_specs<Char>& specs, GetArg get_arg) {
332 int arg_index = -1;
333 Char c = *it;
334 if (c >= '0' && c <= '9') {
335 // Parse an argument index (if followed by '$') or a width possibly
336 // preceded with '0' flag(s).
337 int value = parse_nonnegative_int(it, end, -1);
338 if (it != end && *it == '$') { // value is an argument index
339 ++it;
340 arg_index = value != -1 ? value : max_value<int>();
341 } else {
342 if (c == '0') specs.fill[0] = '0';
343 if (value != 0) {
344 // Nonzero value means that we parsed width and don't need to
345 // parse it or flags again, so return now.
346 if (value == -1) FMT_THROW(format_error("number is too big"));
347 specs.width = value;
348 return arg_index;
349 }
350 }
351 }
352 parse_flags(specs, it, end);
353 // Parse width.
354 if (it != end) {
355 if (*it >= '0' && *it <= '9') {
356 specs.width = parse_nonnegative_int(it, end, -1);
357 if (specs.width == -1) FMT_THROW(format_error("number is too big"));
358 } else if (*it == '*') {
359 ++it;
360 specs.width = static_cast<int>(visit_format_arg(
361 detail::printf_width_handler<Char>(specs), get_arg(-1)));
362 }
363 }
364 return arg_index;
365}
366
367template <typename Char, typename Context>
370 using OutputIt = buffer_appender<Char>;
371 auto out = OutputIt(buf);
372 auto context = basic_printf_context<OutputIt, Char>(out, args);
374
375 // Returns the argument with specified index or, if arg_index is -1, the next
376 // argument.
377 auto get_arg = [&](int arg_index) {
378 if (arg_index < 0)
379 arg_index = parse_ctx.next_arg_id();
380 else
381 parse_ctx.check_arg_id(--arg_index);
382 return detail::get_arg(context, arg_index);
383 };
384
385 const Char* start = parse_ctx.begin();
386 const Char* end = parse_ctx.end();
387 auto it = start;
388 while (it != end) {
389 if (!detail::find<false, Char>(it, end, '%', it)) {
390 it = end; // detail::find leaves it == nullptr if it doesn't find '%'
391 break;
392 }
393 Char c = *it++;
394 if (it != end && *it == c) {
395 out = detail::write(
396 out, basic_string_view<Char>(start, detail::to_unsigned(it - start)));
397 start = ++it;
398 continue;
399 }
401 start, detail::to_unsigned(it - 1 - start)));
402
404 specs.align = align::right;
405
406 // Parse argument index, flags and width.
407 int arg_index = parse_header(it, end, specs, get_arg);
408 if (arg_index == 0) parse_ctx.on_error("argument not found");
409
410 // Parse precision.
411 if (it != end && *it == '.') {
412 ++it;
413 c = it != end ? *it : 0;
414 if ('0' <= c && c <= '9') {
415 specs.precision = parse_nonnegative_int(it, end, 0);
416 } else if (c == '*') {
417 ++it;
418 specs.precision = static_cast<int>(
419 visit_format_arg(detail::printf_precision_handler(), get_arg(-1)));
420 } else {
421 specs.precision = 0;
422 }
423 }
424
425 auto arg = get_arg(arg_index);
426 // For d, i, o, u, x, and X conversion specifiers, if a precision is
427 // specified, the '0' flag is ignored
428 if (specs.precision >= 0 && arg.is_integral())
429 specs.fill[0] =
430 ' '; // Ignore '0' flag for non-numeric types or if '-' present.
431 if (specs.precision >= 0 && arg.type() == detail::type::cstring_type) {
432 auto str = visit_format_arg(detail::get_cstring<Char>(), arg);
433 auto str_end = str + specs.precision;
434 auto nul = std::find(str, str_end, Char());
435 arg = detail::make_arg<basic_printf_context<OutputIt, Char>>(
437 str, detail::to_unsigned(nul != str_end ? nul - str
438 : specs.precision)));
439 }
440 if (specs.alt && visit_format_arg(detail::is_zero_int(), arg))
441 specs.alt = false;
442 if (specs.fill[0] == '0') {
443 if (arg.is_arithmetic() && specs.align != align::left)
444 specs.align = align::numeric;
445 else
446 specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types or if '-'
447 // flag is also present.
448 }
449
450 // Parse length and convert the argument to the required type.
451 c = it != end ? *it++ : 0;
452 Char t = it != end ? *it : 0;
453 using detail::convert_arg;
454 switch (c) {
455 case 'h':
456 if (t == 'h') {
457 ++it;
458 t = it != end ? *it : 0;
459 convert_arg<signed char>(arg, t);
460 } else {
461 convert_arg<short>(arg, t);
462 }
463 break;
464 case 'l':
465 if (t == 'l') {
466 ++it;
467 t = it != end ? *it : 0;
468 convert_arg<long long>(arg, t);
469 } else {
470 convert_arg<long>(arg, t);
471 }
472 break;
473 case 'j':
474 convert_arg<intmax_t>(arg, t);
475 break;
476 case 'z':
477 convert_arg<size_t>(arg, t);
478 break;
479 case 't':
480 convert_arg<std::ptrdiff_t>(arg, t);
481 break;
482 case 'L':
483 // printf produces garbage when 'L' is omitted for long double, no
484 // need to do the same.
485 break;
486 default:
487 --it;
488 convert_arg<void>(arg, c);
489 }
490
491 // Parse type.
492 if (it == end) FMT_THROW(format_error("invalid format string"));
493 specs.type = static_cast<char>(*it++);
494 if (arg.is_integral()) {
495 // Normalize type.
496 switch (specs.type) {
497 case 'i':
498 case 'u':
499 specs.type = 'd';
500 break;
501 case 'c':
503 detail::char_converter<basic_printf_context<OutputIt, Char>>(arg),
504 arg);
505 break;
506 }
507 }
508
509 start = it;
510
511 // Format argument.
512 out = visit_format_arg(
513 detail::printf_arg_formatter<OutputIt, Char>(out, specs, context), arg);
514 }
515 detail::write(out, basic_string_view<Char>(start, to_unsigned(it - start)));
516}
518
519template <typename Char>
522
525
528
529/**
530 \rst
531 Constructs an `~fmt::format_arg_store` object that contains references to
532 arguments and can be implicitly converted to `~fmt::printf_args`.
533 \endrst
534 */
535template <typename... T>
536inline auto make_printf_args(const T&... args)
538 return {args...};
539}
540
541/**
542 \rst
543 Constructs an `~fmt::format_arg_store` object that contains references to
544 arguments and can be implicitly converted to `~fmt::wprintf_args`.
545 \endrst
546 */
547template <typename... T>
548inline auto make_wprintf_args(const T&... args)
550 return {args...};
551}
552
553template <typename S, typename Char = char_t<S>>
554inline auto vsprintf(
555 const S& fmt,
559 vprintf(buffer, to_string_view(fmt), args);
560 return to_string(buffer);
561}
562
563/**
564 \rst
565 Formats arguments and returns the result as a string.
566
567 **Example**::
568
569 std::string message = fmt::sprintf("The answer is %d", 42);
570 \endrst
571*/
572template <typename S, typename... T,
573 typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
574inline auto sprintf(const S& fmt, const T&... args) -> std::basic_string<Char> {
575 using context = basic_printf_context_t<Char>;
576 return vsprintf(to_string_view(fmt), fmt::make_format_args<context>(args...));
577}
578
579template <typename S, typename Char = char_t<S>>
580inline auto vfprintf(
581 std::FILE* f, const S& fmt,
583 -> int {
585 vprintf(buffer, to_string_view(fmt), args);
586 size_t size = buffer.size();
587 return std::fwrite(buffer.data(), sizeof(Char), size, f) < size
588 ? -1
589 : static_cast<int>(size);
590}
591
592/**
593 \rst
594 Prints formatted data to the file *f*.
595
596 **Example**::
597
598 fmt::fprintf(stderr, "Don't %s!", "panic");
599 \endrst
600 */
601template <typename S, typename... T, typename Char = char_t<S>>
602inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
603 using context = basic_printf_context_t<Char>;
604 return vfprintf(f, to_string_view(fmt),
605 fmt::make_format_args<context>(args...));
606}
607
608template <typename S, typename Char = char_t<S>>
609inline auto vprintf(
610 const S& fmt,
612 -> int {
613 return vfprintf(stdout, to_string_view(fmt), args);
614}
615
616/**
617 \rst
618 Prints formatted data to ``stdout``.
619
620 **Example**::
621
622 fmt::printf("Elapsed time: %.2f seconds", 1.23);
623 \endrst
624 */
625template <typename S, typename... T, FMT_ENABLE_IF(detail::is_string<S>::value)>
626inline auto printf(const S& fmt, const T&... args) -> int {
627 return vprintf(
628 to_string_view(fmt),
629 fmt::make_format_args<basic_printf_context_t<char_t<S>>>(args...));
630}
631
632template <typename S, typename Char = char_t<S>>
634 std::basic_ostream<Char>& os, const S& fmt,
636 -> int {
638 vprintf(buffer, to_string_view(fmt), args);
639 os.write(buffer.data(), static_cast<std::streamsize>(buffer.size()));
640 return static_cast<int>(buffer.size());
641}
642template <typename S, typename... T, typename Char = char_t<S>>
644 const T&... args) -> int {
645 return vfprintf(os, to_string_view(fmt),
646 fmt::make_format_args<basic_printf_context_t<Char>>(args...));
647}
648
651
652#endif // FMT_PRINTF_H_
char_type type_
Definition printf.h:119
arg_converter(basic_format_arg< Context > &arg, char_type type)
Definition printf.h:122
void operator()(U)
Definition printf.h:157
basic_format_arg< Context > & arg_
Definition printf.h:118
void operator()(U value)
Definition printf.h:130
typename Context::char_type char_type
Definition printf.h:116
void operator()(bool value)
Definition printf.h:125
void format(typename Context::parse_context_type &parse_ctx, Context &ctx) const
Definition core.h:1416
FMT_CONSTEXPR auto get(int id) const -> format_arg
Definition core.h:1814
basic_format_args< basic_printf_context > args_
Definition printf.h:30
OutputIt out()
Definition printf.h:48
FMT_CONSTEXPR void on_error(const char *message)
Definition printf.h:55
format_arg arg(int id) const
Definition printf.h:53
detail::locale_ref locale()
Definition printf.h:51
basic_printf_context(OutputIt out, basic_format_args< basic_printf_context > args)
Definition printf.h:44
void advance_to(OutputIt it)
Definition printf.h:49
Definition core.h:749
auto size() const FMT_NOEXCEPT -> size_t
Definition core.h:791
auto data() FMT_NOEXCEPT -> T *
Definition core.h:797
void operator()(T value)
Definition printf.h:178
void operator()(T)
Definition printf.h:184
basic_format_arg< Context > & arg_
Definition printf.h:172
char_converter(basic_format_arg< Context > &arg)
Definition printf.h:175
bool operator()(T value)
Definition printf.h:100
bool operator()(T)
Definition printf.h:105
OutputIt operator()(const void *value)
Definition printf.h:288
OutputIt operator()(const char *value)
Definition printf.h:272
printf_arg_formatter(OutputIt iter, format_specs &s, context_type &ctx)
Definition printf.h:241
OutputIt operator()(const wchar_t *value)
Definition printf.h:278
OutputIt operator()(monostate value)
Definition printf.h:244
OutputIt operator()(basic_string_view< Char > value)
Definition printf.h:283
basic_format_specs< Char > format_specs
Definition printf.h:230
OutputIt operator()(T value)
Definition printf.h:247
context_type & context_
Definition printf.h:232
OutputIt write_null_pointer(bool is_string=false)
Definition printf.h:234
OutputIt operator()(typename basic_format_arg< context_type >::handle handle)
Definition printf.h:293
int operator()(T value)
Definition printf.h:83
unsigned operator()(T)
Definition printf.h:218
format_specs & specs_
Definition printf.h:200
basic_format_specs< Char > format_specs
Definition printf.h:198
printf_width_handler(format_specs &specs)
Definition printf.h:203
unsigned operator()(T value)
Definition printf.h:206
Definition core.h:1120
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
Definition color.h:583
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0))
Definition core.h:1447
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Definition core.h:1725
typename detail::char_t_impl< S >::type char_t
Definition core.h:610
#define FMT_END_DETAIL_NAMESPACE
Definition core.h:245
#define FMT_MODULE_EXPORT_BEGIN
Definition core.h:242
#define FMT_CONSTEXPR
Definition core.h:99
type
Definition core.h:1048
#define FMT_BEGIN_NAMESPACE
Definition core.h:235
#define FMT_BEGIN_DETAIL_NAMESPACE
Definition core.h:244
constexpr auto const_check(T value) -> T
Definition core.h:361
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T > > > buffer_appender
Definition core.h:945
#define FMT_ENABLE_IF(...)
Definition core.h:347
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition core.h:412
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept -> int
Definition core.h:2096
typename type_identity< T >::type type_identity_t
Definition core.h:330
typename std::conditional< B, T, F >::type conditional_t
Definition core.h:323
T
Definition core.h:320
#define FMT_END_NAMESPACE
Definition core.h:230
#define FMT_MODULE_EXPORT_END
Definition core.h:243
T find(T... args)
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const basic_format_specs< Char > &specs) -> OutputIt
Definition format.h:1304
conditional_t< num_bits< T >()<=32 &&!FMT_REDUCE_INT_INSTANTIATIONS, uint32_t, conditional_t< num_bits< T >()<=64, uint64_t, uint128_t > > uint32_or_64_or_128_t
Definition format.h:847
#define FMT_DEPRECATED
Definition format.h:120
auto to_string(const T &value) -> std::string
Definition format.h:2600
#define FMT_THROW(x)
Definition format.h:96
FMT_CONSTEXPR auto get_arg(Context &ctx, ID id) -> typename Context::format_arg
Definition format.h:2064
T fwrite(T... args)
T max(T... args)
@ left
Definition core.h:1859
@ none
Definition core.h:1859
@ right
Definition core.h:1859
@ numeric
Definition core.h:1859
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
@ plus
Definition core.h:1863
@ none
Definition core.h:1863
@ space
Definition core.h:1863
void convert_arg(basic_format_arg< Context > &arg, Char type)
Definition printf.h:165
auto vfprintf(std::FILE *f, const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char > > > args) -> int
Definition printf.h:580
auto vsprintf(const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char > > > args) -> std::basic_string< Char >
Definition printf.h:554
auto make_wprintf_args(const T &... args) -> format_arg_store< wprintf_context, T... >
Definition printf.h:548
void vprintf(buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
Definition printf.h:368
basic_printf_context_t< wchar_t > wprintf_context
Definition printf.h:524
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
Definition printf.h:602
auto printf(const S &fmt, const T &... args) -> int
Definition printf.h:626
auto sprintf(const S &fmt, const T &... args) -> std::basic_string< Char >
Definition printf.h:574
basic_printf_context_t< char > printf_context
Definition printf.h:523
void parse_flags(basic_format_specs< Char > &specs, const Char *&it, const Char *end)
Definition printf.h:302
auto make_printf_args(const T &... args) -> format_arg_store< printf_context, T... >
Definition printf.h:536
int parse_header(const Char *&it, const Char *end, basic_format_specs< Char > &specs, GetArg get_arg)
Definition printf.h:330
FMT_CONSTEXPR FMT_INLINE auto operator()(T value) -> iterator
Definition format.h:1988
const basic_format_specs< Char > & specs
Definition format.h:1984
iterator out
Definition format.h:1983
detail::fill_t< Char > fill
Definition core.h:1905
align_t align
Definition core.h:1901
const Char * operator()(const Char *s)
Definition printf.h:191
const Char * operator()(T)
Definition printf.h:190
static bool fits_in_int(T value)
Definition printf.h:73
static bool fits_in_int(int)
Definition printf.h:77
static bool fits_in_int(bool)
Definition printf.h:69
static bool fits_in_int(T value)
Definition printf.h:65
printf_formatter()=delete