WPILibC++ 2024.3.2
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
14#include "format.h"
15
18
19template <typename T> struct printf_formatter { printf_formatter() = delete; };
20
21template <typename Char> class basic_printf_context {
22 private:
25
26 public:
27 using char_type = Char;
29 template <typename T> using formatter_type = printf_formatter<T>;
30
31 /**
32 \rst
33 Constructs a ``printf_context`` object. References to the arguments are
34 stored in the context object so make sure they have appropriate lifetimes.
35 \endrst
36 */
39 : out_(out), args_(args) {}
40
41 auto out() -> detail::buffer_appender<Char> { return out_; }
43
44 auto locale() -> detail::locale_ref { return {}; }
45
47 return args_.get(id);
48 }
49
50 FMT_CONSTEXPR void on_error(const char* message) {
52 }
53};
54
55namespace detail {
56
57// Checks if a value fits in int - used to avoid warnings about comparing
58// signed and unsigned integers.
59template <bool IsSigned> struct int_checker {
60 template <typename T> static auto fits_in_int(T value) -> bool {
61 unsigned max = max_value<int>();
62 return value <= max;
63 }
64 static auto fits_in_int(bool) -> bool { return true; }
65};
66
67template <> struct int_checker<true> {
68 template <typename T> static auto fits_in_int(T value) -> bool {
71 }
72 static auto fits_in_int(int) -> bool { return true; }
73};
74
76 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
77 auto operator()(T value) -> int {
79 throw_format_error("number is too big");
80 return (std::max)(static_cast<int>(value), 0);
81 }
82
83 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
84 auto operator()(T) -> int {
85 throw_format_error("precision is not integer");
86 return 0;
87 }
88};
89
90// An argument visitor that returns true iff arg is a zero integer.
92 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
93 auto operator()(T value) -> bool {
94 return value == 0;
95 }
96
97 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
98 auto operator()(T) -> bool {
99 return false;
100 }
101};
102
103template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
104
105template <> struct make_unsigned_or_bool<bool> { using type = bool; };
106
107template <typename T, typename Context> class arg_converter {
108 private:
109 using char_type = typename Context::char_type;
110
112 char_type type_;
113
114 public:
116 : arg_(arg), type_(type) {}
117
118 void operator()(bool value) {
119 if (type_ != 's') operator()<bool>(value);
120 }
121
122 template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
124 bool is_signed = type_ == 'd' || type_ == 'i';
125 using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
126 if (const_check(sizeof(target_type) <= sizeof(int))) {
127 // Extra casts are used to silence warnings.
128 if (is_signed) {
129 auto n = static_cast<int>(static_cast<target_type>(value));
130 arg_ = detail::make_arg<Context>(n);
131 } else {
132 using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
133 auto n = static_cast<unsigned>(static_cast<unsigned_type>(value));
134 arg_ = detail::make_arg<Context>(n);
135 }
136 } else {
137 if (is_signed) {
138 // glibc's printf doesn't sign extend arguments of smaller types:
139 // std::printf("%lld", -42); // prints "4294967254"
140 // but we don't have to do the same because it's a UB.
141 auto n = static_cast<long long>(value);
142 arg_ = detail::make_arg<Context>(n);
143 } else {
144 auto n = static_cast<typename make_unsigned_or_bool<U>::type>(value);
145 arg_ = detail::make_arg<Context>(n);
146 }
147 }
148 }
149
150 template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
151 void operator()(U) {} // No conversion needed for non-integral types.
152};
153
154// Converts an integer argument to T for printf, if T is an integral type.
155// If T is void, the argument is converted to corresponding signed or unsigned
156// type depending on the type specifier: 'd' and 'i' - signed, other -
157// unsigned).
158template <typename T, typename Context, typename Char>
161}
162
163// Converts an integer argument to char for printf.
164template <typename Context> class char_converter {
165 private:
167
168 public:
170
171 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
173 auto c = static_cast<typename Context::char_type>(value);
174 arg_ = detail::make_arg<Context>(c);
175 }
176
177 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
178 void operator()(T) {} // No conversion needed for non-integral types.
179};
180
181// An argument visitor that return a pointer to a C string if argument is a
182// string or null otherwise.
183template <typename Char> struct get_cstring {
184 template <typename T> auto operator()(T) -> const Char* { return nullptr; }
185 auto operator()(const Char* s) -> const Char* { return s; }
186};
187
188// Checks if an argument is a valid printf width specifier and sets
189// left alignment if it is negative.
190template <typename Char> class printf_width_handler {
191 private:
192 format_specs<Char>& specs_;
193
194 public:
195 explicit printf_width_handler(format_specs<Char>& specs) : specs_(specs) {}
196
197 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
198 auto operator()(T value) -> unsigned {
199 auto width = static_cast<uint32_or_64_or_128_t<T>>(value);
201 specs_.align = align::left;
202 width = 0 - width;
203 }
204 unsigned int_max = max_value<int>();
205 if (width > int_max) throw_format_error("number is too big");
206 return static_cast<unsigned>(width);
207 }
208
209 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
210 auto operator()(T) -> unsigned {
211 throw_format_error("width is not integer");
212 return 0;
213 }
214};
215
216// Workaround for a bug with the XL compiler when initializing
217// printf_arg_formatter's base class.
218template <typename Char>
221 return {iter, s, locale_ref()};
222}
223
224// The ``printf`` argument formatter.
225template <typename Char>
227 private:
230
231 context_type& context_;
232
233 void write_null_pointer(bool is_string = false) {
234 auto s = this->specs;
236 write_bytes(this->out, is_string ? "(null)" : "(nil)", s);
237 }
238
239 public:
241 context_type& ctx)
242 : base(make_arg_formatter(iter, s)), context_(ctx) {}
243
245
246 template <typename T, FMT_ENABLE_IF(detail::is_integral<T>::value)>
248 // MSVC2013 fails to compile separate overloads for bool and Char so use
249 // std::is_same instead.
250 if (!std::is_same<T, Char>::value) {
252 return;
253 }
254 format_specs<Char> fmt_specs = this->specs;
255 if (fmt_specs.type != presentation_type::none &&
256 fmt_specs.type != presentation_type::chr) {
257 return (*this)(static_cast<int>(value));
258 }
259 fmt_specs.sign = sign::none;
260 fmt_specs.alt = false;
261 fmt_specs.fill[0] = ' '; // Ignore '0' flag for char types.
262 // align::numeric needs to be overwritten here since the '0' flag is
263 // ignored for non-numeric types
264 if (fmt_specs.align == align::none || fmt_specs.align == align::numeric)
265 fmt_specs.align = align::right;
266 write<Char>(this->out, static_cast<Char>(value), fmt_specs);
267 }
268
269 template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
272 }
273
274 /** Formats a null-terminated C string. */
275 void operator()(const char* value) {
276 if (value)
278 else
279 write_null_pointer(this->specs.type != presentation_type::pointer);
280 }
281
282 /** Formats a null-terminated wide C string. */
283 void operator()(const wchar_t* value) {
284 if (value)
286 else
287 write_null_pointer(this->specs.type != presentation_type::pointer);
288 }
289
291
292 /** Formats a pointer. */
293 void operator()(const void* value) {
294 if (value)
296 else
297 write_null_pointer();
298 }
299
300 /** Formats an argument of a custom (user-defined) type. */
302 auto parse_ctx = basic_format_parse_context<Char>({});
303 handle.format(parse_ctx, context_);
304 }
305};
306
307template <typename Char>
308void parse_flags(format_specs<Char>& specs, const Char*& it, const Char* end) {
309 for (; it != end; ++it) {
310 switch (*it) {
311 case '-':
312 specs.align = align::left;
313 break;
314 case '+':
315 specs.sign = sign::plus;
316 break;
317 case '0':
318 specs.fill[0] = '0';
319 break;
320 case ' ':
321 if (specs.sign != sign::plus) specs.sign = sign::space;
322 break;
323 case '#':
324 specs.alt = true;
325 break;
326 default:
327 return;
328 }
329 }
330}
331
332template <typename Char, typename GetArg>
333auto parse_header(const Char*& it, const Char* end, format_specs<Char>& specs,
334 GetArg get_arg) -> int {
335 int arg_index = -1;
336 Char c = *it;
337 if (c >= '0' && c <= '9') {
338 // Parse an argument index (if followed by '$') or a width possibly
339 // preceded with '0' flag(s).
340 int value = parse_nonnegative_int(it, end, -1);
341 if (it != end && *it == '$') { // value is an argument index
342 ++it;
343 arg_index = value != -1 ? value : max_value<int>();
344 } else {
345 if (c == '0') specs.fill[0] = '0';
346 if (value != 0) {
347 // Nonzero value means that we parsed width and don't need to
348 // parse it or flags again, so return now.
349 if (value == -1) throw_format_error("number is too big");
350 specs.width = value;
351 return arg_index;
352 }
353 }
354 }
355 parse_flags(specs, it, end);
356 // Parse width.
357 if (it != end) {
358 if (*it >= '0' && *it <= '9') {
359 specs.width = parse_nonnegative_int(it, end, -1);
360 if (specs.width == -1) throw_format_error("number is too big");
361 } else if (*it == '*') {
362 ++it;
363 specs.width = static_cast<int>(visit_format_arg(
365 }
366 }
367 return arg_index;
368}
369
372 using pt = presentation_type;
373 constexpr auto integral_set = sint_set | uint_set | bool_set | char_set;
374 switch (c) {
375 case 'd':
376 return in(t, integral_set) ? pt::dec : pt::none;
377 case 'o':
378 return in(t, integral_set) ? pt::oct : pt::none;
379 case 'x':
380 return in(t, integral_set) ? pt::hex_lower : pt::none;
381 case 'X':
382 return in(t, integral_set) ? pt::hex_upper : pt::none;
383 case 'a':
384 return in(t, float_set) ? pt::hexfloat_lower : pt::none;
385 case 'A':
386 return in(t, float_set) ? pt::hexfloat_upper : pt::none;
387 case 'e':
388 return in(t, float_set) ? pt::exp_lower : pt::none;
389 case 'E':
390 return in(t, float_set) ? pt::exp_upper : pt::none;
391 case 'f':
392 return in(t, float_set) ? pt::fixed_lower : pt::none;
393 case 'F':
394 return in(t, float_set) ? pt::fixed_upper : pt::none;
395 case 'g':
396 return in(t, float_set) ? pt::general_lower : pt::none;
397 case 'G':
398 return in(t, float_set) ? pt::general_upper : pt::none;
399 case 'c':
400 return in(t, integral_set) ? pt::chr : pt::none;
401 case 's':
402 return in(t, string_set | cstring_set) ? pt::string : pt::none;
403 case 'p':
404 return in(t, pointer_set | cstring_set) ? pt::pointer : pt::none;
405 default:
406 return pt::none;
407 }
408}
409
410template <typename Char, typename Context>
413 using iterator = buffer_appender<Char>;
414 auto out = iterator(buf);
415 auto context = basic_printf_context<Char>(out, args);
417
418 // Returns the argument with specified index or, if arg_index is -1, the next
419 // argument.
420 auto get_arg = [&](int arg_index) {
421 if (arg_index < 0)
422 arg_index = parse_ctx.next_arg_id();
423 else
424 parse_ctx.check_arg_id(--arg_index);
425 return detail::get_arg(context, arg_index);
426 };
427
428 const Char* start = parse_ctx.begin();
429 const Char* end = parse_ctx.end();
430 auto it = start;
431 while (it != end) {
432 if (!find<false, Char>(it, end, '%', it)) {
433 it = end; // find leaves it == nullptr if it doesn't find '%'.
434 break;
435 }
436 Char c = *it++;
437 if (it != end && *it == c) {
439 start = ++it;
440 continue;
441 }
443
444 auto specs = format_specs<Char>();
445 specs.align = align::right;
446
447 // Parse argument index, flags and width.
448 int arg_index = parse_header(it, end, specs, get_arg);
449 if (arg_index == 0) throw_format_error("argument not found");
450
451 // Parse precision.
452 if (it != end && *it == '.') {
453 ++it;
454 c = it != end ? *it : 0;
455 if ('0' <= c && c <= '9') {
456 specs.precision = parse_nonnegative_int(it, end, 0);
457 } else if (c == '*') {
458 ++it;
459 specs.precision = static_cast<int>(
461 } else {
462 specs.precision = 0;
463 }
464 }
465
466 auto arg = get_arg(arg_index);
467 // For d, i, o, u, x, and X conversion specifiers, if a precision is
468 // specified, the '0' flag is ignored
469 if (specs.precision >= 0 && arg.is_integral()) {
470 // Ignore '0' for non-numeric types or if '-' present.
471 specs.fill[0] = ' ';
472 }
473 if (specs.precision >= 0 && arg.type() == type::cstring_type) {
475 auto str_end = str + specs.precision;
476 auto nul = std::find(str, str_end, Char());
477 auto sv = basic_string_view<Char>(
478 str, to_unsigned(nul != str_end ? nul - str : specs.precision));
479 arg = make_arg<basic_printf_context<Char>>(sv);
480 }
481 if (specs.alt && visit_format_arg(is_zero_int(), arg)) specs.alt = false;
482 if (specs.fill[0] == '0') {
483 if (arg.is_arithmetic() && specs.align != align::left)
484 specs.align = align::numeric;
485 else
486 specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types or if '-'
487 // flag is also present.
488 }
489
490 // Parse length and convert the argument to the required type.
491 c = it != end ? *it++ : 0;
492 Char t = it != end ? *it : 0;
493 switch (c) {
494 case 'h':
495 if (t == 'h') {
496 ++it;
497 t = it != end ? *it : 0;
498 convert_arg<signed char>(arg, t);
499 } else {
500 convert_arg<short>(arg, t);
501 }
502 break;
503 case 'l':
504 if (t == 'l') {
505 ++it;
506 t = it != end ? *it : 0;
507 convert_arg<long long>(arg, t);
508 } else {
509 convert_arg<long>(arg, t);
510 }
511 break;
512 case 'j':
513 convert_arg<intmax_t>(arg, t);
514 break;
515 case 'z':
516 convert_arg<size_t>(arg, t);
517 break;
518 case 't':
519 convert_arg<std::ptrdiff_t>(arg, t);
520 break;
521 case 'L':
522 // printf produces garbage when 'L' is omitted for long double, no
523 // need to do the same.
524 break;
525 default:
526 --it;
527 convert_arg<void>(arg, c);
528 }
529
530 // Parse type.
531 if (it == end) throw_format_error("invalid format string");
532 char type = static_cast<char>(*it++);
533 if (arg.is_integral()) {
534 // Normalize type.
535 switch (type) {
536 case 'i':
537 case 'u':
538 type = 'd';
539 break;
540 case 'c':
542 break;
543 }
544 }
545 specs.type = parse_printf_presentation_type(type, arg.type());
546 if (specs.type == presentation_type::none)
547 throw_format_error("invalid format specifier");
548
549 start = it;
550
551 // Format argument.
552 visit_format_arg(printf_arg_formatter<Char>(out, specs, context), arg);
553 }
555}
556} // namespace detail
557
560
563
564/**
565 \rst
566 Constructs an `~fmt::format_arg_store` object that contains references to
567 arguments and can be implicitly converted to `~fmt::printf_args`.
568 \endrst
569 */
570template <typename... T>
571inline auto make_printf_args(const T&... args)
573 return {args...};
574}
575
576// DEPRECATED!
577template <typename... T>
578inline auto make_wprintf_args(const T&... args)
580 return {args...};
581}
582
583template <typename Char>
584inline auto vsprintf(
587 -> std::basic_string<Char> {
588 auto buf = basic_memory_buffer<Char>();
589 detail::vprintf(buf, fmt, args);
590 return to_string(buf);
591}
592
593/**
594 \rst
595 Formats arguments and returns the result as a string.
596
597 **Example**::
598
599 std::string message = fmt::sprintf("The answer is %d", 42);
600 \endrst
601*/
602template <typename S, typename... T,
604inline auto sprintf(const S& fmt, const T&... args) -> std::basic_string<Char> {
607}
608
609template <typename Char>
610inline auto vfprintf(
611 std::FILE* f, basic_string_view<Char> fmt,
613 -> int {
614 auto buf = basic_memory_buffer<Char>();
615 detail::vprintf(buf, fmt, args);
616 size_t size = buf.size();
617 return std::fwrite(buf.data(), sizeof(Char), size, f) < size
618 ? -1
619 : static_cast<int>(size);
620}
621
622/**
623 \rst
624 Prints formatted data to the file *f*.
625
626 **Example**::
627
628 fmt::fprintf(stderr, "Don't %s!", "panic");
629 \endrst
630 */
631template <typename S, typename... T, typename Char = char_t<S>>
632inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
633 return vfprintf(f, detail::to_string_view(fmt),
635}
636
637template <typename Char>
641 -> int {
642 return vfprintf(stdout, fmt, args);
643}
644
645/**
646 \rst
647 Prints formatted data to ``stdout``.
648
649 **Example**::
650
651 fmt::printf("Elapsed time: %.2f seconds", 1.23);
652 \endrst
653 */
654template <typename... T>
655inline auto printf(string_view fmt, const T&... args) -> int {
656 return vfprintf(stdout, fmt, make_printf_args(args...));
657}
658template <typename... T>
660 const T&... args) -> int {
661 return vfprintf(stdout, fmt, make_wprintf_args(args...));
662}
663
666
667#endif // FMT_PRINTF_H_
you may not use this file except in compliance with the License You may obtain a copy of the License at software distributed under the License is distributed on an AS IS WITHOUT WARRANTIES OR CONDITIONS OF ANY either express or implied See the License for the specific language governing permissions and limitations under the License LLVM Exceptions to the Apache License As an if
Definition: ThirdPartyNotices.txt:289
Definition: core.h:1629
void format(typename Context::parse_context_type &parse_ctx, Context &ctx) const
Definition: core.h:1633
Definition: core.h:1603
FMT_CONSTEXPR auto get(int id) const -> format_arg
Returns the argument with the specified id.
Definition: core.h:1931
\rst Parsing context consisting of a format string range being parsed and an argument counter for aut...
Definition: core.h:656
\rst A dynamically growing memory buffer for trivially copyable/constructible types with the first SI...
Definition: format.h:918
Definition: printf.h:21
auto out() -> detail::buffer_appender< Char >
Definition: printf.h:41
basic_printf_context(detail::buffer_appender< Char > out, basic_format_args< basic_printf_context > args)
\rst Constructs a printf_context object.
Definition: printf.h:37
auto locale() -> detail::locale_ref
Definition: printf.h:44
Char char_type
Definition: printf.h:27
FMT_CONSTEXPR void on_error(const char *message)
Definition: printf.h:50
void advance_to(detail::buffer_appender< Char >)
Definition: printf.h:42
auto arg(int id) const -> basic_format_arg< basic_printf_context >
Definition: printf.h:46
An implementation of std::basic_string_view for pre-C++17.
Definition: core.h:398
Definition: printf.h:107
arg_converter(basic_format_arg< Context > &arg, char_type type)
Definition: printf.h:115
void operator()(U)
Definition: printf.h:151
void operator()(U value)
Definition: printf.h:123
void operator()(bool value)
Definition: printf.h:118
\rst A contiguous memory buffer with an optional growing ability.
Definition: core.h:798
Definition: printf.h:164
char_converter(basic_format_arg< Context > &arg)
Definition: printf.h:169
void operator()(T)
Definition: printf.h:178
void operator()(T value)
Definition: printf.h:172
Definition: core.h:1529
Definition: printf.h:226
void operator()(typename basic_format_arg< context_type >::handle handle)
Formats an argument of a custom (user-defined) type.
Definition: printf.h:301
printf_arg_formatter(buffer_appender< Char > iter, format_specs< Char > &s, context_type &ctx)
Definition: printf.h:240
void operator()(const void *value)
Formats a pointer.
Definition: printf.h:293
void operator()(const char *value)
Formats a null-terminated C string.
Definition: printf.h:275
void operator()(basic_string_view< Char > value)
Definition: printf.h:290
void operator()(const wchar_t *value)
Formats a null-terminated wide C string.
Definition: printf.h:283
void operator()(T value)
Definition: printf.h:247
void operator()(monostate value)
Definition: printf.h:244
Definition: printf.h:190
auto operator()(T value) -> unsigned
Definition: printf.h:198
printf_width_handler(format_specs< Char > &specs)
Definition: printf.h:195
auto operator()(T) -> unsigned
Definition: printf.h:210
Definition: core.h:1238
\rst An array of references to arguments.
Definition: core.h:1779
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:256
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0))
\rst Visits an argument dispatching to the appropriate visit method based on the argument type.
Definition: core.h:1665
#define FMT_END_EXPORT
Definition: core.h:185
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
\rst Returns a named argument to be used in a formatting function.
Definition: core.h:1841
typename detail::char_t_impl< S >::type char_t
String's character type.
Definition: core.h:646
#define FMT_CONSTEXPR
Definition: core.h:105
#define FMT_BEGIN_NAMESPACE
Definition: core.h:174
constexpr auto make_format_args(T &... args) -> format_arg_store< Context, remove_cvref_t< T >... >
\rst Constructs a ~fmtformat_arg_store object that contains references to arguments and can be implic...
Definition: core.h:1824
#define FMT_BEGIN_EXPORT
Definition: core.h:184
typename type_identity< T >::type type_identity_t
Definition: core.h:267
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:258
presentation_type
Definition: core.h:2019
#define FMT_END_NAMESPACE
Definition: core.h:177
#define FMT_DEPRECATED
Definition: format.h:77
detail namespace with internal helper functions
Definition: xchar.h:20
void convert_arg(basic_format_arg< Context > &arg, Char type)
Definition: printf.h:159
void vprintf(buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
Definition: printf.h:411
auto make_arg_formatter(buffer_appender< Char > iter, format_specs< Char > &s) -> arg_formatter< Char >
Definition: printf.h:219
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
Definition: format.h:811
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const format_specs< Char > &specs) -> OutputIt
Definition: format.h:1819
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition: chrono.h:419
auto parse_printf_presentation_type(char c, type t) -> presentation_type
Definition: printf.h:370
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept -> int
Definition: core.h:2138
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< Char >
Definition: core.h:517
FMT_CONSTEXPR auto get_arg(Context &ctx, ID id) -> decltype(ctx.arg(id))
Definition: format.h:3871
FMT_FUNC void throw_format_error(const char *message)
Definition: format-inl.h:39
constexpr auto in(type t, int set) -> bool
Definition: core.h:611
@ bool_set
Definition: core.h:621
@ uint_set
Definition: core.h:619
@ pointer_set
Definition: core.h:627
@ float_set
Definition: core.h:623
@ cstring_set
Definition: core.h:626
@ char_set
Definition: core.h:622
@ sint_set
Definition: core.h:617
@ string_set
Definition: core.h:625
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2120
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T > > > buffer_appender
Definition: core.h:1113
void parse_flags(format_specs< Char > &specs, const Char *&it, const Char *end)
Definition: printf.h:308
auto parse_header(const Char *&it, const Char *end, format_specs< Char > &specs, GetArg get_arg) -> int
Definition: printf.h:333
constexpr auto is_negative(T value) -> bool
Definition: format.h:1130
type
Definition: core.h:556
constexpr FMT_INLINE auto const_check(T value) -> T
Definition: core.h:323
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition: core.h:374
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:1152
static constexpr const velocity::meters_per_second_t c(299792458.0)
Speed of light in vacuum.
std::string to_string(const T &t)
Definition: base.h:92
UnitTypeLhs() max(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3417
UnitTypeLhs() min(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3409
auto vsprintf(basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char > > > args) -> std::basic_string< Char >
Definition: printf.h:584
auto make_wprintf_args(const T &... args) -> format_arg_store< wprintf_context, T... >
Definition: printf.h:578
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
\rst Prints formatted data to the file f.
Definition: printf.h:632
auto sprintf(const S &fmt, const T &... args) -> std::basic_string< Char >
\rst Formats arguments and returns the result as a string.
Definition: printf.h:604
auto vfprintf(std::FILE *f, basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char > > > args) -> int
Definition: printf.h:610
basic_printf_context< char > printf_context
Definition: printf.h:558
basic_printf_context< wchar_t > wprintf_context
Definition: printf.h:559
auto make_printf_args(const T &... args) -> format_arg_store< printf_context, T... >
\rst Constructs an ~fmtformat_arg_store object that contains references to arguments and can be impli...
Definition: printf.h:571
auto printf(string_view fmt, const T &... args) -> int
\rst Prints formatted data to stdout.
Definition: printf.h:655
FMT_DEPRECATED auto vprintf(basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char > > > args) -> int
Definition: printf.h:638
Definition: format.h:3792
FMT_CONSTEXPR FMT_INLINE auto operator()(T value) -> iterator
Definition: format.h:3801
iterator out
Definition: format.h:3796
const format_specs< Char > & specs
Definition: format.h:3797
Definition: core.h:632
FMT_NORETURN void on_error(const char *message)
Definition: core.h:636
Definition: printf.h:183
auto operator()(T) -> const Char *
Definition: printf.h:184
auto operator()(const Char *s) -> const Char *
Definition: printf.h:185
static auto fits_in_int(int) -> bool
Definition: printf.h:72
static auto fits_in_int(T value) -> bool
Definition: printf.h:68
Definition: printf.h:59
static auto fits_in_int(T value) -> bool
Definition: printf.h:60
static auto fits_in_int(bool) -> bool
Definition: printf.h:64
Definition: core.h:548
Definition: printf.h:91
auto operator()(T value) -> bool
Definition: printf.h:93
auto operator()(T) -> bool
Definition: printf.h:98
bool type
Definition: printf.h:105
Definition: printf.h:103
Definition: printf.h:75
auto operator()(T) -> int
Definition: printf.h:84
auto operator()(T value) -> int
Definition: printf.h:77
detail::fill_t< Char > fill
Definition: core.h:2050
sign_t sign
Definition: core.h:2047
align_t align
Definition: core.h:2046
presentation_type type
Definition: core.h:2045
bool alt
Definition: core.h:2048
Definition: core.h:276
Definition: printf.h:19
printf_formatter()=delete
#define S(label, offset, message)
Definition: Errors.h:119
auto format(wformat_string< T... > fmt, T &&... args) -> std::wstring
Definition: xchar.h:108