36#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
37# define _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
38# define FMT_REMOVE_TRANSITIVE_INCLUDES
51# if defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI)
57# include <system_error>
60# if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L
65# if FMT_HAS_INCLUDE(<string_view>) && \
66 (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION))
67# include <string_view>
68# define FMT_USE_STRING_VIEW
76#if defined(FMT_USE_NONTYPE_TEMPLATE_ARGS)
78#elif defined(__NVCOMPILER)
79# define FMT_USE_NONTYPE_TEMPLATE_ARGS 0
80#elif FMT_GCC_VERSION >= 903 && FMT_CPLUSPLUS >= 201709L
81# define FMT_USE_NONTYPE_TEMPLATE_ARGS 1
82#elif defined(__cpp_nontype_template_args) && \
83 __cpp_nontype_template_args >= 201911L
84# define FMT_USE_NONTYPE_TEMPLATE_ARGS 1
85#elif FMT_CLANG_VERSION >= 1200 && FMT_CPLUSPLUS >= 202002L
86# define FMT_USE_NONTYPE_TEMPLATE_ARGS 1
88# define FMT_USE_NONTYPE_TEMPLATE_ARGS 0
91#if defined __cpp_inline_variables && __cpp_inline_variables >= 201606L
92# define FMT_INLINE_VARIABLE inline
94# define FMT_INLINE_VARIABLE
100#elif defined(__GXX_RTTI) || FMT_HAS_FEATURE(cxx_rtti) || defined(_CPPRTTI) || \
101 defined(__INTEL_RTTI__) || defined(__RTTI)
103# define FMT_USE_RTTI 1
105# define FMT_USE_RTTI 0
109#if defined(FMT_LIB_EXPORT) || defined(FMT_SHARED)
110# define FMT_SO_VISIBILITY(value) FMT_VISIBILITY(value)
112# define FMT_SO_VISIBILITY(value)
115#if FMT_GCC_VERSION || FMT_CLANG_VERSION
116# define FMT_NOINLINE __attribute__((noinline))
123#elif FMT_HAS_CPP14_ATTRIBUTE(deprecated)
124# define FMT_DEPRECATED [[deprecated]]
126# define FMT_DEPRECATED
130#if !FMT_USE_CONSTEVAL
131# define FMT_USE_CONSTEXPR_STRING 0
132#elif defined(__cpp_lib_constexpr_string) && \
133 __cpp_lib_constexpr_string >= 201907L
134# if FMT_CLANG_VERSION && FMT_GLIBCXX_RELEASE
137# if FMT_GLIBCXX_RELEASE < 13
138# define FMT_USE_CONSTEXPR_STRING 0
139# elif FMT_GLIBCXX_RELEASE == 13 && __GLIBCXX__ < 20240521
140# define FMT_USE_CONSTEXPR_STRING 0
142# define FMT_USE_CONSTEXPR_STRING 1
145# define FMT_USE_CONSTEXPR_STRING 1
148# define FMT_USE_CONSTEXPR_STRING 0
150#if FMT_USE_CONSTEXPR_STRING
151# define FMT_CONSTEXPR_STRING constexpr
153# define FMT_CONSTEXPR_STRING
162 decltype(
static_cast<int*
>(
nullptr) -
static_cast<int*
>(
nullptr));
170#elif FMT_USE_EXCEPTIONS
171# define FMT_THROW(x) throw x
173# define FMT_THROW(x) ::fmt::assert_fail(__FILE__, __LINE__, (x).what())
176#ifdef __clang_analyzer__
177# define FMT_CLANG_ANALYZER 1
179# define FMT_CLANG_ANALYZER 0
186#if !defined(FMT_REDUCE_INT_INSTANTIATIONS)
187# define FMT_REDUCE_INT_INSTANTIATIONS 0
192template <
typename Char,
typename Traits,
typename Allocator>
201# if FMT_HAS_BUILTIN(__builtin_clz) || FMT_GCC_VERSION || FMT_ICC_VERSION
202# define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
204# if FMT_HAS_BUILTIN(__builtin_clzll) || FMT_GCC_VERSION || FMT_ICC_VERSION
205# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
212#if FMT_MSC_VERSION && !defined(FMT_BUILTIN_CLZLL)
215# pragma intrinsic(_BitScanReverse)
217# pragma intrinsic(_BitScanReverse64)
221inline auto clz(uint32_t x) ->
int {
225 _BitScanReverse(&r, x);
226 return 31 ^
static_cast<int>(r);
228# define FMT_BUILTIN_CLZ(n) detail::clz(n)
230inline auto clzll(uint64_t x) ->
int {
235 _BitScanReverse64(&r, x);
238 if (_BitScanReverse(&r,
static_cast<uint32_t
>(x >> 32)))
239 return 63 ^
static_cast<int>(r + 32);
241 _BitScanReverse(&r,
static_cast<uint32_t
>(x));
243 return 63 ^
static_cast<int>(r);
245# define FMT_BUILTIN_CLZLL(n) detail::clzll(n)
251 if (condition)
throw std::runtime_error(
"fuzzing limit reached");
255#if defined(FMT_USE_STRING_VIEW)
256template <
typename Char>
using std_string_view = std::basic_string_view<Char>;
264 static constexpr Char
value[
sizeof...(C)] = {C...};
266 return {
value,
sizeof...(C)};
269#if FMT_CPLUSPLUS < 201703L
270template <
typename Char, Char... C>
271constexpr Char string_literal<Char, C...>::value[
sizeof...(C)];
275template <
typename To,
typename From, FMT_ENABLE_IF(sizeof(To) == sizeof(From))>
277#ifdef __cpp_lib_bit_cast
282 std::memcpy(
static_cast<void*
>(&to), &
from,
sizeof(to));
289#elif defined(__BIG_ENDIAN__)
291#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
292 return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;
295 char data[
sizeof(int)];
309 constexpr auto high() const noexcept -> uint64_t {
return hi_; }
310 constexpr auto low() const noexcept -> uint64_t {
return lo_; }
312 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
313 constexpr explicit operator T()
const {
314 return static_cast<T
>(lo_);
319 return lhs.hi_ == rhs.hi_ && lhs.lo_ == rhs.lo_;
323 return !(lhs == rhs);
327 return lhs.hi_ != rhs.hi_ ? lhs.hi_ > rhs.hi_ : lhs.lo_ > rhs.lo_;
332 return {lhs.hi_ | rhs.hi_, lhs.lo_ | rhs.lo_};
337 return {lhs.hi_ & rhs.hi_, lhs.lo_ & rhs.lo_};
341 return {~n.hi_, ~n.lo_};
353 uint64_t hi = (lhs.lo_ >> 32) * rhs;
354 uint64_t lo = (lhs.lo_ & ~uint32_t()) * rhs;
355 uint64_t new_lo = (hi << 32) + lo;
356 return {(hi >> 32) + (new_lo < lo ? 1 : 0), new_lo};
360 return {lhs.hi_ - (lhs.lo_ < rhs ? 1 : 0), lhs.lo_ - rhs};
363 if (shift == 64)
return {0, hi_};
365 return {hi_ >> shift, (hi_ << (64 - shift)) | (lo_ >> shift)};
368 if (shift == 64)
return {lo_, 0};
370 return {hi_ << shift | (lo_ >> (64 - shift)), (lo_ << shift)};
373 return *
this = *
this >> shift;
376 uint64_t new_lo = lo_ + n.lo_;
377 uint64_t new_hi = hi_ + n.hi_ + (new_lo < lo_ ? 1 : 0);
390 hi_ += (lo_ < n ? 1 : 0);
393#if FMT_HAS_BUILTIN(__builtin_addcll) && !defined(__ibmxl__)
394 unsigned long long carry;
395 lo_ = __builtin_addcll(lo_, n, 0, &carry);
397#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !defined(__ibmxl__)
398 unsigned long long result;
399 auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result);
402#elif defined(_MSC_VER) && defined(_M_X64)
403 auto carry = _addcarry_u64(0, lo_, n, &lo_);
404 _addcarry_u64(carry, hi_, 0, &hi_);
407 hi_ += (lo_ < n ? 1 : 0);
424 return (std::numeric_limits<T>::max)();
426template <
typename T>
constexpr auto num_bits() ->
int {
427 return std::numeric_limits<T>::digits;
436template <
typename To,
typename From, FMT_ENABLE_IF(sizeof(To) >
sizeof(From))>
438 constexpr auto size =
static_cast<int>(
sizeof(From) /
sizeof(
unsigned short));
440 unsigned short value[
static_cast<unsigned>(size)];
444 for (
int i = 0; i < size; ++i)
447 for (
int i = size - 1; i >= 0; --i)
453template <
typename UInt>
456 constexpr UInt msb_mask =
static_cast<UInt
>(1) << (
num_bits<UInt>() - 1);
457 for (; (n & msb_mask) == 0; n <<= 1) lz++;
462#ifdef FMT_BUILTIN_CLZ
469#ifdef FMT_BUILTIN_CLZLL
477#if FMT_HAS_BUILTIN(__builtin_assume) && !FMT_ICC_VERSION
478 __builtin_assume(condition);
480 if (!condition) __builtin_unreachable();
486template <
typename OutputIt,
489#if FMT_CLANG_VERSION >= 307 && !FMT_ICC_VERSION
490__attribute__((no_sanitize(
"undefined")))
493reserve(OutputIt it,
size_t n) ->
typename OutputIt::value_type* {
495 size_t size = c.size();
508template <
typename Iterator>
509constexpr auto reserve(Iterator& it,
size_t) -> Iterator& {
513template <
typename OutputIt>
517template <
typename T,
typename OutputIt>
530 auto size = buf.
size();
531 if (buf.
capacity() < size + n)
return nullptr;
533 return buf.
data() + size;
536template <
typename OutputIt,
540 typename OutputIt::container_type::value_type*)
545template <
typename Iterator>
552template <
typename OutputIt,
typename Size,
typename T>
555 for (Size i = 0; i <
count; ++i) *out++ =
value;
558template <
typename T,
typename Size>
561 static_assert(
sizeof(T) == 1,
562 "sizeof(T) must be 1 to use char for initialization");
567template <
typename OutChar,
typename InputIt,
typename OutputIt>
569 OutputIt out) -> OutputIt {
592 constexpr int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07};
593 constexpr uint32_t mins[] = {4194304, 0, 128, 2048, 65536};
594 constexpr int shiftc[] = {0, 18, 12, 6, 0};
595 constexpr int shifte[] = {0, 6, 4, 2, 0};
597 int len =
"\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\0\0\0\0\0\0\0\2\2\2\2\3\3\4"
598 [
static_cast<unsigned char>(*s) >> 3];
602 const char* next = s + len + !len;
604 using uchar =
unsigned char;
608 *c = uint32_t(uchar(s[0]) & masks[len]) << 18;
609 *c |= uint32_t(uchar(s[1]) & 0x3f) << 12;
610 *c |= uint32_t(uchar(s[2]) & 0x3f) << 6;
611 *c |= uint32_t(uchar(s[3]) & 0x3f) << 0;
615 *e = (*c < mins[len]) << 6;
616 *e |= ((*c >> 11) == 0x1b) << 7;
617 *e |= (*c > 0x10FFFF) << 8;
618 *e |= (uchar(s[1]) & 0xc0) >> 2;
619 *e |= (uchar(s[2]) & 0xc0) >> 4;
620 *e |= uchar(s[3]) >> 6;
633 auto decode = [f](
const char* buf_ptr,
const char*
ptr) {
634 auto cp = uint32_t();
639 return result ? (error ? buf_ptr + 1 : end) :
nullptr;
643 const size_t block_size = 4;
644 if (s.
size() >= block_size) {
645 for (
auto end =
p + s.
size() - block_size + 1;
p < end;) {
651 if (num_chars_left == 0)
return;
655 char buf[2 * block_size - 1] = {};
657 const char* buf_ptr = buf;
659 auto end = decode(buf_ptr,
p);
663 }
while (buf_ptr < buf + num_chars_left);
673 (cp >= 0x2e80 && cp <= 0xa4cf && cp != 0x303f) ||
674 (cp >= 0xac00 && cp <= 0xd7a3) ||
675 (cp >= 0xf900 && cp <= 0xfaff) ||
676 (cp >= 0xfe10 && cp <= 0xfe19) ||
677 (cp >= 0xfe30 && cp <= 0xfe6f) ||
678 (cp >= 0xff00 && cp <= 0xff60) ||
679 (cp >= 0xffe0 && cp <= 0xffe6) ||
680 (cp >= 0x20000 && cp <= 0x2fffd) ||
681 (cp >= 0x30000 && cp <= 0x3fffd) ||
683 (cp >= 0x1f300 && cp <= 0x1f64f) ||
685 (cp >= 0x1f900 && cp <= 0x1f9ff))));
694 std::integral_constant<bool, std::numeric_limits<T>::is_signed ||
695 std::is_same<T, int128_opt>::value>;
700 !std::is_same<T, char>::value &&
701 !std::is_same<T, wchar_t>::value>;
703#if defined(FMT_USE_FLOAT128)
705#elif FMT_CLANG_VERSION >= 309 && FMT_HAS_INCLUDE(<quadmath.h>)
706# define FMT_USE_FLOAT128 1
707#elif FMT_GCC_VERSION && defined(_GLIBCXX_USE_FLOAT128) && \
708 !defined(__STRICT_ANSI__)
709# define FMT_USE_FLOAT128 1
711# define FMT_USE_FLOAT128 0
714using float128 = __float128;
719template <
typename T>
using is_float128 = std::is_same<T, float128>;
724template <typename T, bool = is_floating_point<T>::value>
726 sizeof(T) <= sizeof(double)> {};
727template <typename T> struct is_fast_float<T, false> : std::false_type {};
730using fast_float_t = conditional_t<sizeof(T) == sizeof(double), double, float>;
733using is_double_double = bool_constant<std::numeric_limits<T>::digits == 106>;
735#ifndef FMT_USE_FULL_CACHE_DRAGONBOX
736# define FMT_USE_FULL_CACHE_DRAGONBOX 0
742template <typename T> struct allocator : private std::decay<void> {
743 using value_type = T;
745 auto allocate(size_t n) -> T* {
747 T*
p =
static_cast<T*
>(std::malloc(n *
sizeof(T)));
754 constexpr friend auto operator==(allocator, allocator)
noexcept ->
bool {
757 constexpr friend auto operator!=(allocator, allocator)
noexcept ->
bool {
784 typename Allocator = detail::allocator<T>>
795 if (data != store_) alloc_.deallocate(
data, this->
capacity());
801 const size_t max_size =
802 std::allocator_traits<Allocator>::max_size(self.alloc_);
803 size_t old_capacity = buf.
capacity();
804 size_t new_capacity = old_capacity + old_capacity / 2;
805 if (size > new_capacity)
807 else if (new_capacity > max_size)
808 new_capacity =
max_of(size, max_size);
809 T* old_data = buf.
data();
810 T* new_data = self.alloc_.allocate(new_capacity);
814 memcpy(new_data, old_data, buf.
size() *
sizeof(T));
815 self.set(new_data, new_capacity);
819 if (old_data != self.store_) self.alloc_.deallocate(old_data, old_capacity);
827 const Allocator& alloc = Allocator())
829 this->
set(store_, SIZE);
835 template <
typename Alloc = Allocator,
837 propagate_on_container_move_assignment::value)>
839 alloc_ = std::move(other.alloc_);
843 template <
typename Alloc = Allocator,
845 propagate_on_container_move_assignment::value)>
847 T*
data = other.data();
848 if (alloc_ == other.alloc_ ||
data == other.store_)
return true;
849 size_t size = other.size();
858 T*
data = other.data();
859 size_t size = other.size(),
capacity = other.capacity();
860 if (!move_alloc(other))
return;
861 if (
data == other.store_) {
868 other.set(other.store_, 0);
901 template <
typename ContiguousRange>
903 append(range.data(), range.data() + range.size());
909template <
size_t SIZE>
912 auto size = buf.
size();
914 return {buf.
data(), size};
927 inline writer(FILE* f) : buf_(nullptr), file_(f) {}
934 fmt::format_to(
appender(*buf_), fmt, std::forward<T>(args)...);
936 fmt::print(file_, fmt, std::forward<T>(args)...);
948 inline operator writer() {
return buf_; }
949 inline auto str() -> std::string& {
return str_; }
952template <
typename T,
size_t SIZE,
typename Allocator>
962 using std::runtime_error::runtime_error;
988 return {s, N - (std::char_traits<Char>::to_int_type(s[N - 1]) == 0 ? 1 : 0)};
998template <
typename T, FMT_ENABLE_IF(is_
signed<T>::value)>
1002template <
typename T, FMT_ENABLE_IF(!is_
signed<T>::value)>
1009template <
typename T>
1014template <
typename T>
1017#define FMT_POWERS_OF_10(factor) \
1018 factor * 10, (factor) * 100, (factor) * 1000, (factor) * 10000, \
1019 (factor) * 100000, (factor) * 1000000, (factor) * 10000000, \
1020 (factor) * 100000000, (factor) * 1000000000
1027 alignas(2)
static const char data[] =
1028 "0001020304050607080910111213141516171819"
1029 "2021222324252627282930313233343536373839"
1030 "4041424344454647484950515253545556575859"
1031 "6061626364656667686970717273747576777879"
1032 "8081828384858687888990919293949596979899";
1033 return &data[
value * 2];
1037 return static_cast<char>(((
' ' << 24) | (
'+' << 16) | (
'-' << 8)) >>
1038 (
static_cast<int>(s) * 8));
1047 if (n < 10)
return count;
1048 if (n < 100)
return count + 1;
1049 if (n < 1000)
return count + 2;
1050 if (n < 10000)
return count + 3;
1061#ifdef FMT_BUILTIN_CLZLL
1064inline auto do_count_digits(uint64_t n) ->
int {
1069 static constexpr uint8_t bsr2log10[] = {
1070 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5,
1071 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10,
1072 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15, 15,
1073 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 20};
1074 auto t = bsr2log10[FMT_BUILTIN_CLZLL(n | 1) ^ 63];
1075 static constexpr uint64_t zero_or_powers_of_10[] = {
1077 10000000000000000000ULL};
1078 return t - (n < zero_or_powers_of_10[t]);
1085#ifdef FMT_BUILTIN_CLZLL
1092template <
int BITS,
typename UInt>
1094#ifdef FMT_BUILTIN_CLZ
1096 return (FMT_BUILTIN_CLZ(
static_cast<uint32_t
>(n) | 1) ^ 31) / BITS + 1;
1103 }
while ((m >>= BITS) != 0);
1108#ifdef FMT_BUILTIN_CLZ
1111FMT_INLINE auto do_count_digits(uint32_t n) ->
int {
1114# define FMT_INC(T) (((sizeof(#T) - 1ull) << 32) - T)
1115 static constexpr uint64_t table[] = {
1116 FMT_INC(0), FMT_INC(0), FMT_INC(0),
1117 FMT_INC(10), FMT_INC(10), FMT_INC(10),
1118 FMT_INC(100), FMT_INC(100), FMT_INC(100),
1119 FMT_INC(1000), FMT_INC(1000), FMT_INC(1000),
1120 FMT_INC(10000), FMT_INC(10000), FMT_INC(10000),
1121 FMT_INC(100000), FMT_INC(100000), FMT_INC(100000),
1122 FMT_INC(1000000), FMT_INC(1000000), FMT_INC(1000000),
1123 FMT_INC(10000000), FMT_INC(10000000), FMT_INC(10000000),
1124 FMT_INC(100000000), FMT_INC(100000000), FMT_INC(100000000),
1125 FMT_INC(1000000000), FMT_INC(1000000000), FMT_INC(1000000000),
1126 FMT_INC(1000000000), FMT_INC(1000000000)
1128 auto inc = table[FMT_BUILTIN_CLZ(n | 1) ^ 31];
1129 return static_cast<int>((n + inc) >> 32);
1135#ifdef FMT_BUILTIN_CLZ
1141template <
typename Int>
constexpr auto digits10() noexcept ->
int {
1142 return std::numeric_limits<Int>::digits10;
1152template <
typename Char>
1154template <
typename Char>
1157 return {result.grouping, Char(result.thousands_sep)};
1164template <
typename Char>
1173#ifndef FMT_HEADER_ONLY
1185template <
typename Char>
auto equal2(
const Char* lhs,
const char* rhs) ->
bool {
1186 return lhs[0] == Char(rhs[0]) && lhs[1] == Char(rhs[1]);
1188inline auto equal2(
const char* lhs,
const char* rhs) ->
bool {
1189 return memcmp(lhs, rhs, 2) == 0;
1193template <
typename Char>
1200 *out++ =
static_cast<Char
>(
'0' +
value / 10);
1201 *out =
static_cast<Char
>(
'0' +
value % 10);
1206template <
typename Char,
typename UInt>
1211 while (
value >= 100) {
1223 out[--n] =
static_cast<Char
>(
'0' +
value);
1228template <
typename Char,
typename UInt>
1230 int num_digits) -> Char* {
1232 return out + num_digits;
1235template <
typename Char,
typename UInt,
typename OutputIt,
1250template <
typename Char,
typename UInt>
1252 int size,
bool upper =
false) -> Char* {
1255 const char* digits = upper ?
"0123456789ABCDEF" :
"0123456789abcdef";
1256 unsigned digit =
static_cast<unsigned>(
value & ((1u << base_bits) - 1));
1257 *--out =
static_cast<Char
>(base_bits < 4 ? static_cast<char>(
'0' + digit)
1259 }
while ((
value >>= base_bits) != 0);
1264template <
typename Char,
typename UInt>
1266 int num_digits,
bool upper =
false) -> Char* {
1268 return out + num_digits;
1271template <
typename Char,
typename OutputIt,
typename UInt,
1274 int num_digits,
bool upper =
false)
1295 return {&buffer_[0],
size()};
1297 inline auto size() const ->
size_t {
return buffer_.
size() - 1; }
1298 inline auto c_str() const -> const
wchar_t* {
return &buffer_[0]; }
1299 inline auto str() const ->
std::wstring {
return {&buffer_[0],
size()}; }
1305template <
typename WChar,
typename Buffer = memory_buffer>
class to_utf8 {
1313 static_assert(
sizeof(WChar) == 2 ||
sizeof(WChar) == 4,
1314 "expected utf16 or utf32");
1316 FMT_THROW(std::runtime_error(
sizeof(WChar) == 2 ?
"invalid utf16"
1317 :
"invalid utf32"));
1321 auto size() const ->
size_t {
return buffer_.size() - 1; }
1322 auto c_str() const -> const
char* {
return &buffer_[0]; }
1323 auto str() const ->
std::
string {
return std::string(&buffer_[0],
size()); }
1331 if (!
convert(buffer_, s, policy))
return false;
1332 buffer_.push_back(0);
1338 for (
auto p = s.begin();
p != s.end(); ++
p) {
1339 uint32_t c =
static_cast<uint32_t
>(*p);
1340 if (
sizeof(WChar) == 2 && c >= 0xd800 && c <= 0xdfff) {
1343 if (
p == s.end() || (c & 0xfc00) != 0xd800 || (*
p & 0xfc00) != 0xdc00) {
1349 c = (c << 10) + static_cast<uint32_t>(*
p) - 0x35fdc00;
1353 }
else if (c < 0x800) {
1354 buf.
push_back(
static_cast<char>(0xc0 | (c >> 6)));
1355 buf.
push_back(
static_cast<char>(0x80 | (c & 0x3f)));
1356 }
else if ((c >= 0x800 && c <= 0xd7ff) || (c >= 0xe000 && c <= 0xffff)) {
1357 buf.
push_back(
static_cast<char>(0xe0 | (c >> 12)));
1358 buf.
push_back(
static_cast<char>(0x80 | ((c & 0xfff) >> 6)));
1359 buf.
push_back(
static_cast<char>(0x80 | (c & 0x3f)));
1360 }
else if (c >= 0x10000 && c <= 0x10ffff) {
1361 buf.
push_back(
static_cast<char>(0xf0 | (c >> 18)));
1362 buf.
push_back(
static_cast<char>(0x80 | ((c & 0x3ffff) >> 12)));
1363 buf.
push_back(
static_cast<char>(0x80 | ((c & 0xfff) >> 6)));
1364 buf.
push_back(
static_cast<char>(0x80 | (c & 0x3f)));
1377 return {
static_cast<uint64_t
>(
p >> 64),
static_cast<uint64_t
>(
p)};
1378#elif defined(_MSC_VER) && defined(_M_X64)
1379 auto hi = uint64_t();
1380 auto lo = _umul128(x, y, &hi);
1385 uint64_t a = x >> 32;
1386 uint64_t b = x & mask;
1387 uint64_t c = y >> 32;
1388 uint64_t d = y & mask;
1390 uint64_t ac = a * c;
1391 uint64_t bc = b * c;
1392 uint64_t ad = a * d;
1393 uint64_t bd = b * d;
1395 uint64_t intermediate = (bd >> 32) + (ad & mask) + (bc & mask);
1397 return {ac + (intermediate >> 32) + (ad >> 32) + (bc >> 32),
1398 (intermediate << 32) + (bd & mask)};
1402namespace dragonbox {
1406 FMT_ASSERT(e <= 2620 && e >= -2620,
"too large exponent");
1407 static_assert((-1 >> 1) == -1,
"right shift is not arithmetic");
1408 return (e * 315653) >> 20;
1412 FMT_ASSERT(e <= 1233 && e >= -1233,
"too large exponent");
1413 return (e * 1741647) >> 19;
1420 return static_cast<uint64_t
>(
p >> 64);
1421#elif defined(_MSC_VER) && defined(_M_X64)
1422 return __umulh(x, y);
1444 static const int exponent_bits = 8;
1445 static const int kappa = 1;
1446 static const int big_divisor = 100;
1447 static const int small_divisor = 10;
1448 static const int min_k = -31;
1449 static const int max_k = 46;
1450 static const int shorter_interval_tie_lower_threshold = -35;
1451 static const int shorter_interval_tie_upper_threshold = -35;
1456 static const int exponent_bits = 11;
1457 static const int kappa = 2;
1458 static const int big_divisor = 1000;
1459 static const int small_divisor = 100;
1460 static const int min_k = -292;
1461 static const int max_k = 341;
1462 static const int shorter_interval_tie_lower_threshold = -77;
1463 static const int shorter_interval_tie_upper_threshold = -77;
1467template <
typename T>
1469 std::numeric_limits<T>::digits == 113 ||
1472 static const int exponent_bits = 15;
1476template <
typename T>
1493 return std::numeric_limits<Float>::digits != 64;
1501 : (std::numeric_limits<Float>::digits -
1505template <
typename Float>
1515 : std::numeric_limits<Float>::max_exponent - 1;
1519 auto prefix_size = 2;
1521 if (abs_exp < 100)
return prefix_size + 2;
1522 return prefix_size + (abs_exp >= 1000 ? 4 : 3);
1526template <
typename Char,
typename OutputIt>
1530 *out++ =
static_cast<Char
>(
'-');
1533 *out++ =
static_cast<Char
>(
'+');
1535 auto uexp =
static_cast<uint32_t
>(
exp);
1537 if (uexp < 10) *out++ =
'0';
1541 const char* top =
digits2(uexp / 100);
1542 if (uexp >= 1000u) *out++ =
static_cast<Char
>(top[0]);
1543 *out++ =
static_cast<Char
>(top[1]);
1546 const char* d =
digits2(uexp);
1547 *out++ =
static_cast<Char
>(d[0]);
1548 *out++ =
static_cast<Char
>(d[1]);
1561 constexpr basic_fp(uint64_t f_val,
int e_val) :
f(f_val),
e(e_val) {}
1567 template <
typename Float, FMT_ENABLE_IF(!is_
double_
double<Float>::value)>
1569 static_assert(std::numeric_limits<Float>::digits <= 113,
"unsupported FP");
1572 const auto num_float_significand_bits =
1574 const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;
1575 const auto significand_mask = implicit_bit - 1;
1577 f =
static_cast<F
>(u & significand_mask);
1579 num_float_significand_bits);
1582 auto is_predecessor_closer =
f == 0 && biased_e > 1;
1586 f +=
static_cast<F
>(implicit_bit);
1589 return is_predecessor_closer;
1592 template <
typename Float, FMT_ENABLE_IF(is_
double_
double<Float>::value)>
1594 static_assert(std::numeric_limits<double>::is_iec559,
"unsupported FP");
1595 return assign(
static_cast<double>(n));
1602template <
int SHIFT = 0,
typename F>
1606 const auto shifted_implicit_bit = implicit_bit << SHIFT;
1607 while ((
value.f & shifted_implicit_bit) == 0) {
1622 auto product =
static_cast<__uint128_t
>(lhs) * rhs;
1623 auto f =
static_cast<uint64_t
>(product >> 64);
1624 return (
static_cast<uint64_t
>(product) & (1ULL << 63)) != 0 ? f + 1 : f;
1627 uint64_t mask = (1ULL << 32) - 1;
1628 uint64_t a = lhs >> 32, b = lhs & mask;
1629 uint64_t c = rhs >> 32, d = rhs & mask;
1630 uint64_t ac = a * c, bc = b * c, ad = a * d, bd = b * d;
1632 uint64_t mid = (bd >> 32) + (ad & mask) + (bc & mask) + (1U << 31);
1633 return ac + (ad >> 32) + (bc >> 32) + (mid >> 32);
1638 return {
multiply(x.f, y.f), x.e + y.e + 64};
1645template <
typename T>
1650template <
bool C,
typename T,
typename F, FMT_ENABLE_IF(C)>
1654template <
bool C,
typename T,
typename F, FMT_ENABLE_IF(!C)>
1655auto select(T, F false_value) -> F {
1659template <
typename Char,
typename OutputIt>
1662 auto fill_size = specs.fill_size();
1663 if (fill_size == 1)
return detail::fill_n(it, n, specs.fill_unit<Char>());
1664 if (
const Char* data = specs.fill<Char>()) {
1665 for (
size_t i = 0; i < n; ++i) it = copy<Char>(data, data + fill_size, it);
1673template <
typename Char,
align default_align =
align::left,
typename OutputIt,
1676 size_t size,
size_t width, F&& f) -> OutputIt {
1680 size_t padding = spec_width >
width ? spec_width -
width : 0;
1684 default_align ==
align::left ?
"\x1f\x1f\x00\x01" :
"\x00\x1f\x00\x01";
1685 size_t left_padding = padding >> shifts[
static_cast<int>(specs.align())];
1686 size_t right_padding = padding - left_padding;
1687 auto it =
reserve(out, size + padding * specs.fill_size());
1688 if (left_padding != 0) it =
fill<Char>(it, left_padding, specs);
1690 if (right_padding != 0) it =
fill<Char>(it, right_padding, specs);
1694template <
typename Char,
align default_align =
align::left,
typename OutputIt,
1697 size_t size, F&& f) -> OutputIt {
1701template <
typename Char, align default_align = align::left,
typename OutputIt>
1706 const char* data = bytes.data();
1707 return copy<Char>(data, data + bytes.size(), it);
1711template <
typename Char,
typename OutputIt,
typename UIntPtr>
1717 *it++ =
static_cast<Char
>(
'0');
1718 *it++ =
static_cast<Char
>(
'x');
1729 if (cp < 0x20 || cp == 0x7f || cp ==
'"' || cp ==
'\\')
return true;
1740template <
typename Char>
1743 for (; begin != end; ++begin) {
1745 if (
const_check(
sizeof(Char) == 1) && cp >= 0x80)
continue;
1748 return {begin,
nullptr, 0};
1758 result = {sv.
begin(), sv.
end(), cp};
1766template <
size_t w
idth,
typename Char,
typename OutputIt>
1768 *out++ =
static_cast<Char
>(
'\\');
1769 *out++ =
static_cast<Char
>(prefix);
1776template <
typename OutputIt,
typename Char>
1779 auto c =
static_cast<Char
>(escape.cp);
1780 switch (escape.cp) {
1782 *out++ =
static_cast<Char
>(
'\\');
1783 c =
static_cast<Char
>(
'n');
1786 *out++ =
static_cast<Char
>(
'\\');
1787 c =
static_cast<Char
>(
'r');
1790 *out++ =
static_cast<Char
>(
'\\');
1791 c =
static_cast<Char
>(
't');
1795 case '\\': *out++ =
static_cast<Char
>(
'\\');
break;
1798 if (escape.cp < 0x10000)
1800 if (escape.cp < 0x110000)
1803 escape.begin,
to_unsigned(escape.end - escape.begin))) {
1805 static_cast<uint32_t
>(escape_char) & 0xFF);
1813template <
typename Char,
typename OutputIt>
1816 *out++ =
static_cast<Char
>(
'"');
1817 auto begin = str.begin(), end = str.end();
1824 }
while (begin != end);
1825 *out++ =
static_cast<Char
>(
'"');
1829template <
typename Char,
typename OutputIt>
1831 Char v_array[1] = {v};
1832 *out++ =
static_cast<Char
>(
'\'');
1833 if ((
needs_escape(
static_cast<uint32_t
>(v)) && v !=
static_cast<Char
>(
'"')) ||
1834 v ==
static_cast<Char
>(
'\'')) {
1837 static_cast<uint32_t
>(v)});
1841 *out++ =
static_cast<Char
>(
'\'');
1845template <
typename Char,
typename OutputIt>
1858 std::string grouping_;
1859 std::basic_string<Char> thousands_sep_;
1862 std::string::const_iterator group;
1865 auto initial_state()
const -> next_state {
return {grouping_.begin(), 0}; }
1868 auto next(next_state&
state)
const ->
int {
1870 if (
state.group == grouping_.end())
return state.pos += grouping_.back();
1879 if (!localized)
return;
1881 grouping_ = sep.grouping;
1882 if (sep.thousands_sep) thousands_sep_.assign(1, sep.thousands_sep);
1885 : grouping_(
std::move(grouping)), thousands_sep_(
std::move(sep)) {}
1891 auto state = initial_state();
1897 template <
typename Out,
typename C>
1899 auto num_digits =
static_cast<int>(digits.size());
1901 separators.push_back(0);
1902 auto state = initial_state();
1903 while (
int i = next(
state)) {
1904 if (i >= num_digits)
break;
1905 separators.push_back(i);
1907 for (
int i = 0, sep_index =
static_cast<int>(separators.size() - 1);
1908 i < num_digits; ++i) {
1909 if (num_digits - i == separators[sep_index]) {
1911 thousands_sep_.data() + thousands_sep_.size(), out);
1914 *out++ =
static_cast<Char
>(digits[
to_unsigned(i)]);
1922 prefix += (1u + (
value > 0xff ? 1 : 0)) << 24;
1926template <
typename OutputIt,
typename UInt,
typename Char>
1930 static_assert(std::is_same<uint64_or_128_t<UInt>, UInt>::value,
"");
1933 switch (specs.type()) {
1942 prefix_append(prefix,
unsigned(specs.upper() ?
'X' :
'x') << 8 |
'0');
1950 if (specs.alt() && specs.precision <= num_digits &&
value != 0)
1956 prefix_append(prefix,
unsigned(specs.upper() ?
'B' :
'b') << 8 |
'0');
1964 unsigned size = (prefix != 0 ? prefix >> 24 : 0) +
to_unsigned(num_digits) +
1965 to_unsigned(grouping.count_separators(num_digits));
1968 for (
unsigned p = prefix & 0xffffff;
p != 0;
p >>= 8)
1969 *it++ =
static_cast<Char
>(
p & 0xff);
1981template <
typename OutputIt>
1992template <
typename T>
1998 prefix = 0x01000000 |
'-';
1999 abs_value = 0 - abs_value;
2001 constexpr unsigned prefixes[4] = {0, 0, 0x1000000u |
'+', 0x1000000u |
' '};
2002 prefix = prefixes[
static_cast<int>(s)];
2004 return {abs_value, prefix};
2014 template <
typename T, FMT_ENABLE_IF(is_
integer<T>::value)>
2022 template <
typename T, FMT_ENABLE_IF(!is_
integer<T>::value)>
2037 auto width = to_unsigned(specs.width);
2039 padding = width - size;
2042 }
else if (specs.precision > num_digits) {
2043 size = (prefix >> 24) + to_unsigned(specs.precision);
2044 padding = to_unsigned(specs.precision - num_digits);
2049template <
typename Char,
typename OutputIt,
typename T>
2052 static_assert(std::is_same<T, uint32_or_64_or_128_t<T>>::value,
"");
2054 constexpr size_t buffer_size = num_bits<T>();
2055 char buffer[buffer_size];
2057 const char* begin =
nullptr;
2058 const char* end =
buffer + buffer_size;
2060 auto abs_value =
arg.abs_value;
2061 auto prefix =
arg.prefix;
2062 switch (specs.type()) {
2071 prefix_append(prefix,
unsigned(specs.upper() ?
'X' :
'x') << 8 |
'0');
2077 auto num_digits = end - begin;
2078 if (specs.alt() && specs.precision <= num_digits && abs_value != 0)
2085 prefix_append(prefix,
unsigned(specs.upper() ?
'B' :
'b') << 8 |
'0');
2088 return write_char<Char>(out,
static_cast<Char
>(abs_value), specs);
2094 int num_digits =
static_cast<int>(end - begin);
2096 if ((specs.width | (specs.precision + 1)) == 0) {
2098 for (
unsigned p = prefix & 0xffffff;
p != 0;
p >>= 8)
2099 *it++ =
static_cast<Char
>(
p & 0xff);
2103 unsigned padding = sp.padding;
2104 return write_padded<Char, align::right>(
2106 for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8)
2107 *it++ = static_cast<Char>(p & 0xff);
2108 it = detail::fill_n(it, padding, static_cast<Char>(
'0'));
2109 return copy<Char>(begin, end, it);
2113template <
typename Char,
typename OutputIt,
typename T>
2118 return write_int<Char>(out,
arg, specs);
2121template <
typename Char,
typename T,
2123 !std::is_same<T, bool>::value &&
2124 !std::is_same<T, Char>::value)>
2128 if (specs.localized() &&
write_loc(out,
value, specs, loc))
return out;
2134template <
typename Char,
typename OutputIt,
typename T,
2136 !std::is_same<T, bool>::value &&
2137 !std::is_same<T, Char>::value &&
2142 if (specs.localized() &&
write_loc(out,
value, specs, loc))
return out;
2146template <
typename Char,
typename OutputIt>
2150 using unsigned_type =
2152 return check_char_specs(specs)
2153 ? write_char<Char>(out, value, specs)
2154 : write<Char>(out, static_cast<unsigned_type>(value), specs, loc);
2157template <
typename Char,
typename OutputIt,
2163 auto&& it =
reserve(out, s.size());
2167 size_t display_width_limit =
2169 size_t display_width =
2170 !is_debug || specs.
precision == 0 ? 0 : 1;
2171 size_t size = !is_debug || specs.
precision == 0 ? 0 : 1;
2179 size_t cp_width = buf.
count();
2180 if (display_width + cp_width <= display_width_limit) {
2181 display_width += cp_width;
2184 if (display_width < display_width_limit && sv.
end() == s.end()) {
2191 size += display_width_limit - display_width;
2192 display_width = display_width_limit;
2197 if (cp_width + display_width <= display_width_limit) {
2198 display_width += cp_width;
2201 if (is_debug && display_width < display_width_limit &&
2202 sv.
end() == s.end()) {
2212 struct bounded_output_iterator {
2217 FMT_CONSTEXPR auto operator++() -> bounded_output_iterator& {
2220 FMT_CONSTEXPR auto operator++(
int) -> bounded_output_iterator& {
2223 FMT_CONSTEXPR auto operator=(
char c) -> bounded_output_iterator& {
2225 *underlying_iterator++ = c;
2232 return write_padded<char>(
2236 .underlying_iterator
2237 : copy<char>(s.data(), s.data() + size, it);
2241template <
typename Char,
typename OutputIt,
2245 auto data = s.data();
2246 auto size = s.size();
2252 auto buf = counting_buffer<Char>();
2257 return write_padded<Char>(
2258 out, specs, size, [=](reserve_iterator<OutputIt> it) {
2260 :
copy<Char>(data, data + size, it);
2264template <
typename Char,
typename OutputIt>
2267 return write<Char>(out, s, specs);
2270template <
typename Char,
typename OutputIt>
2274 return write_ptr<Char>(out, bit_cast<uintptr_t>(s), &specs);
2279template <
typename Char,
typename OutputIt,
typename T,
2281 !std::is_same<T, bool>::value &&
2282 !std::is_same<T, Char>::value)>
2287 if (negative) abs_value = ~abs_value + 1;
2289 auto size = (negative ? 1 : 0) +
static_cast<size_t>(num_digits);
2290 if (
auto ptr = to_pointer<Char>(out, size)) {
2291 if (negative) *
ptr++ =
static_cast<Char
>(
'-');
2292 format_decimal<Char>(
ptr, abs_value, num_digits);
2295 if (negative) *out++ =
static_cast<Char
>(
'-');
2296 return format_decimal<Char>(out, abs_value, num_digits);
2299template <
typename Char>
2305 if (end -
p <= 0)
p = begin;
2315 if (c ==
'}')
return begin;
2326 }
else if (
p == begin) {
2335template <
typename Char,
typename OutputIt>
2339 isnan ? (specs.
upper() ?
"NAN" :
"nan") : (specs.
upper() ?
"INF" :
"inf");
2340 constexpr size_t str_size = 3;
2341 auto size = str_size + (s !=
sign::none ? 1 : 0);
2343 const bool is_zero_fill =
2345 if (is_zero_fill) specs.
set_fill(
' ');
2346 return write_padded<Char>(out, specs, size,
2350 return copy<Char>(str, str + str_size, it);
2362 return f.significand_size;
2364template <
typename T>
2369template <
typename Char,
typename OutputIt>
2371 int significand_size) -> OutputIt {
2372 return copy<Char>(significand, significand + significand_size, out);
2374template <
typename Char,
typename OutputIt,
typename UInt>
2376 int significand_size) -> OutputIt {
2377 return format_decimal<Char>(out, significand, significand_size);
2379template <
typename Char,
typename OutputIt,
typename T,
typename Grouping>
2381 int significand_size,
int exponent,
2382 const Grouping& grouping) -> OutputIt {
2383 if (!grouping.has_separator()) {
2384 out = write_significand<Char>(out, significand, significand_size);
2388 write_significand<char>(
appender(
buffer), significand, significand_size);
2393template <
typename Char,
typename UInt,
2396 int integral_size, Char decimal_point) -> Char* {
2398 out += significand_size + 1;
2400 int floating_size = significand_size - integral_size;
2401 for (
int i = floating_size / 2; i > 0; --i) {
2403 write2digits(out,
static_cast<size_t>(significand % 100));
2406 if (floating_size % 2 != 0) {
2407 *--out =
static_cast<Char
>(
'0' + significand % 10);
2415template <
typename OutputIt,
typename UInt,
typename Char,
2418 int significand_size,
int integral_size,
2419 Char decimal_point) -> OutputIt {
2421 Char
buffer[digits10<UInt>() + 2];
2427template <
typename OutputIt,
typename Char>
2429 int significand_size,
int integral_size,
2430 Char decimal_point) -> OutputIt {
2436 significand + significand_size, out);
2439template <
typename OutputIt,
typename Char,
typename T,
typename Grouping>
2441 int significand_size,
int integral_size,
2443 const Grouping& grouping) -> OutputIt {
2444 if (!grouping.has_separator()) {
2460 return std::numeric_limits<T>::digits10 != 0
2461 ?
min_of(16, std::numeric_limits<T>::digits10 + 1)
2479 template <
typename Out,
typename C>
2485template <
typename Char,
typename Grouping,
typename OutputIt,
2488 int significand_size, Char decimal_point,
2491 using iterator = reserve_iterator<OutputIt>;
2493 int exp = f.exponent + significand_size;
2494 long long size = significand_size + (s !=
sign::none ? 1 : 0);
2495 if (f.exponent >= 0) {
2499 abort_fuzzing_if(num_zeros > 5000);
2504 if (num_zeros > 0) size += num_zeros;
2506 auto grouping = Grouping(loc, specs.
localized());
2507 size += grouping.count_separators(
exp);
2508 return write_padded<Char, align::right>(
2511 it = write_significand<Char>(it, f.significand, significand_size,
2512 f.exponent, grouping);
2513 if (!specs.
alt())
return it;
2515 return num_zeros > 0 ?
detail::fill_n(it, num_zeros, Char(
'0')) : it;
2520 int num_zeros = specs.
alt() ? specs.
precision - significand_size : 0;
2521 size += 1 +
max_of(num_zeros, 0);
2522 auto grouping = Grouping(loc, specs.
localized());
2523 size += grouping.count_separators(
exp);
2524 return write_padded<Char, align::right>(
2528 decimal_point, grouping);
2529 return num_zeros > 0 ?
detail::fill_n(it, num_zeros, Char(
'0')) : it;
2533 int num_zeros = -
exp;
2534 if (significand_size == 0 && specs.
precision >= 0 &&
2538 bool pointy = num_zeros != 0 || significand_size != 0 || specs.
alt();
2539 size += 1 + (pointy ? 1 : 0) + num_zeros;
2540 return write_padded<Char, align::right>(
2544 if (!pointy)
return it;
2547 return write_significand<Char>(it, f.significand, significand_size);
2551template <
typename Char,
typename Grouping,
typename OutputIt,
2558 int exp = f.exponent + significand_size - 1;
2562 return write_fixed<Char, Grouping>(out, f, significand_size, point, specs,
2568 long long size = significand_size + (s !=
sign::none ? 1 : 0);
2572 }
else if (significand_size == 1) {
2576 char exp_char = specs.
upper() ?
'E' :
'e';
2581 if (num_zeros > 0) it =
detail::fill_n(it, num_zeros, Char(
'0'));
2582 *it++ = Char(exp_char);
2583 return write_exponent<Char>(
exp, it);
2586 return specs.
width > 0
2587 ? write_padded<Char, align::right>(out, specs, usize,
write)
2591template <
typename Char,
typename OutputIt,
typename DecimalFP>
2596 return do_write_float<Char, fallback_digit_grouping<Char>>(out, f, specs, s,
2599 return do_write_float<Char, digit_grouping<Char>>(out, f, specs, s,
2608template <
typename T,
typename Enable =
void>
2611template <
typename T>
2613 : std::true_type {};
2615template <
typename T,
2618 constexpr T inf = T(std::numeric_limits<double>::infinity());
2621 return std::isfinite(
value);
2623template <
typename T, FMT_ENABLE_IF(!has_isfinite<T>::value)>
2625 T inf = T(std::numeric_limits<double>::infinity());
2630template <
typename T, FMT_ENABLE_IF(is_
floating_po
int<T>::value)>
2633#ifdef __cpp_if_constexpr
2634 if constexpr (std::numeric_limits<double>::is_iec559) {
2636 return (bits >> (num_bits<uint64_t>() - 1)) != 0;
2640 return std::signbit(
static_cast<double>(
value));
2646 if (exp10 > 0 &&
precision > max_value<int>() - exp10)
2647 FMT_THROW(format_error(
"number is too big"));
2654 using bigit = uint32_t;
2655 using double_bigit = uint64_t;
2656 enum { bigit_bits = num_bits<bigit>() };
2657 enum { bigits_capacity = 32 };
2664 return i >= exp_ && i < num_bigits() ? bigits_[i - exp_] : 0;
2668 auto result = double_bigit(bigits_[
index]) - other - borrow;
2669 bigits_[
index] =
static_cast<bigit
>(result);
2670 borrow =
static_cast<bigit
>(result >> (bigit_bits * 2 - 1));
2674 int num_bigits =
static_cast<int>(bigits_.
size()) - 1;
2675 while (num_bigits > 0 && bigits_[num_bigits] == 0) --num_bigits;
2676 bigits_.
resize(to_unsigned(num_bigits + 1));
2681 FMT_ASSERT(other.exp_ >= exp_,
"unaligned bigints");
2684 int i = other.exp_ - exp_;
2685 for (
size_t j = 0, n = other.bigits_.size(); j != n; ++i, ++j)
2686 subtract_bigits(i, other.bigits_[j], borrow);
2687 if (borrow != 0) subtract_bigits(i, 0, borrow);
2689 remove_leading_zeros();
2694 const double_bigit wide_value = value;
2695 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2696 double_bigit result = bigits_[i] * wide_value + carry;
2697 bigits_[i] =
static_cast<bigit
>(result);
2698 carry =
static_cast<bigit
>(result >> bigit_bits);
2700 if (carry != 0) bigits_.
push_back(carry);
2703 template <
typename UInt, FMT_ENABLE_IF(std::is_same<UInt, u
int64_t>::value ||
2704 std::is_same<UInt, u
int128_t>::value)>
2708 const int shift = num_bits<half_uint>() - bigit_bits;
2709 const UInt lower =
static_cast<half_uint
>(value);
2710 const UInt upper = value >> num_bits<half_uint>();
2712 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2713 UInt result = lower * bigits_[i] +
static_cast<bigit
>(carry);
2714 carry = (upper * bigits_[i] << shift) + (result >> bigit_bits) +
2715 (carry >> bigit_bits);
2716 bigits_[i] =
static_cast<bigit
>(result);
2718 while (carry != 0) {
2719 bigits_.
push_back(
static_cast<bigit
>(carry));
2720 carry >>= bigit_bits;
2724 template <
typename UInt, FMT_ENABLE_IF(std::is_same<UInt, u
int64_t>::value ||
2725 std::is_same<UInt, u
int128_t>::value)>
2727 size_t num_bigits = 0;
2729 bigits_[num_bigits++] =
static_cast<bigit
>(n);
2732 bigits_.
resize(num_bigits);
2744 auto size = other.bigits_.size();
2746 auto data = other.bigits_.data();
2747 copy<bigit>(data, data + size, bigits_.
data());
2757 return static_cast<int>(bigits_.
size()) + exp_;
2762 exp_ += shift / bigit_bits;
2763 shift %= bigit_bits;
2764 if (shift == 0)
return *
this;
2766 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2767 bigit c = bigits_[i] >> (bigit_bits - shift);
2768 bigits_[i] = (bigits_[i] << shift) + carry;
2771 if (carry != 0) bigits_.
push_back(carry);
2782 int num_bigits1 = b1.num_bigits(), num_bigits2 = b2.num_bigits();
2783 if (num_bigits1 != num_bigits2)
return num_bigits1 > num_bigits2 ? 1 : -1;
2784 int i =
static_cast<int>(b1.bigits_.size()) - 1;
2785 int j =
static_cast<int>(b2.bigits_.size()) - 1;
2787 if (end < 0) end = 0;
2788 for (; i >= end; --i, --j) {
2789 bigit b1_bigit = b1.bigits_[i], b2_bigit = b2.bigits_[j];
2790 if (b1_bigit != b2_bigit)
return b1_bigit > b2_bigit ? 1 : -1;
2792 if (i != j)
return i > j ? 1 : -1;
2798 const bigint& rhs) ->
int {
2799 int max_lhs_bigits =
max_of(lhs1.num_bigits(), lhs2.num_bigits());
2800 int num_rhs_bigits = rhs.num_bigits();
2801 if (max_lhs_bigits + 1 < num_rhs_bigits)
return -1;
2802 if (max_lhs_bigits > num_rhs_bigits)
return 1;
2803 double_bigit borrow = 0;
2804 int min_exp =
min_of(
min_of(lhs1.exp_, lhs2.exp_), rhs.exp_);
2805 for (
int i = num_rhs_bigits - 1; i >= min_exp; --i) {
2806 double_bigit sum = double_bigit(lhs1.get_bigit(i)) + lhs2.get_bigit(i);
2807 bigit rhs_bigit = rhs.get_bigit(i);
2808 if (sum > rhs_bigit + borrow)
return 1;
2809 borrow = rhs_bigit + borrow - sum;
2810 if (borrow > 1)
return -1;
2811 borrow <<= bigit_bits;
2813 return borrow != 0 ? -1 : 0;
2819 if (
exp == 0)
return *
this = 1;
2820 int bitmask = 1 << (num_bits<unsigned>() -
2826 while (bitmask != 0) {
2828 if ((
exp & bitmask) != 0) *
this *= 5;
2835 int num_bigits =
static_cast<int>(bigits_.
size());
2836 int num_result_bigits = 2 * num_bigits;
2840 for (
int bigit_index = 0; bigit_index < num_bigits; ++bigit_index) {
2843 for (
int i = 0, j = bigit_index; j >= 0; ++i, --j) {
2845 sum += double_bigit(n[i]) * n[j];
2847 bigits_[bigit_index] =
static_cast<bigit
>(sum);
2848 sum >>= num_bits<bigit>();
2851 for (
int bigit_index = num_bigits; bigit_index < num_result_bigits;
2853 for (
int j = num_bigits - 1, i = bigit_index - j; i < num_bigits;)
2854 sum += double_bigit(n[i++]) * n[j--];
2855 bigits_[bigit_index] =
static_cast<bigit
>(sum);
2856 sum >>= num_bits<bigit>();
2858 remove_leading_zeros();
2865 int exp_difference = exp_ - other.exp_;
2866 if (exp_difference <= 0)
return;
2867 int num_bigits =
static_cast<int>(bigits_.
size());
2869 for (
int i = num_bigits - 1, j = i + exp_difference; i >= 0; --i, --j)
2870 bigits_[j] = bigits_[i];
2872 exp_ -= exp_difference;
2879 if (
compare(*
this, divisor) < 0)
return 0;
2880 FMT_ASSERT(divisor.bigits_[divisor.bigits_.size() - 1u] != 0,
"");
2884 subtract_aligned(divisor);
2886 }
while (
compare(*
this, divisor) >= 0);
2902 unsigned flags,
int num_digits,
2913 bool is_predecessor_closer = (flags & dragon::predecessor_closer) != 0;
2914 int shift = is_predecessor_closer ? 2 : 1;
2916 numerator =
value.f;
2917 numerator <<=
value.e + shift;
2920 if (is_predecessor_closer) {
2922 upper_store <<=
value.e + 1;
2923 upper = &upper_store;
2926 denominator <<= shift;
2927 }
else if (exp10 < 0) {
2929 lower.assign(numerator);
2930 if (is_predecessor_closer) {
2931 upper_store.assign(numerator);
2933 upper = &upper_store;
2935 numerator *=
value.f;
2936 numerator <<= shift;
2938 denominator <<= shift -
value.e;
2940 numerator =
value.f;
2941 numerator <<= shift;
2943 denominator <<= shift -
value.e;
2945 if (is_predecessor_closer) {
2946 upper_store = 1ULL << 1;
2947 upper = &upper_store;
2950 int even =
static_cast<int>((
value.f & 1) == 0);
2951 if (!upper) upper = &lower;
2952 bool shortest = num_digits < 0;
2953 if ((flags & dragon::fixup) != 0) {
2954 if (add_compare(numerator, *upper, denominator) + even <= 0) {
2957 if (num_digits < 0) {
2959 if (upper != &lower) *upper *= 10;
2968 char* data = buf.
data();
2971 bool low =
compare(numerator, lower) - even < 0;
2973 bool high = add_compare(numerator, *upper, denominator) + even > 0;
2974 data[num_digits++] =
static_cast<char>(
'0' + digit);
2977 ++data[num_digits - 1];
2979 int result = add_compare(numerator, numerator, denominator);
2981 if (result > 0 || (result == 0 && (digit % 2) != 0))
2982 ++data[num_digits - 1];
2985 exp10 -= num_digits - 1;
2990 if (upper != &lower) *upper *= 10;
2994 exp10 -= num_digits - 1;
2995 if (num_digits <= 0) {
2997 if (num_digits == 0) {
2999 digit = add_compare(numerator, numerator, denominator) > 0 ?
'1' :
'0';
3005 for (
int i = 0; i < num_digits - 1; ++i) {
3007 buf[i] =
static_cast<char>(
'0' + digit);
3011 auto result = add_compare(numerator, numerator, denominator);
3012 if (result > 0 || (result == 0 && (digit % 2) != 0)) {
3014 const auto overflow =
'0' + 10;
3015 buf[num_digits - 1] = overflow;
3017 for (
int i = num_digits - 1; i > 0 && buf[i] == overflow; --i) {
3021 if (buf[0] == overflow) {
3023 if ((flags & dragon::fixed) != 0)
3032 buf[num_digits - 1] =
static_cast<char>(
'0' + digit);
3036template <
typename Float, FMT_ENABLE_IF(!is_
double_
double<Float>::value)>
3041 static_assert(!std::is_same<Float, float>::value,
"");
3046 using carrier_uint =
typename info::carrier_uint;
3051 f.
e += num_float_significand_bits;
3052 if (!has_implicit_bit<Float>()) --f.
e;
3054 const auto num_fraction_bits =
3055 num_float_significand_bits + (has_implicit_bit<Float>() ? 1 : 0);
3056 const auto num_xdigits = (num_fraction_bits + 3) / 4;
3058 const auto leading_shift = ((num_xdigits - 1) * 4);
3059 const auto leading_mask = carrier_uint(0xF) << leading_shift;
3060 const auto leading_xdigit =
3061 static_cast<uint32_t
>((f.
f & leading_mask) >> leading_shift);
3062 if (leading_xdigit > 1) f.
e -= (32 -
countl_zero(leading_xdigit) - 1);
3064 int print_xdigits = num_xdigits - 1;
3066 const int shift = ((print_xdigits - specs.
precision - 1) * 4);
3067 const auto mask = carrier_uint(0xF) << shift;
3068 const auto v =
static_cast<uint32_t
>((f.
f & mask) >> shift);
3071 const auto inc = carrier_uint(1) << (shift + 4);
3077 if (!has_implicit_bit<Float>()) {
3078 const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;
3079 if ((f.
f & implicit_bit) == implicit_bit) {
3088 char xdigits[num_bits<carrier_uint>() / 4];
3093 while (print_xdigits > 0 && xdigits[print_xdigits] ==
'0') --print_xdigits;
3098 if (specs.
alt() || print_xdigits > 0 || print_xdigits < specs.
precision)
3100 buf.
append(xdigits + 1, xdigits + 1 + print_xdigits);
3108 abs_e =
static_cast<uint32_t
>(-f.
e);
3111 abs_e =
static_cast<uint32_t
>(f.
e);
3116template <
typename Float, FMT_ENABLE_IF(is_
double_
double<Float>::value)>
3118 buffer<char>& buf) {
3119 format_hexfloat(
static_cast<double>(value), specs, buf);
3129 return U
"\x9999999a\x828f5c29\x80418938\x80068db9\x8000a7c6\x800010c7"
3130 U
"\x800001ae\x8000002b"[
index];
3133template <
typename Float>
3138 static_assert(!std::is_same<Float, float>::value,
"");
3153 bool use_dragon =
true;
3154 unsigned dragon_flags = 0;
3156 const auto inv_log2_10 = 0.3010299956639812;
3163 auto e = (f.e + count_digits<1>(f.f) - 1) * inv_log2_10 - 1e-10;
3164 exp =
static_cast<int>(e);
3166 dragon_flags = dragon::fixup;
3170 auto br = bit_cast<uint64_t>(
static_cast<double>(
value));
3172 const uint64_t significand_mask =
3173 (
static_cast<uint64_t
>(1) << num_significand_bits<double>()) - 1;
3174 uint64_t significand = (br & significand_mask);
3175 int exponent =
static_cast<int>((br & exponent_mask<double>()) >>
3176 num_significand_bits<double>());
3178 if (exponent != 0) {
3179 exponent -= exponent_bias<double>() + num_significand_bits<double>();
3181 (
static_cast<uint64_t
>(1) << num_significand_bits<double>());
3185 FMT_ASSERT(significand != 0,
"zeros should not appear here");
3187 FMT_ASSERT(shift >= num_bits<uint64_t>() - num_significand_bits<double>(),
3189 shift -= (num_bits<uint64_t>() - num_significand_bits<double>() - 2);
3190 exponent = (std::numeric_limits<double>::min_exponent -
3191 num_significand_bits<double>()) -
3193 significand <<= shift;
3198 const int k = info::kappa - dragonbox::floor_log10_pow2(exponent);
3200 const int beta = exponent + dragonbox::floor_log2_pow10(k);
3201 uint64_t first_segment;
3202 bool has_more_segments;
3203 int digits_in_the_first_segment;
3205 const auto r = dragonbox::umul192_upper128(
3206 significand << beta, dragonbox::get_cached_power(k));
3207 first_segment = r.high();
3208 has_more_segments = r.low() != 0;
3211 if (first_segment >= 1000000000000000000ULL) {
3212 digits_in_the_first_segment = 19;
3216 digits_in_the_first_segment = 18;
3217 first_segment *= 10;
3226 if (digits_in_the_first_segment >
precision) {
3230 exp += digits_in_the_first_segment;
3238 if ((first_segment |
static_cast<uint64_t
>(has_more_segments)) >
3239 5000000000000000000ULL) {
3256 const uint32_t first_subsegment =
static_cast<uint32_t
>(
3257 dragonbox::umul128_upper64(first_segment, 7922816251426433760ULL) >>
3259 const uint64_t second_third_subsegments =
3260 first_segment - first_subsegment * 10000000000ULL;
3264 bool should_round_up;
3268 auto print_subsegment = [&](uint32_t subsegment,
char*
buffer) {
3269 int number_of_digits_printed = 0;
3272 if ((number_of_digits_to_print & 1) != 0) {
3278 prod = ((subsegment *
static_cast<uint64_t
>(720575941)) >> 24) + 1;
3279 digits =
static_cast<uint32_t
>(prod >> 32);
3280 *
buffer =
static_cast<char>(
'0' + digits);
3281 number_of_digits_printed++;
3291 prod = ((subsegment *
static_cast<uint64_t
>(450359963)) >> 20) + 1;
3292 digits =
static_cast<uint32_t
>(prod >> 32);
3294 number_of_digits_printed += 2;
3298 while (number_of_digits_printed < number_of_digits_to_print) {
3299 prod =
static_cast<uint32_t
>(prod) *
static_cast<uint64_t
>(100);
3300 digits =
static_cast<uint32_t
>(prod >> 32);
3302 number_of_digits_printed += 2;
3307 print_subsegment(first_subsegment, buf.data());
3326 uint32_t fractional_part =
static_cast<uint32_t
>(prod);
3329 8 - number_of_digits_to_print) ||
3330 ((fractional_part >> 31) &
3331 ((digits & 1) | (second_third_subsegments != 0) |
3332 has_more_segments)) != 0;
3340 should_round_up = second_third_subsegments > 5000000000ULL ||
3341 (second_third_subsegments == 5000000000ULL &&
3342 ((digits & 1) != 0 || has_more_segments));
3351 const uint32_t second_subsegment =
3352 static_cast<uint32_t
>(dragonbox::umul128_upper64(
3353 second_third_subsegments, 1844674407370955162ULL));
3354 const uint32_t third_subsegment =
3355 static_cast<uint32_t
>(second_third_subsegments) -
3356 second_subsegment * 10;
3358 number_of_digits_to_print =
precision - 9;
3359 print_subsegment(second_subsegment, buf.data() + 9);
3366 uint32_t fractional_part =
static_cast<uint32_t
>(prod);
3369 8 - number_of_digits_to_print) ||
3370 ((fractional_part >> 31) &
3371 ((digits & 1) | (third_subsegment != 0) |
3372 has_more_segments)) != 0;
3379 should_round_up = third_subsegment > 5 ||
3380 (third_subsegment == 5 &&
3381 ((digits & 1) != 0 || has_more_segments));
3386 if (should_round_up) {
3388 for (
int i =
precision - 1; i > 0 && buf[i] >
'9'; --i) {
3405 exp += digits_in_the_first_segment - 1;
3410 bool is_predecessor_closer = binary32 ? f.assign(
static_cast<float>(
value))
3411 : f.assign(converted_value);
3412 if (is_predecessor_closer) dragon_flags |= dragon::predecessor_closer;
3413 if (
fixed) dragon_flags |= dragon::fixed;
3416 const int max_double_digits = 767;
3422 auto num_digits = buf.size();
3423 while (num_digits > 0 && buf[num_digits - 1] ==
'0') {
3427 buf.try_resize(num_digits);
3432template <
typename Char,
typename OutputIt,
typename T,
3436 if (specs.
localized() && write_loc(out, value, specs, loc))
return out;
3442 return write_nonfinite<Char>(out,
detail::isnan(value), specs, s);
3452 if (precision < 0) {
3457 auto dec = dragonbox::to_decimal(
static_cast<fast_float_t<T>
>(value));
3458 return write_float<Char>(out,
dec, specs, s, exp_upper, loc);
3466 return write_bytes<Char, align::right>(out, {buffer.
data(), buffer.
size()},
3471 if (precision == max_value<int>())
3478 }
else if (precision == 0) {
3482 std::is_same<T, float>(), buffer);
3485 auto f = big_decimal_fp{buffer.
data(),
static_cast<int>(buffer.
size()),
exp};
3486 return write_float<Char>(out, f, specs, s, exp_upper, loc);
3489template <
typename Char,
typename OutputIt,
typename T,
3495 auto mask = exponent_mask<fast_float_t<T>>();
3497 return write_nonfinite<Char>(out, std::isnan(
value), {}, s);
3499 auto dec = dragonbox::to_decimal(
static_cast<fast_float_t<T>
>(
value));
3500 auto significand =
dec.significand;
3502 int exponent =
dec.exponent + significand_size - 1;
3504 return write_fixed<Char, fallback_digit_grouping<Char>>(
3505 out,
dec, significand_size, Char(
'.'), {}, s);
3509 const char* prefix =
"e+";
3510 int abs_exponent = exponent;
3512 abs_exponent = -exponent;
3515 auto has_decimal_point = significand_size != 1;
3516 size_t size = std::is_pointer<OutputIt>::value
3519 (has_decimal_point ? 1 : 0) +
3520 (abs_exponent >= 100 ? 5 : 4));
3521 if (
auto ptr = to_pointer<Char>(out, size)) {
3523 if (has_decimal_point) {
3525 ptr = format_decimal<Char>(
ptr, significand, significand_size + 1);
3529 *
ptr++ =
static_cast<Char
>(
'0' + significand);
3531 if (std::is_same<Char, char>::value) {
3532 memcpy(
ptr, prefix, 2);
3538 if (abs_exponent >= 100) {
3539 *
ptr++ =
static_cast<Char
>(
'0' + abs_exponent / 100);
3540 abs_exponent %= 100;
3543 return select<std::is_pointer<OutputIt>::value>(
ptr + 2, out);
3549 has_decimal_point ? Char(
'.') : Char());
3551 it = write_exponent<Char>(exponent, it);
3555template <
typename Char,
typename OutputIt,
typename T,
3557 !is_fast_float<T>::value)>
3559 return write<Char>(out,
value, {});
3562template <
typename Char,
typename OutputIt>
3569template <
typename Char,
typename OutputIt>
3572 return copy_noinline<Char>(
value.begin(),
value.end(), out);
3575template <
typename Char,
typename OutputIt,
typename T,
3583 typename Char,
typename OutputIt,
typename T,
3584 bool check = std::is_enum<T>::value && !std::is_same<T, Char>::value &&
3585 mapped_type_constant<T, Char>::value != type::custom_type,
3591template <
typename Char,
typename OutputIt,
typename T,
3597 ? write<Char>(out, value ? 1 : 0, specs, {})
3598 :
write_bytes<Char>(out, value ?
"true" :
"false", specs);
3601template <
typename Char,
typename OutputIt>
3608template <
typename Char,
typename OutputIt>
3615template <
typename Char,
typename OutputIt,
typename T,
3619 return write_ptr<Char>(out, bit_cast<uintptr_t>(value), &specs);
3622template <
typename Char,
typename OutputIt,
typename T,
3624 type::custom_type &&
3625 !std::is_fundamental<T>::value)>
3631 return f.format(
value, ctx);
3634template <
typename T>
3647 template <
typename T, FMT_ENABLE_IF(is_builtin<T>::value)>
3649 write<Char>(out,
value);
3652 template <
typename T, FMT_ENABLE_IF(!is_builtin<T>::value)>
3660 auto format_ctx =
context(out, {}, {});
3661 h.
format(parse_ctx, format_ctx);
3670 template <
typename T, FMT_ENABLE_IF(is_builtin<T>::value)>
3675 template <
typename T, FMT_ENABLE_IF(!is_builtin<T>::value)>
3687 template <
typename T, FMT_ENABLE_IF(is_
integer<T>::value)>
3692 template <
typename T, FMT_ENABLE_IF(!is_
integer<T>::value)>
3699template <
typename Context>
3710 value =
static_cast<int>(result);
3713#if FMT_USE_NONTYPE_TEMPLATE_ARGS
3714template <
typename T,
typename Char,
size_t N,
3715 fmt::detail::fixed_string<Char, N> Str>
3716struct static_named_arg : view {
3717 static constexpr auto name = Str.data;
3720 static_named_arg(
const T& v) : value(v) {}
3723template <
typename T,
typename Char,
size_t N,
3724 fmt::detail::fixed_string<Char, N> Str>
3725struct is_named_arg<static_named_arg<T, Char, N, Str>> : std::true_type {};
3727template <
typename T,
typename Char,
size_t N,
3728 fmt::detail::fixed_string<Char, N> Str>
3729struct is_static_named_arg<static_named_arg<T, Char, N, Str>> : std::true_type {
3732template <
typename Char,
size_t N, fmt::detail::fixed_
string<Char, N> Str>
3734 template <
typename T>
auto operator=(T&& value)
const {
3735 return static_named_arg<T, Char, N, Str>(std::forward<T>(value));
3743 return {str, std::forward<T>(
value)};
3752 void on_text(
const Char* begin,
const Char* end) {
3753 copy_noinline<Char>(begin, end, ctx.out());
3763 int arg_id = ctx.arg_id(
id);
3774 auto arg = ctx.arg(
id);
3777 if (
arg.format_custom(begin, parse_ctx, ctx))
return parse_ctx.
begin();
3785 specs.precision_ref, ctx);
3798 const char* message)
noexcept;
3803template <
typename T,
typename Char, type TYPE>
3804template <
typename FormatContext>
3806 const T& val, FormatContext& ctx)
const ->
decltype(ctx.out()) {
3807 if (!specs_.dynamic())
3808 return write<Char>(ctx.out(), val, specs_, ctx.locale());
3813 specs_.precision_ref, ctx);
3814 return write<Char>(ctx.out(), val, specs, ctx.locale());
3837 : out_(out), args_(args), loc_(loc) {}
3843 return args_.
get(
id);
3847 return args_.
get(name);
3850 return args_.
get_id(name);
3867 template <
typename T, FMT_ENABLE_IF(!detail::is_
float128<T>::value)>
3870 template <
typename T, FMT_ENABLE_IF(detail::is_
float128<T>::value)>
3873 template <
typename Visitor>
auto visit(Visitor&& vis) ->
decltype(vis(0)) {
3874 return value_.
visit(vis);
3882 std::string separator_;
3883 std::string grouping_;
3884 std::string decimal_point_;
3895 std::string decimal_point =
".")
3896 : separator_(sep.data(), sep.size()),
3897 grouping_(grouping),
3898 decimal_point_(decimal_point) {}
3902 return do_put(out, val, specs);
3906#define FMT_FORMAT_AS(Type, Base) \
3907 template <typename Char> \
3908 struct formatter<Type, Char> : formatter<Base, Char> { \
3909 template <typename FormatContext> \
3910 FMT_CONSTEXPR auto format(Type value, FormatContext& ctx) const \
3911 -> decltype(ctx.out()) { \
3912 return formatter<Base, Char>::format(value, ctx); \
3927template <
typename Char,
size_t N>
3930template <
typename Char,
typename Traits,
typename Allocator>
3932 :
public formatter<basic_string_view<Char>, Char> {};
3934template <
int N,
typename Char>
3936template <
int N,
typename Char>
3938 :
formatter<unsigned long long, Char> {};
3940template <
typename Char>
3943 detail::type::float_type> {};
3945template <
typename T,
typename Char>
3947 :
formatter<detail::format_as_result<T>, Char> {
3948 template <
typename FormatContext>
3950 ->
decltype(ctx.out()) {
3963template <
typename T>
auto ptr(T
p) ->
const void* {
3964 static_assert(std::is_pointer<T>::value,
"fmt::ptr used with non-pointer");
3976template <
typename Enum>
3982template <
typename Enum, FMT_ENABLE_IF(std::is_enum<Enum>::value)>
3988#ifdef __cpp_lib_byte
3989template <
typename Char>
3991 static auto format_as(std::byte b) ->
unsigned char {
3992 return static_cast<unsigned char>(b);
3994 template <
typename Context>
3995 auto format(std::byte b, Context& ctx)
const ->
decltype(ctx.out()) {
4013 return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,
4017 template <
typename FormatContext>
4018 auto format(
bytes b, FormatContext& ctx)
const ->
decltype(ctx.out()) {
4019 auto specs = specs_;
4021 specs.width_ref, ctx);
4023 specs.precision_ref, ctx);
4052 return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,
4056 template <
typename FormatContext>
4058 ->
decltype(ctx.out()) {
4059 auto specs = specs_;
4061 specs.width_ref, ctx);
4063 specs.precision_ref, ctx);
4076template <
typename T,
typename Char>
4081 template <
typename FormatContext>
4083 ->
decltype(ctx.out()) {
4084 return view.fmt->format(*view.value, ctx);
4098 auto it = ctx.begin(), end = ctx.end();
4099 if (it == end)
return it;
4105 if ((c >=
'0' && c <=
'9') || c ==
'{') {
4107 width_ = specs.
width;
4110 return formatter_.parse(ctx);
4113 template <
typename FormatContext,
typename F>
4114 auto write_padded(FormatContext& ctx, F write)
const ->
decltype(ctx.out()) {
4115 if (width_ == 0)
return write(ctx.out());
4119 specs.
width = width_;
4132#if FMT_USE_NONTYPE_TEMPLATE_ARGS
4133template <detail::fixed_
string S>
constexpr auto operator""_a() {
4157 enum { buffer_size = std::numeric_limits<unsigned long long>::digits10 + 3 };
4158 mutable char buffer_[buffer_size];
4161 template <
typename UInt>
4167 template <
typename Int>
4170 bool negative = value < 0;
4171 if (negative) abs_value = 0 - abs_value;
4172 auto begin = format_unsigned(abs_value);
4173 if (negative) *--begin =
'-';
4180 : str_(format_signed(value)) {}
4182 : str_(format_signed(value)) {}
4184 : str_(format_unsigned(value)) {}
4186 : str_(format_unsigned(value)) {}
4188 : str_(format_unsigned(value)) {}
4202 buffer_[buffer_size - 1] =
'\0';
4207 inline auto str() const ->
std::
string {
return {str_,
size()}; }
4210#if FMT_CLANG_ANALYZER
4211# define FMT_STRING_IMPL(s, base) s
4213# define FMT_STRING_IMPL(s, base) \
4217 struct FMT_VISIBILITY("hidden") FMT_COMPILE_STRING : base { \
4218 using char_type = fmt::remove_cvref_t<decltype(s[0])>; \
4219 constexpr explicit operator fmt::basic_string_view<char_type>() \
4221 return fmt::detail::compile_string_to_view<char_type>(s); \
4224 using FMT_STRING_VIEW = \
4225 fmt::basic_string_view<typename FMT_COMPILE_STRING::char_type>; \
4226 fmt::detail::ignore_unused(FMT_STRING_VIEW(FMT_COMPILE_STRING())); \
4227 return FMT_COMPILE_STRING(); \
4239#define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string)
4242 -> std::system_error;
4259template <
typename... T>
4261 -> std::system_error {
4279 const char* message)
noexcept;
4289 return {buf.data(), buf.size()};
4292template <
typename... T>
4298template <
typename OutputIt,
4307template <
typename OutputIt,
typename... T,
4310 T&&... args) -> OutputIt {
4311 return fmt::vformat_to(out, loc, fmt.str,
vargs<T...>{{args...}});
4314template <
typename... T>
4317 T&&... args) ->
size_t {
4334template <
typename... T>
4347template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
4355template <
typename T, FMT_ENABLE_IF(detail::use_format_as<T>::value)>
4361template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value &&
4362 !detail::use_format_as<T>::value)>
4367 return {buffer.
data(), buffer.
size()};
4373#ifdef FMT_HEADER_ONLY
4374# define FMT_FUNC inline
4379#ifdef FMT_REMOVE_TRANSITIVE_INCLUDES
4380# undef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
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
typename std::enable_if< B, T >::type enable_if_t
Definition base.h:304
#define FMT_ASSERT(condition, message)
Definition base.h:391
#define FMT_END_EXPORT
Definition base.h:264
std::integral_constant< bool, B > bool_constant
Definition base.h:307
#define FMT_BUILTIN_TYPES
Definition base.h:293
#define FMT_PRAGMA_CLANG(x)
Definition base.h:222
#define FMT_CONSTEVAL
Definition base.h:140
basic_string_view< char > string_view
Definition base.h:613
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Returns a named argument to be used in a formatting function.
Definition base.h:2831
constexpr auto min_of(T a, T b) -> T
Definition base.h:344
#define FMT_FALLTHROUGH
Definition base.h:186
#define FMT_NODISCARD
Definition base.h:201
typename std::remove_reference< T >::type remove_reference_t
Definition base.h:309
typename fstring< T... >::t format_string
Definition base.h:2779
#define FMT_GCC_VERSION
Definition base.h:35
#define FMT_OPTIMIZE_SIZE
Definition base.h:287
basic_appender< char > appender
Definition base.h:616
typename std::remove_cv< remove_reference_t< T > >::type remove_cvref_t
Definition base.h:313
constexpr auto max_of(T a, T b) -> T
Definition base.h:347
#define FMT_CONSTEXPR
Definition base.h:113
align
Definition base.h:681
arg_id_kind
Definition base.h:683
#define FMT_BEGIN_NAMESPACE
Definition base.h:253
sign
Definition base.h:682
conditional_t< std::is_same< OutputIt, appender >::value, context, generic_context< OutputIt, Char > > basic_format_context
Definition base.h:629
#define FMT_API
Definition base.h:283
#define FMT_ENABLE_IF(...)
Definition base.h:341
#define FMT_BEGIN_EXPORT
Definition base.h:263
void void_t
Definition base.h:328
#define FMT_INLINE
Definition base.h:247
#define FMT_NO_UNIQUE_ADDRESS
Definition base.h:175
#define FMT_NORETURN
Definition base.h:193
#define FMT_MSC_WARNING(...)
Definition base.h:227
typename std::conditional< B, T, F >::type conditional_t
Definition base.h:306
#define FMT_CONSTEXPR20
Definition base.h:141
typename std::underlying_type< T >::type underlying_t
Definition base.h:317
#define FMT_END_NAMESPACE
Definition base.h:256
conditional_t< std::is_same< Char, char >::value, context, generic_context< basic_appender< Char >, Char > > buffered_context
Definition base.h:635
#define FMT_EXPORT
Definition base.h:262
A dynamically growing memory buffer for trivially copyable/constructible types with the first SIZE el...
Definition format.h:785
const T & const_reference
Definition format.h:824
FMT_CONSTEXPR20 ~basic_memory_buffer()
Definition format.h:832
auto operator=(basic_memory_buffer &&other) noexcept -> basic_memory_buffer &
Moves the content of the other basic_memory_buffer object to this one.
Definition format.h:883
void reserve(size_t new_capacity)
Increases the buffer capacity to new_capacity.
Definition format.h:898
auto get_allocator() const -> Allocator
Definition format.h:891
FMT_CONSTEXPR20 void append(const ContiguousRange &range)
Definition format.h:902
FMT_CONSTEXPR basic_memory_buffer(const Allocator &alloc=Allocator())
Definition format.h:826
FMT_CONSTEXPR void resize(size_t count)
Resizes the buffer to contain count elements.
Definition format.h:895
FMT_CONSTEXPR20 basic_memory_buffer(basic_memory_buffer &&other) noexcept
Constructs a basic_memory_buffer object moving the content of the other object to it.
Definition format.h:877
T value_type
Definition format.h:823
FMT_CONSTEXPR void copy_fill_from(const basic_specs &specs)
Definition base.h:831
FMT_CONSTEXPR void set_fill(char c)
Definition base.h:810
constexpr auto align() const -> align
Definition base.h:744
FMT_CONSTEXPR auto dynamic_precision() const -> arg_id_kind
Definition base.h:758
constexpr auto sign() const -> sign
Definition base.h:771
FMT_CONSTEXPR void set_alt()
Definition base.h:782
constexpr auto localized() const -> bool
Definition base.h:785
constexpr auto dynamic() const -> bool
Definition base.h:767
constexpr auto upper() const -> bool
Definition base.h:778
constexpr auto type() const -> presentation_type
Definition base.h:737
constexpr auto alt() const -> bool
Definition base.h:781
constexpr auto dynamic_width() const -> arg_id_kind
Definition base.h:751
constexpr auto fill_unit() const -> Char
Definition base.h:803
FMT_CONSTEXPR void set_align(fmt::align a)
Definition base.h:747
constexpr auto fill_size() const -> size_t
Definition base.h:790
An implementation of std::basic_string_view for pre-C++17.
Definition base.h:515
constexpr auto end() const noexcept -> iterator
Definition base.h:563
constexpr auto size() const noexcept -> size_t
Returns the string size.
Definition base.h:560
constexpr auto data() const noexcept -> const Char *
Returns a pointer to the string data.
Definition base.h:557
constexpr auto begin() const noexcept -> iterator
Definition base.h:562
FMT_CONSTEXPR void align(const bigint &other)
Definition format.h:2864
FMT_CONSTEXPR auto operator<<=(int shift) -> bigint &
Definition format.h:2760
FMT_CONSTEXPR20 void square()
Definition format.h:2834
FMT_CONSTEXPR bigint()
Definition format.h:2737
FMT_CONSTEXPR auto operator*=(Int value) -> bigint &
Definition format.h:2775
FMT_CONSTEXPR void operator=(Int n)
Definition format.h:2751
FMT_CONSTEXPR void assign(const bigint &other)
Definition format.h:2743
void operator=(const bigint &)=delete
bigint(uint64_t n)
Definition format.h:2738
FMT_CONSTEXPR20 void assign_pow10(int exp)
Definition format.h:2817
friend FMT_CONSTEXPR auto compare(const bigint &b1, const bigint &b2) -> int
Definition format.h:2781
FMT_CONSTEXPR auto num_bigits() const -> int
Definition format.h:2756
friend FMT_CONSTEXPR auto add_compare(const bigint &lhs1, const bigint &lhs2, const bigint &rhs) -> int
Definition format.h:2797
FMT_CONSTEXPR auto divmod_assign(const bigint &divisor) -> int
Definition format.h:2877
bigint(const bigint &)=delete
A contiguous memory buffer with an optional growing ability.
Definition base.h:1763
FMT_CONSTEXPR buffer(grow_fun grow, size_t sz) noexcept
Definition base.h:1775
FMT_CONSTEXPR20 void append(const U *begin, const U *end)
Appends data to the end of the buffer.
Definition base.h:1845
FMT_CONSTEXPR void push_back(const T &value)
Definition base.h:1832
constexpr auto size() const noexcept -> size_t
Returns the size of this buffer.
Definition base.h:1805
FMT_CONSTEXPR void try_reserve(size_t new_capacity)
Definition base.h:1828
auto end() noexcept -> T *
Definition base.h:1799
FMT_CONSTEXPR void try_resize(size_t count)
Definition base.h:1819
constexpr auto capacity() const noexcept -> size_t
Returns the capacity of this buffer.
Definition base.h:1808
FMT_CONSTEXPR auto data() noexcept -> T *
Returns a pointer to the buffer data (not null-terminated).
Definition base.h:1811
constexpr auto count() const noexcept -> size_t
Definition base.h:2035
auto apply(Out out, basic_string_view< C > digits) const -> Out
Definition format.h:1898
digit_grouping(locale_ref loc, bool localized=true)
Definition format.h:1878
digit_grouping(std::string grouping, std::basic_string< Char > sep)
Definition format.h:1884
auto has_separator() const -> bool
Definition format.h:1887
auto count_separators(int num_digits) const -> int
Definition format.h:1889
constexpr auto has_separator() const -> bool
Definition format.h:2475
constexpr auto count_separators(int) const -> int
Definition format.h:2477
constexpr fallback_digit_grouping(locale_ref, bool)
Definition format.h:2473
constexpr auto apply(Out out, basic_string_view< C >) const -> Out
Definition format.h:2480
static auto convert(Buffer &buf, basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort) -> bool
Definition format.h:1335
auto convert(basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort) -> bool
Definition format.h:1328
to_utf8(basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort)
Definition format.h:1311
to_utf8()
Definition format.h:1310
auto c_str() const -> const char *
Definition format.h:1322
auto size() const -> size_t
Definition format.h:1321
auto str() const -> std::string
Definition format.h:1323
FMT_CONSTEXPR auto operator>>=(int shift) -> uint128_fallback &
Definition format.h:372
constexpr uint128_fallback(uint64_t hi, uint64_t lo)
Definition format.h:306
FMT_CONSTEXPR auto operator>>(int shift) const -> uint128_fallback
Definition format.h:362
friend constexpr auto operator==(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition format.h:317
friend FMT_CONSTEXPR auto operator*(const uint128_fallback &lhs, uint32_t rhs) -> uint128_fallback
Definition format.h:350
friend constexpr auto operator|(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition format.h:329
friend constexpr auto operator-(const uint128_fallback &lhs, uint64_t rhs) -> uint128_fallback
Definition format.h:358
FMT_CONSTEXPR auto operator<<(int shift) const -> uint128_fallback
Definition format.h:367
friend constexpr auto operator!=(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition format.h:321
friend constexpr auto operator~(const uint128_fallback &n) -> uint128_fallback
Definition format.h:339
friend FMT_CONSTEXPR auto operator+(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition format.h:343
friend constexpr auto operator>(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition format.h:325
constexpr uint128_fallback(uint64_t value=0)
Definition format.h:307
constexpr auto high() const noexcept -> uint64_t
Definition format.h:309
FMT_CONSTEXPR void operator+=(uint128_fallback n)
Definition format.h:375
friend constexpr auto operator&(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition format.h:334
FMT_CONSTEXPR20 auto operator+=(uint64_t n) noexcept -> uint128_fallback &
Definition format.h:387
FMT_CONSTEXPR void operator&=(uint128_fallback n)
Definition format.h:382
constexpr auto low() const noexcept -> uint64_t
Definition format.h:310
FMT_API utf8_to_utf16(string_view s)
Definition format-inl.h:1415
auto size() const -> size_t
Definition format.h:1297
auto c_str() const -> const wchar_t *
Definition format.h:1298
auto str() const -> std::wstring
Definition format.h:1299
generic_context(const generic_context &)=delete
void operator=(const generic_context &)=delete
constexpr generic_context(OutputIt out, basic_format_args< generic_context > args, locale_ref loc={})
Definition format.h:3834
constexpr auto out() const -> iterator
Definition format.h:3853
generic_context(generic_context &&)=default
@ builtin_types
Definition format.h:3832
void advance_to(iterator it)
Definition format.h:3855
auto arg(basic_string_view< Char > name) const -> basic_format_arg< generic_context >
Definition format.h:3845
OutputIt iterator
Definition format.h:3831
constexpr auto arg_id(basic_string_view< Char > name) const -> int
Definition format.h:3849
constexpr auto arg(int id) const -> basic_format_arg< generic_context >
Definition format.h:3842
Char char_type
Definition format.h:3830
constexpr auto locale() const -> locale_ref
Definition format.h:3859
loc_value(T)
Definition format.h:3871
loc_value(T value)
Definition format.h:3868
auto visit(Visitor &&vis) -> decltype(vis(0))
Definition format.h:3873
Parsing context consisting of a format string range being parsed and an argument counter for automati...
Definition base.h:850
constexpr auto begin() const noexcept -> iterator
Returns an iterator to the beginning of the format string range being parsed.
Definition base.h:869
FMT_CONSTEXPR void check_arg_id(int id)
Reports an error if using the automatic argument indexing; otherwise switches to the manual indexing.
Definition base.h:893
FMT_CONSTEXPR auto next_arg_id() -> int
Reports an error if using the manual argument indexing; otherwise returns the next argument index and...
Definition base.h:881
string_buffer()
Definition format.h:946
auto str() -> std::string &
Definition format.h:949
void print(format_string< T... > fmt, T &&... args)
Formats args according to specifications in fmt and writes the output to the file.
Definition format.h:932
writer(detail::buffer< char > &buf)
Definition format.h:928
writer(FILE *f)
Definition format.h:927
FMT_API auto get_cached_power(int k) noexcept -> uint128_fallback
Definition format-inl.h:1146
auto floor_log10_pow2(int e) noexcept -> int
Definition format.h:1405
auto floor_log2_pow10(int e) noexcept -> int
Definition format.h:1411
FMT_API auto to_decimal(T x) noexcept -> decimal_fp< T >
Definition format-inl.h:1263
auto umul128_upper64(uint64_t x, uint64_t y) noexcept -> uint64_t
Definition format.h:1417
auto umul192_upper128(uint64_t x, uint128_fallback y) noexcept -> uint128_fallback
Definition format.h:1430
Converts a string literal into a format string that will be parsed at compile time and converted into...
Definition printf.h:50
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:1010
FMT_CONSTEXPR auto display_width_of(uint32_t cp) noexcept -> size_t
Definition format.h:666
uint128_t uintptr_t
Definition format.h:418
FMT_CONSTEXPR auto code_point_length(const Char *begin) -> int
Definition base.h:1303
auto get_iterator(Buf &buf, OutputIt) -> decltype(buf.out())
Definition base.h:2126
constexpr auto digits10< int128_opt >() noexcept -> int
Definition format.h:1144
FMT_CONSTEXPR FMT_NOINLINE auto write_int_noinline(OutputIt out, write_int_arg< T > arg, const format_specs &specs) -> OutputIt
Definition format.h:2114
FMT_CONSTEXPR20 auto isfinite(T value) -> bool
Definition format.h:2617
struct detail::fixed_string deallocate
FMT_CONSTEXPR auto do_format_base2e(int base_bits, Char *out, UInt value, int size, bool upper=false) -> Char *
Definition format.h:1251
FMT_CONSTEXPR auto compare(const Char *s1, const Char *s2, size_t n) -> int
Definition base.h:467
conditional_t< long_short, int, long long > long_type
Definition base.h:1126
FMT_CONSTEXPR auto write_padded(OutputIt out, const format_specs &specs, size_t size, size_t width, F &&f) -> OutputIt
Definition format.h:1675
constexpr auto to_ascii(Char c) -> char
Definition base.h:1297
constexpr auto fractional_part_rounding_thresholds(int index) -> uint32_t
Definition format.h:3122
FMT_CONSTEXPR20 auto bit_cast(const From &from) -> To
Definition format.h:276
FMT_CONSTEXPR FMT_NOINLINE auto fill(OutputIt it, size_t n, const basic_specs &specs) -> OutputIt
Definition format.h:1660
FMT_CONSTEXPR auto operator*(fp x, fp y) -> fp
Definition format.h:1637
FMT_CONSTEXPR void ignore_unused(const T &...)
Definition base.h:358
auto decimal_point(locale_ref loc) -> Char
Definition format.h:1166
FMT_INLINE void assume(bool condition)
Definition format.h:475
constexpr auto num_bits< uint128_fallback >() -> int
Definition format.h:432
constexpr auto use_fixed(int exp, int exp_upper) -> bool
Definition format.h:2467
bool_constant< is_integral< T >::value &&!std::is_same< T, bool >::value && !std::is_same< T, char >::value && !std::is_same< T, wchar_t >::value > is_integer
Definition format.h:698
void(*)(detail::buffer< char > &, int, const char *) format_func
Definition format.h:3796
constexpr auto has_implicit_bit() -> bool
Definition format.h:1491
constexpr auto num_bits() -> int
Definition format.h:426
uint128_opt
Definition base.h:411
FMT_CONSTEXPR void prefix_append(unsigned &prefix, unsigned value)
Definition format.h:1920
auto is_big_endian() -> bool
Definition format.h:286
FMT_CONSTEXPR auto count_digits_fallback(T n) -> int
Definition format.h:1041
conditional_t< FMT_USE_INT128, uint128_opt, uint128_fallback > uint128_t
Definition format.h:413
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const format_specs &specs={}) -> OutputIt
Definition format.h:1702
constexpr auto digits10() noexcept -> int
Definition format.h:1141
dragon
Definition format.h:2892
@ fixup
Definition format.h:2894
@ predecessor_closer
Definition format.h:2893
conditional_t< long_short, unsigned, unsigned long long > ulong_type
Definition base.h:1127
FMT_API void print(FILE *, string_view)
constexpr auto digits10< uint128_t >() noexcept -> int
Definition format.h:1145
FMT_INLINE auto umul128(uint64_t x, uint64_t y) noexcept -> uint128_fallback
Definition format.h:1374
FMT_CONSTEXPR20 void adjust_precision(int &precision, int exp10)
Definition format.h:2643
constexpr auto max_value() -> T
Definition format.h:423
int128_opt
Definition base.h:410
FMT_CONSTEXPR auto make_write_int_arg(T value, sign s) -> write_int_arg< uint32_or_64_or_128_t< T > >
Definition format.h:1993
FMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t< Int >
Definition base.h:432
FMT_END_EXPORT auto equal2(const Char *lhs, const char *rhs) -> bool
Definition format.h:1185
constexpr FMT_INLINE_VARIABLE uint32_t invalid_code_point
Definition format.h:627
auto write_ptr(OutputIt out, UIntPtr value, const format_specs *specs) -> OutputIt
Definition format.h:1712
auto write_int(OutputIt out, UInt value, unsigned prefix, const format_specs &specs, const digit_grouping< Char > &grouping) -> OutputIt
Definition format.h:1927
auto base_iterator(OutputIt it, typename OutputIt::container_type::value_type *) -> OutputIt
Definition format.h:539
FMT_API auto decimal_point_impl(locale_ref loc) -> Char
Definition format-inl.h:125
constexpr auto to_pointer(OutputIt, size_t) -> T *
Definition format.h:518
auto write_loc(OutputIt, const loc_value &, const format_specs &, locale_ref) -> bool
Definition format.h:1982
to_utf8_error_policy
Definition format.h:1302
FMT_API void format_error_code(buffer< char > &out, int error_code, string_view message) noexcept
Definition format-inl.h:78
auto digits2(size_t value) -> const char *
Definition format.h:1024
FMT_CONSTEXPR20 auto write_float(OutputIt out, const DecimalFP &f, const format_specs &specs, sign s, int exp_upper, locale_ref loc) -> OutputIt
Definition format.h:2592
conditional_t< std::is_same< T, float >::value||doublish, double, T > convert_float_result
Definition format.h:1642
FMT_CONSTEXPR auto multiply(uint64_t lhs, uint64_t rhs) -> uint64_t
Definition format.h:1620
FMT_API auto is_printable(uint32_t cp) -> bool
Definition format-inl.h:1799
FMT_CONSTEXPR20 void format_hexfloat(Float value, format_specs specs, buffer< char > &buf)
Definition format.h:3037
FMT_CONSTEXPR FMT_NOINLINE auto copy_noinline(InputIt begin, InputIt end, OutputIt out) -> OutputIt
Definition format.h:568
constexpr auto is_constant_evaluated(bool default_value=false) noexcept -> bool
Definition base.h:360
FMT_API auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result< Char >
Definition format-inl.h:118
template FMT_API auto thousands_sep_impl< wchar_t >(locale_ref) -> thousands_sep_result< wchar_t >
auto write_escaped_char(OutputIt out, Char v) -> OutputIt
Definition format.h:1830
constexpr auto num_bits< int128_opt >() -> int
Definition format.h:430
auto thousands_sep(locale_ref loc) -> thousands_sep_result< Char >
Definition format.h:1155
FMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
Definition format.h:553
FMT_ALWAYS_INLINE constexpr auto const_check(T val) -> T
Definition base.h:377
constexpr auto exponent_bias() -> int
Definition format.h:1512
constexpr auto num_significand_bits() -> int
Definition format.h:1498
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:1433
bool_constant< std::is_same< T, int >::value||FMT_BUILTIN_TYPES > is_builtin
Definition format.h:3635
FMT_API auto write_console(int fd, string_view text) -> bool
Definition format-inl.h:1700
FMT_CONSTEXPR20 auto copy(InputIt begin, InputIt end, OutputIt out) -> OutputIt
Definition base.h:2068
remove_reference_t< decltype(reserve(std::declval< OutputIt & >(), 0))> reserve_iterator
Definition format.h:514
FMT_CONSTEXPR auto write_exponent(int exp, OutputIt out) -> OutputIt
Definition format.h:1527
FMT_CONSTEXPR auto utf8_decode(const char *s, uint32_t *c, int *e) -> const char *
Definition format.h:590
FMT_CONSTEXPR void abort_fuzzing_if(bool condition)
Definition format.h:248
FMT_FUNC void vformat_to(buffer< char > &buf, string_view fmt, format_args args, locale_ref loc)
Definition format-inl.h:1456
constexpr auto getsign(sign s) -> Char
Definition format.h:1036
std::integral_constant< bool, std::numeric_limits< T >::is_signed|| std::is_same< T, int128_opt >::value > is_signed
Definition format.h:693
FMT_CONSTEXPR20 auto write_nonfinite(OutputIt out, bool isnan, format_specs specs, sign s) -> OutputIt
Definition format.h:2336
constexpr auto write_significand(OutputIt out, const char *significand, int significand_size) -> OutputIt
Definition format.h:2370
auto write_escaped_cp(OutputIt out, const find_escape_result< Char > &escape) -> OutputIt
Definition format.h:1777
FMT_CONSTEXPR auto parse_align(const Char *begin, const Char *end, format_specs &specs) -> const Char *
Definition format.h:2300
constexpr auto get_significand_size(const big_decimal_fp &f) -> int
Definition format.h:2361
FMT_CONSTEXPR auto format_base2e(int base_bits, Char *out, UInt value, int num_digits, bool upper=false) -> Char *
Definition format.h:1265
FMT_CONSTEXPR auto write_char(OutputIt out, Char value, const format_specs &specs) -> OutputIt
Definition format.h:1846
FMT_CONSTEXPR auto compute_exp_size(int exp) -> int
Definition format.h:1518
auto needs_escape(uint32_t cp) -> bool
Definition format.h:1728
constexpr auto convert_float(T value) -> convert_float_result< T >
Definition format.h:1646
auto write_codepoint(OutputIt out, char prefix, uint32_t cp) -> OutputIt
Definition format.h:1767
FMT_INLINE FMT_CONSTEXPR auto signbit(T value) -> bool
Definition format.h:2631
typename V::value_type char_t
String's character (code unit) type. detail:: is intentional to prevent ADL.
Definition base.h:973
constexpr auto to_string_view(const Char *s) -> basic_string_view< Char >
Definition base.h:948
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:3700
conditional_t< num_bits< T >()<=64, uint64_t, uint128_t > uint64_or_128_t
Definition format.h:1015
state
Definition base.h:1457
@ use_utf8
Definition base.h:452
FMT_CONSTEXPR void for_each_codepoint(string_view s, F f)
Definition format.h:632
constexpr friend auto operator==(allocator, allocator) noexcept -> bool
Definition format.h:754
FMT_CONSTEVAL auto exp_upper() -> int
Definition format.h:2459
FMT_CONSTEXPR20 auto reserve(OutputIt it, size_t n) -> typename OutputIt::value_type *
Definition format.h:493
constexpr friend auto operator!=(allocator, allocator) noexcept -> bool
Definition format.h:757
FMT_EXPORT constexpr auto compile_string_to_view(const Char(&s)[N]) -> basic_string_view< Char >
Definition format.h:984
FMT_CONSTEXPR20 auto countl_zero_fallback(UInt n) -> int
Definition format.h:454
constexpr auto is_negative(T value) -> bool
Definition format.h:999
FMT_CONSTEXPR FMT_INLINE auto write(basic_appender< Char > out, T value, const format_specs &specs, locale_ref loc) -> basic_appender< Char >
Definition format.h:2125
std::is_same< T, float128 > is_float128
Definition format.h:719
FMT_API void do_report_error(format_func func, int error_code, const char *message) noexcept
Definition format-inl.h:101
auto get_buffer(OutputIt out) -> iterator_buffer< OutputIt, T >
Definition base.h:2116
auto find_escape(const Char *begin, const Char *end) -> find_escape_result< Char >
Definition format.h:1741
FMT_CONSTEXPR20 auto format_float(Float value, int precision, const format_specs &specs, bool binary32, buffer< char > &buf) -> int
Definition format.h:3134
FMT_CONSTEXPR20 FMT_INLINE void write2digits(Char *out, size_t value)
Definition format.h:1194
constexpr auto num_bits< uint128_opt >() -> int
Definition format.h:431
constexpr auto count() -> int
Definition base.h:1071
FMT_CONSTEXPR20 auto do_format_decimal(Char *out, UInt value, int size) -> Char *
Definition format.h:1207
FMT_CONSTEXPR20 auto count_digits(uint64_t n) -> int
Definition format.h:1084
FMT_BEGIN_EXPORT template FMT_API auto thousands_sep_impl< char >(locale_ref) -> thousands_sep_result< char >
conditional_t< sizeof(Char)==1, unsigned char, unsigned > unsigned_char
Definition base.h:438
constexpr auto exponent_mask() -> typename dragonbox::float_info< Float >::carrier_uint
Definition format.h:1506
auto select(T true_value, F) -> T
Definition format.h:1651
FMT_CONSTEXPR FMT_INLINE auto format_decimal(Char *out, UInt value, int num_digits) -> Char *
Definition format.h:1229
FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP &f, const format_specs &specs, sign s, int exp_upper, locale_ref loc) -> OutputIt
Definition format.h:2553
FMT_CONSTEXPR20 auto countl_zero(uint32_t n) -> int
Definition format.h:461
FMT_CONSTEXPR20 void format_dragon(basic_fp< uint128_t > value, unsigned flags, int num_digits, buffer< char > &buf, int &exp10)
Definition format.h:2901
auto write_escaped_string(OutputIt out, basic_string_view< Char > str) -> OutputIt
Definition format.h:1814
FMT_CONSTEXPR20 auto get_container(OutputIt it) -> typename OutputIt::container_type &
Definition base.h:495
FMT_CONSTEXPR20 auto write_fixed(OutputIt out, const DecimalFP &f, int significand_size, Char decimal_point, const format_specs &specs, sign s, locale_ref loc={}) -> OutputIt
Definition format.h:2487
FMT_CONSTEXPR auto normalize(basic_fp< F > value) -> basic_fp< F >
Definition format.h:1603
FMT_CONSTEXPR auto parse_format_specs(const Char *begin, const Char *end, dynamic_format_specs< Char > &specs, parse_context< Char > &ctx, type arg_type) -> const Char *
Definition base.h:1461
constexpr auto isnan(T value) -> bool
Definition format.h:2604
constexpr auto format_as(Enum e) noexcept -> underlying_t< Enum >
Definition format.h:3983
Definition PointerIntPair.h:280
bytes(string_view s)
Definition format.h:4004
string_view data
Definition format.h:4002
FMT_CONSTEXPR basic_fp(Float n)
Definition format.h:1564
constexpr basic_fp(uint64_t f_val, int e_val)
Definition format.h:1561
FMT_CONSTEXPR auto assign(Float n) -> bool
Definition format.h:1568
constexpr basic_fp()
Definition format.h:1560
int e
Definition format.h:1555
static constexpr int num_significand_bits
Definition format.h:1557
F f
Definition format.h:1554
const char * significand
Definition format.h:2356
int significand_size
Definition format.h:2357
int exponent
Definition format.h:2358
int exponent
Definition format.h:1484
significand_type significand
Definition format.h:1483
typename float_info< T >::carrier_uint significand_type
Definition format.h:1482
detail::uint128_t carrier_uint
Definition format.h:1478
detail::uint128_t carrier_uint
Definition format.h:1471
uint64_t carrier_uint
Definition format.h:1455
uint32_t carrier_uint
Definition format.h:1443
FMT_CONSTEXPR auto operator()(T) -> unsigned long long
Definition format.h:3693
FMT_CONSTEXPR auto operator()(T value) -> unsigned long long
Definition format.h:3688
const Char * end
Definition format.h:1736
const Char * begin
Definition format.h:1735
uint32_t cp
Definition format.h:1737
Char data[N]
Definition format.h:979
FMT_CONSTEXPR20 fixed_string(const Char(&s)[N])
Definition format.h:975
FMT_ASSERT(n<=max_value< size_t >()/sizeof(T), "")
if(!p) FMT_THROW(std return p
Definition format.h:748
T * p
Definition format.h:747
std::string grouping
Definition format.h:2011
auto operator()(T value) -> bool
Definition format.h:2015
auto operator()(T) -> bool
Definition format.h:2023
std::basic_string< Char > decimal_point
Definition format.h:2012
const format_specs & specs
Definition format.h:2009
std::basic_string< Char > sep
Definition format.h:2010
basic_appender< Char > out
Definition format.h:2008
Definition format-inl.h:57
FMT_CONSTEXPR size_padding(int num_digits, unsigned prefix, const format_specs &specs)
Definition format.h:2033
unsigned padding
Definition format.h:2031
unsigned size
Definition format.h:2030
static constexpr Char value[sizeof...(C)]
Definition format.h:264
Char thousands_sep
Definition format.h:1149
std::string grouping
Definition format.h:1148
const Char * str
Definition format.h:3740
auto operator=(T &&value) const -> named_arg< Char, T >
Definition format.h:3742
unsigned prefix
Definition format.h:1989
UInt abs_value
Definition format.h:1988
T value
Definition format.h:4030
const T * value
Definition format.h:4073
const formatter< T, Char > * fmt
Definition format.h:4072
void pointer
Definition format.h:163
void reference
Definition format.h:164
output_iterator_tag iterator_category
Definition format.h:159
decltype(static_cast< int * >(nullptr) - static_cast< int * >(nullptr)) difference_type
Definition format.h:161
T value_type
Definition format.h:160
int index
Definition base.h:1283
basic_string_view< Char > name
Definition base.h:1284
#define S(label, offset, message)
Definition Errors.h:113