WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
std.h
Go to the documentation of this file.
1// Formatting library for C++ - formatters for standard library types
2//
3// Copyright (c) 2012 - present, Victor Zverovich
4// All rights reserved.
5//
6// For the license information refer to format.h.
7
8#ifndef FMT_STD_H_
9#define FMT_STD_H_
10
11#include "format.h"
12#include "ostream.h"
13
14#ifndef FMT_MODULE
15# include <atomic>
16# include <bitset>
17# include <complex>
18# include <exception>
19# include <functional> // std::reference_wrapper
20# include <memory>
21# include <thread>
22# include <type_traits>
23# include <typeinfo> // std::type_info
24# include <utility> // std::make_index_sequence
25
26// Check FMT_CPLUSPLUS to suppress a bogus warning in MSVC.
27# if FMT_CPLUSPLUS >= 201703L
28# if FMT_HAS_INCLUDE(<filesystem>) && \
29 (!defined(FMT_CPP_LIB_FILESYSTEM) || FMT_CPP_LIB_FILESYSTEM != 0)
30# include <filesystem>
31# endif
32# if FMT_HAS_INCLUDE(<variant>)
33# include <variant>
34# endif
35# if FMT_HAS_INCLUDE(<optional>)
36# include <optional>
37# endif
38# endif
39// Use > instead of >= in the version check because <source_location> may be
40// available after C++17 but before C++20 is marked as implemented.
41# if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<source_location>)
42# include <source_location>
43# endif
44# if FMT_CPLUSPLUS > 202002L && FMT_HAS_INCLUDE(<expected>)
45# include <expected>
46# endif
47#endif // FMT_MODULE
48
49#if FMT_HAS_INCLUDE(<version>)
50# include <version>
51#endif
52
53// GCC 4 does not support FMT_HAS_INCLUDE.
54#if FMT_HAS_INCLUDE(<cxxabi.h>) || defined(__GLIBCXX__)
55# include <cxxabi.h>
56// Android NDK with gabi++ library on some architectures does not implement
57// abi::__cxa_demangle().
58# ifndef __GABIXX_CXXABI_H__
59# define FMT_HAS_ABI_CXA_DEMANGLE
60# endif
61#endif
62
63// For older Xcode versions, __cpp_lib_xxx flags are inaccurately defined.
64#ifndef FMT_CPP_LIB_FILESYSTEM
65# ifdef __cpp_lib_filesystem
66# define FMT_CPP_LIB_FILESYSTEM __cpp_lib_filesystem
67# else
68# define FMT_CPP_LIB_FILESYSTEM 0
69# endif
70#endif
71
72#ifndef FMT_CPP_LIB_VARIANT
73# ifdef __cpp_lib_variant
74# define FMT_CPP_LIB_VARIANT __cpp_lib_variant
75# else
76# define FMT_CPP_LIB_VARIANT 0
77# endif
78#endif
79
81namespace detail {
82
83#if FMT_CPP_LIB_FILESYSTEM
84
85template <typename Char, typename PathChar>
86auto get_path_string(const std::filesystem::path& p,
87 const std::basic_string<PathChar>& native) {
88 if constexpr (std::is_same_v<Char, char> && std::is_same_v<PathChar, wchar_t>)
89 return to_utf8<wchar_t>(native, to_utf8_error_policy::replace);
90 else
91 return p.string<Char>();
92}
93
94template <typename Char, typename PathChar>
95void write_escaped_path(basic_memory_buffer<Char>& quoted,
96 const std::filesystem::path& p,
97 const std::basic_string<PathChar>& native) {
98 if constexpr (std::is_same_v<Char, char> &&
99 std::is_same_v<PathChar, wchar_t>) {
100 auto buf = basic_memory_buffer<wchar_t>();
101 write_escaped_string<wchar_t>(std::back_inserter(buf), native);
102 bool valid = to_utf8<wchar_t>::convert(quoted, {buf.data(), buf.size()});
103 FMT_ASSERT(valid, "invalid utf16");
104 } else if constexpr (std::is_same_v<Char, PathChar>) {
106 std::back_inserter(quoted), native);
107 } else {
108 write_escaped_string<Char>(std::back_inserter(quoted), p.string<Char>());
109 }
110}
111
112#endif // FMT_CPP_LIB_FILESYSTEM
113
114#if defined(__cpp_lib_expected) || FMT_CPP_LIB_VARIANT
115template <typename Char, typename OutputIt, typename T>
116auto write_escaped_alternative(OutputIt out, const T& v) -> OutputIt {
117 if constexpr (has_to_string_view<T>::value)
119 if constexpr (std::is_same_v<T, Char>) return write_escaped_char(out, v);
120 return write<Char>(out, v);
121}
122#endif
123
124#if FMT_CPP_LIB_VARIANT
125
126template <typename> struct is_variant_like_ : std::false_type {};
127template <typename... Types>
128struct is_variant_like_<std::variant<Types...>> : std::true_type {};
129
130template <typename Variant, typename Char> class is_variant_formattable {
131 template <size_t... Is>
132 static std::conjunction<
134 check(std::index_sequence<Is...>);
135
136 public:
137 static constexpr bool value = decltype(check(
138 std::make_index_sequence<std::variant_size<Variant>::value>()))::value;
139};
140
141#endif // FMT_CPP_LIB_VARIANT
142
143#if FMT_USE_RTTI
144
145template <typename Char, typename OutputIt>
146auto write_demangled_name(OutputIt out, const std::type_info& ti) -> OutputIt {
147# ifdef FMT_HAS_ABI_CXA_DEMANGLE
148 int status = 0;
149 size_t size = 0;
150 std::unique_ptr<char, void (*)(void*)> demangled_name_ptr(
151 abi::__cxa_demangle(ti.name(), nullptr, &size, &status), &std::free);
152
153 string_view demangled_name_view;
154 if (demangled_name_ptr) {
155 demangled_name_view = demangled_name_ptr.get();
156
157 // Normalization of stdlib inline namespace names.
158 // libc++ inline namespaces.
159 // std::__1::* -> std::*
160 // std::__1::__fs::* -> std::*
161 // libstdc++ inline namespaces.
162 // std::__cxx11::* -> std::*
163 // std::filesystem::__cxx11::* -> std::filesystem::*
164 if (demangled_name_view.starts_with("std::")) {
165 char* begin = demangled_name_ptr.get();
166 char* to = begin + 5; // std::
167 for (char *from = to, *end = begin + demangled_name_view.size();
168 from < end;) {
169 // This is safe, because demangled_name is NUL-terminated.
170 if (from[0] == '_' && from[1] == '_') {
171 char* next = from + 1;
172 while (next < end && *next != ':') next++;
173 if (next[0] == ':' && next[1] == ':') {
174 from = next + 2;
175 continue;
176 }
177 }
178 *to++ = *from++;
179 }
180 demangled_name_view = {begin, detail::to_unsigned(to - begin)};
181 }
182 } else {
183 demangled_name_view = string_view(ti.name());
184 }
185 return detail::write_bytes<Char>(out, demangled_name_view);
186# elif FMT_MSC_VERSION
187 const string_view demangled_name(ti.name());
188 for (size_t i = 0; i < demangled_name.size(); ++i) {
189 auto sub = demangled_name;
190 sub.remove_prefix(i);
191 if (sub.starts_with("enum ")) {
192 i += 4;
193 continue;
194 }
195 if (sub.starts_with("class ") || sub.starts_with("union ")) {
196 i += 5;
197 continue;
198 }
199 if (sub.starts_with("struct ")) {
200 i += 6;
201 continue;
202 }
203 if (*sub.begin() != ' ') *out++ = *sub.begin();
204 }
205 return out;
206# else
207 return detail::write_bytes<Char>(out, string_view(ti.name()));
208# endif
209}
210
211#endif // FMT_USE_RTTI
212
213template <typename T, typename Enable = void>
214struct has_flip : std::false_type {};
215
216template <typename T>
217struct has_flip<T, void_t<decltype(std::declval<T>().flip())>>
218 : std::true_type {};
219
220template <typename T> struct is_bit_reference_like {
221 static constexpr bool value = std::is_convertible<T, bool>::value &&
222 std::is_nothrow_assignable<T, bool>::value &&
224};
225
226// Workaround for libc++ incompatibility with C++ standard.
227// According to the Standard, `bitset::operator[] const` returns bool.
228#ifdef _LIBCPP_VERSION
229template <typename C>
230struct is_bit_reference_like<std::__bit_const_reference<C>> {
231 static constexpr bool value = true;
232};
233#endif
234
235template <typename T, typename Enable = void>
236struct has_format_as : std::false_type {};
237template <typename T>
238struct has_format_as<T, void_t<decltype(format_as(std::declval<const T&>()))>>
239 : std::true_type {};
240
241template <typename T, typename Enable = void>
242struct has_format_as_member : std::false_type {};
243template <typename T>
245 T, void_t<decltype(formatter<T>::format_as(std::declval<const T&>()))>>
246 : std::true_type {};
247
248} // namespace detail
249
250template <typename T, typename Deleter>
251auto ptr(const std::unique_ptr<T, Deleter>& p) -> const void* {
252 return p.get();
253}
254template <typename T> auto ptr(const std::shared_ptr<T>& p) -> const void* {
255 return p.get();
256}
257
258#if FMT_CPP_LIB_FILESYSTEM
259
260class path : public std::filesystem::path {
261 public:
262 auto display_string() const -> std::string {
263 const std::filesystem::path& base = *this;
264 return fmt::format(FMT_STRING("{}"), base);
265 }
266 auto system_string() const -> std::string { return string(); }
267
268 auto generic_display_string() const -> std::string {
269 const std::filesystem::path& base = *this;
270 return fmt::format(FMT_STRING("{:g}"), base);
271 }
272 auto generic_system_string() const -> std::string { return generic_string(); }
273};
274
275template <typename Char> struct formatter<std::filesystem::path, Char> {
276 private:
277 format_specs specs_;
278 detail::arg_ref<Char> width_ref_;
279 bool debug_ = false;
280 char path_type_ = 0;
281
282 public:
283 FMT_CONSTEXPR void set_debug_format(bool set = true) { debug_ = set; }
284
285 FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) {
286 auto it = ctx.begin(), end = ctx.end();
287 if (it == end) return it;
288
289 it = detail::parse_align(it, end, specs_);
290 if (it == end) return it;
291
292 Char c = *it;
293 if ((c >= '0' && c <= '9') || c == '{')
294 it = detail::parse_width(it, end, specs_, width_ref_, ctx);
295 if (it != end && *it == '?') {
296 debug_ = true;
297 ++it;
298 }
299 if (it != end && (*it == 'g')) path_type_ = detail::to_ascii(*it++);
300 return it;
301 }
302
303 template <typename FormatContext>
304 auto format(const std::filesystem::path& p, FormatContext& ctx) const {
305 auto specs = specs_;
306 auto path_string =
307 !path_type_ ? p.native()
308 : p.generic_string<std::filesystem::path::value_type>();
309
310 detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,
311 ctx);
312 if (!debug_) {
313 auto s = detail::get_path_string<Char>(p, path_string);
314 return detail::write(ctx.out(), basic_string_view<Char>(s), specs);
315 }
316 auto quoted = basic_memory_buffer<Char>();
317 detail::write_escaped_path(quoted, p, path_string);
318 return detail::write(ctx.out(),
319 basic_string_view<Char>(quoted.data(), quoted.size()),
320 specs);
321 }
322};
323
324#endif // FMT_CPP_LIB_FILESYSTEM
325
326template <size_t N, typename Char>
327struct formatter<std::bitset<N>, Char>
328 : nested_formatter<basic_string_view<Char>, Char> {
329 private:
330 // This is a functor because C++11 doesn't support generic lambdas.
331 struct writer {
332 const std::bitset<N>& bs;
333
334 template <typename OutputIt>
335 FMT_CONSTEXPR auto operator()(OutputIt out) -> OutputIt {
336 for (auto pos = N; pos > 0; --pos)
337 out = detail::write<Char>(out, bs[pos - 1] ? Char('1') : Char('0'));
338 return out;
339 }
340 };
341
342 public:
343 template <typename FormatContext>
344 auto format(const std::bitset<N>& bs, FormatContext& ctx) const
345 -> decltype(ctx.out()) {
346 return this->write_padded(ctx, writer{bs});
347 }
348};
349
350template <typename Char>
351struct formatter<std::thread::id, Char> : basic_ostream_formatter<Char> {};
352
353#ifdef __cpp_lib_optional
354template <typename T, typename Char>
355struct formatter<std::optional<T>, Char,
356 std::enable_if_t<is_formattable<T, Char>::value>> {
357 private:
358 formatter<T, Char> underlying_;
359 static constexpr basic_string_view<Char> optional =
360 detail::string_literal<Char, 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l',
361 '('>{};
362 static constexpr basic_string_view<Char> none =
363 detail::string_literal<Char, 'n', 'o', 'n', 'e'>{};
364
365 template <class U>
366 FMT_CONSTEXPR static auto maybe_set_debug_format(U& u, bool set)
367 -> decltype(u.set_debug_format(set)) {
368 u.set_debug_format(set);
369 }
370
371 template <class U>
372 FMT_CONSTEXPR static void maybe_set_debug_format(U&, ...) {}
373
374 public:
375 FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) {
376 maybe_set_debug_format(underlying_, true);
377 return underlying_.parse(ctx);
378 }
379
380 template <typename FormatContext>
381 auto format(const std::optional<T>& opt, FormatContext& ctx) const
382 -> decltype(ctx.out()) {
383 if (!opt) return detail::write<Char>(ctx.out(), none);
384
385 auto out = ctx.out();
386 out = detail::write<Char>(out, optional);
387 ctx.advance_to(out);
388 out = underlying_.format(*opt, ctx);
389 return detail::write(out, ')');
390 }
391};
392#endif // __cpp_lib_optional
393
394#ifdef __cpp_lib_expected
395template <typename T, typename E, typename Char>
396struct formatter<std::expected<T, E>, Char,
397 std::enable_if_t<(std::is_void<T>::value ||
398 is_formattable<T, Char>::value) &&
399 is_formattable<E, Char>::value>> {
400 FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
401 return ctx.begin();
402 }
403
404 template <typename FormatContext>
405 auto format(const std::expected<T, E>& value, FormatContext& ctx) const
406 -> decltype(ctx.out()) {
407 auto out = ctx.out();
408
409 if (value.has_value()) {
410 out = detail::write<Char>(out, "expected(");
411 if constexpr (!std::is_void<T>::value)
412 out = detail::write_escaped_alternative<Char>(out, *value);
413 } else {
414 out = detail::write<Char>(out, "unexpected(");
415 out = detail::write_escaped_alternative<Char>(out, value.error());
416 }
417 *out++ = ')';
418 return out;
419 }
420};
421#endif // __cpp_lib_expected
422
423#ifdef __cpp_lib_source_location
424template <> struct formatter<std::source_location> {
425 FMT_CONSTEXPR auto parse(parse_context<>& ctx) { return ctx.begin(); }
426
427 template <typename FormatContext>
428 auto format(const std::source_location& loc, FormatContext& ctx) const
429 -> decltype(ctx.out()) {
430 auto out = ctx.out();
431 out = detail::write(out, loc.file_name());
432 out = detail::write(out, ':');
433 out = detail::write<char>(out, loc.line());
434 out = detail::write(out, ':');
435 out = detail::write<char>(out, loc.column());
436 out = detail::write(out, ": ");
437 out = detail::write(out, loc.function_name());
438 return out;
439 }
440};
441#endif
442
443#if FMT_CPP_LIB_VARIANT
444
445template <typename T> struct is_variant_like {
446 static constexpr bool value = detail::is_variant_like_<T>::value;
447};
448
449template <typename Char> struct formatter<std::monostate, Char> {
450 FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
451 return ctx.begin();
452 }
453
454 template <typename FormatContext>
455 auto format(const std::monostate&, FormatContext& ctx) const
456 -> decltype(ctx.out()) {
457 return detail::write<Char>(ctx.out(), "monostate");
458 }
459};
460
461template <typename Variant, typename Char>
462struct formatter<Variant, Char,
463 std::enable_if_t<std::conjunction_v<
464 is_variant_like<Variant>,
465 detail::is_variant_formattable<Variant, Char>>>> {
466 FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
467 return ctx.begin();
468 }
469
470 template <typename FormatContext>
471 auto format(const Variant& value, FormatContext& ctx) const
472 -> decltype(ctx.out()) {
473 auto out = ctx.out();
474
475 out = detail::write<Char>(out, "variant(");
476 FMT_TRY {
477 std::visit(
478 [&](const auto& v) {
479 out = detail::write_escaped_alternative<Char>(out, v);
480 },
481 value);
482 }
483 FMT_CATCH(const std::bad_variant_access&) {
484 detail::write<Char>(out, "valueless by exception");
485 }
486 *out++ = ')';
487 return out;
488 }
489};
490
491#endif // FMT_CPP_LIB_VARIANT
492
493template <> struct formatter<std::error_code> {
494 private:
495 format_specs specs_;
496 detail::arg_ref<char> width_ref_;
497 bool debug_ = false;
498
499 public:
500 FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* {
501 auto it = ctx.begin(), end = ctx.end();
502 if (it == end) return it;
503
504 it = detail::parse_align(it, end, specs_);
505
506 char c = *it;
507 if (it != end && ((c >= '0' && c <= '9') || c == '{'))
508 it = detail::parse_width(it, end, specs_, width_ref_, ctx);
509
510 if (it != end && *it == '?') {
511 debug_ = true;
512 ++it;
513 }
514 if (it != end && *it == 's') {
516 ++it;
517 }
518 return it;
519 }
520
521 template <typename FormatContext>
522 FMT_CONSTEXPR20 auto format(const std::error_code& ec,
523 FormatContext& ctx) const -> decltype(ctx.out()) {
524 auto specs = specs_;
525 detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,
526 ctx);
527 auto buf = memory_buffer();
528 if (specs_.type() == presentation_type::string) {
529 buf.append(ec.message());
530 } else {
531 buf.append(string_view(ec.category().name()));
532 buf.push_back(':');
533 detail::write<char>(appender(buf), ec.value());
534 }
535 auto quoted = memory_buffer();
536 auto str = string_view(buf.data(), buf.size());
537 if (debug_) {
538 detail::write_escaped_string<char>(std::back_inserter(quoted), str);
539 str = string_view(quoted.data(), quoted.size());
540 }
541 return detail::write<char>(ctx.out(), str, specs);
542 }
543};
544
545#if FMT_USE_RTTI
546template <typename Char>
547struct formatter<std::type_info, Char // DEPRECATED! Mixing code unit types.
548 > {
549 public:
550 FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
551 return ctx.begin();
552 }
553
554 template <typename Context>
555 auto format(const std::type_info& ti, Context& ctx) const
556 -> decltype(ctx.out()) {
557 return detail::write_demangled_name<Char>(ctx.out(), ti);
558 }
559};
560#endif // FMT_USE_RTTI
561
562template <typename T, typename Char>
564 T, Char, // DEPRECATED! Mixing code unit types.
565 typename std::enable_if<std::is_base_of<std::exception, T>::value>::type> {
566 private:
567 bool with_typename_ = false;
568
569 public:
570 FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
571 auto it = ctx.begin();
572 auto end = ctx.end();
573 if (it == end || *it == '}') return it;
574 if (*it == 't') {
575 ++it;
576 with_typename_ = FMT_USE_RTTI != 0;
577 }
578 return it;
579 }
580
581 template <typename Context>
582 auto format(const std::exception& ex, Context& ctx) const
583 -> decltype(ctx.out()) {
584 auto out = ctx.out();
585#if FMT_USE_RTTI
586 if (with_typename_) {
587 out = detail::write_demangled_name<Char>(out, typeid(ex));
588 *out++ = ':';
589 *out++ = ' ';
590 }
591#endif
592 return detail::write_bytes<Char>(out, string_view(ex.what()));
593 }
594};
595
596// We can't use std::vector<bool, Allocator>::reference and
597// std::bitset<N>::reference because the compiler can't deduce Allocator and N
598// in partial specialization.
599template <typename BitRef, typename Char>
600struct formatter<BitRef, Char,
601 enable_if_t<detail::is_bit_reference_like<BitRef>::value>>
602 : formatter<bool, Char> {
603 template <typename FormatContext>
604 FMT_CONSTEXPR auto format(const BitRef& v, FormatContext& ctx) const
605 -> decltype(ctx.out()) {
606 return formatter<bool, Char>::format(v, ctx);
607 }
608};
609
610template <typename T, typename Char>
611struct formatter<std::atomic<T>, Char,
612 enable_if_t<is_formattable<T, Char>::value>>
613 : formatter<T, Char> {
614 template <typename FormatContext>
615 auto format(const std::atomic<T>& v, FormatContext& ctx) const
616 -> decltype(ctx.out()) {
617 return formatter<T, Char>::format(v.load(), ctx);
618 }
619};
620
621#ifdef __cpp_lib_atomic_flag_test
622template <typename Char>
623struct formatter<std::atomic_flag, Char> : formatter<bool, Char> {
624 template <typename FormatContext>
625 auto format(const std::atomic_flag& v, FormatContext& ctx) const
626 -> decltype(ctx.out()) {
627 return formatter<bool, Char>::format(v.test(), ctx);
628 }
629};
630#endif // __cpp_lib_atomic_flag_test
631
632template <typename T, typename Char> struct formatter<std::complex<T>, Char> {
633 private:
635
636 template <typename FormatContext, typename OutputIt>
637 FMT_CONSTEXPR auto do_format(const std::complex<T>& c,
639 FormatContext& ctx, OutputIt out) const
640 -> OutputIt {
641 if (c.real() != 0) {
642 *out++ = Char('(');
643 out = detail::write<Char>(out, c.real(), specs, ctx.locale());
644 specs.set_sign(sign::plus);
645 out = detail::write<Char>(out, c.imag(), specs, ctx.locale());
646 if (!detail::isfinite(c.imag())) *out++ = Char(' ');
647 *out++ = Char('i');
648 *out++ = Char(')');
649 return out;
650 }
651 out = detail::write<Char>(out, c.imag(), specs, ctx.locale());
652 if (!detail::isfinite(c.imag())) *out++ = Char(' ');
653 *out++ = Char('i');
654 return out;
655 }
656
657 public:
658 FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {
659 if (ctx.begin() == ctx.end() || *ctx.begin() == '}') return ctx.begin();
660 return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,
662 }
663
664 template <typename FormatContext>
665 auto format(const std::complex<T>& c, FormatContext& ctx) const
666 -> decltype(ctx.out()) {
667 auto specs = specs_;
668 if (specs.dynamic()) {
670 specs.width_ref, ctx);
672 specs.precision_ref, ctx);
673 }
674
675 if (specs.width == 0) return do_format(c, specs, ctx, ctx.out());
676 auto buf = basic_memory_buffer<Char>();
677
678 auto outer_specs = format_specs();
679 outer_specs.width = specs.width;
680 outer_specs.copy_fill_from(specs);
681 outer_specs.set_align(specs.align());
682
683 specs.width = 0;
684 specs.set_fill({});
685 specs.set_align(align::none);
686
687 do_format(c, specs, ctx, basic_appender<Char>(buf));
688 return detail::write<Char>(ctx.out(),
689 basic_string_view<Char>(buf.data(), buf.size()),
690 outer_specs);
691 }
692};
693
694template <typename T, typename Char>
695struct formatter<std::reference_wrapper<T>, Char,
696 // Guard against format_as because reference_wrapper is
697 // implicitly convertible to T&.
698 enable_if_t<is_formattable<remove_cvref_t<T>, Char>::value &&
699 !detail::has_format_as<T>::value &&
700 !detail::has_format_as_member<T>::value>>
701 : formatter<remove_cvref_t<T>, Char> {
702 template <typename FormatContext>
703 auto format(std::reference_wrapper<T> ref, FormatContext& ctx) const
704 -> decltype(ctx.out()) {
705 return formatter<remove_cvref_t<T>, Char>::format(ref.get(), ctx);
706 }
707};
708
710
711#endif // FMT_STD_H_
constexpr auto format_as(HAL_AddressableLEDColorOrder order)
Definition AddressableLEDTypes.h:33
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or glfw and nanopb were modified for use in Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
Definition ThirdPartyNotices.txt:140
Definition base.h:2474
A dynamically growing memory buffer for trivially copyable/constructible types with the first SIZE el...
Definition format.h:774
constexpr bool dynamic() const
Definition base.h:783
FMT_CONSTEXPR void set_fill(char c)
Definition base.h:826
constexpr auto align() const -> align
Definition base.h:760
FMT_CONSTEXPR auto dynamic_precision() const -> arg_id_kind
Definition base.h:774
FMT_CONSTEXPR void set_sign(fmt::sign s)
Definition base.h:790
constexpr auto type() const -> presentation_type
Definition base.h:753
constexpr auto dynamic_width() const -> arg_id_kind
Definition base.h:767
FMT_CONSTEXPR void set_align(fmt::align a)
Definition base.h:763
FMT_CONSTEXPR void set_type(presentation_type t)
Definition base.h:756
constexpr auto size() const noexcept -> size_t
Returns the string size.
Definition base.h:563
FMT_CONSTEXPR void remove_prefix(size_t n) noexcept
Definition base.h:572
FMT_CONSTEXPR auto starts_with(basic_string_view< Char > sv) const noexcept -> bool
Definition base.h:577
auto convert(basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort) -> bool
Definition format.h:1295
Definition base.h:2146
Parsing context consisting of a format string range being parsed and an argument counter for automati...
Definition base.h:866
constexpr auto begin() const noexcept -> iterator
Returns an iterator to the beginning of the format string range being parsed.
Definition base.h:885
FMT_CONSTEXPR void advance_to(iterator it)
Advances the begin iterator to it.
Definition base.h:891
constexpr auto end() const noexcept -> iterator
Returns an iterator past the end of the format string range being parsed.
Definition base.h:888
#define FMT_STRING(s)
Constructs a legacy compile-time format string from a string literal s.
Definition format.h:4196
basic_memory_buffer< char > memory_buffer
Definition format.h:875
#define FMT_USE_RTTI
Definition format.h:105
FMT_INLINE auto format(const Locale &loc, format_string< T... > fmt, T &&... args) -> std::string
Definition format.h:4252
detail namespace with internal helper functions
Definition input_adapters.h:32
FMT_CONSTEXPR20 auto isfinite(T value) -> bool
Definition format.h:2575
constexpr auto to_ascii(Char c) -> char
Definition base.h:1280
FMT_CONSTEXPR auto write(OutputIt out, Char value, const format_specs &specs, locale_ref loc={}) -> OutputIt
Definition format.h:1815
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const format_specs &specs={}) -> OutputIt
Definition format.h:1661
@ value
the parser finished reading a JSON value
FMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t< Int >
Definition base.h:437
auto write_escaped_char(OutputIt out, Char v) -> OutputIt
Definition format.h:1789
FMT_CONSTEXPR auto parse_width(const Char *begin, const Char *end, format_specs &specs, arg_ref< Char > &width_ref, parse_context< Char > &ctx) -> const Char *
Definition base.h:1416
typename make_void< Ts... >::type void_t
Definition void_t.h:21
FMT_CONSTEXPR auto parse_align(const Char *begin, const Char *end, format_specs &specs) -> const Char *
Definition format.h:2258
constexpr auto to_string_view(const Char *s) -> basic_string_view< Char >
Definition base.h:931
FMT_CONSTEXPR void handle_dynamic_spec(arg_id_kind kind, int &value, const arg_ref< typename Context::char_type > &ref, Context &ctx)
Definition format.h:3646
FMT_CONSTEXPR auto maybe_set_debug_format(Formatter &f, bool set) -> decltype(f.set_debug_format(set))
Definition ranges.h:238
auto write_escaped_string(OutputIt out, basic_string_view< Char > str) -> OutputIt
Definition format.h:1773
Definition PointerIntPair.h:280
auto ptr(const std::unique_ptr< T, Deleter > &p) -> const void *
Definition std.h:251
Definition ostream.h:75
Definition base.h:1273
arg_ref< Char > width_ref
Definition base.h:1274
arg_ref< Char > precision_ref
Definition base.h:1275
Definition std.h:214
Definition std.h:242
Definition std.h:236
Definition std.h:220
Definition format.h:264
Definition base.h:983
Definition base.h:855
int width
Definition base.h:856
int precision
Definition base.h:857
FMT_CONSTEXPR auto format(const BitRef &v, FormatContext &ctx) const -> decltype(ctx.out())
Definition std.h:604
FMT_CONSTEXPR auto parse(parse_context< Char > &ctx) -> const Char *
Definition std.h:570
auto format(const std::exception &ex, Context &ctx) const -> decltype(ctx.out())
Definition std.h:582
auto format(const std::atomic< T > &v, FormatContext &ctx) const -> decltype(ctx.out())
Definition std.h:615
auto format(const std::bitset< N > &bs, FormatContext &ctx) const -> decltype(ctx.out())
Definition std.h:344
auto format(const std::complex< T > &c, FormatContext &ctx) const -> decltype(ctx.out())
Definition std.h:665
FMT_CONSTEXPR auto parse(parse_context< Char > &ctx) -> const Char *
Definition std.h:658
FMT_CONSTEXPR20 auto format(const std::error_code &ec, FormatContext &ctx) const -> decltype(ctx.out())
Definition std.h:522
FMT_CONSTEXPR auto parse(parse_context<> &ctx) -> const char *
Definition std.h:500
Definition base.h:664
Definition base.h:339
Definition format.h:4050
Definition base.h:1262
typename std::enable_if< B, T >::type enable_if_t
Definition base.h:312
#define FMT_ASSERT(condition, message)
Definition base.h:396
basic_string_view< char > string_view
Definition base.h:616
#define FMT_TRY
Definition base.h:160
basic_appender< char > appender
Definition base.h:632
#define FMT_CONSTEXPR
Definition base.h:113
#define FMT_BEGIN_NAMESPACE
Definition base.h:261
#define FMT_CATCH(x)
Definition base.h:161
#define FMT_CONSTEXPR20
Definition base.h:141
#define FMT_END_NAMESPACE
Definition base.h:264
bool_constant<!std::is_same< detail::mapped_t< conditional_t< std::is_void< T >::value, int *, T >, Char >, void >::value > is_formattable
Definition base.h:2792