WPILibC++ 2023.4.3-108-ge5452e3
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>
24};
25
26template <typename OutputIt, typename Char> class basic_printf_context {
27 private:
28 OutputIt out_;
30
31 public:
32 using char_type = Char;
35 template <typename T> using formatter_type = printf_formatter<T>;
36
37 /**
38 \rst
39 Constructs a ``printf_context`` object. References to the arguments are
40 stored in the context object so make sure they have appropriate lifetimes.
41 \endrst
42 */
45 : out_(out), args_(args) {}
46
47 OutputIt out() { return out_; }
48 void advance_to(OutputIt it) { out_ = it; }
49
50 detail::locale_ref locale() { return {}; }
51
52 format_arg arg(int id) const { return args_.get(id); }
53
54 FMT_CONSTEXPR void on_error(const char* message) {
55 detail::error_handler().on_error(message);
56 }
57};
58
60
61// Checks if a value fits in int - used to avoid warnings about comparing
62// signed and unsigned integers.
63template <bool IsSigned> struct int_checker {
64 template <typename T> static bool fits_in_int(T value) {
65 unsigned max = max_value<int>();
66 return value <= max;
67 }
68 static bool fits_in_int(bool) { return true; }
69};
70
71template <> struct int_checker<true> {
72 template <typename T> static bool fits_in_int(T value) {
75 }
76 static bool fits_in_int(int) { return true; }
77};
78
80 public:
81 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
84 FMT_THROW(format_error("number is too big"));
85 return (std::max)(static_cast<int>(value), 0);
86 }
87
88 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
89 int operator()(T) {
90 FMT_THROW(format_error("precision is not integer"));
91 return 0;
92 }
93};
94
95// An argument visitor that returns true iff arg is a zero integer.
97 public:
98 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
99 bool operator()(T value) {
100 return value == 0;
101 }
102
103 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
104 bool operator()(T) {
105 return false;
106 }
107};
108
109template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
110
111template <> struct make_unsigned_or_bool<bool> { using type = bool; };
112
113template <typename T, typename Context> class arg_converter {
114 private:
115 using char_type = typename Context::char_type;
116
118 char_type type_;
119
120 public:
122 : arg_(arg), type_(type) {}
123
124 void operator()(bool value) {
125 if (type_ != 's') operator()<bool>(value);
126 }
127
128 template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
130 bool is_signed = type_ == 'd' || type_ == 'i';
131 using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
132 if (const_check(sizeof(target_type) <= sizeof(int))) {
133 // Extra casts are used to silence warnings.
134 if (is_signed) {
135 arg_ = detail::make_arg<Context>(
136 static_cast<int>(static_cast<target_type>(value)));
137 } else {
138 using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
139 arg_ = detail::make_arg<Context>(
140 static_cast<unsigned>(static_cast<unsigned_type>(value)));
141 }
142 } else {
143 if (is_signed) {
144 // glibc's printf doesn't sign extend arguments of smaller types:
145 // std::printf("%lld", -42); // prints "4294967254"
146 // but we don't have to do the same because it's a UB.
147 arg_ = detail::make_arg<Context>(static_cast<long long>(value));
148 } else {
149 arg_ = detail::make_arg<Context>(
150 static_cast<typename make_unsigned_or_bool<U>::type>(value));
151 }
152 }
153 }
154
155 template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
156 void operator()(U) {} // No conversion needed for non-integral types.
157};
158
159// Converts an integer argument to T for printf, if T is an integral type.
160// If T is void, the argument is converted to corresponding signed or unsigned
161// type depending on the type specifier: 'd' and 'i' - signed, other -
162// unsigned).
163template <typename T, typename Context, typename Char>
166}
167
168// Converts an integer argument to char for printf.
169template <typename Context> class char_converter {
170 private:
172
173 public:
175
176 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
178 arg_ = detail::make_arg<Context>(
179 static_cast<typename Context::char_type>(value));
180 }
181
182 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
183 void operator()(T) {} // No conversion needed for non-integral types.
184};
185
186// An argument visitor that return a pointer to a C string if argument is a
187// string or null otherwise.
188template <typename Char> struct get_cstring {
189 template <typename T> const Char* operator()(T) { return nullptr; }
190 const Char* operator()(const Char* s) { return s; }
191};
192
193// Checks if an argument is a valid printf width specifier and sets
194// left alignment if it is negative.
195template <typename Char> class printf_width_handler {
196 private:
198
199 format_specs& specs_;
200
201 public:
202 explicit printf_width_handler(format_specs& specs) : specs_(specs) {}
203
204 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
205 unsigned operator()(T value) {
206 auto width = static_cast<uint32_or_64_or_128_t<T>>(value);
208 specs_.align = align::left;
209 width = 0 - width;
210 }
211 unsigned int_max = max_value<int>();
212 if (width > int_max) FMT_THROW(format_error("number is too big"));
213 return static_cast<unsigned>(width);
214 }
215
216 template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
217 unsigned operator()(T) {
218 FMT_THROW(format_error("width is not integer"));
219 return 0;
220 }
221};
222
223// The ``printf`` argument formatter.
224template <typename OutputIt, typename Char>
226 private:
230
231 context_type& context_;
232
233 OutputIt write_null_pointer(bool is_string = false) {
234 auto s = this->specs;
236 return write_bytes(this->out, is_string ? "(null)" : "(nil)", s);
237 }
238
239 public:
241 : base{iter, s, locale_ref()}, context_(ctx) {}
242
244
245 template <typename T, FMT_ENABLE_IF(detail::is_integral<T>::value)>
246 OutputIt operator()(T value) {
247 // MSVC2013 fails to compile separate overloads for bool and Char so use
248 // std::is_same instead.
249 if (std::is_same<T, Char>::value) {
250 format_specs fmt_specs = this->specs;
251 if (fmt_specs.type != presentation_type::none &&
252 fmt_specs.type != presentation_type::chr) {
253 return (*this)(static_cast<int>(value));
254 }
255 fmt_specs.sign = sign::none;
256 fmt_specs.alt = false;
257 fmt_specs.fill[0] = ' '; // Ignore '0' flag for char types.
258 // align::numeric needs to be overwritten here since the '0' flag is
259 // ignored for non-numeric types
260 if (fmt_specs.align == align::none || fmt_specs.align == align::numeric)
261 fmt_specs.align = align::right;
262 return write<Char>(this->out, static_cast<Char>(value), fmt_specs);
263 }
264 return base::operator()(value);
265 }
266
267 template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
268 OutputIt operator()(T value) {
269 return base::operator()(value);
270 }
271
272 /** Formats a null-terminated C string. */
273 OutputIt operator()(const char* value) {
274 if (value) return base::operator()(value);
275 return write_null_pointer(this->specs.type != presentation_type::pointer);
276 }
277
278 /** Formats a null-terminated wide C string. */
279 OutputIt operator()(const wchar_t* value) {
280 if (value) return base::operator()(value);
281 return write_null_pointer(this->specs.type != presentation_type::pointer);
282 }
283
285 return base::operator()(value);
286 }
287
288 /** Formats a pointer. */
289 OutputIt operator()(const void* value) {
290 return value ? base::operator()(value) : write_null_pointer();
291 }
292
293 /** Formats an argument of a custom (user-defined) type. */
295 auto parse_ctx =
297 handle.format(parse_ctx, context_);
298 return this->out;
299 }
300};
301
302template <typename Char>
303void parse_flags(basic_format_specs<Char>& specs, const Char*& it,
304 const Char* end) {
305 for (; it != end; ++it) {
306 switch (*it) {
307 case '-':
308 specs.align = align::left;
309 break;
310 case '+':
311 specs.sign = sign::plus;
312 break;
313 case '0':
314 specs.fill[0] = '0';
315 break;
316 case ' ':
317 if (specs.sign != sign::plus) {
318 specs.sign = sign::space;
319 }
320 break;
321 case '#':
322 specs.alt = true;
323 break;
324 default:
325 return;
326 }
327 }
328}
329
330template <typename Char, typename GetArg>
331int parse_header(const Char*& it, const Char* end,
332 basic_format_specs<Char>& specs, GetArg get_arg) {
333 int arg_index = -1;
334 Char c = *it;
335 if (c >= '0' && c <= '9') {
336 // Parse an argument index (if followed by '$') or a width possibly
337 // preceded with '0' flag(s).
338 int value = parse_nonnegative_int(it, end, -1);
339 if (it != end && *it == '$') { // value is an argument index
340 ++it;
341 arg_index = value != -1 ? value : max_value<int>();
342 } else {
343 if (c == '0') specs.fill[0] = '0';
344 if (value != 0) {
345 // Nonzero value means that we parsed width and don't need to
346 // parse it or flags again, so return now.
347 if (value == -1) FMT_THROW(format_error("number is too big"));
348 specs.width = value;
349 return arg_index;
350 }
351 }
352 }
353 parse_flags(specs, it, end);
354 // Parse width.
355 if (it != end) {
356 if (*it >= '0' && *it <= '9') {
357 specs.width = parse_nonnegative_int(it, end, -1);
358 if (specs.width == -1) FMT_THROW(format_error("number is too big"));
359 } else if (*it == '*') {
360 ++it;
361 specs.width = static_cast<int>(visit_format_arg(
362 detail::printf_width_handler<Char>(specs), get_arg(-1)));
363 }
364 }
365 return arg_index;
366}
367
368template <typename Char, typename Context>
371 using OutputIt = buffer_appender<Char>;
372 auto out = OutputIt(buf);
373 auto context = basic_printf_context<OutputIt, Char>(out, args);
375
376 // Returns the argument with specified index or, if arg_index is -1, the next
377 // argument.
378 auto get_arg = [&](int arg_index) {
379 if (arg_index < 0)
380 arg_index = parse_ctx.next_arg_id();
381 else
382 parse_ctx.check_arg_id(--arg_index);
383 return detail::get_arg(context, arg_index);
384 };
385
386 const Char* start = parse_ctx.begin();
387 const Char* end = parse_ctx.end();
388 auto it = start;
389 while (it != end) {
390 if (!detail::find<false, Char>(it, end, '%', it)) {
391 it = end; // detail::find leaves it == nullptr if it doesn't find '%'
392 break;
393 }
394 Char c = *it++;
395 if (it != end && *it == c) {
396 out = detail::write(
397 out, basic_string_view<Char>(start, detail::to_unsigned(it - start)));
398 start = ++it;
399 continue;
400 }
402 start, detail::to_unsigned(it - 1 - start)));
403
405 specs.align = align::right;
406
407 // Parse argument index, flags and width.
408 int arg_index = parse_header(it, end, specs, get_arg);
409 if (arg_index == 0) parse_ctx.on_error("argument not found");
410
411 // Parse precision.
412 if (it != end && *it == '.') {
413 ++it;
414 c = it != end ? *it : 0;
415 if ('0' <= c && c <= '9') {
416 specs.precision = parse_nonnegative_int(it, end, 0);
417 } else if (c == '*') {
418 ++it;
419 specs.precision = static_cast<int>(
420 visit_format_arg(detail::printf_precision_handler(), get_arg(-1)));
421 } else {
422 specs.precision = 0;
423 }
424 }
425
426 auto arg = get_arg(arg_index);
427 // For d, i, o, u, x, and X conversion specifiers, if a precision is
428 // specified, the '0' flag is ignored
429 if (specs.precision >= 0 && arg.is_integral())
430 specs.fill[0] =
431 ' '; // Ignore '0' flag for non-numeric types or if '-' present.
432 if (specs.precision >= 0 && arg.type() == detail::type::cstring_type) {
433 auto str = visit_format_arg(detail::get_cstring<Char>(), arg);
434 auto str_end = str + specs.precision;
435 auto nul = std::find(str, str_end, Char());
436 arg = detail::make_arg<basic_printf_context<OutputIt, Char>>(
438 str, detail::to_unsigned(nul != str_end ? nul - str
439 : specs.precision)));
440 }
441 if (specs.alt && visit_format_arg(detail::is_zero_int(), arg))
442 specs.alt = false;
443 if (specs.fill[0] == '0') {
444 if (arg.is_arithmetic() && specs.align != align::left)
445 specs.align = align::numeric;
446 else
447 specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types or if '-'
448 // flag is also present.
449 }
450
451 // Parse length and convert the argument to the required type.
452 c = it != end ? *it++ : 0;
453 Char t = it != end ? *it : 0;
455 switch (c) {
456 case 'h':
457 if (t == 'h') {
458 ++it;
459 t = it != end ? *it : 0;
460 convert_arg<signed char>(arg, t);
461 } else {
462 convert_arg<short>(arg, t);
463 }
464 break;
465 case 'l':
466 if (t == 'l') {
467 ++it;
468 t = it != end ? *it : 0;
469 convert_arg<long long>(arg, t);
470 } else {
471 convert_arg<long>(arg, t);
472 }
473 break;
474 case 'j':
475 convert_arg<intmax_t>(arg, t);
476 break;
477 case 'z':
478 convert_arg<size_t>(arg, t);
479 break;
480 case 't':
481 convert_arg<std::ptrdiff_t>(arg, t);
482 break;
483 case 'L':
484 // printf produces garbage when 'L' is omitted for long double, no
485 // need to do the same.
486 break;
487 default:
488 --it;
489 convert_arg<void>(arg, c);
490 }
491
492 // Parse type.
493 if (it == end) FMT_THROW(format_error("invalid format string"));
494 char type = static_cast<char>(*it++);
495 if (arg.is_integral()) {
496 // Normalize type.
497 switch (type) {
498 case 'i':
499 case 'u':
500 type = 'd';
501 break;
502 case 'c':
504 detail::char_converter<basic_printf_context<OutputIt, Char>>(arg),
505 arg);
506 break;
507 }
508 }
510 if (specs.type == presentation_type::none)
511 parse_ctx.on_error("invalid type specifier");
512
513 start = it;
514
515 // Format argument.
516 out = visit_format_arg(
517 detail::printf_arg_formatter<OutputIt, Char>(out, specs, context), arg);
518 }
519 detail::write(out, basic_string_view<Char>(start, to_unsigned(it - start)));
520}
522
523template <typename Char>
526
529
532
533/**
534 \rst
535 Constructs an `~fmt::format_arg_store` object that contains references to
536 arguments and can be implicitly converted to `~fmt::printf_args`.
537 \endrst
538 */
539template <typename... T>
540inline auto make_printf_args(const T&... args)
542 return {args...};
543}
544
545/**
546 \rst
547 Constructs an `~fmt::format_arg_store` object that contains references to
548 arguments and can be implicitly converted to `~fmt::wprintf_args`.
549 \endrst
550 */
551template <typename... T>
552inline auto make_wprintf_args(const T&... args)
554 return {args...};
555}
556
557template <typename S, typename Char = char_t<S>>
558inline auto vsprintf(
559 const S& fmt,
561 -> std::basic_string<Char> {
564 return to_string(buffer);
565}
566
567/**
568 \rst
569 Formats arguments and returns the result as a string.
570
571 **Example**::
572
573 std::string message = fmt::sprintf("The answer is %d", 42);
574 \endrst
575*/
576template <typename S, typename... T,
578inline auto sprintf(const S& fmt, const T&... args) -> std::basic_string<Char> {
579 using context = basic_printf_context_t<Char>;
581 fmt::make_format_args<context>(args...));
582}
583
584template <typename S, typename Char = char_t<S>>
585inline auto vfprintf(
586 std::FILE* f, const S& fmt,
588 -> int {
591 size_t size = buffer.size();
592 return std::fwrite(buffer.data(), sizeof(Char), size, f) < size
593 ? -1
594 : static_cast<int>(size);
595}
596
597/**
598 \rst
599 Prints formatted data to the file *f*.
600
601 **Example**::
602
603 fmt::fprintf(stderr, "Don't %s!", "panic");
604 \endrst
605 */
606template <typename S, typename... T, typename Char = char_t<S>>
607inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
608 using context = basic_printf_context_t<Char>;
609 return vfprintf(f, detail::to_string_view(fmt),
610 fmt::make_format_args<context>(args...));
611}
612
613template <typename S, typename Char = char_t<S>>
614inline auto vprintf(
615 const S& fmt,
617 -> int {
618 return vfprintf(stdout, detail::to_string_view(fmt), args);
619}
620
621/**
622 \rst
623 Prints formatted data to ``stdout``.
624
625 **Example**::
626
627 fmt::printf("Elapsed time: %.2f seconds", 1.23);
628 \endrst
629 */
630template <typename S, typename... T, FMT_ENABLE_IF(detail::is_string<S>::value)>
631inline auto printf(const S& fmt, const T&... args) -> int {
632 return vprintf(
635}
636
639
640#endif // FMT_PRINTF_H_
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:66
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: printf.h:113
arg_converter(basic_format_arg< Context > &arg, char_type type)
Definition: printf.h:121
void operator()(U)
Definition: printf.h:156
void operator()(U value)
Definition: printf.h:129
void operator()(bool value)
Definition: printf.h:124
Definition: core.h:1588
void format(typename Context::parse_context_type &parse_ctx, Context &ctx) const
Definition: core.h:1592
Definition: core.h:1562
FMT_CONSTEXPR auto get(int id) const -> format_arg
Returns the argument with the specified id.
Definition: core.h:2029
\rst Parsing context consisting of a format string range being parsed and an argument counter for aut...
Definition: core.h:654
constexpr basic_format_parse_context(basic_string_view< Char > format_str, ErrorHandler eh={}, int next_arg_id=0)
Definition: core.h:665
\rst A dynamically growing memory buffer for trivially copyable/constructible types with the first SI...
Definition: format.h:819
Definition: printf.h:26
OutputIt out()
Definition: printf.h:47
Char char_type
Definition: printf.h:32
FMT_CONSTEXPR void on_error(const char *message)
Definition: printf.h:54
format_arg arg(int id) const
Definition: printf.h:52
detail::locale_ref locale()
Definition: printf.h:50
basic_printf_context(OutputIt out, basic_format_args< basic_printf_context > args)
\rst Constructs a printf_context object.
Definition: printf.h:43
void advance_to(OutputIt it)
Definition: printf.h:48
Definition: printf.h:22
An implementation of std::basic_string_view for pre-C++17.
Definition: core.h:430
\rst A contiguous memory buffer with an optional growing ability.
Definition: core.h:862
FMT_CONSTEXPR auto data() noexcept -> T *
Returns a pointer to the buffer data.
Definition: core.h:908
constexpr auto size() const noexcept -> size_t
Returns the size of this buffer.
Definition: core.h:902
Definition: printf.h:169
void operator()(T value)
Definition: printf.h:177
void operator()(T)
Definition: printf.h:183
char_converter(basic_format_arg< Context > &arg)
Definition: printf.h:174
\rst An array of references to arguments.
Definition: core.h:1877
A formatting error such as invalid format string.
Definition: format.h:957
Definition: printf.h:96
bool operator()(T value)
Definition: printf.h:99
bool operator()(T)
Definition: printf.h:104
Definition: core.h:1710
Definition: printf.h:225
OutputIt operator()(const void *value)
Formats a pointer.
Definition: printf.h:289
OutputIt operator()(const char *value)
Formats a null-terminated C string.
Definition: printf.h:273
printf_arg_formatter(OutputIt iter, format_specs &s, context_type &ctx)
Definition: printf.h:240
OutputIt operator()(const wchar_t *value)
Formats a null-terminated wide C string.
Definition: printf.h:279
OutputIt operator()(monostate value)
Definition: printf.h:243
OutputIt operator()(basic_string_view< Char > value)
Definition: printf.h:284
OutputIt operator()(T value)
Definition: printf.h:246
OutputIt operator()(typename basic_format_arg< context_type >::handle handle)
Formats an argument of a custom (user-defined) type.
Definition: printf.h:294
Definition: printf.h:79
int operator()(T value)
Definition: printf.h:82
int operator()(T)
Definition: printf.h:89
Definition: printf.h:195
unsigned operator()(T)
Definition: printf.h:217
printf_width_handler(format_specs &specs)
Definition: printf.h:202
unsigned operator()(T value)
Definition: printf.h:205
Definition: core.h:1240
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:298
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2325
constexpr FMT_INLINE auto const_check(T value) -> T
Definition: core.h:356
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:1623
typename detail::char_t_impl< S >::type char_t
String's character type.
Definition: core.h:644
#define FMT_END_DETAIL_NAMESPACE
Definition: core.h:227
#define FMT_MODULE_EXPORT_BEGIN
Definition: core.h:224
FMT_CONSTEXPR auto parse_presentation_type(Char type) -> presentation_type
Definition: core.h:2522
constexpr auto make_format_args(Args &&... args) -> format_arg_store< Context, remove_cvref_t< Args >... >
\rst Constructs a ~fmtformat_arg_store object that contains references to arguments and can be implic...
Definition: core.h:1923
#define FMT_CONSTEXPR
Definition: core.h:106
type
Definition: core.h:575
#define FMT_BEGIN_NAMESPACE
Definition: core.h:214
#define FMT_BEGIN_DETAIL_NAMESPACE
Definition: core.h:226
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T > > > buffer_appender
Definition: core.h:1106
#define FMT_ENABLE_IF(...)
Definition: core.h:335
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition: core.h:407
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept -> int
Definition: core.h:2343
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< Char >
Definition: core.h:536
typename type_identity< T >::type type_identity_t
Definition: core.h:309
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:300
#define FMT_END_NAMESPACE
Definition: core.h:217
#define FMT_MODULE_EXPORT_END
Definition: core.h:225
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const basic_format_specs< Char > &specs) -> OutputIt
Definition: format.h:1686
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
Definition: format.h:1004
constexpr auto is_negative(T value) -> bool
Definition: format.h:1009
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:1031
#define FMT_THROW(x)
Definition: format.h:95
FMT_CONSTEXPR auto get_arg(Context &ctx, ID id) -> typename Context::format_arg
Definition: format.h:3484
constexpr common_t< T1, T2 > max(const T1 x, const T2 y) noexcept
Compile-time pairwise maximum function.
Definition: max.hpp:35
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
static EIGEN_DEPRECATED const end_t end
Definition: IndexedViewHelper.h:181
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition: chrono.h:426
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:93
void convert_arg(basic_format_arg< Context > &arg, Char type)
Definition: printf.h:164
auto vfprintf(std::FILE *f, const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char > > > args) -> int
Definition: printf.h:585
auto vsprintf(const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char > > > args) -> std::basic_string< Char >
Definition: printf.h:558
auto make_wprintf_args(const T &... args) -> format_arg_store< wprintf_context, T... >
\rst Constructs an ~fmtformat_arg_store object that contains references to arguments and can be impli...
Definition: printf.h:552
void vprintf(buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
Definition: printf.h:369
basic_printf_context_t< wchar_t > wprintf_context
Definition: printf.h:528
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
\rst Prints formatted data to the file f.
Definition: printf.h:607
auto printf(const S &fmt, const T &... args) -> int
\rst Prints formatted data to stdout.
Definition: printf.h:631
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:578
basic_printf_context_t< char > printf_context
Definition: printf.h:527
void parse_flags(basic_format_specs< Char > &specs, const Char *&it, const Char *end)
Definition: printf.h:303
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:540
int parse_header(const Char *&it, const Char *end, basic_format_specs< Char > &specs, GetArg get_arg)
Definition: printf.h:331
Definition: format.h:3399
FMT_CONSTEXPR FMT_INLINE auto operator()(T value) -> iterator
Definition: format.h:3408
const basic_format_specs< Char > & specs
Definition: format.h:3404
iterator out
Definition: format.h:3403
Definition: core.h:2141
presentation_type type
Definition: core.h:2144
sign_t sign
Definition: core.h:2146
detail::fill_t< Char > fill
Definition: core.h:2149
align_t align
Definition: core.h:2145
bool alt
Definition: core.h:2147
int precision
Definition: core.h:2143
int width
Definition: core.h:2142
Definition: printf.h:188
const Char * operator()(const Char *s)
Definition: printf.h:190
const Char * operator()(T)
Definition: printf.h:189
static bool fits_in_int(T value)
Definition: printf.h:72
static bool fits_in_int(int)
Definition: printf.h:76
Definition: printf.h:63
static bool fits_in_int(bool)
Definition: printf.h:68
static bool fits_in_int(T value)
Definition: printf.h:64
Definition: core.h:566
bool type
Definition: printf.h:111
Definition: printf.h:109
Definition: core.h:325
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:87