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))
122#if !FMT_USE_CONSTEVAL
123# define FMT_USE_CONSTEXPR_STRING 0
124#elif defined(__cpp_lib_constexpr_string) && \
125 __cpp_lib_constexpr_string >= 201907L
126# if FMT_CLANG_VERSION && FMT_GLIBCXX_RELEASE
129# if FMT_GLIBCXX_RELEASE < 13
130# define FMT_USE_CONSTEXPR_STRING 0
131# elif FMT_GLIBCXX_RELEASE == 13 && __GLIBCXX__ < 20240521
132# define FMT_USE_CONSTEXPR_STRING 0
134# define FMT_USE_CONSTEXPR_STRING 1
137# define FMT_USE_CONSTEXPR_STRING 1
140# define FMT_USE_CONSTEXPR_STRING 0
142#if FMT_USE_CONSTEXPR_STRING
143# define FMT_CONSTEXPR_STRING constexpr
145# define FMT_CONSTEXPR_STRING
154 decltype(
static_cast<int*
>(
nullptr) -
static_cast<int*
>(
nullptr));
161# if FMT_USE_EXCEPTIONS
162# if FMT_MSC_VERSION || defined(__NVCC__)
165template <
typename Exception>
inline void do_throw(
const Exception& x) {
168 volatile bool b =
true;
173# define FMT_THROW(x) detail::do_throw(x)
175# define FMT_THROW(x) throw x
178# define FMT_THROW(x) \
179 ::fmt::detail::assert_fail(__FILE__, __LINE__, (x).what())
187#if !defined(FMT_REDUCE_INT_INSTANTIATIONS)
188# define FMT_REDUCE_INT_INSTANTIATIONS 0
193template <
typename Char,
typename Traits,
typename Allocator>
202# if FMT_HAS_BUILTIN(__builtin_clz) || FMT_GCC_VERSION || FMT_ICC_VERSION
203# define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
205# if FMT_HAS_BUILTIN(__builtin_clzll) || FMT_GCC_VERSION || FMT_ICC_VERSION
206# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
213#if FMT_MSC_VERSION && !defined(FMT_BUILTIN_CLZLL)
216# pragma intrinsic(_BitScanReverse)
218# pragma intrinsic(_BitScanReverse64)
222inline auto clz(uint32_t x) ->
int {
226 _BitScanReverse(&r, x);
227 return 31 ^
static_cast<int>(r);
229# define FMT_BUILTIN_CLZ(n) detail::clz(n)
231inline auto clzll(uint64_t x) ->
int {
236 _BitScanReverse64(&r, x);
239 if (_BitScanReverse(&r,
static_cast<uint32_t
>(x >> 32)))
240 return 63 ^
static_cast<int>(r + 32);
242 _BitScanReverse(&r,
static_cast<uint32_t
>(x));
244 return 63 ^
static_cast<int>(r);
246# define FMT_BUILTIN_CLZLL(n) detail::clzll(n)
252 if (condition)
throw std::runtime_error(
"fuzzing limit reached");
256#if defined(FMT_USE_STRING_VIEW)
257template <
typename Char>
using std_string_view = std::basic_string_view<Char>;
265 static constexpr Char
value[
sizeof...(C)] = {C...};
267 return {
value,
sizeof...(C)};
270#if FMT_CPLUSPLUS < 201703L
271template <
typename Char, Char... C>
272constexpr Char string_literal<Char, C...>
::value[
sizeof...(C)];
276template <
typename To,
typename From, FMT_ENABLE_IF(sizeof(To) == sizeof(From))>
278#ifdef __cpp_lib_bit_cast
283 std::memcpy(
static_cast<void*
>(&to), &
from,
sizeof(to));
290#elif defined(__BIG_ENDIAN__)
292#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
293 return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;
296 char data[
sizeof(int)];
310 constexpr auto high() const noexcept -> uint64_t {
return hi_; }
311 constexpr auto low() const noexcept -> uint64_t {
return lo_; }
313 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
314 constexpr explicit operator T()
const {
315 return static_cast<T
>(lo_);
320 return lhs.hi_ == rhs.hi_ && lhs.lo_ == rhs.lo_;
324 return !(lhs == rhs);
328 return lhs.hi_ != rhs.hi_ ? lhs.hi_ > rhs.hi_ : lhs.lo_ > rhs.lo_;
333 return {lhs.hi_ | rhs.hi_, lhs.lo_ | rhs.lo_};
338 return {lhs.hi_ & rhs.hi_, lhs.lo_ & rhs.lo_};
342 return {~n.hi_, ~n.lo_};
354 uint64_t hi = (lhs.lo_ >> 32) * rhs;
355 uint64_t lo = (lhs.lo_ & ~uint32_t()) * rhs;
356 uint64_t new_lo = (hi << 32) + lo;
357 return {(hi >> 32) + (new_lo < lo ? 1 : 0), new_lo};
361 return {lhs.hi_ - (lhs.lo_ < rhs ? 1 : 0), lhs.lo_ - rhs};
364 if (shift == 64)
return {0, hi_};
366 return {hi_ >> shift, (hi_ << (64 - shift)) | (lo_ >> shift)};
369 if (shift == 64)
return {lo_, 0};
371 return {hi_ << shift | (lo_ >> (64 - shift)), (lo_ << shift)};
374 return *
this = *
this >> shift;
377 uint64_t new_lo = lo_ + n.lo_;
378 uint64_t new_hi = hi_ + n.hi_ + (new_lo < lo_ ? 1 : 0);
391 hi_ += (lo_ < n ? 1 : 0);
394#if FMT_HAS_BUILTIN(__builtin_addcll) && !defined(__ibmxl__)
395 unsigned long long carry;
396 lo_ = __builtin_addcll(lo_, n, 0, &carry);
398#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !defined(__ibmxl__)
399 unsigned long long result;
400 auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result);
403#elif defined(_MSC_VER) && defined(_M_X64)
404 auto carry = _addcarry_u64(0, lo_, n, &lo_);
405 _addcarry_u64(carry, hi_, 0, &hi_);
408 hi_ += (lo_ < n ? 1 : 0);
425 return (std::numeric_limits<T>::max)();
427template <
typename T>
constexpr auto num_bits() ->
int {
428 return std::numeric_limits<T>::digits;
437template <
typename To,
typename From, FMT_ENABLE_IF(sizeof(To) >
sizeof(From))>
439 constexpr auto size =
static_cast<int>(
sizeof(From) /
sizeof(
unsigned short));
441 unsigned short value[
static_cast<unsigned>(size)];
445 for (
int i = 0; i < size; ++i)
448 for (
int i = size - 1; i >= 0; --i)
454template <
typename UInt>
457 constexpr UInt msb_mask =
static_cast<UInt
>(1) << (
num_bits<UInt>() - 1);
458 for (; (n & msb_mask) == 0; n <<= 1) lz++;
463#ifdef FMT_BUILTIN_CLZ
470#ifdef FMT_BUILTIN_CLZLL
478#if FMT_HAS_BUILTIN(__builtin_assume) && !FMT_ICC_VERSION
479 __builtin_assume(condition);
481 if (!condition) __builtin_unreachable();
487template <
typename OutputIt,
490#if FMT_CLANG_VERSION >= 307 && !FMT_ICC_VERSION
491__attribute__((no_sanitize(
"undefined")))
494reserve(OutputIt it,
size_t n) ->
typename OutputIt::value_type* {
496 size_t size = c.size();
509template <
typename Iterator>
510constexpr auto reserve(Iterator& it,
size_t) -> Iterator& {
514template <
typename OutputIt>
518template <
typename T,
typename OutputIt>
526 auto size = buf.
size();
527 if (buf.
capacity() < size + n)
return nullptr;
529 return buf.
data() + size;
532template <
typename OutputIt,
536 typename OutputIt::container_type::value_type*)
541template <
typename Iterator>
548template <
typename OutputIt,
typename Size,
typename T>
551 for (Size i = 0; i <
count; ++i) *out++ =
value;
554template <
typename T,
typename Size>
557 static_assert(
sizeof(T) == 1,
558 "sizeof(T) must be 1 to use char for initialization");
563template <
typename OutChar,
typename InputIt,
typename OutputIt>
565 OutputIt out) -> OutputIt {
588 constexpr int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07};
589 constexpr uint32_t mins[] = {4194304, 0, 128, 2048, 65536};
590 constexpr int shiftc[] = {0, 18, 12, 6, 0};
591 constexpr int shifte[] = {0, 6, 4, 2, 0};
593 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"
594 [
static_cast<unsigned char>(*s) >> 3];
598 const char* next = s + len + !len;
600 using uchar =
unsigned char;
604 *c = uint32_t(uchar(s[0]) & masks[len]) << 18;
605 *c |= uint32_t(uchar(s[1]) & 0x3f) << 12;
606 *c |= uint32_t(uchar(s[2]) & 0x3f) << 6;
607 *c |= uint32_t(uchar(s[3]) & 0x3f) << 0;
611 *e = (*c < mins[len]) << 6;
612 *e |= ((*c >> 11) == 0x1b) << 7;
613 *e |= (*c > 0x10FFFF) << 8;
614 *e |= (uchar(s[1]) & 0xc0) >> 2;
615 *e |= (uchar(s[2]) & 0xc0) >> 4;
616 *e |= uchar(s[3]) >> 6;
629 auto decode = [f](
const char* buf_ptr,
const char*
ptr) {
630 auto cp = uint32_t();
635 return result ? (
error ? buf_ptr + 1 : end) :
nullptr;
639 const size_t block_size = 4;
640 if (s.
size() >= block_size) {
641 for (
auto end = p + s.
size() - block_size + 1; p < end;) {
647 if (num_chars_left == 0)
return;
651 char buf[2 * block_size - 1] = {};
653 const char* buf_ptr = buf;
655 auto end = decode(buf_ptr, p);
659 }
while (buf_ptr < buf + num_chars_left);
669 (cp >= 0x2e80 && cp <= 0xa4cf && cp != 0x303f) ||
670 (cp >= 0xac00 && cp <= 0xd7a3) ||
671 (cp >= 0xf900 && cp <= 0xfaff) ||
672 (cp >= 0xfe10 && cp <= 0xfe19) ||
673 (cp >= 0xfe30 && cp <= 0xfe6f) ||
674 (cp >= 0xff00 && cp <= 0xff60) ||
675 (cp >= 0xffe0 && cp <= 0xffe6) ||
676 (cp >= 0x20000 && cp <= 0x2fffd) ||
677 (cp >= 0x30000 && cp <= 0x3fffd) ||
679 (cp >= 0x1f300 && cp <= 0x1f64f) ||
681 (cp >= 0x1f900 && cp <= 0x1f9ff))));
690 std::integral_constant<bool, std::numeric_limits<T>::is_signed ||
691 std::is_same<T, int128_opt>::value>;
696 !std::is_same<T, char>::value &&
697 !std::is_same<T, wchar_t>::value>;
699#if defined(FMT_USE_FLOAT128)
701#elif FMT_CLANG_VERSION >= 309 && FMT_HAS_INCLUDE(<quadmath.h>)
702# define FMT_USE_FLOAT128 1
703#elif FMT_GCC_VERSION && defined(_GLIBCXX_USE_FLOAT128) && \
704 !defined(__STRICT_ANSI__)
705# define FMT_USE_FLOAT128 1
707# define FMT_USE_FLOAT128 0
710using float128 = __float128;
715template <
typename T>
using is_float128 = std::is_same<T, float128>;
720template <typename T, bool = is_floating_point<T>::value>
721struct is_fast_float :
bool_constant<std::numeric_limits<T>::is_iec559 &&
722 sizeof(T) <= sizeof(double)> {};
723template <typename T> struct is_fast_float<T, false> : std::false_type {};
726using fast_float_t = conditional_t<sizeof(T) == sizeof(double), double, float>;
729using is_double_double = bool_constant<std::numeric_limits<T>::digits == 106>;
731#ifndef FMT_USE_FULL_CACHE_DRAGONBOX
732# define FMT_USE_FULL_CACHE_DRAGONBOX 0
738template <typename T> struct allocator : private std::decay<void> {
739 using value_type = T;
741 T* allocate(size_t n) {
742 FMT_ASSERT(n <= max_value<size_t>() / sizeof(T), "");
743 T* p = static_cast<T*>(std::malloc(n * sizeof(T)));
744 if (!p) FMT_THROW(std::bad_alloc());
748 void deallocate(T* p, size_t) { std::free(p); }
757enum { inline_buffer_size = 500 };
772template <typename T, size_t SIZE = inline_buffer_size,
773 typename Allocator = detail::allocator<T>>
774class basic_memory_buffer : public detail::buffer<T> {
779 FMT_NO_UNIQUE_ADDRESS Allocator alloc_;
782 FMT_CONSTEXPR20 void deallocate() {
783 T* data = this->data();
784 if (data != store_) alloc_.deallocate(data, this->capacity());
787 static
FMT_CONSTEXPR20 void grow(detail::buffer<T>& buf, size_t size) {
790 const size_t max_size =
791 std::allocator_traits<Allocator>::max_size(self.alloc_);
792 size_t old_capacity = buf.capacity();
793 size_t new_capacity = old_capacity + old_capacity / 2;
794 if (size > new_capacity)
796 else if (new_capacity > max_size)
797 new_capacity =
max_of(size, max_size);
798 T* old_data = buf.data();
799 T* new_data = self.alloc_.allocate(new_capacity);
803 memcpy(new_data, old_data, buf.size() *
sizeof(T));
804 self.set(new_data, new_capacity);
808 if (old_data != self.store_) self.alloc_.deallocate(old_data, old_capacity);
816 const Allocator& alloc = Allocator())
817 :
detail::buffer<T>(grow), alloc_(alloc) {
818 this->
set(store_, SIZE);
826 alloc_ = std::move(other.alloc_);
827 T* data = other.data();
828 size_t size = other.size(), capacity = other.capacity();
829 if (data == other.store_) {
830 this->
set(store_, capacity);
833 this->
set(data, capacity);
836 other.set(other.store_, 0);
866 void reserve(
size_t new_capacity) { this->try_reserve(new_capacity); }
869 template <
typename ContiguousRange>
871 append(range.data(), range.data() + range.size());
877template <
size_t SIZE>
880 auto size = buf.size();
882 return {buf.data(), size};
895 inline writer(FILE* f) : buf_(nullptr), file_(f) {}
902 fmt::format_to(
appender(*buf_), fmt, std::forward<T>(args)...);
904 fmt::print(file_, fmt, std::forward<T>(args)...);
916 inline operator writer() {
return buf_; }
917 inline std::string&
str() {
return str_; }
920template <
typename T,
size_t SIZE,
typename Allocator>
930 using std::runtime_error::runtime_error;
956 return {s, N - (std::char_traits<Char>::to_int_type(s[N - 1]) == 0 ? 1 : 0)};
966template <
typename T, FMT_ENABLE_IF(is_
signed<T>::value)>
970template <
typename T, FMT_ENABLE_IF(!is_
signed<T>::value)>
985#define FMT_POWERS_OF_10(factor) \
986 factor * 10, (factor) * 100, (factor) * 1000, (factor) * 10000, \
987 (factor) * 100000, (factor) * 1000000, (factor) * 10000000, \
988 (factor) * 100000000, (factor) * 1000000000
995 alignas(2)
static const char data[] =
996 "0001020304050607080910111213141516171819"
997 "2021222324252627282930313233343536373839"
998 "4041424344454647484950515253545556575859"
999 "6061626364656667686970717273747576777879"
1000 "8081828384858687888990919293949596979899";
1001 return &data[
value * 2];
1005 return static_cast<char>(((
' ' << 24) | (
'+' << 16) | (
'-' << 8)) >>
1006 (
static_cast<int>(s) * 8));
1015 if (n < 10)
return count;
1016 if (n < 100)
return count + 1;
1017 if (n < 1000)
return count + 2;
1018 if (n < 10000)
return count + 3;
1029#ifdef FMT_BUILTIN_CLZLL
1032inline auto do_count_digits(uint64_t n) ->
int {
1037 static constexpr uint8_t bsr2log10[] = {
1038 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5,
1039 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10,
1040 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15, 15,
1041 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 20};
1042 auto t = bsr2log10[FMT_BUILTIN_CLZLL(n | 1) ^ 63];
1043 static constexpr uint64_t zero_or_powers_of_10[] = {
1045 10000000000000000000ULL};
1046 return t - (n < zero_or_powers_of_10[t]);
1053#ifdef FMT_BUILTIN_CLZLL
1060template <
int BITS,
typename UInt>
1062#ifdef FMT_BUILTIN_CLZ
1064 return (FMT_BUILTIN_CLZ(
static_cast<uint32_t
>(n) | 1) ^ 31) / BITS + 1;
1071 }
while ((m >>= BITS) != 0);
1076#ifdef FMT_BUILTIN_CLZ
1079FMT_INLINE auto do_count_digits(uint32_t n) ->
int {
1082# define FMT_INC(T) (((sizeof(#T) - 1ull) << 32) - T)
1083 static constexpr uint64_t table[] = {
1084 FMT_INC(0), FMT_INC(0), FMT_INC(0),
1085 FMT_INC(10), FMT_INC(10), FMT_INC(10),
1086 FMT_INC(100), FMT_INC(100), FMT_INC(100),
1087 FMT_INC(1000), FMT_INC(1000), FMT_INC(1000),
1088 FMT_INC(10000), FMT_INC(10000), FMT_INC(10000),
1089 FMT_INC(100000), FMT_INC(100000), FMT_INC(100000),
1090 FMT_INC(1000000), FMT_INC(1000000), FMT_INC(1000000),
1091 FMT_INC(10000000), FMT_INC(10000000), FMT_INC(10000000),
1092 FMT_INC(100000000), FMT_INC(100000000), FMT_INC(100000000),
1093 FMT_INC(1000000000), FMT_INC(1000000000), FMT_INC(1000000000),
1094 FMT_INC(1000000000), FMT_INC(1000000000)
1096 auto inc = table[FMT_BUILTIN_CLZ(n | 1) ^ 31];
1097 return static_cast<int>((n + inc) >> 32);
1103#ifdef FMT_BUILTIN_CLZ
1109template <
typename Int>
constexpr auto digits10() noexcept ->
int {
1110 return std::numeric_limits<Int>::digits10;
1120template <
typename Char>
1122template <
typename Char>
1125 return {result.grouping, Char(result.thousands_sep)};
1132template <
typename Char>
1141#ifndef FMT_HEADER_ONLY
1153template <
typename Char>
auto equal2(
const Char* lhs,
const char* rhs) ->
bool {
1154 return lhs[0] == Char(rhs[0]) && lhs[1] == Char(rhs[1]);
1156inline auto equal2(
const char* lhs,
const char* rhs) ->
bool {
1157 return memcmp(lhs, rhs, 2) == 0;
1161template <
typename Char>
1168 *out++ =
static_cast<Char
>(
'0' +
value / 10);
1169 *out =
static_cast<Char
>(
'0' +
value % 10);
1174template <
typename Char,
typename UInt>
1179 while (
value >= 100) {
1191 out[--n] =
static_cast<Char
>(
'0' +
value);
1196template <
typename Char,
typename UInt>
1198 int num_digits) -> Char* {
1200 return out + num_digits;
1203template <
typename Char,
typename UInt,
typename OutputIt,
1218template <
typename Char,
typename UInt>
1220 int size,
bool upper =
false) -> Char* {
1223 const char* digits = upper ?
"0123456789ABCDEF" :
"0123456789abcdef";
1224 unsigned digit =
static_cast<unsigned>(
value & ((1u << base_bits) - 1));
1225 *--out =
static_cast<Char
>(base_bits < 4 ? static_cast<char>(
'0' + digit)
1227 }
while ((
value >>= base_bits) != 0);
1232template <
typename Char,
typename UInt>
1234 int num_digits,
bool upper =
false) -> Char* {
1236 return out + num_digits;
1239template <
typename Char,
typename OutputIt,
typename UInt,
1242 int num_digits,
bool upper =
false)
1263 return {&buffer_[0],
size()};
1265 inline auto size() const ->
size_t {
return buffer_.
size() - 1; }
1266 inline auto c_str() const -> const
wchar_t* {
return &buffer_[0]; }
1267 inline auto str() const ->
std::wstring {
return {&buffer_[0],
size()}; }
1273template <
typename WChar,
typename Buffer = memory_buffer>
class to_utf8 {
1281 static_assert(
sizeof(WChar) == 2 ||
sizeof(WChar) == 4,
1282 "Expect utf16 or utf32");
1284 FMT_THROW(std::runtime_error(
sizeof(WChar) == 2 ?
"invalid utf16"
1285 :
"invalid utf32"));
1288 auto size() const ->
size_t {
return buffer_.size() - 1; }
1289 auto c_str() const -> const
char* {
return &buffer_[0]; }
1290 auto str() const ->
std::
string {
return std::string(&buffer_[0],
size()); }
1298 if (!
convert(buffer_, s, policy))
return false;
1299 buffer_.push_back(0);
1305 for (
auto p = s.begin(); p != s.end(); ++p) {
1306 uint32_t c =
static_cast<uint32_t
>(*p);
1307 if (
sizeof(WChar) == 2 && c >= 0xd800 && c <= 0xdfff) {
1310 if (p == s.end() || (c & 0xfc00) != 0xd800 || (*p & 0xfc00) != 0xdc00) {
1316 c = (c << 10) + static_cast<uint32_t>(*p) - 0x35fdc00;
1320 buf.push_back(
static_cast<char>(c));
1321 }
else if (c < 0x800) {
1322 buf.push_back(
static_cast<char>(0xc0 | (c >> 6)));
1323 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
1324 }
else if ((c >= 0x800 && c <= 0xd7ff) || (c >= 0xe000 && c <= 0xffff)) {
1325 buf.push_back(
static_cast<char>(0xe0 | (c >> 12)));
1326 buf.push_back(
static_cast<char>(0x80 | ((c & 0xfff) >> 6)));
1327 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
1328 }
else if (c >= 0x10000 && c <= 0x10ffff) {
1329 buf.push_back(
static_cast<char>(0xf0 | (c >> 18)));
1330 buf.push_back(
static_cast<char>(0x80 | ((c & 0x3ffff) >> 12)));
1331 buf.push_back(
static_cast<char>(0x80 | ((c & 0xfff) >> 6)));
1332 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
1345 return {
static_cast<uint64_t
>(p >> 64),
static_cast<uint64_t
>(p)};
1346#elif defined(_MSC_VER) && defined(_M_X64)
1347 auto hi = uint64_t();
1348 auto lo = _umul128(x, y, &hi);
1353 uint64_t a = x >> 32;
1354 uint64_t b = x & mask;
1355 uint64_t c = y >> 32;
1356 uint64_t d = y & mask;
1358 uint64_t ac = a * c;
1359 uint64_t bc = b * c;
1360 uint64_t ad = a * d;
1361 uint64_t bd = b * d;
1363 uint64_t intermediate = (bd >> 32) + (ad & mask) + (bc & mask);
1365 return {ac + (intermediate >> 32) + (ad >> 32) + (bc >> 32),
1366 (intermediate << 32) + (bd & mask)};
1370namespace dragonbox {
1374 FMT_ASSERT(e <= 2620 && e >= -2620,
"too large exponent");
1375 static_assert((-1 >> 1) == -1,
"right shift is not arithmetic");
1376 return (e * 315653) >> 20;
1380 FMT_ASSERT(e <= 1233 && e >= -1233,
"too large exponent");
1381 return (e * 1741647) >> 19;
1388 return static_cast<uint64_t
>(p >> 64);
1389#elif defined(_MSC_VER) && defined(_M_X64)
1390 return __umulh(x, y);
1412 static const int exponent_bits = 8;
1413 static const int kappa = 1;
1414 static const int big_divisor = 100;
1415 static const int small_divisor = 10;
1416 static const int min_k = -31;
1417 static const int max_k = 46;
1418 static const int shorter_interval_tie_lower_threshold = -35;
1419 static const int shorter_interval_tie_upper_threshold = -35;
1424 static const int exponent_bits = 11;
1425 static const int kappa = 2;
1426 static const int big_divisor = 1000;
1427 static const int small_divisor = 100;
1428 static const int min_k = -292;
1429 static const int max_k = 341;
1430 static const int shorter_interval_tie_lower_threshold = -77;
1431 static const int shorter_interval_tie_upper_threshold = -77;
1435template <
typename T>
1437 std::numeric_limits<T>::digits == 113 ||
1440 static const int exponent_bits = 15;
1444template <
typename T>
1461 return std::numeric_limits<Float>::digits != 64;
1469 : (std::numeric_limits<Float>::digits -
1473template <
typename Float>
1483 : std::numeric_limits<Float>::max_exponent - 1;
1487 auto prefix_size = 2;
1489 if (
exp < 100)
return prefix_size + 2;
1490 return prefix_size + (abs_exp >= 1000 ? 4 : 3);
1494template <
typename Char,
typename OutputIt>
1498 *out++ =
static_cast<Char
>(
'-');
1501 *out++ =
static_cast<Char
>(
'+');
1503 auto uexp =
static_cast<uint32_t
>(
exp);
1505 if (uexp < 10) *out++ =
'0';
1509 const char* top =
digits2(uexp / 100);
1510 if (uexp >= 1000u) *out++ =
static_cast<Char
>(top[0]);
1511 *out++ =
static_cast<Char
>(top[1]);
1514 const char* d =
digits2(uexp);
1515 *out++ =
static_cast<Char
>(d[0]);
1516 *out++ =
static_cast<Char
>(d[1]);
1529 constexpr basic_fp(uint64_t f_val,
int e_val) :
f(f_val),
e(e_val) {}
1535 template <
typename Float, FMT_ENABLE_IF(!is_
double_
double<Float>::value)>
1537 static_assert(std::numeric_limits<Float>::digits <= 113,
"unsupported FP");
1540 const auto num_float_significand_bits =
1542 const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;
1543 const auto significand_mask = implicit_bit - 1;
1545 f =
static_cast<F
>(u & significand_mask);
1547 num_float_significand_bits);
1550 auto is_predecessor_closer =
f == 0 && biased_e > 1;
1554 f +=
static_cast<F
>(implicit_bit);
1557 return is_predecessor_closer;
1560 template <
typename Float, FMT_ENABLE_IF(is_
double_
double<Float>::value)>
1562 static_assert(std::numeric_limits<double>::is_iec559,
"unsupported FP");
1563 return assign(
static_cast<double>(n));
1570template <
int SHIFT = 0,
typename F>
1574 const auto shifted_implicit_bit = implicit_bit << SHIFT;
1575 while ((
value.f & shifted_implicit_bit) == 0) {
1590 auto product =
static_cast<__uint128_t
>(lhs) * rhs;
1591 auto f =
static_cast<uint64_t
>(product >> 64);
1592 return (
static_cast<uint64_t
>(product) & (1ULL << 63)) != 0 ? f + 1 : f;
1595 uint64_t mask = (1ULL << 32) - 1;
1596 uint64_t a = lhs >> 32, b = lhs & mask;
1597 uint64_t c = rhs >> 32, d = rhs & mask;
1598 uint64_t ac = a * c, bc = b * c, ad = a * d, bd = b * d;
1600 uint64_t mid = (bd >> 32) + (ad & mask) + (bc & mask) + (1U << 31);
1601 return ac + (ad >> 32) + (bc >> 32) + (mid >> 32);
1606 return {
multiply(x.f, y.f), x.e + y.e + 64};
1613template <
typename T>
1618template <
typename Char,
typename OutputIt>
1621 auto fill_size = specs.fill_size();
1622 if (fill_size == 1)
return detail::fill_n(it, n, specs.fill_unit<Char>());
1623 if (
const Char* data = specs.fill<Char>()) {
1624 for (
size_t i = 0; i < n; ++i) it = copy<Char>(data, data + fill_size, it);
1632template <
typename Char,
align default_align =
align::left,
typename OutputIt,
1635 size_t size,
size_t width, F&& f) -> OutputIt {
1639 size_t padding = spec_width >
width ? spec_width -
width : 0;
1643 default_align ==
align::left ?
"\x1f\x1f\x00\x01" :
"\x00\x1f\x00\x01";
1644 size_t left_padding = padding >> shifts[
static_cast<int>(specs.align())];
1645 size_t right_padding = padding - left_padding;
1646 auto it =
reserve(out, size + padding * specs.fill_size());
1647 if (left_padding != 0) it =
fill<Char>(it, left_padding, specs);
1649 if (right_padding != 0) it =
fill<Char>(it, right_padding, specs);
1653template <
typename Char,
align default_align =
align::left,
typename OutputIt,
1656 size_t size, F&& f) -> OutputIt {
1660template <
typename Char, align default_align = align::left,
typename OutputIt>
1665 const char* data = bytes.data();
1666 return copy<Char>(data, data + bytes.size(), it);
1670template <
typename Char,
typename OutputIt,
typename UIntPtr>
1676 *it++ =
static_cast<Char
>(
'0');
1677 *it++ =
static_cast<Char
>(
'x');
1688 if (cp < 0x20 || cp == 0x7f || cp ==
'"' || cp ==
'\\')
return true;
1699template <
typename Char>
1702 for (; begin != end; ++begin) {
1704 if (
const_check(
sizeof(Char) == 1) && cp >= 0x80)
continue;
1707 return {begin,
nullptr, 0};
1717 result = {sv.
begin(), sv.
end(), cp};
1725template <
size_t w
idth,
typename Char,
typename OutputIt>
1727 *out++ =
static_cast<Char
>(
'\\');
1728 *out++ =
static_cast<Char
>(prefix);
1735template <
typename OutputIt,
typename Char>
1738 auto c =
static_cast<Char
>(
escape.cp);
1741 *out++ =
static_cast<Char
>(
'\\');
1742 c =
static_cast<Char
>(
'n');
1745 *out++ =
static_cast<Char
>(
'\\');
1746 c =
static_cast<Char
>(
'r');
1749 *out++ =
static_cast<Char
>(
'\\');
1750 c =
static_cast<Char
>(
't');
1754 case '\\': *out++ =
static_cast<Char
>(
'\\');
break;
1759 if (
escape.cp < 0x110000)
1764 static_cast<uint32_t
>(escape_char) & 0xFF);
1772template <
typename Char,
typename OutputIt>
1775 *out++ =
static_cast<Char
>(
'"');
1776 auto begin = str.begin(), end = str.end();
1783 }
while (begin != end);
1784 *out++ =
static_cast<Char
>(
'"');
1788template <
typename Char,
typename OutputIt>
1790 Char v_array[1] = {v};
1791 *out++ =
static_cast<Char
>(
'\'');
1792 if ((
needs_escape(
static_cast<uint32_t
>(v)) && v !=
static_cast<Char
>(
'"')) ||
1793 v ==
static_cast<Char
>(
'\'')) {
1796 static_cast<uint32_t
>(v)});
1800 *out++ =
static_cast<Char
>(
'\'');
1804template <
typename Char,
typename OutputIt>
1814template <
typename Char,
typename OutputIt>
1818 using unsigned_type =
1822 :
write<Char>(out, static_cast<unsigned_type>(
value), specs, loc);
1827 std::string grouping_;
1828 std::basic_string<Char> thousands_sep_;
1831 std::string::const_iterator group;
1834 auto initial_state()
const -> next_state {
return {grouping_.begin(), 0}; }
1837 auto next(next_state&
state)
const ->
int {
1839 if (
state.group == grouping_.end())
return state.pos += grouping_.back();
1847 template <
typename Locale,
1850 if (!localized)
return;
1852 grouping_ = sep.grouping;
1853 if (sep.thousands_sep) thousands_sep_.assign(1, sep.thousands_sep);
1856 : grouping_(
std::move(grouping)), thousands_sep_(
std::move(sep)) {}
1862 auto state = initial_state();
1868 template <
typename Out,
typename C>
1870 auto num_digits =
static_cast<int>(digits.size());
1872 separators.push_back(0);
1873 auto state = initial_state();
1874 while (
int i = next(
state)) {
1875 if (i >= num_digits)
break;
1876 separators.push_back(i);
1878 for (
int i = 0, sep_index =
static_cast<int>(separators.size() - 1);
1879 i < num_digits; ++i) {
1880 if (num_digits - i == separators[sep_index]) {
1882 thousands_sep_.data() + thousands_sep_.size(), out);
1885 *out++ =
static_cast<Char
>(digits[
to_unsigned(i)]);
1893 prefix += (1u + (
value > 0xff ? 1 : 0)) << 24;
1897template <
typename OutputIt,
typename UInt,
typename Char>
1901 static_assert(std::is_same<uint64_or_128_t<UInt>, UInt>
::value,
"");
1904 switch (specs.
type()) {
1935 unsigned size = (prefix != 0 ? prefix >> 24 : 0) +
to_unsigned(num_digits) +
1936 to_unsigned(grouping.count_separators(num_digits));
1939 for (
unsigned p = prefix & 0xffffff; p != 0; p >>= 8)
1940 *it++ =
static_cast<Char
>(p & 0xff);
1948 locale_ref loc) -> bool;
1950template <
typename OutputIt>
1961template <
typename T>
1967 prefix = 0x01000000 |
'-';
1968 abs_value = 0 - abs_value;
1970 constexpr unsigned prefixes[4] = {0, 0, 0x1000000u |
'+', 0x1000000u |
' '};
1971 prefix = prefixes[
static_cast<int>(s)];
1973 return {abs_value, prefix};
1983 template <
typename T, FMT_ENABLE_IF(is_
integer<T>::value)>
1991 template <
typename T, FMT_ENABLE_IF(!is_
integer<T>::value)>
2006 auto width = to_unsigned(specs.width);
2008 padding = width - size;
2011 }
else if (specs.
precision > num_digits) {
2012 size = (prefix >> 24) + to_unsigned(specs.precision);
2013 padding = to_unsigned(specs.precision - num_digits);
2018template <
typename Char,
typename OutputIt,
typename T>
2021 static_assert(std::is_same<T, uint32_or_64_or_128_t<T>>::value,
"");
2023 constexpr size_t buffer_size = num_bits<T>();
2024 char buffer[buffer_size];
2026 const char* begin =
nullptr;
2027 const char* end =
buffer + buffer_size;
2029 auto abs_value =
arg.abs_value;
2030 auto prefix =
arg.prefix;
2031 switch (specs.
type()) {
2046 auto num_digits = end - begin;
2047 if (specs.
alt() && specs.
precision <= num_digits && abs_value != 0)
2057 return write_char<Char>(out,
static_cast<Char
>(abs_value), specs);
2063 int num_digits =
static_cast<int>(end - begin);
2067 for (
unsigned p = prefix & 0xffffff; p != 0; p >>= 8)
2068 *it++ =
static_cast<Char
>(p & 0xff);
2072 unsigned padding = sp.padding;
2073 return write_padded<Char, align::right>(
2075 for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8)
2076 *it++ = static_cast<Char>(p & 0xff);
2077 it = detail::fill_n(it, padding, static_cast<Char>(
'0'));
2078 return copy<Char>(begin, end, it);
2082template <
typename Char,
typename OutputIt,
typename T>
2087 return write_int<Char>(out,
arg, specs);
2090template <
typename Char,
typename T,
2092 !std::is_same<T, bool>::value &&
2093 !std::is_same<T, Char>::value)>
2103template <
typename Char,
typename OutputIt,
typename T,
2105 !std::is_same<T, bool>::value &&
2106 !std::is_same<T, Char>::value &&
2115template <
typename Char,
typename OutputIt,
2121 auto&& it =
reserve(out, s.size());
2125 size_t display_width_limit =
2127 size_t display_width =
2128 !is_debug || specs.
precision == 0 ? 0 : 1;
2129 size_t size = !is_debug || specs.
precision == 0 ? 0 : 1;
2137 size_t cp_width = buf.
count();
2138 if (display_width + cp_width <= display_width_limit) {
2139 display_width += cp_width;
2142 if (display_width < display_width_limit && sv.
end() == s.end()) {
2149 size += display_width_limit - display_width;
2150 display_width = display_width_limit;
2155 if (cp_width + display_width <= display_width_limit) {
2156 display_width += cp_width;
2159 if (is_debug && display_width < display_width_limit &&
2160 sv.
end() == s.end()) {
2170 struct bounded_output_iterator {
2175 FMT_CONSTEXPR auto operator++() -> bounded_output_iterator& {
2178 FMT_CONSTEXPR auto operator++(
int) -> bounded_output_iterator& {
2181 FMT_CONSTEXPR auto operator=(
char c) -> bounded_output_iterator& {
2183 *underlying_iterator++ = c;
2190 return write_padded<char>(
2194 .underlying_iterator
2195 : copy<char>(s.data(), s.data() + size, it);
2199template <
typename Char,
typename OutputIt,
2203 auto data = s.data();
2204 auto size = s.size();
2210 auto buf = counting_buffer<Char>();
2215 return write_padded<Char>(
2216 out, specs, size, [&](reserve_iterator<OutputIt> it) {
2218 :
copy<Char>(data, data + size, it);
2222template <
typename Char,
typename OutputIt>
2225 return write<Char>(out, s, specs);
2228template <
typename Char,
typename OutputIt>
2232 return write_ptr<Char>(out, bit_cast<uintptr_t>(s), &specs);
2237template <
typename Char,
typename OutputIt,
typename T,
2239 !std::is_same<T, bool>::value &&
2240 !std::is_same<T, Char>::value)>
2245 if (negative) abs_value = ~abs_value + 1;
2247 auto size = (negative ? 1 : 0) +
static_cast<size_t>(num_digits);
2248 if (
auto ptr = to_pointer<Char>(out, size)) {
2249 if (negative) *
ptr++ =
static_cast<Char
>(
'-');
2250 format_decimal<Char>(
ptr, abs_value, num_digits);
2253 if (negative) *out++ =
static_cast<Char
>(
'-');
2254 return format_decimal<Char>(out, abs_value, num_digits);
2257template <
typename Char>
2263 if (end - p <= 0) p = begin;
2273 if (c ==
'}')
return begin;
2284 }
else if (p == begin) {
2293template <
typename Char,
typename OutputIt>
2297 isnan ? (specs.
upper() ?
"NAN" :
"nan") : (specs.
upper() ?
"INF" :
"inf");
2298 constexpr size_t str_size = 3;
2299 auto size = str_size + (s !=
sign::none ? 1 : 0);
2301 const bool is_zero_fill =
2303 if (is_zero_fill) specs.
set_fill(
' ');
2304 return write_padded<Char>(out, specs, size,
2308 return copy<Char>(str, str + str_size, it);
2320 return f.significand_size;
2322template <
typename T>
2327template <
typename Char,
typename OutputIt>
2329 int significand_size) -> OutputIt {
2330 return copy<Char>(significand, significand + significand_size, out);
2332template <
typename Char,
typename OutputIt,
typename UInt>
2334 int significand_size) -> OutputIt {
2335 return format_decimal<Char>(out, significand, significand_size);
2337template <
typename Char,
typename OutputIt,
typename T,
typename Grouping>
2339 int significand_size,
int exponent,
2340 const Grouping& grouping) -> OutputIt {
2341 if (!grouping.has_separator()) {
2342 out = write_significand<Char>(out, significand, significand_size);
2346 write_significand<char>(
appender(
buffer), significand, significand_size);
2351template <
typename Char,
typename UInt,
2354 int integral_size, Char decimal_point) -> Char* {
2356 out += significand_size + 1;
2358 int floating_size = significand_size - integral_size;
2359 for (
int i = floating_size / 2; i > 0; --i) {
2361 write2digits(out,
static_cast<size_t>(significand % 100));
2364 if (floating_size % 2 != 0) {
2365 *--out =
static_cast<Char
>(
'0' + significand % 10);
2373template <
typename OutputIt,
typename UInt,
typename Char,
2376 int significand_size,
int integral_size,
2377 Char decimal_point) -> OutputIt {
2379 Char
buffer[digits10<UInt>() + 2];
2385template <
typename OutputIt,
typename Char>
2387 int significand_size,
int integral_size,
2388 Char decimal_point) -> OutputIt {
2394 significand + significand_size, out);
2397template <
typename OutputIt,
typename Char,
typename T,
typename Grouping>
2399 int significand_size,
int integral_size,
2401 const Grouping& grouping) -> OutputIt {
2402 if (!grouping.has_separator()) {
2418 return std::numeric_limits<T>::digits10 != 0
2419 ?
min_of(16, std::numeric_limits<T>::digits10 + 1)
2437 template <
typename Out,
typename C>
2443template <
typename Char,
typename Grouping,
typename OutputIt,
2446 int significand_size, Char decimal_point,
2449 using iterator = reserve_iterator<OutputIt>;
2451 int exp = f.exponent + significand_size;
2452 long long size = significand_size + (s !=
sign::none ? 1 : 0);
2453 if (f.exponent >= 0) {
2457 abort_fuzzing_if(num_zeros > 5000);
2462 if (num_zeros > 0) size += num_zeros;
2464 auto grouping = Grouping(loc, specs.
localized());
2465 size += grouping.count_separators(
exp);
2466 return write_padded<Char, align::right>(
2469 it = write_significand<Char>(it, f.significand, significand_size,
2470 f.exponent, grouping);
2471 if (!specs.
alt())
return it;
2473 return num_zeros > 0 ?
detail::fill_n(it, num_zeros, Char(
'0')) : it;
2478 int num_zeros = specs.
alt() ? specs.
precision - significand_size : 0;
2479 size += 1 +
max_of(num_zeros, 0);
2480 auto grouping = Grouping(loc, specs.
localized());
2481 size += grouping.count_separators(
exp);
2482 return write_padded<Char, align::right>(
2486 decimal_point, grouping);
2487 return num_zeros > 0 ?
detail::fill_n(it, num_zeros, Char(
'0')) : it;
2491 int num_zeros = -
exp;
2492 if (significand_size == 0 && specs.
precision >= 0 &&
2496 bool pointy = num_zeros != 0 || significand_size != 0 || specs.
alt();
2497 size += 1 + (pointy ? 1 : 0) + num_zeros;
2498 return write_padded<Char, align::right>(
2502 if (!pointy)
return it;
2505 return write_significand<Char>(it, f.significand, significand_size);
2509template <
typename Char,
typename Grouping,
typename OutputIt,
2516 int exp = f.exponent + significand_size - 1;
2520 return write_fixed<Char, Grouping>(out, f, significand_size, point, specs,
2526 long long size = significand_size + (s !=
sign::none ? 1 : 0);
2530 }
else if (significand_size == 1) {
2534 char exp_char = specs.
upper() ?
'E' :
'e';
2539 if (num_zeros > 0) it =
detail::fill_n(it, num_zeros, Char(
'0'));
2540 *it++ = Char(exp_char);
2541 return write_exponent<Char>(
exp, it);
2544 return specs.
width > 0
2545 ? write_padded<Char, align::right>(out, specs, usize,
write)
2549template <
typename Char,
typename OutputIt,
typename DecimalFP>
2554 return do_write_float<Char, fallback_digit_grouping<Char>>(out, f, specs, s,
2557 return do_write_float<Char, digit_grouping<Char>>(out, f, specs, s,
2566template <
typename T,
typename Enable =
void>
2569template <
typename T>
2571 : std::true_type {};
2573template <
typename T,
2576 constexpr T inf = T(std::numeric_limits<double>::infinity());
2579 return std::isfinite(
value);
2581template <
typename T, FMT_ENABLE_IF(!has_isfinite<T>::value)>
2583 T inf = T(std::numeric_limits<double>::infinity());
2588template <
typename T, FMT_ENABLE_IF(is_
floating_po
int<T>::value)>
2591#ifdef __cpp_if_constexpr
2592 if constexpr (std::numeric_limits<double>::is_iec559) {
2594 return (bits >> (num_bits<uint64_t>() - 1)) != 0;
2598 return std::signbit(
static_cast<double>(
value));
2604 if (exp10 > 0 &&
precision > max_value<int>() - exp10)
2605 FMT_THROW(format_error(
"number is too big"));
2612 using bigit = uint32_t;
2613 using double_bigit = uint64_t;
2614 enum { bigit_bits = num_bits<bigit>() };
2615 enum { bigits_capacity = 32 };
2622 return i >= exp_ && i < num_bigits() ? bigits_[i - exp_] : 0;
2626 auto result = double_bigit(bigits_[
index]) - other - borrow;
2627 bigits_[
index] =
static_cast<bigit
>(result);
2628 borrow =
static_cast<bigit
>(result >> (bigit_bits * 2 - 1));
2632 int num_bigits =
static_cast<int>(bigits_.
size()) - 1;
2633 while (num_bigits > 0 && bigits_[num_bigits] == 0) --num_bigits;
2634 bigits_.
resize(to_unsigned(num_bigits + 1));
2639 FMT_ASSERT(other.exp_ >= exp_,
"unaligned bigints");
2642 int i = other.exp_ - exp_;
2643 for (
size_t j = 0, n = other.bigits_.size(); j != n; ++i, ++j)
2644 subtract_bigits(i, other.bigits_[j], borrow);
2645 if (borrow != 0) subtract_bigits(i, 0, borrow);
2647 remove_leading_zeros();
2652 const double_bigit wide_value =
value;
2653 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2654 double_bigit result = bigits_[i] * wide_value + carry;
2655 bigits_[i] =
static_cast<bigit
>(result);
2656 carry =
static_cast<bigit
>(result >> bigit_bits);
2658 if (carry != 0) bigits_.
push_back(carry);
2661 template <
typename UInt, FMT_ENABLE_IF(std::is_same<UInt, u
int64_t>::value ||
2662 std::is_same<UInt, u
int128_t>::value)>
2666 const int shift = num_bits<half_uint>() - bigit_bits;
2667 const UInt lower =
static_cast<half_uint
>(
value);
2668 const UInt upper =
value >> num_bits<half_uint>();
2670 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2671 UInt result = lower * bigits_[i] +
static_cast<bigit
>(carry);
2672 carry = (upper * bigits_[i] << shift) + (result >> bigit_bits) +
2673 (carry >> bigit_bits);
2674 bigits_[i] =
static_cast<bigit
>(result);
2676 while (carry != 0) {
2677 bigits_.
push_back(
static_cast<bigit
>(carry));
2678 carry >>= bigit_bits;
2682 template <
typename UInt, FMT_ENABLE_IF(std::is_same<UInt, u
int64_t>::value ||
2683 std::is_same<UInt, u
int128_t>::value)>
2685 size_t num_bigits = 0;
2687 bigits_[num_bigits++] =
static_cast<bigit
>(n);
2690 bigits_.
resize(num_bigits);
2702 auto size = other.bigits_.size();
2704 auto data = other.bigits_.data();
2705 copy<bigit>(data, data + size, bigits_.
data());
2715 return static_cast<int>(bigits_.
size()) + exp_;
2720 exp_ += shift / bigit_bits;
2721 shift %= bigit_bits;
2722 if (shift == 0)
return *
this;
2724 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2725 bigit c = bigits_[i] >> (bigit_bits - shift);
2726 bigits_[i] = (bigits_[i] << shift) + carry;
2729 if (carry != 0) bigits_.
push_back(carry);
2740 int num_bigits1 = b1.num_bigits(), num_bigits2 = b2.num_bigits();
2741 if (num_bigits1 != num_bigits2)
return num_bigits1 > num_bigits2 ? 1 : -1;
2742 int i =
static_cast<int>(b1.bigits_.size()) - 1;
2743 int j =
static_cast<int>(b2.bigits_.size()) - 1;
2745 if (end < 0) end = 0;
2746 for (; i >= end; --i, --j) {
2747 bigit b1_bigit = b1.bigits_[i], b2_bigit = b2.bigits_[j];
2748 if (b1_bigit != b2_bigit)
return b1_bigit > b2_bigit ? 1 : -1;
2750 if (i != j)
return i > j ? 1 : -1;
2756 const bigint& rhs) ->
int {
2757 int max_lhs_bigits =
max_of(lhs1.num_bigits(), lhs2.num_bigits());
2758 int num_rhs_bigits = rhs.num_bigits();
2759 if (max_lhs_bigits + 1 < num_rhs_bigits)
return -1;
2760 if (max_lhs_bigits > num_rhs_bigits)
return 1;
2761 double_bigit borrow = 0;
2762 int min_exp =
min_of(
min_of(lhs1.exp_, lhs2.exp_), rhs.exp_);
2763 for (
int i = num_rhs_bigits - 1; i >= min_exp; --i) {
2764 double_bigit sum = double_bigit(lhs1.get_bigit(i)) + lhs2.get_bigit(i);
2765 bigit rhs_bigit = rhs.get_bigit(i);
2766 if (sum > rhs_bigit + borrow)
return 1;
2767 borrow = rhs_bigit + borrow - sum;
2768 if (borrow > 1)
return -1;
2769 borrow <<= bigit_bits;
2771 return borrow != 0 ? -1 : 0;
2777 if (
exp == 0)
return *
this = 1;
2778 int bitmask = 1 << (num_bits<unsigned>() -
2784 while (bitmask != 0) {
2786 if ((
exp & bitmask) != 0) *
this *= 5;
2793 int num_bigits =
static_cast<int>(bigits_.
size());
2794 int num_result_bigits = 2 * num_bigits;
2798 for (
int bigit_index = 0; bigit_index < num_bigits; ++bigit_index) {
2801 for (
int i = 0, j = bigit_index; j >= 0; ++i, --j) {
2803 sum += double_bigit(n[i]) * n[j];
2805 bigits_[bigit_index] =
static_cast<bigit
>(sum);
2806 sum >>= num_bits<bigit>();
2809 for (
int bigit_index = num_bigits; bigit_index < num_result_bigits;
2811 for (
int j = num_bigits - 1, i = bigit_index - j; i < num_bigits;)
2812 sum += double_bigit(n[i++]) * n[j--];
2813 bigits_[bigit_index] =
static_cast<bigit
>(sum);
2814 sum >>= num_bits<bigit>();
2816 remove_leading_zeros();
2823 int exp_difference = exp_ - other.exp_;
2824 if (exp_difference <= 0)
return;
2825 int num_bigits =
static_cast<int>(bigits_.
size());
2827 for (
int i = num_bigits - 1, j = i + exp_difference; i >= 0; --i, --j)
2828 bigits_[j] = bigits_[i];
2830 exp_ -= exp_difference;
2837 if (
compare(*
this, divisor) < 0)
return 0;
2838 FMT_ASSERT(divisor.bigits_[divisor.bigits_.size() - 1u] != 0,
"");
2842 subtract_aligned(divisor);
2844 }
while (
compare(*
this, divisor) >= 0);
2860 unsigned flags,
int num_digits,
2871 bool is_predecessor_closer = (flags & dragon::predecessor_closer) != 0;
2872 int shift = is_predecessor_closer ? 2 : 1;
2874 numerator =
value.f;
2875 numerator <<=
value.e + shift;
2878 if (is_predecessor_closer) {
2880 upper_store <<=
value.e + 1;
2881 upper = &upper_store;
2884 denominator <<= shift;
2885 }
else if (exp10 < 0) {
2887 lower.assign(numerator);
2888 if (is_predecessor_closer) {
2889 upper_store.assign(numerator);
2891 upper = &upper_store;
2893 numerator *=
value.f;
2894 numerator <<= shift;
2896 denominator <<= shift -
value.e;
2898 numerator =
value.f;
2899 numerator <<= shift;
2901 denominator <<= shift -
value.e;
2903 if (is_predecessor_closer) {
2904 upper_store = 1ULL << 1;
2905 upper = &upper_store;
2908 int even =
static_cast<int>((
value.f & 1) == 0);
2909 if (!upper) upper = &lower;
2910 bool shortest = num_digits < 0;
2911 if ((flags & dragon::fixup) != 0) {
2912 if (add_compare(numerator, *upper, denominator) + even <= 0) {
2915 if (num_digits < 0) {
2917 if (upper != &lower) *upper *= 10;
2926 char* data = buf.
data();
2929 bool low =
compare(numerator, lower) - even < 0;
2931 bool high = add_compare(numerator, *upper, denominator) + even > 0;
2932 data[num_digits++] =
static_cast<char>(
'0' + digit);
2935 ++data[num_digits - 1];
2937 int result = add_compare(numerator, numerator, denominator);
2939 if (result > 0 || (result == 0 && (digit % 2) != 0))
2940 ++data[num_digits - 1];
2943 exp10 -= num_digits - 1;
2948 if (upper != &lower) *upper *= 10;
2952 exp10 -= num_digits - 1;
2953 if (num_digits <= 0) {
2955 if (num_digits == 0) {
2957 digit = add_compare(numerator, numerator, denominator) > 0 ?
'1' :
'0';
2963 for (
int i = 0; i < num_digits - 1; ++i) {
2965 buf[i] =
static_cast<char>(
'0' + digit);
2969 auto result = add_compare(numerator, numerator, denominator);
2970 if (result > 0 || (result == 0 && (digit % 2) != 0)) {
2972 const auto overflow =
'0' + 10;
2973 buf[num_digits - 1] = overflow;
2975 for (
int i = num_digits - 1; i > 0 && buf[i] == overflow; --i) {
2979 if (buf[0] == overflow) {
2981 if ((flags & dragon::fixed) != 0)
2990 buf[num_digits - 1] =
static_cast<char>(
'0' + digit);
2994template <
typename Float, FMT_ENABLE_IF(!is_
double_
double<Float>::value)>
2999 static_assert(!std::is_same<Float, float>::value,
"");
3004 using carrier_uint =
typename info::carrier_uint;
3009 f.
e += num_float_significand_bits;
3010 if (!has_implicit_bit<Float>()) --f.
e;
3012 const auto num_fraction_bits =
3013 num_float_significand_bits + (has_implicit_bit<Float>() ? 1 : 0);
3014 const auto num_xdigits = (num_fraction_bits + 3) / 4;
3016 const auto leading_shift = ((num_xdigits - 1) * 4);
3017 const auto leading_mask = carrier_uint(0xF) << leading_shift;
3018 const auto leading_xdigit =
3019 static_cast<uint32_t
>((f.
f & leading_mask) >> leading_shift);
3020 if (leading_xdigit > 1) f.
e -= (32 -
countl_zero(leading_xdigit) - 1);
3022 int print_xdigits = num_xdigits - 1;
3024 const int shift = ((print_xdigits - specs.
precision - 1) * 4);
3025 const auto mask = carrier_uint(0xF) << shift;
3026 const auto v =
static_cast<uint32_t
>((f.
f & mask) >> shift);
3029 const auto inc = carrier_uint(1) << (shift + 4);
3035 if (!has_implicit_bit<Float>()) {
3036 const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;
3037 if ((f.
f & implicit_bit) == implicit_bit) {
3046 char xdigits[num_bits<carrier_uint>() / 4];
3051 while (print_xdigits > 0 && xdigits[print_xdigits] ==
'0') --print_xdigits;
3056 if (specs.
alt() || print_xdigits > 0 || print_xdigits < specs.
precision)
3058 buf.
append(xdigits + 1, xdigits + 1 + print_xdigits);
3066 abs_e =
static_cast<uint32_t
>(-f.
e);
3069 abs_e =
static_cast<uint32_t
>(f.
e);
3074template <
typename Float, FMT_ENABLE_IF(is_
double_
double<Float>::value)>
3076 buffer<char>& buf) {
3077 format_hexfloat(
static_cast<double>(value), specs, buf);
3087 return U
"\x9999999a\x828f5c29\x80418938\x80068db9\x8000a7c6\x800010c7"
3088 U
"\x800001ae\x8000002b"[
index];
3091template <
typename Float>
3096 static_assert(!std::is_same<Float, float>::value,
"");
3111 bool use_dragon =
true;
3112 unsigned dragon_flags = 0;
3114 const auto inv_log2_10 = 0.3010299956639812;
3121 auto e = (f.e + count_digits<1>(f.f) - 1) * inv_log2_10 - 1e-10;
3122 exp =
static_cast<int>(e);
3124 dragon_flags = dragon::fixup;
3128 auto br = bit_cast<uint64_t>(
static_cast<double>(
value));
3130 const uint64_t significand_mask =
3131 (
static_cast<uint64_t
>(1) << num_significand_bits<double>()) - 1;
3132 uint64_t significand = (br & significand_mask);
3133 int exponent =
static_cast<int>((br & exponent_mask<double>()) >>
3134 num_significand_bits<double>());
3136 if (exponent != 0) {
3137 exponent -= exponent_bias<double>() + num_significand_bits<double>();
3139 (
static_cast<uint64_t
>(1) << num_significand_bits<double>());
3143 FMT_ASSERT(significand != 0,
"zeros should not appear here");
3145 FMT_ASSERT(shift >= num_bits<uint64_t>() - num_significand_bits<double>(),
3147 shift -= (num_bits<uint64_t>() - num_significand_bits<double>() - 2);
3148 exponent = (std::numeric_limits<double>::min_exponent -
3149 num_significand_bits<double>()) -
3151 significand <<= shift;
3156 const int k = info::kappa - dragonbox::floor_log10_pow2(exponent);
3158 const int beta = exponent + dragonbox::floor_log2_pow10(k);
3159 uint64_t first_segment;
3160 bool has_more_segments;
3161 int digits_in_the_first_segment;
3163 const auto r = dragonbox::umul192_upper128(
3164 significand << beta, dragonbox::get_cached_power(k));
3165 first_segment = r.high();
3166 has_more_segments = r.low() != 0;
3169 if (first_segment >= 1000000000000000000ULL) {
3170 digits_in_the_first_segment = 19;
3174 digits_in_the_first_segment = 18;
3175 first_segment *= 10;
3184 if (digits_in_the_first_segment >
precision) {
3188 exp += digits_in_the_first_segment;
3196 if ((first_segment |
static_cast<uint64_t
>(has_more_segments)) >
3197 5000000000000000000ULL) {
3214 const uint32_t first_subsegment =
static_cast<uint32_t
>(
3215 dragonbox::umul128_upper64(first_segment, 7922816251426433760ULL) >>
3217 const uint64_t second_third_subsegments =
3218 first_segment - first_subsegment * 10000000000ULL;
3222 bool should_round_up;
3226 auto print_subsegment = [&](uint32_t subsegment,
char*
buffer) {
3227 int number_of_digits_printed = 0;
3230 if ((number_of_digits_to_print & 1) != 0) {
3236 prod = ((subsegment *
static_cast<uint64_t
>(720575941)) >> 24) + 1;
3237 digits =
static_cast<uint32_t
>(prod >> 32);
3238 *
buffer =
static_cast<char>(
'0' + digits);
3239 number_of_digits_printed++;
3249 prod = ((subsegment *
static_cast<uint64_t
>(450359963)) >> 20) + 1;
3250 digits =
static_cast<uint32_t
>(prod >> 32);
3252 number_of_digits_printed += 2;
3256 while (number_of_digits_printed < number_of_digits_to_print) {
3257 prod =
static_cast<uint32_t
>(prod) *
static_cast<uint64_t
>(100);
3258 digits =
static_cast<uint32_t
>(prod >> 32);
3260 number_of_digits_printed += 2;
3265 print_subsegment(first_subsegment, buf.data());
3284 uint32_t fractional_part =
static_cast<uint32_t
>(prod);
3287 8 - number_of_digits_to_print) ||
3288 ((fractional_part >> 31) &
3289 ((digits & 1) | (second_third_subsegments != 0) |
3290 has_more_segments)) != 0;
3298 should_round_up = second_third_subsegments > 5000000000ULL ||
3299 (second_third_subsegments == 5000000000ULL &&
3300 ((digits & 1) != 0 || has_more_segments));
3309 const uint32_t second_subsegment =
3310 static_cast<uint32_t
>(dragonbox::umul128_upper64(
3311 second_third_subsegments, 1844674407370955162ULL));
3312 const uint32_t third_subsegment =
3313 static_cast<uint32_t
>(second_third_subsegments) -
3314 second_subsegment * 10;
3316 number_of_digits_to_print =
precision - 9;
3317 print_subsegment(second_subsegment, buf.data() + 9);
3324 uint32_t fractional_part =
static_cast<uint32_t
>(prod);
3327 8 - number_of_digits_to_print) ||
3328 ((fractional_part >> 31) &
3329 ((digits & 1) | (third_subsegment != 0) |
3330 has_more_segments)) != 0;
3337 should_round_up = third_subsegment > 5 ||
3338 (third_subsegment == 5 &&
3339 ((digits & 1) != 0 || has_more_segments));
3344 if (should_round_up) {
3346 for (
int i =
precision - 1; i > 0 && buf[i] >
'9'; --i) {
3363 exp += digits_in_the_first_segment - 1;
3368 bool is_predecessor_closer = binary32 ? f.assign(
static_cast<float>(
value))
3369 : f.assign(converted_value);
3370 if (is_predecessor_closer) dragon_flags |= dragon::predecessor_closer;
3371 if (
fixed) dragon_flags |= dragon::fixed;
3374 const int max_double_digits = 767;
3380 auto num_digits = buf.size();
3381 while (num_digits > 0 && buf[num_digits - 1] ==
'0') {
3385 buf.try_resize(num_digits);
3390template <
typename Char,
typename OutputIt,
typename T,
3394 if (specs.
localized() && write_loc(out, value, specs, loc))
return out;
3400 return write_nonfinite<Char>(out,
detail::isnan(value), specs, s);
3410 if (precision < 0) {
3415 auto dec = dragonbox::to_decimal(
static_cast<fast_float_t<T>
>(value));
3416 return write_float<Char>(out,
dec, specs, s, exp_upper, loc);
3424 return write_bytes<Char, align::right>(out, {buffer.
data(), buffer.
size()},
3429 if (precision == max_value<int>())
3436 }
else if (precision == 0) {
3440 std::is_same<T, float>(), buffer);
3443 auto f = big_decimal_fp{buffer.
data(),
static_cast<int>(buffer.
size()),
exp};
3444 return write_float<Char>(out, f, specs, s, exp_upper, loc);
3447template <
typename Char,
typename OutputIt,
typename T,
3453 auto mask = exponent_mask<fast_float_t<T>>();
3455 return write_nonfinite<Char>(out, std::isnan(
value), {}, s);
3457 auto dec = dragonbox::to_decimal(
static_cast<fast_float_t<T>
>(
value));
3459 int exp =
dec.exponent + significand_size - 1;
3461 return write_fixed<Char, fallback_digit_grouping<Char>>(
3462 out,
dec, significand_size, Char(
'.'), {}, s);
3466 auto has_decimal_point = significand_size != 1;
3474 has_decimal_point ? Char(
'.') : Char());
3476 it = write_exponent<Char>(
exp, it);
3480template <
typename Char,
typename OutputIt,
typename T,
3482 !is_fast_float<T>::value)>
3484 return write<Char>(out,
value, {});
3487template <
typename Char,
typename OutputIt>
3494template <
typename Char,
typename OutputIt>
3497 return copy_noinline<Char>(
value.begin(),
value.end(), out);
3500template <
typename Char,
typename OutputIt,
typename T,
3508 typename Char,
typename OutputIt,
typename T,
3509 bool check = std::is_enum<T>::value && !std::is_same<T, Char>::value &&
3510 mapped_type_constant<T, Char>::value != type::custom_type,
3516template <
typename Char,
typename OutputIt,
typename T,
3519 locale_ref = {}) -> OutputIt {
3522 ? write<Char>(out, value ? 1 : 0, specs, {})
3526template <
typename Char,
typename OutputIt>
3533template <
typename Char,
typename OutputIt>
3540template <
typename Char,
typename OutputIt,
typename T,
3543 locale_ref = {}) -> OutputIt {
3544 return write_ptr<Char>(out, bit_cast<uintptr_t>(value), &specs);
3547template <
typename Char,
typename OutputIt,
typename T,
3549 type::custom_type &&
3550 !std::is_fundamental<T>::value)>
3556 return f.format(
value, ctx);
3559template <
typename T>
3572 template <
typename T, FMT_ENABLE_IF(is_builtin<T>::value)>
3574 write<Char>(out,
value);
3577 template <
typename T, FMT_ENABLE_IF(!is_builtin<T>::value)>
3585 auto format_ctx =
context(out, {}, {});
3586 h.
format(parse_ctx, format_ctx);
3595 template <
typename T, FMT_ENABLE_IF(is_builtin<T>::value)>
3600 template <
typename T, FMT_ENABLE_IF(!is_builtin<T>::value)>
3612 template <
typename T, FMT_ENABLE_IF(is_
integer<T>::value)>
3617 template <
typename T, FMT_ENABLE_IF(!is_
integer<T>::value)>
3624template <
typename Context,
typename ID>
3626 auto arg = ctx.arg(
id);
3631template <
typename Context>
3642 return static_cast<int>(
value);
3645template <
typename Context>
3652#if FMT_USE_NONTYPE_TEMPLATE_ARGS
3653template <
typename T,
typename Char,
size_t N,
3654 fmt::detail::fixed_string<Char, N> Str>
3655struct static_named_arg : view {
3656 static constexpr auto name = Str.data;
3659 static_named_arg(
const T& v) : value(v) {}
3662template <
typename T,
typename Char,
size_t N,
3663 fmt::detail::fixed_string<Char, N> Str>
3664struct is_named_arg<static_named_arg<T, Char, N, Str>> : std::true_type {};
3666template <
typename T,
typename Char,
size_t N,
3667 fmt::detail::fixed_string<Char, N> Str>
3668struct is_static_named_arg<static_named_arg<T, Char, N, Str>> : std::true_type {
3671template <
typename Char,
size_t N, fmt::detail::fixed_
string<Char, N> Str>
3673 template <
typename T>
auto operator=(T&& value)
const {
3674 return static_named_arg<T, Char, N, Str>(std::forward<T>(value));
3682 return {str, std::forward<T>(
value)};
3691 void on_text(
const Char* begin,
const Char* end) {
3692 copy_noinline<Char>(begin, end, ctx.out());
3702 int arg_id = ctx.arg_id(
id);
3715 if (
arg.format_custom(begin, parse_ctx, ctx))
return parse_ctx.
begin();
3723 specs.precision_ref, ctx);
3735 const char* message)
noexcept;
3740template <
typename T,
typename Char, type TYPE>
3741template <
typename FormatContext>
3743 const T& val, FormatContext& ctx)
const ->
decltype(ctx.out()) {
3744 if (!specs_.dynamic())
3745 return write<Char>(ctx.out(), val, specs_, ctx.locale());
3750 specs_.precision_ref, ctx);
3751 return write<Char>(ctx.out(), val, specs, ctx.locale());
3755template <
typename T,
typename Enable =
void>
3757template <
typename T>
3768template <
typename Char>
3772 parse_format_string(
3792 template <
typename T>
3799 : out_(out), args_(args), loc_(loc) {}
3805 return args_.
get(
id);
3809 return args_.
get(name);
3812 return args_.
get_id(name);
3829 template <
typename T, FMT_ENABLE_IF(!detail::is_
float128<T>::value)>
3832 template <
typename T, FMT_ENABLE_IF(detail::is_
float128<T>::value)>
3835 template <
typename Visitor>
auto visit(Visitor&& vis) ->
decltype(vis(0)) {
3836 return value_.
visit(vis);
3844 std::string separator_;
3845 std::string grouping_;
3846 std::string decimal_point_;
3857 std::string decimal_point =
".")
3858 : separator_(sep.data(), sep.size()),
3859 grouping_(grouping),
3860 decimal_point_(decimal_point) {}
3864 return do_put(out, val, specs);
3868#define FMT_FORMAT_AS(Type, Base) \
3869 template <typename Char> \
3870 struct formatter<Type, Char> : formatter<Base, Char> { \
3871 template <typename FormatContext> \
3872 FMT_CONSTEXPR auto format(Type value, FormatContext& ctx) const \
3873 -> decltype(ctx.out()) { \
3874 return formatter<Base, Char>::format(value, ctx); \
3889template <
typename Char,
size_t N>
3892template <
typename Char,
typename Traits,
typename Allocator>
3894 :
public formatter<basic_string_view<Char>, Char> {};
3896template <
int N,
typename Char>
3898template <
int N,
typename Char>
3900 :
formatter<unsigned long long, Char> {};
3902template <
typename Char>
3905 detail::type::float_type> {};
3907template <
typename T,
typename Char>
3909 :
formatter<detail::format_as_result<T>, Char> {
3910 template <
typename FormatContext>
3912 ->
decltype(ctx.out()) {
3925template <
typename T>
auto ptr(T p) ->
const void* {
3926 static_assert(std::is_pointer<T>::value,
"fmt::ptr used with non-pointer");
3938template <
typename Enum>
3944template <
typename Enum, FMT_ENABLE_IF(std::is_enum<Enum>::value)>
3950#ifdef __cpp_lib_byte
3951template <
typename Char>
3953 static auto format_as(std::byte b) ->
unsigned char {
3954 return static_cast<unsigned char>(
b);
3956 template <
typename Context>
3957 auto format(std::byte b, Context& ctx)
const ->
decltype(ctx.out()) {
3975 return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,
3979 template <
typename FormatContext>
3980 auto format(
bytes b, FormatContext& ctx)
const ->
decltype(ctx.out()) {
3981 auto specs = specs_;
3983 specs.width_ref, ctx);
3985 specs.precision_ref, ctx);
4014 return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,
4018 template <
typename FormatContext>
4020 ->
decltype(ctx.out()) {
4021 auto specs = specs_;
4023 specs.width_ref, ctx);
4025 specs.precision_ref, ctx);
4038template <
typename T,
typename Char>
4043 template <
typename FormatContext>
4045 ->
decltype(ctx.out()) {
4046 return view.fmt->format(*view.value, ctx);
4060 auto it = ctx.begin(), end = ctx.end();
4061 if (it == end)
return it;
4067 if ((c >=
'0' && c <=
'9') || c ==
'{') {
4069 width_ = specs.
width;
4072 return formatter_.parse(ctx);
4075 template <
typename FormatContext,
typename F>
4076 auto write_padded(FormatContext& ctx, F write)
const ->
decltype(ctx.out()) {
4077 if (width_ == 0)
return write(ctx.out());
4081 specs.
width = width_;
4094#if FMT_USE_NONTYPE_TEMPLATE_ARGS
4095template <detail::fixed_
string S>
constexpr auto operator""_a() {
4119 enum { buffer_size = std::numeric_limits<unsigned long long>::digits10 + 3 };
4120 mutable char buffer_[buffer_size];
4123 template <
typename UInt>
4129 template <
typename Int>
4132 bool negative = value < 0;
4133 if (negative) abs_value = 0 - abs_value;
4134 auto begin = format_unsigned(abs_value);
4135 if (negative) *--begin =
'-';
4142 : str_(format_signed(value)) {}
4144 : str_(format_signed(value)) {}
4146 : str_(format_unsigned(value)) {}
4148 : str_(format_unsigned(value)) {}
4150 : str_(format_unsigned(value)) {}
4164 buffer_[buffer_size - 1] =
'\0';
4169 inline auto str() const ->
std::
string {
return {str_,
size()}; }
4172#define FMT_STRING_IMPL(s, base) \
4176 struct FMT_VISIBILITY("hidden") FMT_COMPILE_STRING : base { \
4177 using char_type = fmt::remove_cvref_t<decltype(s[0])>; \
4178 constexpr explicit operator fmt::basic_string_view<char_type>() const { \
4179 return fmt::detail::compile_string_to_view<char_type>(s); \
4182 using FMT_STRING_VIEW = \
4183 fmt::basic_string_view<typename FMT_COMPILE_STRING::char_type>; \
4184 fmt::detail::ignore_unused(FMT_STRING_VIEW(FMT_COMPILE_STRING())); \
4185 return FMT_COMPILE_STRING(); \
4196#define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string)
4199 -> std::system_error;
4216template <
typename... T>
4218 -> std::system_error {
4236 const char* message)
noexcept;
4242template <
typename Locale, FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
4250template <
typename Locale,
typename... T,
4257template <
typename OutputIt,
typename Locale,
4266template <
typename OutputIt,
typename Locale,
typename... T,
4271 return fmt::vformat_to(out, loc, fmt.str,
vargs<T...>{{args...}});
4274template <
typename Locale,
typename... T,
4278 T&&... args) ->
size_t {
4296template <
typename... T>
4309template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
4317template <
typename T, FMT_ENABLE_IF(detail::use_format_as<T>::value)>
4323template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value &&
4324 !detail::use_format_as<T>::value)>
4329 return {buffer.
data(), buffer.
size()};
4335#ifdef FMT_HEADER_ONLY
4336# define FMT_FUNC inline
4341#ifdef FMT_REMOVE_TRANSITIVE_INCLUDES
4342# 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
A dynamically growing memory buffer for trivially copyable/constructible types with the first SIZE el...
Definition format.h:774
const T & const_reference
Definition format.h:813
FMT_CONSTEXPR20 ~basic_memory_buffer()
Definition format.h:821
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:851
void reserve(size_t new_capacity)
Increases the buffer capacity to new_capacity.
Definition format.h:866
auto get_allocator() const -> Allocator
Definition format.h:859
FMT_CONSTEXPR20 void append(const ContiguousRange &range)
Definition format.h:870
FMT_CONSTEXPR basic_memory_buffer(const Allocator &alloc=Allocator())
Definition format.h:815
FMT_CONSTEXPR void resize(size_t count)
Resizes the buffer to contain count elements.
Definition format.h:863
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:845
T value_type
Definition format.h:812
constexpr bool dynamic() const
Definition base.h:783
FMT_CONSTEXPR void copy_fill_from(const basic_specs &specs)
Definition base.h:847
FMT_CONSTEXPR void set_fill(char c)
Definition base.h:826
constexpr auto align() const -> align
Definition base.h:760
FMT_CONSTEXPR auto dynamic_precision() const -> arg_id_kind
Definition base.h:774
constexpr auto sign() const -> sign
Definition base.h:787
FMT_CONSTEXPR void set_alt()
Definition base.h:798
constexpr auto localized() const -> bool
Definition base.h:801
constexpr auto upper() const -> bool
Definition base.h:794
constexpr auto type() const -> presentation_type
Definition base.h:753
constexpr auto alt() const -> bool
Definition base.h:797
constexpr auto dynamic_width() const -> arg_id_kind
Definition base.h:767
constexpr auto fill_unit() const -> Char
Definition base.h:819
FMT_CONSTEXPR void set_align(fmt::align a)
Definition base.h:763
constexpr auto fill_size() const -> size_t
Definition base.h:806
An implementation of std::basic_string_view for pre-C++17.
Definition base.h:518
constexpr auto end() const noexcept -> iterator
Definition base.h:566
constexpr auto size() const noexcept -> size_t
Returns the string size.
Definition base.h:563
constexpr auto data() const noexcept -> const Char *
Returns a pointer to the string data.
Definition base.h:560
constexpr auto begin() const noexcept -> iterator
Definition base.h:565
FMT_CONSTEXPR void align(const bigint &other)
Definition format.h:2822
FMT_CONSTEXPR auto operator<<=(int shift) -> bigint &
Definition format.h:2718
FMT_CONSTEXPR20 void square()
Definition format.h:2792
FMT_CONSTEXPR bigint()
Definition format.h:2695
FMT_CONSTEXPR auto operator*=(Int value) -> bigint &
Definition format.h:2733
FMT_CONSTEXPR void operator=(Int n)
Definition format.h:2709
FMT_CONSTEXPR void assign(const bigint &other)
Definition format.h:2701
void operator=(const bigint &)=delete
bigint(uint64_t n)
Definition format.h:2696
FMT_CONSTEXPR20 void assign_pow10(int exp)
Definition format.h:2775
friend FMT_CONSTEXPR auto compare(const bigint &b1, const bigint &b2) -> int
Definition format.h:2739
FMT_CONSTEXPR auto num_bigits() const -> int
Definition format.h:2714
friend FMT_CONSTEXPR auto add_compare(const bigint &lhs1, const bigint &lhs2, const bigint &rhs) -> int
Definition format.h:2755
FMT_CONSTEXPR auto divmod_assign(const bigint &divisor) -> int
Definition format.h:2835
bigint(const bigint &)=delete
A contiguous memory buffer with an optional growing ability.
Definition base.h:1746
FMT_CONSTEXPR20 void append(const U *begin, const U *end)
Appends data to the end of the buffer.
Definition base.h:1828
FMT_CONSTEXPR void push_back(const T &value)
Definition base.h:1815
constexpr auto size() const noexcept -> size_t
Returns the size of this buffer.
Definition base.h:1788
FMT_CONSTEXPR void try_reserve(size_t new_capacity)
Definition base.h:1811
auto end() noexcept -> T *
Definition base.h:1782
FMT_CONSTEXPR void try_resize(size_t count)
Definition base.h:1802
constexpr auto capacity() const noexcept -> size_t
Returns the capacity of this buffer.
Definition base.h:1791
FMT_CONSTEXPR auto data() noexcept -> T *
Returns a pointer to the buffer data (not null-terminated).
Definition base.h:1794
constexpr auto count() const noexcept -> size_t
Definition base.h:2018
auto apply(Out out, basic_string_view< C > digits) const -> Out
Definition format.h:1869
digit_grouping(std::string grouping, std::basic_string< Char > sep)
Definition format.h:1855
auto has_separator() const -> bool
Definition format.h:1858
digit_grouping(Locale loc, bool localized=true)
Definition format.h:1849
auto count_separators(int num_digits) const -> int
Definition format.h:1860
constexpr auto has_separator() const -> bool
Definition format.h:2433
constexpr auto count_separators(int) const -> int
Definition format.h:2435
constexpr fallback_digit_grouping(locale_ref, bool)
Definition format.h:2431
constexpr auto apply(Out out, basic_string_view< C >) const -> Out
Definition format.h:2438
static auto convert(Buffer &buf, basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort) -> bool
Definition format.h:1302
auto convert(basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort) -> bool
Definition format.h:1295
to_utf8(basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort)
Definition format.h:1279
to_utf8()
Definition format.h:1278
auto c_str() const -> const char *
Definition format.h:1289
auto size() const -> size_t
Definition format.h:1288
auto str() const -> std::string
Definition format.h:1290
FMT_CONSTEXPR auto operator>>=(int shift) -> uint128_fallback &
Definition format.h:373
constexpr uint128_fallback(uint64_t hi, uint64_t lo)
Definition format.h:307
FMT_CONSTEXPR auto operator>>(int shift) const -> uint128_fallback
Definition format.h:363
friend constexpr auto operator==(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition format.h:318
friend FMT_CONSTEXPR auto operator*(const uint128_fallback &lhs, uint32_t rhs) -> uint128_fallback
Definition format.h:351
friend constexpr auto operator|(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition format.h:330
friend constexpr auto operator-(const uint128_fallback &lhs, uint64_t rhs) -> uint128_fallback
Definition format.h:359
FMT_CONSTEXPR auto operator<<(int shift) const -> uint128_fallback
Definition format.h:368
friend constexpr auto operator!=(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition format.h:322
friend constexpr auto operator~(const uint128_fallback &n) -> uint128_fallback
Definition format.h:340
friend FMT_CONSTEXPR auto operator+(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition format.h:344
friend constexpr auto operator>(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition format.h:326
constexpr uint128_fallback(uint64_t value=0)
Definition format.h:308
constexpr auto high() const noexcept -> uint64_t
Definition format.h:310
FMT_CONSTEXPR void operator+=(uint128_fallback n)
Definition format.h:376
friend constexpr auto operator&(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition format.h:335
FMT_CONSTEXPR20 auto operator+=(uint64_t n) noexcept -> uint128_fallback &
Definition format.h:388
FMT_CONSTEXPR void operator&=(uint128_fallback n)
Definition format.h:383
constexpr auto low() const noexcept -> uint64_t
Definition format.h:311
FMT_API utf8_to_utf16(string_view s)
Definition format-inl.h:1411
auto size() const -> size_t
Definition format.h:1265
auto c_str() const -> const wchar_t *
Definition format.h:1266
auto str() const -> std::wstring
Definition format.h:1267
generic_context(const generic_context &)=delete
void operator=(const generic_context &)=delete
constexpr auto locale() const -> detail::locale_ref
Definition format.h:3821
constexpr auto out() const -> iterator
Definition format.h:3815
generic_context(generic_context &&)=default
void advance_to(iterator it)
Definition format.h:3817
@ builtin_types
Definition format.h:3794
auto arg(basic_string_view< Char > name) const -> basic_format_arg< generic_context >
Definition format.h:3807
OutputIt iterator
Definition format.h:3790
constexpr auto arg_id(basic_string_view< Char > name) const -> int
Definition format.h:3811
constexpr auto arg(int id) const -> basic_format_arg< generic_context >
Definition format.h:3804
Char char_type
Definition format.h:3789
constexpr generic_context(OutputIt out, basic_format_args< generic_context > args, detail::locale_ref loc={})
Definition format.h:3796
loc_value(T)
Definition format.h:3833
loc_value(T value)
Definition format.h:3830
auto visit(Visitor &&vis) -> decltype(vis(0))
Definition format.h:3835
Parsing context consisting of a format string range being parsed and an argument counter for automati...
Definition base.h:866
constexpr auto begin() const noexcept -> iterator
Returns an iterator to the beginning of the format string range being parsed.
Definition base.h:885
FMT_CONSTEXPR void check_arg_id(int id)
Reports an error if using the automatic argument indexing; otherwise switches to the manual indexing.
Definition base.h:909
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:897
std::string & str()
Definition format.h:917
string_buffer()
Definition format.h:914
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:900
writer(detail::buffer< char > &buf)
Definition format.h:896
writer(FILE *f)
Definition format.h:895
FMT_API auto get_cached_power(int k) noexcept -> uint128_fallback
Definition format-inl.h:1139
auto floor_log10_pow2(int e) noexcept -> int
Definition format.h:1373
auto floor_log2_pow10(int e) noexcept -> int
Definition format.h:1379
FMT_API auto to_decimal(T x) noexcept -> decimal_fp< T >
Definition format-inl.h:1259
auto umul128_upper64(uint64_t x, uint64_t y) noexcept -> uint64_t
Definition format.h:1385
auto umul192_upper128(uint64_t x, uint128_fallback y) noexcept -> uint128_fallback
Definition format.h:1398
detail namespace with internal helper functions
Definition input_adapters.h:32
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:978
FMT_CONSTEXPR auto display_width_of(uint32_t cp) noexcept -> size_t
Definition format.h:662
uint128_t uintptr_t
Definition format.h:419
FMT_CONSTEXPR auto code_point_length(const Char *begin) -> int
Definition base.h:1286
auto get_iterator(Buf &buf, OutputIt) -> decltype(buf.out())
Definition base.h:2109
constexpr auto digits10< int128_opt >() noexcept -> int
Definition format.h:1112
FMT_CONSTEXPR FMT_NOINLINE auto write_int_noinline(OutputIt out, write_int_arg< T > arg, const format_specs &specs) -> OutputIt
Definition format.h:2083
FMT_CONSTEXPR20 auto isfinite(T value) -> bool
Definition format.h:2575
FMT_CONSTEXPR auto do_format_base2e(int base_bits, Char *out, UInt value, int size, bool upper=false) -> Char *
Definition format.h:1219
FMT_CONSTEXPR auto compare(const Char *s1, const Char *s2, size_t n) -> int
Definition base.h:470
conditional_t< long_short, int, long long > long_type
Definition base.h:1109
FMT_CONSTEXPR auto write_padded(OutputIt out, const format_specs &specs, size_t size, size_t width, F &&f) -> OutputIt
Definition format.h:1634
constexpr auto to_ascii(Char c) -> char
Definition base.h:1280
constexpr auto fractional_part_rounding_thresholds(int index) -> uint32_t
Definition format.h:3080
FMT_CONSTEXPR20 auto bit_cast(const From &from) -> To
Definition format.h:277
FMT_CONSTEXPR FMT_NOINLINE auto fill(OutputIt it, size_t n, const basic_specs &specs) -> OutputIt
Definition format.h:1619
FMT_CONSTEXPR auto operator*(fp x, fp y) -> fp
Definition format.h:1605
FMT_CONSTEXPR int get_dynamic_spec(arg_id_kind kind, const arg_ref< typename Context::char_type > &ref, Context &ctx)
Definition format.h:3632
FMT_CONSTEXPR void ignore_unused(const T &...)
Definition base.h:363
auto decimal_point(locale_ref loc) -> Char
Definition format.h:1134
FMT_INLINE void assume(bool condition)
Definition format.h:476
constexpr auto num_bits< uint128_fallback >() -> int
Definition format.h:433
constexpr auto use_fixed(int exp, int exp_upper) -> bool
Definition format.h:2425
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:694
void(*)(detail::buffer< char > &, int, const char *) format_func
Definition format.h:3733
constexpr auto has_implicit_bit() -> bool
Definition format.h:1459
constexpr auto num_bits() -> int
Definition format.h:427
uint128_opt
Definition base.h:416
FMT_CONSTEXPR void prefix_append(unsigned &prefix, unsigned value)
Definition format.h:1891
auto is_big_endian() -> bool
Definition format.h:287
FMT_CONSTEXPR auto write(OutputIt out, Char value, const format_specs &specs, locale_ref loc={}) -> OutputIt
Definition format.h:1815
FMT_CONSTEXPR auto count_digits_fallback(T n) -> int
Definition format.h:1009
conditional_t< FMT_USE_INT128, uint128_opt, uint128_fallback > uint128_t
Definition format.h:414
FMT_CONSTEXPR auto get_arg(Context &ctx, ID id) -> basic_format_arg< Context >
Definition format.h:3625
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const format_specs &specs={}) -> OutputIt
Definition format.h:1661
constexpr auto digits10() noexcept -> int
Definition format.h:1109
dragon
Definition format.h:2850
@ fixup
Definition format.h:2852
@ predecessor_closer
Definition format.h:2851
conditional_t< long_short, unsigned, unsigned long long > ulong_type
Definition base.h:1110
FMT_API void print(FILE *, string_view)
constexpr auto digits10< uint128_t >() noexcept -> int
Definition format.h:1113
FMT_CONSTEXPR20 void adjust_precision(int &precision, int exp10)
Definition format.h:2601
constexpr auto max_value() -> T
Definition format.h:424
typename std::enable_if< B, T >::type enable_if_t
Definition cpp_future.h:38
int128_opt
Definition base.h:415
FMT_CONSTEXPR auto make_write_int_arg(T value, sign s) -> write_int_arg< uint32_or_64_or_128_t< T > >
Definition format.h:1962
@ value
the parser finished reading a JSON value
FMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t< Int >
Definition base.h:437
FMT_END_EXPORT auto equal2(const Char *lhs, const char *rhs) -> bool
Definition format.h:1153
constexpr FMT_INLINE_VARIABLE uint32_t invalid_code_point
Definition format.h:623
auto write_ptr(OutputIt out, UIntPtr value, const format_specs *specs) -> OutputIt
Definition format.h:1671
@ use_utf8
Definition base.h:457
auto write_int(OutputIt out, UInt value, unsigned prefix, const format_specs &specs, const digit_grouping< Char > &grouping) -> OutputIt
Definition format.h:1898
auto base_iterator(OutputIt it, typename OutputIt::container_type::value_type *) -> OutputIt
Definition format.h:535
FMT_API auto decimal_point_impl(locale_ref loc) -> Char
Definition format-inl.h:117
FMT_CONSTEXPR auto check_char_specs(const format_specs &specs) -> bool
Definition base.h:1649
constexpr auto to_pointer(OutputIt, size_t) -> T *
Definition format.h:519
auto write_loc(OutputIt, const loc_value &, const format_specs &, locale_ref) -> bool
Definition format.h:1951
to_utf8_error_policy
Definition format.h:1270
FMT_API void format_error_code(buffer< char > &out, int error_code, string_view message) noexcept
Definition format-inl.h:43
auto digits2(size_t value) -> const char *
Definition format.h:992
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:2550
conditional_t< std::is_same< T, float >::value||doublish, double, T > convert_float_result
Definition format.h:1610
FMT_CONSTEXPR auto multiply(uint64_t lhs, uint64_t rhs) -> uint64_t
Definition format.h:1588
FMT_API auto is_printable(uint32_t cp) -> bool
Definition format-inl.h:1795
FMT_CONSTEXPR20 void format_hexfloat(Float value, format_specs specs, buffer< char > &buf)
Definition format.h:2995
FMT_CONSTEXPR FMT_NOINLINE auto copy_noinline(InputIt begin, InputIt end, OutputIt out) -> OutputIt
Definition format.h:564
constexpr auto is_constant_evaluated(bool default_value=false) noexcept -> bool
Definition base.h:365
FMT_API auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result< Char >
Definition format-inl.h:110
template FMT_API auto thousands_sep_impl< wchar_t >(locale_ref) -> thousands_sep_result< wchar_t >
@ error
throw a parse_error exception in case of a tag
auto write_escaped_char(OutputIt out, Char v) -> OutputIt
Definition format.h:1789
constexpr auto num_bits< int128_opt >() -> int
Definition format.h:431
auto thousands_sep(locale_ref loc) -> thousands_sep_result< Char >
Definition format.h:1123
FMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
Definition format.h:549
FMT_ALWAYS_INLINE constexpr auto const_check(T val) -> T
Definition base.h:382
constexpr auto exponent_bias() -> int
Definition format.h:1480
constexpr auto num_significand_bits() -> int
Definition format.h:1466
FMT_CONSTEXPR auto parse_width(const Char *begin, const Char *end, format_specs &specs, arg_ref< Char > &width_ref, parse_context< Char > &ctx) -> const Char *
Definition base.h:1416
bool_constant< std::is_same< T, int >::value||FMT_BUILTIN_TYPES > is_builtin
Definition format.h:3560
FMT_API auto write_console(int fd, string_view text) -> bool
Definition format-inl.h:1696
FMT_CONSTEXPR20 auto copy(InputIt begin, InputIt end, OutputIt out) -> OutputIt
Definition base.h:2051
remove_reference_t< decltype(reserve(std::declval< OutputIt & >(), 0))> reserve_iterator
Definition format.h:515
FMT_CONSTEXPR auto write_exponent(int exp, OutputIt out) -> OutputIt
Definition format.h:1495
FMT_CONSTEXPR auto utf8_decode(const char *s, uint32_t *c, int *e) -> const char *
Definition format.h:586
FMT_CONSTEXPR void abort_fuzzing_if(bool condition)
Definition format.h:249
constexpr auto getsign(sign s) -> Char
Definition format.h:1004
std::integral_constant< bool, std::numeric_limits< T >::is_signed|| std::is_same< T, int128_opt >::value > is_signed
Definition format.h:689
FMT_CONSTEXPR20 auto write_nonfinite(OutputIt out, bool isnan, format_specs specs, sign s) -> OutputIt
Definition format.h:2294
typename make_void< Ts... >::type void_t
Definition void_t.h:21
constexpr auto write_significand(OutputIt out, const char *significand, int significand_size) -> OutputIt
Definition format.h:2328
auto write_escaped_cp(OutputIt out, const find_escape_result< Char > &escape) -> OutputIt
Definition format.h:1736
FMT_CONSTEXPR auto parse_align(const Char *begin, const Char *end, format_specs &specs) -> const Char *
Definition format.h:2258
constexpr auto get_significand_size(const big_decimal_fp &f) -> int
Definition format.h:2319
FMT_CONSTEXPR auto format_base2e(int base_bits, Char *out, UInt value, int num_digits, bool upper=false) -> Char *
Definition format.h:1233
FMT_CONSTEXPR auto write_char(OutputIt out, Char value, const format_specs &specs) -> OutputIt
Definition format.h:1805
FMT_CONSTEXPR auto compute_exp_size(int exp) -> int
Definition format.h:1486
auto needs_escape(uint32_t cp) -> bool
Definition format.h:1687
constexpr auto convert_float(T value) -> convert_float_result< T >
Definition format.h:1614
auto write_codepoint(OutputIt out, char prefix, uint32_t cp) -> OutputIt
Definition format.h:1726
typename V::value_type char_t
String's character (code unit) type. detail:: is intentional to prevent ADL.
Definition base.h:956
constexpr auto to_string_view(const Char *s) -> basic_string_view< Char >
Definition base.h:931
FMT_CONSTEXPR void handle_dynamic_spec(arg_id_kind kind, int &value, const arg_ref< typename Context::char_type > &ref, Context &ctx)
Definition format.h:3646
std::integral_constant< bool, Value > bool_constant
Definition type_traits.h:743
conditional_t< num_bits< T >()<=64, uint64_t, uint128_t > uint64_or_128_t
Definition format.h:983
state
Definition base.h:1440
FMT_CONSTEXPR void for_each_codepoint(string_view s, F f)
Definition format.h:628
FMT_CONSTEVAL auto exp_upper() -> int
Definition format.h:2417
FMT_CONSTEXPR20 auto reserve(OutputIt it, size_t n) -> typename OutputIt::value_type *
Definition format.h:494
FMT_EXPORT constexpr auto compile_string_to_view(const Char(&s)[N]) -> basic_string_view< Char >
Definition format.h:952
FMT_CONSTEXPR20 auto countl_zero_fallback(UInt n) -> int
Definition format.h:455
constexpr auto is_negative(T value) -> bool
Definition format.h:967
std::is_same< T, float128 > is_float128
Definition format.h:715
FMT_API void do_report_error(format_func func, int error_code, const char *message) noexcept
Definition format-inl.h:66
auto get_buffer(OutputIt out) -> iterator_buffer< OutputIt, T >
Definition base.h:2099
auto find_escape(const Char *begin, const Char *end) -> find_escape_result< Char >
Definition format.h:1700
FMT_CONSTEXPR20 auto format_float(Float value, int precision, const format_specs &specs, bool binary32, buffer< char > &buf) -> int
Definition format.h:3092
FMT_CONSTEXPR20 FMT_INLINE void write2digits(Char *out, size_t value)
Definition format.h:1162
constexpr auto num_bits< uint128_opt >() -> int
Definition format.h:432
constexpr auto count() -> int
Definition base.h:1054
FMT_CONSTEXPR20 auto do_format_decimal(Char *out, UInt value, int size) -> Char *
Definition format.h:1175
FMT_CONSTEXPR20 auto count_digits(uint64_t n) -> int
Definition format.h:1052
void vformat_to(buffer< Char > &buf, basic_string_view< Char > fmt, typename vformat_args< Char >::type args, locale_ref loc={})
Definition format.h:3769
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:443
constexpr auto exponent_mask() -> typename dragonbox::float_info< Float >::carrier_uint
Definition format.h:1474
FMT_CONSTEXPR FMT_INLINE auto format_decimal(Char *out, UInt value, int num_digits) -> Char *
Definition format.h:1197
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:2511
FMT_CONSTEXPR20 auto countl_zero(uint32_t n) -> int
Definition format.h:462
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition string_escape.h:50
FMT_CONSTEXPR20 void format_dragon(basic_fp< uint128_t > value, unsigned flags, int num_digits, buffer< char > &buf, int &exp10)
Definition format.h:2859
auto write_escaped_string(OutputIt out, basic_string_view< Char > str) -> OutputIt
Definition format.h:1773
auto umul128(uint64_t x, uint64_t y) noexcept -> uint128_fallback
Definition format.h:1342
FMT_CONSTEXPR20 auto get_container(OutputIt it) -> typename OutputIt::container_type &
Definition base.h:498
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:2445
FMT_CONSTEXPR auto normalize(basic_fp< F > value) -> basic_fp< F >
Definition format.h:1571
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:1444
constexpr auto isnan(T value) -> bool
Definition format.h:2562
FMT_INLINE FMT_CONSTEXPR bool signbit(T value)
Definition format.h:2589
constexpr auto format_as(Enum e) noexcept -> underlying_t< Enum >
Definition format.h:3945
Definition PointerIntPair.h:280
bytes(string_view s)
Definition format.h:3966
string_view data
Definition format.h:3964
FMT_CONSTEXPR basic_fp(Float n)
Definition format.h:1532
constexpr basic_fp(uint64_t f_val, int e_val)
Definition format.h:1529
FMT_CONSTEXPR auto assign(Float n) -> bool
Definition format.h:1536
constexpr basic_fp()
Definition format.h:1528
int e
Definition format.h:1523
static constexpr int num_significand_bits
Definition format.h:1525
F f
Definition format.h:1522
const char * significand
Definition format.h:2314
int significand_size
Definition format.h:2315
int exponent
Definition format.h:2316
int exponent
Definition format.h:1452
significand_type significand
Definition format.h:1451
typename float_info< T >::carrier_uint significand_type
Definition format.h:1450
detail::uint128_t carrier_uint
Definition format.h:1446
detail::uint128_t carrier_uint
Definition format.h:1439
uint64_t carrier_uint
Definition format.h:1423
uint32_t carrier_uint
Definition format.h:1411
FMT_CONSTEXPR auto operator()(T) -> unsigned long long
Definition format.h:3618
FMT_CONSTEXPR auto operator()(T value) -> unsigned long long
Definition format.h:3613
const Char * end
Definition format.h:1695
const Char * begin
Definition format.h:1694
uint32_t cp
Definition format.h:1696
Char data[N]
Definition format.h:947
FMT_CONSTEXPR20 fixed_string(const Char(&s)[N])
Definition format.h:943
std::string grouping
Definition format.h:1980
auto operator()(T value) -> bool
Definition format.h:1984
auto operator()(T) -> bool
Definition format.h:1992
std::basic_string< Char > decimal_point
Definition format.h:1981
const format_specs & specs
Definition format.h:1978
std::basic_string< Char > sep
Definition format.h:1979
basic_appender< Char > out
Definition format.h:1977
Definition format-inl.h:92
FMT_CONSTEXPR size_padding(int num_digits, unsigned prefix, const format_specs &specs)
Definition format.h:2002
unsigned padding
Definition format.h:2000
unsigned size
Definition format.h:1999
static constexpr Char value[sizeof...(C)]
Definition format.h:265
Char thousands_sep
Definition format.h:1117
std::string grouping
Definition format.h:1116
const Char * str
Definition format.h:3679
auto operator=(T &&value) const -> named_arg< Char, T >
Definition format.h:3681
unsigned prefix
Definition format.h:1958
UInt abs_value
Definition format.h:1957
T value
Definition format.h:3992
const T * value
Definition format.h:4035
const formatter< T, Char > * fmt
Definition format.h:4034
void pointer
Definition format.h:155
void reference
Definition format.h:156
output_iterator_tag iterator_category
Definition format.h:151
decltype(static_cast< int * >(nullptr) - static_cast< int * >(nullptr)) difference_type
Definition format.h:153
T value_type
Definition format.h:152
int index
Definition base.h:1266
basic_string_view< Char > name
Definition base.h:1267
#define S(label, offset, message)
Definition Errors.h:113
#define FMT_ASSERT(condition, message)
Definition base.h:396
#define FMT_END_EXPORT
Definition base.h:272
#define FMT_BUILTIN_TYPES
Definition base.h:301
#define FMT_PRAGMA_CLANG(x)
Definition base.h:230
#define FMT_CONSTEVAL
Definition base.h:140
basic_string_view< char > string_view
Definition base.h:616
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:2844
constexpr auto min_of(T a, T b) -> T
Definition base.h:352
#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:317
typename fstring< T... >::t format_string
Definition base.h:2789
#define FMT_GCC_VERSION
Definition base.h:35
#define FMT_OPTIMIZE_SIZE
Definition base.h:295
basic_appender< char > appender
Definition base.h:632
typename std::remove_cv< remove_reference_t< T > >::type remove_cvref_t
Definition base.h:321
constexpr auto max_of(T a, T b) -> T
Definition base.h:355
#define FMT_CONSTEXPR
Definition base.h:113
align
Definition base.h:697
arg_id_kind
Definition base.h:699
#define FMT_BEGIN_NAMESPACE
Definition base.h:261
sign
Definition base.h:698
conditional_t< std::is_same< OutputIt, appender >::value, context, generic_context< OutputIt, Char > > basic_format_context
Definition base.h:645
#define FMT_API
Definition base.h:291
#define FMT_ENABLE_IF(...)
Definition base.h:349
#define FMT_BEGIN_EXPORT
Definition base.h:271
void void_t
Definition base.h:336
#define FMT_INLINE
Definition base.h:255
#define FMT_NO_UNIQUE_ADDRESS
Definition base.h:175
basic_format_args< context > format_args
Definition base.h:660
#define FMT_NORETURN
Definition base.h:193
#define FMT_MSC_WARNING(...)
Definition base.h:235
typename std::conditional< B, T, F >::type conditional_t
Definition base.h:314
#define FMT_CONSTEXPR20
Definition base.h:141
typename std::underlying_type< T >::type underlying_t
Definition base.h:325
#define FMT_END_NAMESPACE
Definition base.h:264
conditional_t< std::is_same< Char, char >::value, context, generic_context< basic_appender< Char >, Char > > buffered_context
Definition base.h:651
#define FMT_EXPORT
Definition base.h:270