39#include <initializer_list>
43#include <system_error>
45#ifdef __cpp_lib_bit_cast
51#if defined __cpp_inline_variables && __cpp_inline_variables >= 201606L
52# define FMT_INLINE_VARIABLE inline
54# define FMT_INLINE_VARIABLE
57#if FMT_HAS_CPP17_ATTRIBUTE(fallthrough)
58# define FMT_FALLTHROUGH [[fallthrough]]
59#elif defined(__clang__)
60# define FMT_FALLTHROUGH [[clang::fallthrough]]
61#elif FMT_GCC_VERSION >= 700 && \
62 (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 520)
63# define FMT_FALLTHROUGH [[gnu::fallthrough]]
65# define FMT_FALLTHROUGH
69# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VERSION >= 1900
70# define FMT_DEPRECATED [[deprecated]]
72# if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__)
73# define FMT_DEPRECATED __attribute__((deprecated))
75# define FMT_DEPRECATED __declspec(deprecated)
77# define FMT_DEPRECATED
82#ifndef FMT_NO_UNIQUE_ADDRESS
83# if FMT_CPLUSPLUS >= 202002L
84# if FMT_HAS_CPP_ATTRIBUTE(no_unique_address)
85# define FMT_NO_UNIQUE_ADDRESS [[no_unique_address]]
87# elif (FMT_MSC_VERSION >= 1929) && !FMT_CLANG_VERSION
88# define FMT_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
92#ifndef FMT_NO_UNIQUE_ADDRESS
93# define FMT_NO_UNIQUE_ADDRESS
96#if FMT_GCC_VERSION || defined(__clang__)
97# define FMT_VISIBILITY(value) __attribute__((visibility(value)))
99# define FMT_VISIBILITY(value)
103# define FMT_HAS_BUILTIN(x) __has_builtin(x)
105# define FMT_HAS_BUILTIN(x) 0
108#if FMT_GCC_VERSION || FMT_CLANG_VERSION
109# define FMT_NOINLINE __attribute__((noinline))
116# if FMT_MSC_VERSION || defined(__NVCC__)
119template <
typename Exception>
inline void do_throw(
const Exception& x) {
122 volatile bool b =
true;
127# define FMT_THROW(x) detail::do_throw(x)
129# define FMT_THROW(x) throw x
132# define FMT_THROW(x) \
133 ::fmt::detail::assert_fail(__FILE__, __LINE__, (x).what())
139# define FMT_CATCH(x) catch (x)
141# define FMT_TRY if (true)
142# define FMT_CATCH(x) if (false)
145#ifndef FMT_MAYBE_UNUSED
146# if FMT_HAS_CPP17_ATTRIBUTE(maybe_unused)
147# define FMT_MAYBE_UNUSED [[maybe_unused]]
149# define FMT_MAYBE_UNUSED
153#ifndef FMT_USE_USER_DEFINED_LITERALS
155# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \
156 FMT_MSC_VERSION >= 1900) && \
157 (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 480)
158# define FMT_USE_USER_DEFINED_LITERALS 1
160# define FMT_USE_USER_DEFINED_LITERALS 0
168#if !defined(FMT_REDUCE_INT_INSTANTIATIONS)
169# define FMT_REDUCE_INT_INSTANTIATIONS 0
175# if FMT_HAS_BUILTIN(__builtin_clz) || FMT_GCC_VERSION || FMT_ICC_VERSION
176# define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
178# if FMT_HAS_BUILTIN(__builtin_clzll) || FMT_GCC_VERSION || FMT_ICC_VERSION
179# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
186# if FMT_HAS_BUILTIN(__builtin_ctz) || FMT_GCC_VERSION || FMT_ICC_VERSION || \
187 defined(__NVCOMPILER)
188# define FMT_BUILTIN_CTZ(n) __builtin_ctz(n)
190# if FMT_HAS_BUILTIN(__builtin_ctzll) || FMT_GCC_VERSION || \
191 FMT_ICC_VERSION || defined(__NVCOMPILER)
192# define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n)
203#if FMT_MSC_VERSION && !defined(FMT_BUILTIN_CLZLL) && \
204 !defined(FMT_BUILTIN_CTZLL)
208# if !defined(__clang__)
209# pragma intrinsic(_BitScanForward)
210# pragma intrinsic(_BitScanReverse)
212# pragma intrinsic(_BitScanForward64)
213# pragma intrinsic(_BitScanReverse64)
217inline auto clz(uint32_t x) ->
int {
219 _BitScanReverse(&r, x);
225 return 31 ^
static_cast<int>(r);
227# define FMT_BUILTIN_CLZ(n) detail::clz(n)
229inline auto clzll(uint64_t x) ->
int {
232 _BitScanReverse64(&r, x);
235 if (_BitScanReverse(&r,
static_cast<uint32_t
>(x >> 32)))
236 return 63 ^
static_cast<int>(r + 32);
238 _BitScanReverse(&r,
static_cast<uint32_t
>(x));
242 return 63 ^
static_cast<int>(r);
244# define FMT_BUILTIN_CLZLL(n) detail::clzll(n)
246inline auto ctz(uint32_t x) ->
int {
248 _BitScanForward(&r, x);
251 return static_cast<int>(r);
253# define FMT_BUILTIN_CTZ(n) detail::ctz(n)
255inline auto ctzll(uint64_t x) ->
int {
260 _BitScanForward64(&r, x);
263 if (_BitScanForward(&r,
static_cast<uint32_t
>(x)))
return static_cast<int>(r);
265 _BitScanForward(&r,
static_cast<uint32_t
>(x >> 32));
268 return static_cast<int>(r);
270# define FMT_BUILTIN_CTZLL(n) detail::ctzll(n)
279template <
typename P1,
typename... Pn>
285template <
typename P1,
typename... Pn>
294 if (condition)
throw std::runtime_error(
"fuzzing limit reached");
299 static constexpr CharT
value[
sizeof...(C)] = {C...};
301 return {
value,
sizeof...(C)};
305#if FMT_CPLUSPLUS < 201703L
306template <
typename CharT, CharT... C>
307constexpr CharT string_literal<CharT, C...>::value[
sizeof...(C)];
310template <
typename Streambuf>
class formatbuf :
public Streambuf {
312 using char_type =
typename Streambuf::char_type;
313 using streamsize =
decltype(std::declval<Streambuf>().sputn(
nullptr, 0));
314 using int_type =
typename Streambuf::int_type;
315 using traits_type =
typename Streambuf::traits_type;
330 if (!traits_type::eq_int_type(ch, traits_type::eof()))
331 buffer_.
push_back(
static_cast<char_type
>(ch));
335 auto xsputn(
const char_type* s, streamsize
count) -> streamsize
override {
342template <
typename To,
typename From, FMT_ENABLE_IF(sizeof(To) == sizeof(From))>
344#ifdef __cpp_lib_bit_cast
349 std::memcpy(
static_cast<void*
>(&to), &
from,
sizeof(to));
356#elif defined(__BIG_ENDIAN__)
358#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
359 return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;
362 char data[
sizeof(int)];
364 return bit_cast<bytes>(1).data[0] == 0;
376 constexpr uint64_t
high() const noexcept {
return hi_; }
377 constexpr uint64_t
low() const noexcept {
return lo_; }
379 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
380 constexpr explicit operator T()
const {
381 return static_cast<T
>(lo_);
386 return lhs.hi_ == rhs.hi_ && lhs.lo_ == rhs.lo_;
390 return !(lhs == rhs);
394 return lhs.hi_ != rhs.hi_ ? lhs.hi_ > rhs.hi_ : lhs.lo_ > rhs.lo_;
399 return {lhs.hi_ | rhs.hi_, lhs.lo_ | rhs.lo_};
404 return {lhs.hi_ & rhs.hi_, lhs.lo_ & rhs.lo_};
408 return {~n.hi_, ~n.lo_};
419 uint64_t hi = (lhs.lo_ >> 32) * rhs;
420 uint64_t lo = (lhs.lo_ & ~uint32_t()) * rhs;
421 uint64_t new_lo = (hi << 32) + lo;
422 return {(hi >> 32) + (new_lo < lo ? 1 : 0), new_lo};
426 return {lhs.hi_ - (lhs.lo_ < rhs ? 1 : 0), lhs.lo_ - rhs};
429 if (shift == 64)
return {0, hi_};
431 return {hi_ >> shift, (hi_ << (64 - shift)) | (lo_ >> shift)};
434 if (shift == 64)
return {lo_, 0};
436 return {hi_ << shift | (lo_ >> (64 - shift)), (lo_ << shift)};
439 return *
this = *
this >> shift;
442 uint64_t new_lo = lo_ + n.lo_;
443 uint64_t new_hi = hi_ + n.hi_ + (new_lo < lo_ ? 1 : 0);
456 hi_ += (lo_ < n ? 1 : 0);
459#if FMT_HAS_BUILTIN(__builtin_addcll) && !defined(__ibmxl__)
460 unsigned long long carry;
461 lo_ = __builtin_addcll(lo_, n, 0, &carry);
463#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !defined(__ibmxl__)
464 unsigned long long result;
465 auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result);
468#elif defined(_MSC_VER) && defined(_M_X64)
469 auto carry = _addcarry_u64(0, lo_, n, &lo_);
470 _addcarry_u64(carry, hi_, 0, &hi_);
473 hi_ += (lo_ < n ? 1 : 0);
492template <
typename T>
constexpr auto num_bits() ->
int {
493 return std::numeric_limits<T>::digits;
501template <
typename To,
typename From, FMT_ENABLE_IF(sizeof(To) >
sizeof(From))>
503 constexpr auto size =
static_cast<int>(
sizeof(From) /
sizeof(
unsigned));
505 unsigned value[
static_cast<unsigned>(size)];
509 for (
int i = 0; i < size; ++i)
510 result = (result << num_bits<unsigned>()) |
data.value[i];
512 for (
int i = size - 1; i >= 0; --i)
513 result = (result << num_bits<unsigned>()) |
data.value[i];
518template <
typename UInt>
521 constexpr UInt msb_mask =
static_cast<UInt
>(1) << (num_bits<UInt>() - 1);
522 for (; (n & msb_mask) == 0; n <<= 1) lz++;
527#ifdef FMT_BUILTIN_CLZ
534#ifdef FMT_BUILTIN_CLZLL
542#if FMT_HAS_BUILTIN(__builtin_assume) && !FMT_ICC_VERSION
543 __builtin_assume(condition);
545 if (!condition) __builtin_unreachable();
552template <
typename T>
using sentinel_t =
decltype(std::end(std::declval<T&>()));
555template <
typename Char>
556inline auto get_data(std::basic_string<Char>& s) -> Char* {
559template <
typename Container>
560inline auto get_data(Container&
c) ->
typename Container::value_type* {
566template <
typename Container, FMT_ENABLE_IF(is_contiguous<Container>::value)>
567#if FMT_CLANG_VERSION >= 307 && !FMT_ICC_VERSION
568__attribute__((no_sanitize(
"undefined")))
571reserve(std::back_insert_iterator<Container> it,
size_t n) ->
572 typename Container::value_type* {
574 size_t size =
c.size();
586template <
typename Iterator>
587constexpr auto reserve(Iterator& it,
size_t) -> Iterator& {
591template <
typename OutputIt>
595template <
typename T,
typename OutputIt>
601 auto size = buf.
size();
602 if (buf.
capacity() < size + n)
return nullptr;
604 return buf.
data() + size;
607template <
typename Container, FMT_ENABLE_IF(is_contiguous<Container>::value)>
609 typename Container::value_type*)
610 -> std::back_insert_iterator<Container> {
614template <
typename Iterator>
621template <
typename OutputIt,
typename Size,
typename T>
624 for (Size i = 0; i <
count; ++i) *out++ =
value;
627template <
typename T,
typename Size>
630 return fill_n<T*, Size, T>(out,
count,
value);
642template <
typename OutChar,
typename InputIt,
typename OutputIt>
644 OutputIt out) -> OutputIt {
645 return copy_str<OutChar>(begin, end, out);
667 constexpr const int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07};
668 constexpr const uint32_t mins[] = {4194304, 0, 128, 2048, 65536};
669 constexpr const int shiftc[] = {0, 18, 12, 6, 0};
670 constexpr const int shifte[] = {0, 6, 4, 2, 0};
672 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"
673 [
static_cast<unsigned char>(*s) >> 3];
677 const char* next = s + len + !len;
679 using uchar =
unsigned char;
683 *
c = uint32_t(uchar(s[0]) & masks[len]) << 18;
684 *
c |= uint32_t(uchar(s[1]) & 0x3f) << 12;
685 *
c |= uint32_t(uchar(s[2]) & 0x3f) << 6;
686 *
c |= uint32_t(uchar(s[3]) & 0x3f) << 0;
690 *
e = (*
c < mins[len]) << 6;
691 *
e |= ((*
c >> 11) == 0x1b) << 7;
692 *
e |= (*
c > 0x10FFFF) << 8;
693 *
e |= (uchar(s[1]) & 0xc0) >> 2;
694 *
e |= (uchar(s[2]) & 0xc0) >> 4;
695 *
e |= uchar(s[3]) >> 6;
708 auto decode = [f](
const char* buf_ptr,
const char*
ptr) {
709 auto cp = uint32_t();
714 return result ? (
error ? buf_ptr + 1 : end) :
nullptr;
717 const size_t block_size = 4;
718 if (s.
size() >= block_size) {
719 for (
auto end = p + s.
size() - block_size + 1; p < end;) {
724 if (
auto num_chars_left = s.
data() + s.
size() - p) {
725 char buf[2 * block_size - 1] = {};
726 copy_str<char>(p, p + num_chars_left, buf);
727 const char* buf_ptr = buf;
729 auto end = decode(buf_ptr, p);
733 }
while (buf_ptr - buf < num_chars_left);
737template <
typename Char>
744 size_t num_code_points = 0;
746 struct count_code_points {
756 (cp >= 0x2e80 && cp <= 0xa4cf && cp != 0x303f) ||
757 (cp >= 0xac00 && cp <= 0xd7a3) ||
758 (cp >= 0xf900 && cp <= 0xfaff) ||
759 (cp >= 0xfe10 && cp <= 0xfe19) ||
760 (cp >= 0xfe30 && cp <= 0xfe6f) ||
761 (cp >= 0xff00 && cp <= 0xff60) ||
762 (cp >= 0xffe0 && cp <= 0xffe6) ||
763 (cp >= 0x20000 && cp <= 0x2fffd) ||
764 (cp >= 0x30000 && cp <= 0x3fffd) ||
766 (cp >= 0x1f300 && cp <= 0x1f64f) ||
768 (cp >= 0x1f900 && cp <= 0x1f9ff))));
774 return num_code_points;
779 string_view(
reinterpret_cast<const char*
>(s.data()), s.size()));
782template <
typename Char>
784 size_t size = s.size();
785 return n < size ? n : size;
790 const char*
data = s.data();
791 size_t num_code_points = 0;
792 for (
size_t i = 0, size = s.size(); i != size; ++i) {
793 if ((
data[i] & 0xc0) != 0x80 && ++num_code_points > n)
return i;
801 string_view(
reinterpret_cast<const char*
>(s.data()), s.size()), n);
811 std::is_same<T, int128_opt>::value>;
816 !std::is_same<T, char>::value &&
817 !std::is_same<T, wchar_t>::value>;
820# define FMT_USE_FLOAT 1
822#ifndef FMT_USE_DOUBLE
823# define FMT_USE_DOUBLE 1
825#ifndef FMT_USE_LONG_DOUBLE
826# define FMT_USE_LONG_DOUBLE 1
829#ifndef FMT_USE_FLOAT128
832# if FMT_HAS_INCLUDE(<quadmath.h>)
833# define FMT_USE_FLOAT128 1
835# elif defined(__GNUC__)
837# if defined(_GLIBCXX_USE_FLOAT128) && !defined(__STRICT_ANSI__)
838# define FMT_USE_FLOAT128 1
841# ifndef FMT_USE_FLOAT128
842# define FMT_USE_FLOAT128 0
851template <
typename T>
using is_float128 = std::is_same<T, float128>;
857template <typename T, bool = std::is_floating_point<T>::value>
858struct is_fast_float :
bool_constant<std::numeric_limits<T>::is_iec559 &&
859 sizeof(T) <= sizeof(double)> {};
860template <typename T> struct is_fast_float<T, false> : std::false_type {};
863using is_double_double = bool_constant<std::numeric_limits<T>::digits == 106>;
865#ifndef FMT_USE_FULL_CACHE_DRAGONBOX
866# define FMT_USE_FULL_CACHE_DRAGONBOX 0
871void buffer<T>::append(const U* begin, const U* end) {
872 while (begin != end) {
873 auto count = to_unsigned(end - begin);
874 try_reserve(size_ + count);
875 auto free_cap = capacity_ - size_;
876 if (free_cap < count) count = free_cap;
877 std::uninitialized_copy_n(begin, count, ptr_ + size_);
883template <typename T, typename Enable = void>
884struct is_locale : std::false_type {};
886struct is_locale<T, void_t<decltype(T::classic())>> : std::true_type {};
893enum { inline_buffer_size = 500 };
916template <typename T, size_t SIZE = inline_buffer_size,
917 typename Allocator = std::allocator<T>>
918class basic_memory_buffer final : public detail::buffer<T> {
923 FMT_NO_UNIQUE_ADDRESS Allocator alloc_;
926 FMT_CONSTEXPR20 void deallocate() {
927 T* data = this->data();
928 if (data != store_) alloc_.deallocate(data, this->capacity());
934 const size_t max_size = std::allocator_traits<Allocator>::max_size(alloc_);
935 size_t old_capacity = this->capacity();
936 size_t new_capacity = old_capacity + old_capacity / 2;
937 if (size > new_capacity)
939 else if (new_capacity > max_size)
940 new_capacity = size > max_size ? size : max_size;
941 T* old_data = this->data();
943 std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
947 std::uninitialized_copy_n(old_data, this->size(), new_data);
948 this->
set(new_data, new_capacity);
952 if (old_data != store_) alloc_.deallocate(old_data, old_capacity);
960 const Allocator& alloc = Allocator())
962 this->
set(store_, SIZE);
970 alloc_ = std::move(other.alloc_);
971 T* data = other.
data();
972 size_t size = other.
size(), capacity = other.
capacity();
973 if (data == other.store_) {
974 this->
set(store_, capacity);
975 detail::copy_str<T>(other.store_, other.store_ + size, store_);
977 this->
set(data, capacity);
980 other.
set(other.store_, 0);
1019 void reserve(
size_t new_capacity) { this->try_reserve(new_capacity); }
1023 template <
typename ContiguousRange>
1025 append(range.data(), range.data() + range.size());
1031template <
typename T,
size_t SIZE,
typename Allocator>
1044#if FMT_CLANG_VERSION
1045# pragma clang diagnostic ignored "-Wweak-vtables"
1049class FMT_VISIBILITY("default") format_error :
public std::runtime_error {
1051 using std::runtime_error::runtime_error;
1055#if FMT_USE_NONTYPE_TEMPLATE_ARGS
1056template <
typename Char,
size_t N>
struct fixed_string {
1057 constexpr fixed_string(
const Char (&str)[N]) {
1058 detail::copy_str<Char, const Char*, Char*>(
static_cast<const Char*
>(str),
1066template <
typename Char,
size_t N>
1071 return {s, N - (std::char_traits<Char>::to_int_type(s[N - 1]) == 0 ? 1 : 0)};
1073template <
typename Char>
1076 return {s.
data(), s.size()};
1085 template <
typename T, FMT_ENABLE_IF(!detail::is_
float128<T>::value)>
1088 template <
typename T, FMT_ENABLE_IF(detail::is_
float128<T>::value)>
1091 template <
typename Visitor>
auto visit(Visitor&& vis) ->
decltype(vis(0)) {
1100 std::string separator_;
1101 std::string grouping_;
1102 std::string decimal_point_;
1113 std::initializer_list<unsigned char> g = {3},
1115 : separator_(sep.data(), sep.size()),
1116 grouping_(g.begin(), g.end()),
1121 return do_put(out, val, specs);
1129template <
typename T, FMT_ENABLE_IF(is_
signed<T>::value)>
1133template <
typename T, FMT_ENABLE_IF(!is_
signed<T>::value)>
1138template <
typename T>
1148template <
typename T>
1153template <
typename T>
1156#define FMT_POWERS_OF_10(factor) \
1157 factor * 10, (factor)*100, (factor)*1000, (factor)*10000, (factor)*100000, \
1158 (factor)*1000000, (factor)*10000000, (factor)*100000000, \
1164 return &
"0001020304050607080910111213141516171819"
1165 "2021222324252627282930313233343536373839"
1166 "4041424344454647484950515253545556575859"
1167 "6061626364656667686970717273747576777879"
1168 "8081828384858687888990919293949596979899"[
value * 2];
1172template <
typename Char,
typename Sign>
constexpr Char
sign(Sign s) {
1173#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 604
1174 static_assert(std::is_same<Sign, sign_t>::value,
"");
1176 return static_cast<Char
>(
"\0-+ "[s]);
1185 if (n < 10)
return count;
1186 if (n < 100)
return count + 1;
1187 if (n < 1000)
return count + 2;
1188 if (n < 10000)
return count + 3;
1199#ifdef FMT_BUILTIN_CLZLL
1202inline auto do_count_digits(uint64_t n) ->
int {
1207 static constexpr uint8_t bsr2log10[] = {
1208 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5,
1209 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10,
1210 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15, 15,
1211 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 20};
1212 auto t = bsr2log10[FMT_BUILTIN_CLZLL(n | 1) ^ 63];
1213 static constexpr const uint64_t zero_or_powers_of_10[] = {
1215 10000000000000000000ULL};
1216 return t - (n < zero_or_powers_of_10[t]);
1223#ifdef FMT_BUILTIN_CLZLL
1225 return do_count_digits(n);
1232template <
int BITS,
typename UInt>
1234#ifdef FMT_BUILTIN_CLZ
1236 return (FMT_BUILTIN_CLZ(
static_cast<uint32_t
>(n) | 1) ^ 31) / BITS + 1;
1243 }
while ((m >>= BITS) != 0);
1248#ifdef FMT_BUILTIN_CLZ
1251FMT_INLINE auto do_count_digits(uint32_t n) ->
int {
1254# define FMT_INC(T) (((sizeof(#T) - 1ull) << 32) - T)
1255 static constexpr uint64_t table[] = {
1256 FMT_INC(0), FMT_INC(0), FMT_INC(0),
1257 FMT_INC(10), FMT_INC(10), FMT_INC(10),
1258 FMT_INC(100), FMT_INC(100), FMT_INC(100),
1259 FMT_INC(1000), FMT_INC(1000), FMT_INC(1000),
1260 FMT_INC(10000), FMT_INC(10000), FMT_INC(10000),
1261 FMT_INC(100000), FMT_INC(100000), FMT_INC(100000),
1262 FMT_INC(1000000), FMT_INC(1000000), FMT_INC(1000000),
1263 FMT_INC(10000000), FMT_INC(10000000), FMT_INC(10000000),
1264 FMT_INC(100000000), FMT_INC(100000000), FMT_INC(100000000),
1265 FMT_INC(1000000000), FMT_INC(1000000000), FMT_INC(1000000000),
1266 FMT_INC(1000000000), FMT_INC(1000000000)
1268 auto inc = table[FMT_BUILTIN_CLZ(n | 1) ^ 31];
1269 return static_cast<int>((n + inc) >> 32);
1275#ifdef FMT_BUILTIN_CLZ
1277 return do_count_digits(n);
1283template <
typename Int>
constexpr auto digits10() noexcept ->
int {
1294template <
typename Char>
1296template <
typename Char>
1299 return {result.grouping, Char(result.thousands_sep)};
1306template <
typename Char>
1309 return Char(decimal_point_impl<char>(loc));
1312 return decimal_point_impl<wchar_t>(loc);
1316template <
typename Char>
auto equal2(
const Char* lhs,
const char* rhs) ->
bool {
1317 return lhs[0] == Char(rhs[0]) && lhs[1] == Char(rhs[1]);
1319inline auto equal2(
const char* lhs,
const char* rhs) ->
bool {
1320 return memcmp(lhs, rhs, 2) == 0;
1324template <
typename Char>
1327#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1000
1328# pragma GCC diagnostic push
1329# pragma GCC diagnostic ignored "-Wstringop-overflow"
1331 memcpy(dst, src, 2);
1332#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1000
1333# pragma GCC diagnostic pop
1337 *dst++ =
static_cast<Char
>(*src++);
1338 *dst =
static_cast<Char
>(*src);
1349template <
typename Char,
typename UInt>
1355 while (
value >= 100) {
1364 *--out =
static_cast<Char
>(
'0' +
value);
1372template <
typename Char,
typename UInt,
typename Iterator,
1377 Char
buffer[digits10<UInt>() + 1] = {};
1379 return {out, detail::copy_str_noinline<Char>(
buffer, end, out)};
1382template <
unsigned BASE_BITS,
typename Char,
typename UInt>
1384 bool upper =
false) -> Char* {
1388 const char* digits = upper ?
"0123456789ABCDEF" :
"0123456789abcdef";
1389 unsigned digit =
static_cast<unsigned>(
value & ((1 << BASE_BITS) - 1));
1390 *--
buffer =
static_cast<Char
>(BASE_BITS < 4 ? static_cast<char>(
'0' + digit)
1392 }
while ((
value >>= BASE_BITS) != 0);
1396template <
unsigned BASE_BITS,
typename Char,
typename It,
typename UInt>
1398 bool upper =
false) -> It {
1400 format_uint<BASE_BITS>(
ptr,
value, num_digits, upper);
1404 char buffer[num_bits<UInt>() / BASE_BITS + 1];
1405 format_uint<BASE_BITS>(
buffer,
value, num_digits, upper);
1406 return detail::copy_str_noinline<Char>(
buffer,
buffer + num_digits, out);
1417 auto size() const ->
size_t {
return buffer_.
size() - 1; }
1418 auto c_str() const -> const
wchar_t* {
return &buffer_[0]; }
1419 auto str() const ->
std::wstring {
return {&buffer_[0],
size()}; }
1425template <
typename WChar,
typename Buffer = memory_buffer>
class to_utf8 {
1433 static_assert(
sizeof(WChar) == 2 ||
sizeof(WChar) == 4,
1434 "Expect utf16 or utf32");
1436 FMT_THROW(std::runtime_error(
sizeof(WChar) == 2 ?
"invalid utf16"
1437 :
"invalid utf32"));
1440 size_t size()
const {
return buffer_.size() - 1; }
1441 const char*
c_str()
const {
return &buffer_[0]; }
1442 std::string
str()
const {
return std::string(&buffer_[0],
size()); }
1449 if (!
convert(buffer_, s, policy))
return false;
1450 buffer_.push_back(0);
1456 for (
auto p = s.
begin(); p != s.
end(); ++p) {
1457 uint32_t
c =
static_cast<uint32_t
>(*p);
1458 if (
sizeof(WChar) == 2 &&
c >= 0xd800 &&
c <= 0xdfff) {
1461 if (p == s.
end() || (
c & 0xfc00) != 0xd800 || (*p & 0xfc00) != 0xdc00) {
1466 c = (c << 10) + static_cast<uint32_t>(*p) - 0x35fdc00;
1468 }
else if (
c < 0x80) {
1469 buf.push_back(
static_cast<char>(
c));
1470 }
else if (
c < 0x800) {
1471 buf.push_back(
static_cast<char>(0xc0 | (
c >> 6)));
1472 buf.push_back(
static_cast<char>(0x80 | (
c & 0x3f)));
1473 }
else if ((
c >= 0x800 &&
c <= 0xd7ff) || (
c >= 0xe000 &&
c <= 0xffff)) {
1474 buf.push_back(
static_cast<char>(0xe0 | (
c >> 12)));
1475 buf.push_back(
static_cast<char>(0x80 | ((
c & 0xfff) >> 6)));
1476 buf.push_back(
static_cast<char>(0x80 | (
c & 0x3f)));
1477 }
else if (
c >= 0x10000 &&
c <= 0x10ffff) {
1478 buf.push_back(
static_cast<char>(0xf0 | (
c >> 18)));
1479 buf.push_back(
static_cast<char>(0x80 | ((
c & 0x3ffff) >> 12)));
1480 buf.push_back(
static_cast<char>(0x80 | ((
c & 0xfff) >> 6)));
1481 buf.push_back(
static_cast<char>(0x80 | (
c & 0x3f)));
1494 return {
static_cast<uint64_t
>(p >> 64),
static_cast<uint64_t
>(p)};
1495#elif defined(_MSC_VER) && defined(_M_X64)
1496 auto hi = uint64_t();
1497 auto lo = _umul128(x, y, &hi);
1500 const uint64_t mask =
static_cast<uint64_t
>(max_value<uint32_t>());
1502 uint64_t a = x >> 32;
1503 uint64_t
b = x & mask;
1504 uint64_t
c = y >> 32;
1505 uint64_t d = y & mask;
1507 uint64_t ac = a *
c;
1508 uint64_t bc =
b *
c;
1509 uint64_t ad = a * d;
1510 uint64_t bd =
b * d;
1512 uint64_t intermediate = (bd >> 32) + (ad & mask) + (bc & mask);
1514 return {ac + (intermediate >> 32) + (ad >> 32) + (bc >> 32),
1515 (intermediate << 32) + (bd & mask)};
1519namespace dragonbox {
1523 FMT_ASSERT(e <= 2620 && e >= -2620,
"too large exponent");
1524 static_assert((-1 >> 1) == -1,
"right shift is not arithmetic");
1525 return (
e * 315653) >> 20;
1529 FMT_ASSERT(e <= 1233 && e >= -1233,
"too large exponent");
1530 return (
e * 1741647) >> 19;
1537 return static_cast<uint64_t
>(p >> 64);
1538#elif defined(_MSC_VER) && defined(_M_X64)
1539 return __umulh(x, y);
1561 static const int exponent_bits = 8;
1562 static const int kappa = 1;
1563 static const int big_divisor = 100;
1564 static const int small_divisor = 10;
1565 static const int min_k = -31;
1566 static const int max_k = 46;
1567 static const int shorter_interval_tie_lower_threshold = -35;
1568 static const int shorter_interval_tie_upper_threshold = -35;
1573 static const int exponent_bits = 11;
1574 static const int kappa = 2;
1575 static const int big_divisor = 1000;
1576 static const int small_divisor = 100;
1577 static const int min_k = -292;
1578 static const int max_k = 341;
1579 static const int shorter_interval_tie_lower_threshold = -77;
1580 static const int shorter_interval_tie_upper_threshold = -77;
1584template <
typename T>
1586 std::numeric_limits<T>::digits == 113 ||
1589 static const int exponent_bits = 15;
1593template <
typename T>
1610 return std::numeric_limits<Float>::digits != 64;
1618 : (std::numeric_limits<Float>::digits -
1619 (has_implicit_bit<Float>() ? 1 : 0));
1622template <
typename Float>
1627 << num_significand_bits<Float>();
1632 : std::numeric_limits<Float>::max_exponent - 1;
1636template <
typename Char,
typename It>
1638 FMT_ASSERT(-10000 < exp && exp < 10000,
"exponent out of range");
1640 *it++ =
static_cast<Char
>(
'-');
1643 *it++ =
static_cast<Char
>(
'+');
1647 if (exp >= 1000) *it++ =
static_cast<Char
>(top[0]);
1648 *it++ =
static_cast<Char
>(top[1]);
1652 *it++ =
static_cast<Char
>(d[0]);
1653 *it++ =
static_cast<Char
>(d[1]);
1663 static_cast<int>(
sizeof(
F) * num_bits<unsigned char>());
1666 constexpr basic_fp(uint64_t f_val,
int e_val) :
f(f_val),
e(e_val) {}
1672 template <
typename Float, FMT_ENABLE_IF(!is_
double_
double<Float>::value)>
1674 static_assert(std::numeric_limits<Float>::digits <= 113,
"unsupported FP");
1677 const auto num_float_significand_bits =
1678 detail::num_significand_bits<Float>();
1679 const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;
1680 const auto significand_mask = implicit_bit - 1;
1681 auto u = bit_cast<carrier_uint>(n);
1682 f =
static_cast<F>(u & significand_mask);
1683 auto biased_e =
static_cast<int>((u & exponent_mask<Float>()) >>
1684 num_float_significand_bits);
1687 auto is_predecessor_closer =
f == 0 && biased_e > 1;
1690 else if (has_implicit_bit<Float>())
1691 f +=
static_cast<F>(implicit_bit);
1692 e = biased_e - exponent_bias<Float>() - num_float_significand_bits;
1693 if (!has_implicit_bit<Float>()) ++
e;
1694 return is_predecessor_closer;
1697 template <
typename Float, FMT_ENABLE_IF(is_
double_
double<Float>::value)>
1699 static_assert(std::numeric_limits<double>::is_iec559,
"unsupported FP");
1700 return assign(
static_cast<double>(n));
1707template <
int SHIFT = 0,
typename F>
1710 const auto implicit_bit =
F(1) << num_significand_bits<double>();
1711 const auto shifted_implicit_bit = implicit_bit << SHIFT;
1712 while ((
value.f & shifted_implicit_bit) == 0) {
1718 num_significand_bits<double>() - SHIFT - 1;
1727 auto product =
static_cast<__uint128_t
>(lhs) * rhs;
1728 auto f =
static_cast<uint64_t
>(product >> 64);
1729 return (
static_cast<uint64_t
>(product) & (1ULL << 63)) != 0 ? f + 1 : f;
1732 uint64_t mask = (1ULL << 32) - 1;
1733 uint64_t a = lhs >> 32,
b = lhs & mask;
1734 uint64_t
c = rhs >> 32, d = rhs & mask;
1735 uint64_t ac = a *
c, bc =
b *
c, ad = a * d, bd =
b * d;
1737 uint64_t mid = (bd >> 32) + (ad & mask) + (bc & mask) + (1U << 31);
1738 return ac + (ad >> 32) + (bc >> 32) + (mid >> 32);
1764#if FMT_CPLUSPLUS < 201703L
1765template <
typename T>
1769template <typename T, bool doublish = num_bits<T>() == num_bits<double>()>
1773template <
typename T>
1778template <
typename OutputIt,
typename Char>
1781 auto fill_size =
fill.size();
1784 for (
size_t i = 0; i < n; ++i)
1785 it = copy_str<Char>(
data,
data + fill_size, it);
1792template <
align::type align = align::left,
typename OutputIt,
typename Char,
1795 size_t size,
size_t width,
F&& f) -> OutputIt {
1796 static_assert(
align == align::left ||
align == align::right,
"");
1798 size_t padding = spec_width >
width ? spec_width -
width : 0;
1801 auto* shifts =
align == align::left ?
"\x1f\x1f\x00\x01" :
"\x00\x1f\x00\x01";
1802 size_t left_padding = padding >> shifts[specs.align];
1803 size_t right_padding = padding - left_padding;
1804 auto it =
reserve(out, size + padding * specs.fill.size());
1805 if (left_padding != 0) it =
fill(it, left_padding, specs.fill);
1807 if (right_padding != 0) it =
fill(it, right_padding, specs.fill);
1811template <
align::type align = align::left,
typename OutputIt,
typename Char,
1814 size_t size,
F&& f) -> OutputIt {
1815 return write_padded<align>(out, specs, size, size, f);
1818template <align::type align = align::left,
typename Char,
typename OutputIt>
1821 return write_padded<align>(
1823 const char* data = bytes.data();
1824 return copy_str<Char>(data, data + bytes.size(), it);
1828template <
typename Char,
typename OutputIt,
typename UIntPtr>
1831 int num_digits = count_digits<4>(
value);
1834 *it++ =
static_cast<Char
>(
'0');
1835 *it++ =
static_cast<Char
>(
'x');
1836 return format_uint<4, Char>(it,
value, num_digits);
1838 return specs ? write_padded<align::right>(out, *specs, size,
write)
1846 return cp < 0x20 || cp == 0x7f || cp ==
'"' || cp ==
'\\' ||
1856template <
typename Char>
1859 std::make_unsigned<Char>,
1862template <
typename Char>
1865 for (; begin != end; ++begin) {
1867 if (
const_check(
sizeof(Char) == 1) && cp >= 0x80)
continue;
1870 return {begin,
nullptr, 0};
1875 if (!
is_utf8())
return find_escape<char>(begin, end);
1880 result = {sv.
begin(), sv.
end(), cp};
1888#define FMT_STRING_IMPL(s, base, explicit) \
1892 struct FMT_VISIBILITY("hidden") FMT_COMPILE_STRING : base { \
1893 using char_type FMT_MAYBE_UNUSED = fmt::remove_cvref_t<decltype(s[0])>; \
1894 FMT_MAYBE_UNUSED FMT_CONSTEXPR explicit \
1895 operator fmt::basic_string_view<char_type>() const { \
1896 return fmt::detail_exported::compile_string_to_view<char_type>(s); \
1899 return FMT_COMPILE_STRING(); \
1912#define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string, )
1914template <
size_t w
idth,
typename Char,
typename OutputIt>
1916 *out++ =
static_cast<Char
>(
'\\');
1917 *out++ =
static_cast<Char
>(prefix);
1920 format_uint<4>(buf, cp,
width);
1921 return copy_str<Char>(buf, buf +
width, out);
1924template <
typename OutputIt,
typename Char>
1927 auto c =
static_cast<Char
>(
escape.cp);
1930 *out++ =
static_cast<Char
>(
'\\');
1931 c =
static_cast<Char
>(
'n');
1934 *out++ =
static_cast<Char
>(
'\\');
1935 c =
static_cast<Char
>(
'r');
1938 *out++ =
static_cast<Char
>(
'\\');
1939 c =
static_cast<Char
>(
't');
1946 *out++ =
static_cast<Char
>(
'\\');
1950 return write_codepoint<2, Char>(out,
'x',
escape.cp);
1952 if (
escape.cp < 0x10000) {
1953 return write_codepoint<4, Char>(out,
'u',
escape.cp);
1955 if (
escape.cp < 0x110000) {
1956 return write_codepoint<8, Char>(out,
'U',
escape.cp);
1960 out = write_codepoint<2, Char>(out,
'x',
1961 static_cast<uint32_t
>(escape_char) & 0xFF);
1969template <
typename Char,
typename OutputIt>
1972 *out++ =
static_cast<Char
>(
'"');
1973 auto begin = str.begin(), end = str.end();
1976 out = copy_str<Char>(begin,
escape.begin, out);
1979 out = write_escaped_cp<OutputIt, Char>(out,
escape);
1980 }
while (begin != end);
1981 *out++ =
static_cast<Char
>(
'"');
1985template <
typename Char,
typename OutputIt>
1987 *out++ =
static_cast<Char
>(
'\'');
1988 if ((
needs_escape(
static_cast<uint32_t
>(v)) && v !=
static_cast<Char
>(
'"')) ||
1989 v ==
static_cast<Char
>(
'\'')) {
1995 *out++ =
static_cast<Char
>(
'\'');
1999template <
typename Char,
typename OutputIt>
2009template <
typename Char,
typename OutputIt>
2014 using unsigned_type =
2018 :
write(out, static_cast<unsigned_type>(value), specs, loc);
2030 if (specs.
align == align::numeric) {
2036 }
else if (specs.
precision > num_digits) {
2047template <
typename OutputIt,
typename Char,
typename W>
2051 W write_digits) -> OutputIt {
2056 for (
unsigned p = prefix & 0xffffff; p != 0; p >>= 8)
2057 *it++ =
static_cast<Char
>(p & 0xff);
2062 return write_padded<align::right>(
2064 for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8)
2065 *it++ = static_cast<Char>(p & 0xff);
2066 it = detail::fill_n(it, data.padding, static_cast<Char>(
'0'));
2067 return write_digits(it);
2073 std::string grouping_;
2074 std::basic_string<Char> thousands_sep_;
2077 std::string::const_iterator group;
2080 next_state initial_state()
const {
return {grouping_.begin(), 0}; }
2083 int next(next_state&
state)
const {
2084 if (thousands_sep_.empty())
return max_value<int>();
2085 if (
state.group == grouping_.end())
return state.pos += grouping_.back();
2086 if (*
state.group <= 0 || *
state.group == max_value<char>())
2087 return max_value<int>();
2094 if (!localized)
return;
2095 auto sep = thousands_sep<Char>(loc);
2096 grouping_ = sep.grouping;
2097 if (sep.thousands_sep) thousands_sep_.assign(1, sep.thousands_sep);
2100 : grouping_(
std::move(grouping)), thousands_sep_(
std::move(sep)) {}
2106 auto state = initial_state();
2112 template <
typename Out,
typename C>
2114 auto num_digits =
static_cast<int>(digits.
size());
2116 separators.push_back(0);
2117 auto state = initial_state();
2118 while (
int i = next(
state)) {
2119 if (i >= num_digits)
break;
2120 separators.push_back(i);
2122 for (
int i = 0, sep_index =
static_cast<int>(separators.size() - 1);
2123 i < num_digits; ++i) {
2124 if (num_digits - i == separators[sep_index]) {
2126 copy_str<Char>(thousands_sep_.data(),
2127 thousands_sep_.data() + thousands_sep_.size(), out);
2130 *out++ =
static_cast<Char
>(digits[
to_unsigned(i)]);
2137template <
typename OutputIt,
typename UInt,
typename Char>
2141 static_assert(std::is_same<uint64_or_128_t<UInt>, UInt>::value,
"");
2145 unsigned size =
to_unsigned((prefix != 0 ? 1 : 0) + num_digits +
2146 grouping.count_separators(num_digits));
2147 return write_padded<align::right>(
2150 char sign =
static_cast<char>(prefix);
2151 *it++ =
static_cast<Char
>(
sign);
2160template <
typename OutputIt,
typename Char>
2168 prefix += (1u + (
value > 0xff ? 1 : 0)) << 24;
2176template <
typename T>
2182 prefix = 0x01000000 |
'-';
2183 abs_value = 0 - abs_value;
2185 constexpr const unsigned prefixes[4] = {0, 0, 0x1000000u |
'+',
2187 prefix = prefixes[
sign];
2189 return {abs_value, prefix};
2199 template <
typename T, FMT_ENABLE_IF(is_
integer<T>::value)>
2207 template <
typename T, FMT_ENABLE_IF(!is_
integer<T>::value)>
2213template <
typename Char,
typename OutputIt,
typename T>
2217 static_assert(std::is_same<T, uint32_or_64_or_128_t<T>>::value,
"");
2218 auto abs_value =
arg.abs_value;
2219 auto prefix =
arg.prefix;
2220 switch (specs.
type) {
2226 return format_decimal<Char>(it, abs_value, num_digits).end;
2233 prefix_append(prefix,
unsigned(upper ?
'X' :
'x') << 8 |
'0');
2234 int num_digits = count_digits<4>(abs_value);
2237 return format_uint<4, Char>(it, abs_value, num_digits, upper);
2244 prefix_append(prefix,
unsigned(upper ?
'B' :
'b') << 8 |
'0');
2245 int num_digits = count_digits<1>(abs_value);
2246 return write_int(out, num_digits, prefix, specs,
2248 return format_uint<1, Char>(it, abs_value, num_digits);
2252 int num_digits = count_digits<3>(abs_value);
2255 if (specs.
alt && specs.
precision <= num_digits && abs_value != 0)
2257 return write_int(out, num_digits, prefix, specs,
2259 return format_uint<3, Char>(it, abs_value, num_digits);
2263 return write_char(out,
static_cast<Char
>(abs_value), specs);
2269template <
typename Char,
typename OutputIt,
typename T>
2275template <
typename Char,
typename OutputIt,
typename T,
2277 !std::is_same<T, bool>::value &&
2278 std::is_same<OutputIt, buffer_appender<Char>>::value)>
2287template <
typename Char,
typename OutputIt,
typename T,
2289 !std::is_same<T, bool>::value &&
2290 !std::is_same<OutputIt, buffer_appender<Char>>::value)>
2293 locale_ref loc) -> OutputIt {
2331 it.count_ +=
static_cast<size_t>(n);
2338template <
typename Char,
typename OutputIt>
2341 auto data = s.data();
2342 auto size = s.size();
2347 if (specs.
width != 0) {
2356 return copy_str<Char>(
data,
data + size, it);
2359template <
typename Char,
typename OutputIt>
2364 return write(out, s, specs);
2366template <
typename Char,
typename OutputIt>
2372 : write_ptr<Char>(out, bit_cast<uintptr_t>(s), &specs);
2375template <
typename Char,
typename OutputIt,
typename T,
2377 !std::is_same<T, bool>::value &&
2378 !std::is_same<T, Char>::value)>
2383 if (negative) abs_value = ~abs_value + 1;
2385 auto size = (negative ? 1 : 0) +
static_cast<size_t>(num_digits);
2387 if (
auto ptr = to_pointer<Char>(it, size)) {
2388 if (negative) *
ptr++ =
static_cast<Char
>(
'-');
2389 format_decimal<Char>(
ptr, abs_value, num_digits);
2392 if (negative) *it++ =
static_cast<Char
>(
'-');
2393 it = format_decimal<Char>(it, abs_value, num_digits).end;
2398template <
typename Char>
2402 auto align = align::none;
2404 if (end - p <= 0) p = begin;
2408 align = align::left;
2411 align = align::right;
2414 align = align::center;
2417 if (
align != align::none) {
2420 if (
c ==
'}')
return begin;
2431 }
else if (p == begin) {
2458template <
typename ErrorHandler = error_handler,
typename Char>
2460 ErrorHandler&& eh = {})
2462 auto result = float_specs();
2463 result.showpoint = specs.
alt;
2465 switch (specs.
type) {
2470 result.upper =
true;
2476 result.upper =
true;
2480 result.showpoint |= specs.
precision != 0;
2483 result.upper =
true;
2487 result.showpoint |= specs.
precision != 0;
2490 result.upper =
true;
2496 eh.on_error(
"invalid format specifier");
2502template <
typename Char,
typename OutputIt>
2507 isnan ? (fspecs.upper ?
"NAN" :
"nan") : (fspecs.upper ?
"INF" :
"inf");
2508 constexpr size_t str_size = 3;
2509 auto sign = fspecs.sign;
2510 auto size = str_size + (
sign ? 1 : 0);
2512 const bool is_zero_fill =
2513 specs.
fill.size() == 1 && *specs.
fill.data() ==
static_cast<Char
>(
'0');
2514 if (is_zero_fill) specs.
fill[0] =
static_cast<Char
>(
' ');
2516 if (
sign) *it++ = detail::sign<Char>(
sign);
2517 return copy_str<Char>(str, str + str_size, it);
2529 return f.significand_size;
2531template <
typename T>
2536template <
typename Char,
typename OutputIt>
2538 int significand_size) -> OutputIt {
2539 return copy_str<Char>(significand, significand + significand_size, out);
2541template <
typename Char,
typename OutputIt,
typename UInt>
2543 int significand_size) -> OutputIt {
2544 return format_decimal<Char>(out, significand, significand_size).end;
2546template <
typename Char,
typename OutputIt,
typename T,
typename Grouping>
2548 int significand_size,
int exponent,
2549 const Grouping& grouping) -> OutputIt {
2550 if (!grouping.has_separator()) {
2551 out = write_significand<Char>(out, significand, significand_size);
2555 write_significand<char>(
appender(
buffer), significand, significand_size);
2560template <
typename Char,
typename UInt,
2566 out += significand_size + 1;
2568 int floating_size = significand_size - integral_size;
2569 for (
int i = floating_size / 2; i > 0; --i) {
2571 copy2(out,
digits2(
static_cast<std::size_t
>(significand % 100)));
2574 if (floating_size % 2 != 0) {
2575 *--out =
static_cast<Char
>(
'0' + significand % 10);
2583template <
typename OutputIt,
typename UInt,
typename Char,
2586 int significand_size,
int integral_size,
2589 Char
buffer[digits10<UInt>() + 2];
2592 return detail::copy_str_noinline<Char>(
buffer, end, out);
2595template <
typename OutputIt,
typename Char>
2597 int significand_size,
int integral_size,
2599 out = detail::copy_str_noinline<Char>(significand,
2600 significand + integral_size, out);
2603 return detail::copy_str_noinline<Char>(significand + integral_size,
2604 significand + significand_size, out);
2607template <
typename OutputIt,
typename Char,
typename T,
typename Grouping>
2609 int significand_size,
int integral_size,
2611 const Grouping& grouping) -> OutputIt {
2612 if (!grouping.has_separator()) {
2621 return detail::copy_str_noinline<Char>(
buffer.
data() + integral_size,
2625template <
typename OutputIt,
typename DecimalFP,
typename Char,
2626 typename Grouping = digit_grouping<Char>>
2631 auto significand = f.significand;
2633 const Char
zero =
static_cast<Char
>(
'0');
2634 auto sign = fspecs.sign;
2639 fspecs.locale ? detail::decimal_point<Char>(loc) :
static_cast<Char
>(
'.');
2641 int output_exp = f.exponent + significand_size - 1;
2642 auto use_exp_format = [=]() {
2649 output_exp >= (fspecs.precision > 0 ? fspecs.precision :
exp_upper);
2651 if (use_exp_format()) {
2653 if (fspecs.showpoint) {
2654 num_zeros = fspecs.precision - significand_size;
2655 if (num_zeros < 0) num_zeros = 0;
2657 }
else if (significand_size == 1) {
2660 auto abs_output_exp = output_exp >= 0 ? output_exp : -output_exp;
2662 if (abs_output_exp >= 100) exp_digits = abs_output_exp >= 1000 ? 4 : 3;
2665 char exp_char = fspecs.upper ?
'E' :
'e';
2666 auto write = [=](iterator it) {
2667 if (
sign) *it++ = detail::sign<Char>(
sign);
2672 *it++ =
static_cast<Char
>(exp_char);
2673 return write_exponent<Char>(output_exp, it);
2675 return specs.
width > 0 ? write_padded<align::right>(out, specs, size,
write)
2679 int exp = f.exponent + significand_size;
2680 if (f.exponent >= 0) {
2683 int num_zeros = fspecs.precision - exp;
2685 if (fspecs.showpoint) {
2688 if (num_zeros > 0) size +=
to_unsigned(num_zeros);
2690 auto grouping = Grouping(loc, fspecs.locale);
2691 size +=
to_unsigned(grouping.count_separators(exp));
2692 return write_padded<align::right>(out, specs, size, [&](iterator it) {
2693 if (
sign) *it++ = detail::sign<Char>(
sign);
2694 it = write_significand<Char>(it, significand, significand_size,
2695 f.exponent, grouping);
2696 if (!fspecs.showpoint)
return it;
2700 }
else if (exp > 0) {
2702 int num_zeros = fspecs.showpoint ? fspecs.precision - significand_size : 0;
2703 size += 1 +
to_unsigned(num_zeros > 0 ? num_zeros : 0);
2704 auto grouping = Grouping(loc, fspecs.locale);
2705 size +=
to_unsigned(grouping.count_separators(exp));
2706 return write_padded<align::right>(out, specs, size, [&](iterator it) {
2707 if (
sign) *it++ = detail::sign<Char>(
sign);
2714 int num_zeros = -exp;
2715 if (significand_size == 0 && fspecs.precision >= 0 &&
2716 fspecs.precision < num_zeros) {
2717 num_zeros = fspecs.precision;
2719 bool pointy = num_zeros != 0 || significand_size != 0 || fspecs.showpoint;
2720 size += 1 + (pointy ? 1 : 0) +
to_unsigned(num_zeros);
2721 return write_padded<align::right>(out, specs, size, [&](iterator it) {
2722 if (
sign) *it++ = detail::sign<Char>(
sign);
2724 if (!pointy)
return it;
2727 return write_significand<Char>(it, significand, significand_size);
2739 template <
typename Out,
typename C>
2745template <
typename OutputIt,
typename DecimalFP,
typename Char>
2763template <
typename T,
typename Enable =
void>
2766template <
typename T>
2768 : std::true_type {};
2770template <
typename T, FMT_ENABLE_IF(std::is_
floating_po
int<T>::value&&
2771 has_isfinite<T>::value)>
2773 constexpr T inf = T(std::numeric_limits<double>::infinity());
2778template <
typename T, FMT_ENABLE_IF(!has_isfinite<T>::value)>
2780 T inf = T(std::numeric_limits<double>::infinity());
2785template <
typename T, FMT_ENABLE_IF(is_
floating_po
int<T>::value)>
2788#ifdef __cpp_if_constexpr
2789 if constexpr (std::numeric_limits<double>::is_iec559) {
2790 auto bits = detail::bit_cast<uint64_t>(
static_cast<double>(
value));
2791 return (
bits >> (num_bits<uint64_t>() - 1)) != 0;
2801 if (exp10 > 0 &&
precision > max_value<int>() - exp10)
2802 FMT_THROW(format_error(
"number is too big"));
2810 using bigit = uint32_t;
2811 using double_bigit = uint64_t;
2812 enum { bigits_capacity = 32 };
2823 static constexpr const int bigit_bits = num_bits<bigit>();
2827 FMT_CONSTEXPR20 void subtract_bigits(
int index, bigit other, bigit& borrow) {
2828 auto result =
static_cast<double_bigit
>((*this)[
index]) - other - borrow;
2829 (*this)[
index] =
static_cast<bigit
>(result);
2830 borrow =
static_cast<bigit
>(result >> (bigit_bits * 2 - 1));
2841 FMT_ASSERT(other.exp_ >= exp_,
"unaligned bigints");
2844 int i = other.exp_ - exp_;
2845 for (
size_t j = 0, n = other.bigits_.size(); j != n; ++i, ++j)
2846 subtract_bigits(i, other.bigits_[j], borrow);
2847 while (borrow > 0) subtract_bigits(i, 0, borrow);
2848 remove_leading_zeros();
2852 const double_bigit wide_value =
value;
2854 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2855 double_bigit result = bigits_[i] * wide_value + carry;
2856 bigits_[i] =
static_cast<bigit
>(result);
2857 carry =
static_cast<bigit
>(result >> bigit_bits);
2859 if (carry != 0) bigits_.
push_back(carry);
2862 template <
typename UInt, FMT_ENABLE_IF(std::is_same<UInt, u
int64_t>::value ||
2863 std::is_same<UInt, u
int128_t>::value)>
2867 const int shift = num_bits<half_uint>() - bigit_bits;
2868 const UInt lower =
static_cast<half_uint
>(
value);
2869 const UInt upper =
value >> num_bits<half_uint>();
2871 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2872 UInt result = lower * bigits_[i] +
static_cast<bigit
>(carry);
2873 carry = (upper * bigits_[i] << shift) + (result >> bigit_bits) +
2874 (carry >> bigit_bits);
2875 bigits_[i] =
static_cast<bigit
>(result);
2877 while (carry != 0) {
2878 bigits_.
push_back(
static_cast<bigit
>(carry));
2879 carry >>= bigit_bits;
2883 template <
typename UInt, FMT_ENABLE_IF(std::is_same<UInt, u
int64_t>::value ||
2884 std::is_same<UInt, u
int128_t>::value)>
2888 bigits_[
num_bigits++] =
static_cast<bigit
>(n);
2903 auto size = other.bigits_.
size();
2916 return static_cast<int>(bigits_.
size()) + exp_;
2921 exp_ += shift / bigit_bits;
2922 shift %= bigit_bits;
2923 if (shift == 0)
return *
this;
2925 for (
size_t i = 0, n = bigits_.
size(); i < n; ++i) {
2926 bigit
c = bigits_[i] >> (bigit_bits - shift);
2927 bigits_[i] = (bigits_[i] << shift) + carry;
2930 if (carry != 0) bigits_.
push_back(carry);
2942 if (num_lhs_bigits != num_rhs_bigits)
2943 return num_lhs_bigits > num_rhs_bigits ? 1 : -1;
2944 int i =
static_cast<int>(lhs.bigits_.
size()) - 1;
2945 int j =
static_cast<int>(rhs.bigits_.
size()) - 1;
2947 if (end < 0) end = 0;
2948 for (; i >= end; --i, --j) {
2949 bigit lhs_bigit = lhs[i], rhs_bigit = rhs[j];
2950 if (lhs_bigit != rhs_bigit)
return lhs_bigit > rhs_bigit ? 1 : -1;
2952 if (i != j)
return i > j ? 1 : -1;
2959 auto minimum = [](
int a,
int b) {
return a <
b ? a :
b; };
2960 auto maximum = [](
int a,
int b) {
return a >
b ? a :
b; };
2963 if (max_lhs_bigits + 1 < num_rhs_bigits)
return -1;
2964 if (max_lhs_bigits > num_rhs_bigits)
return 1;
2965 auto get_bigit = [](
const bigint& n,
int i) -> bigit {
2966 return i >= n.exp_ && i < n.
num_bigits() ? n[i - n.exp_] : 0;
2968 double_bigit borrow = 0;
2969 int min_exp = minimum(minimum(lhs1.exp_, lhs2.exp_), rhs.exp_);
2970 for (
int i = num_rhs_bigits - 1; i >= min_exp; --i) {
2972 static_cast<double_bigit
>(get_bigit(lhs1, i)) + get_bigit(lhs2, i);
2973 bigit rhs_bigit = get_bigit(rhs, i);
2974 if (sum > rhs_bigit + borrow)
return 1;
2975 borrow = rhs_bigit + borrow - sum;
2976 if (borrow > 1)
return -1;
2977 borrow <<= bigit_bits;
2979 return borrow != 0 ? -1 : 0;
2985 if (
exp == 0)
return *
this = 1;
2988 while (
exp >= bitmask) bitmask <<= 1;
2994 while (bitmask != 0) {
2996 if ((
exp & bitmask) != 0) *
this *= 5;
3008 for (
int bigit_index = 0; bigit_index <
num_bigits; ++bigit_index) {
3011 for (
int i = 0, j = bigit_index; j >= 0; ++i, --j) {
3013 sum +=
static_cast<double_bigit
>(n[i]) * n[j];
3015 (*this)[bigit_index] =
static_cast<bigit
>(sum);
3016 sum >>= num_bits<bigit>();
3019 for (
int bigit_index =
num_bigits; bigit_index < num_result_bigits;
3022 sum +=
static_cast<double_bigit
>(n[i++]) * n[j--];
3023 (*this)[bigit_index] =
static_cast<bigit
>(sum);
3024 sum >>= num_bits<bigit>();
3026 remove_leading_zeros();
3033 int exp_difference = exp_ - other.exp_;
3034 if (exp_difference <= 0)
return;
3037 for (
int i =
num_bigits - 1, j = i + exp_difference; i >= 0; --i, --j)
3038 bigits_[j] = bigits_[i];
3039 std::uninitialized_fill_n(bigits_.
data(), exp_difference, 0);
3040 exp_ -= exp_difference;
3070 unsigned flags,
int num_digits,
3082 int shift = is_predecessor_closer ? 2 : 1;
3084 numerator =
value.f;
3085 numerator <<=
value.e + shift;
3088 if (is_predecessor_closer) {
3090 upper_store <<=
value.e + 1;
3091 upper = &upper_store;
3094 denominator <<= shift;
3095 }
else if (exp10 < 0) {
3097 lower.assign(numerator);
3098 if (is_predecessor_closer) {
3099 upper_store.assign(numerator);
3101 upper = &upper_store;
3103 numerator *=
value.f;
3104 numerator <<= shift;
3106 denominator <<= shift -
value.e;
3108 numerator =
value.f;
3109 numerator <<= shift;
3111 denominator <<= shift -
value.e;
3113 if (is_predecessor_closer) {
3114 upper_store = 1ULL << 1;
3115 upper = &upper_store;
3118 int even =
static_cast<int>((
value.f & 1) == 0);
3119 if (!upper) upper = &lower;
3120 bool shortest = num_digits < 0;
3122 if (add_compare(numerator, *upper, denominator) + even <= 0) {
3125 if (num_digits < 0) {
3127 if (upper != &lower) *upper *= 10;
3139 bool low = compare(numerator, lower) - even < 0;
3141 bool high = add_compare(numerator, *upper, denominator) + even > 0;
3142 data[num_digits++] =
static_cast<char>(
'0' + digit);
3145 ++
data[num_digits - 1];
3147 int result = add_compare(numerator, numerator, denominator);
3149 if (result > 0 || (result == 0 && (digit % 2) != 0))
3150 ++
data[num_digits - 1];
3153 exp10 -= num_digits - 1;
3158 if (upper != &lower) *upper *= 10;
3162 exp10 -= num_digits - 1;
3163 if (num_digits <= 0) {
3165 auto digit = add_compare(numerator, numerator, denominator) > 0 ?
'1' :
'0';
3170 for (
int i = 0; i < num_digits - 1; ++i) {
3172 buf[i] =
static_cast<char>(
'0' + digit);
3176 auto result = add_compare(numerator, numerator, denominator);
3177 if (result > 0 || (result == 0 && (digit % 2) != 0)) {
3179 const auto overflow =
'0' + 10;
3180 buf[num_digits - 1] = overflow;
3182 for (
int i = num_digits - 1; i > 0 && buf[i] == overflow; --i) {
3186 if (buf[0] == overflow) {
3195 buf[num_digits - 1] =
static_cast<char>(
'0' + digit);
3199template <
typename Float, FMT_ENABLE_IF(!is_
double_
double<Float>::value)>
3204 static_assert(!std::is_same<Float, float>::value,
"");
3209 using carrier_uint =
typename info::carrier_uint;
3211 constexpr auto num_float_significand_bits =
3212 detail::num_significand_bits<Float>();
3215 f.
e += num_float_significand_bits;
3216 if (!has_implicit_bit<Float>()) --f.
e;
3218 constexpr auto num_fraction_bits =
3219 num_float_significand_bits + (has_implicit_bit<Float>() ? 1 : 0);
3220 constexpr auto num_xdigits = (num_fraction_bits + 3) / 4;
3222 constexpr auto leading_shift = ((num_xdigits - 1) * 4);
3223 const auto leading_mask = carrier_uint(0xF) << leading_shift;
3224 const auto leading_xdigit =
3225 static_cast<uint32_t
>((f.
f & leading_mask) >> leading_shift);
3226 if (leading_xdigit > 1) f.
e -= (32 -
countl_zero(leading_xdigit) - 1);
3228 int print_xdigits = num_xdigits - 1;
3230 const int shift = ((print_xdigits -
precision - 1) * 4);
3231 const auto mask = carrier_uint(0xF) << shift;
3232 const auto v =
static_cast<uint32_t
>((f.
f & mask) >> shift);
3235 const auto inc = carrier_uint(1) << (shift + 4);
3241 if (!has_implicit_bit<Float>()) {
3242 const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;
3243 if ((f.
f & implicit_bit) == implicit_bit) {
3252 char xdigits[num_bits<carrier_uint>() / 4];
3254 format_uint<4>(xdigits, f.
f, num_xdigits, specs.
upper);
3257 while (print_xdigits > 0 && xdigits[print_xdigits] ==
'0') --print_xdigits;
3264 buf.
append(xdigits + 1, xdigits + 1 + print_xdigits);
3272 abs_e =
static_cast<uint32_t
>(-f.
e);
3275 abs_e =
static_cast<uint32_t
>(f.
e);
3280template <
typename Float, FMT_ENABLE_IF(is_
double_
double<Float>::value)>
3282 float_specs specs, buffer<char>& buf) {
3286template <
typename Float>
3290 static_assert(!std::is_same<Float, float>::value,
"");
3306 bool use_dragon =
true;
3307 unsigned dragon_flags = 0;
3309 const auto inv_log2_10 = 0.3010299956639812;
3316 auto e = (f.e + count_digits<1>(f.f) - 1) * inv_log2_10 - 1
e-10;
3317 exp =
static_cast<int>(
e);
3322 if (specs.binary32) {
3325 return dec.exponent;
3329 return dec.exponent;
3333 auto br = bit_cast<uint64_t>(
static_cast<double>(
value));
3335 const uint64_t significand_mask =
3336 (
static_cast<uint64_t
>(1) << num_significand_bits<double>()) - 1;
3337 uint64_t significand = (br & significand_mask);
3338 int exponent =
static_cast<int>((br & exponent_mask<double>()) >>
3339 num_significand_bits<double>());
3341 if (exponent != 0) {
3342 exponent -= exponent_bias<double>() + num_significand_bits<double>();
3344 (
static_cast<uint64_t
>(1) << num_significand_bits<double>());
3348 FMT_ASSERT(significand != 0,
"zeros should not appear here");
3350 FMT_ASSERT(shift >= num_bits<uint64_t>() - num_significand_bits<double>(),
3352 shift -= (num_bits<uint64_t>() - num_significand_bits<double>() - 2);
3353 exponent = (std::numeric_limits<double>::min_exponent -
3354 num_significand_bits<double>()) -
3356 significand <<= shift;
3364 uint64_t first_segment;
3365 bool has_more_segments;
3366 int digits_in_the_first_segment;
3370 first_segment = r.high();
3371 has_more_segments = r.low() != 0;
3374 if (first_segment >= 1000000000000000000ULL) {
3375 digits_in_the_first_segment = 19;
3379 digits_in_the_first_segment = 18;
3380 first_segment *= 10;
3389 if (digits_in_the_first_segment >
precision) {
3393 exp += digits_in_the_first_segment;
3401 if ((first_segment |
static_cast<uint64_t
>(has_more_segments)) >
3402 5000000000000000000ULL) {
3419 const uint32_t first_subsegment =
static_cast<uint32_t
>(
3422 const uint64_t second_third_subsegments =
3423 first_segment - first_subsegment * 10000000000ULL;
3427 bool should_round_up;
3431 auto print_subsegment = [&](uint32_t subsegment,
char*
buffer) {
3432 int number_of_digits_printed = 0;
3435 if ((number_of_digits_to_print & 1) != 0) {
3441 prod = ((subsegment *
static_cast<uint64_t
>(720575941)) >> 24) + 1;
3442 digits =
static_cast<uint32_t
>(prod >> 32);
3443 *
buffer =
static_cast<char>(
'0' + digits);
3444 number_of_digits_printed++;
3454 prod = ((subsegment *
static_cast<uint64_t
>(450359963)) >> 20) + 1;
3455 digits =
static_cast<uint32_t
>(prod >> 32);
3457 number_of_digits_printed += 2;
3461 while (number_of_digits_printed < number_of_digits_to_print) {
3462 prod =
static_cast<uint32_t
>(prod) *
static_cast<uint64_t
>(100);
3463 digits =
static_cast<uint32_t
>(prod >> 32);
3465 number_of_digits_printed += 2;
3470 print_subsegment(first_subsegment, buf.data());
3489 uint32_t fractional_part =
static_cast<uint32_t
>(prod);
3490 should_round_up = fractional_part >=
3492 [8 - number_of_digits_to_print] ||
3493 ((fractional_part >> 31) &
3494 ((digits & 1) | (second_third_subsegments != 0) |
3495 has_more_segments)) != 0;
3503 should_round_up = second_third_subsegments > 5000000000ULL ||
3504 (second_third_subsegments == 5000000000ULL &&
3505 ((digits & 1) != 0 || has_more_segments));
3514 const uint32_t second_subsegment =
3516 second_third_subsegments, 1844674407370955162ULL));
3517 const uint32_t third_subsegment =
3518 static_cast<uint32_t
>(second_third_subsegments) -
3519 second_subsegment * 10;
3521 number_of_digits_to_print =
precision - 9;
3522 print_subsegment(second_subsegment, buf.data() + 9);
3529 uint32_t fractional_part =
static_cast<uint32_t
>(prod);
3530 should_round_up = fractional_part >=
3532 [8 - number_of_digits_to_print] ||
3533 ((fractional_part >> 31) &
3534 ((digits & 1) | (third_subsegment != 0) |
3535 has_more_segments)) != 0;
3542 should_round_up = third_subsegment > 5 ||
3543 (third_subsegment == 5 &&
3544 ((digits & 1) != 0 || has_more_segments));
3549 if (should_round_up) {
3551 for (
int i =
precision - 1; i > 0 && buf[i] >
'9'; --i) {
3568 exp += digits_in_the_first_segment - 1;
3573 bool is_predecessor_closer = specs.binary32
3574 ? f.assign(
static_cast<float>(
value))
3575 : f.assign(converted_value);
3580 const int max_double_digits = 767;
3584 if (!
fixed && !specs.showpoint) {
3586 auto num_digits = buf.size();
3587 while (num_digits > 0 && buf[num_digits - 1] ==
'0') {
3591 buf.try_resize(num_digits);
3595template <
typename Char,
typename OutputIt,
typename T>
3600 fspecs.
sign = specs.sign;
3602 fspecs.
sign = sign::minus;
3604 }
else if (fspecs.
sign == sign::minus) {
3605 fspecs.
sign = sign::none;
3611 if (specs.align == align::numeric && fspecs.
sign) {
3613 *it++ = detail::sign<Char>(fspecs.
sign);
3615 fspecs.
sign = sign::none;
3616 if (specs.width != 0) --specs.width;
3644template <
typename Char,
typename OutputIt,
typename T,
3654template <
typename Char,
typename OutputIt,
typename T,
3662 fspecs.sign = sign::minus;
3669 floaty_uint mask = exponent_mask<floaty>();
3670 if ((bit_cast<floaty_uint>(
value) & mask) == mask)
3677template <
typename Char,
typename OutputIt,
typename T,
3679 !is_fast_float<T>::value)>
3684template <
typename Char,
typename OutputIt>
3691template <
typename Char,
typename OutputIt>
3695 it = copy_str_noinline<Char>(
value.begin(),
value.end(), it);
3699template <
typename Char,
typename OutputIt,
typename T,
3707 typename Char,
typename OutputIt,
typename T,
3709 std::is_enum<T>::value && !std::is_same<T, Char>::value &&
3710 mapped_type_constant<T, basic_format_context<OutputIt, Char>>::value !=
3717template <
typename Char,
typename OutputIt,
typename T,
3724 ?
write(out, value ? 1 : 0, specs, {})
3725 :
write_bytes(out, value ?
"true" :
"false", specs);
3728template <
typename Char,
typename OutputIt>
3735template <
typename Char,
typename OutputIt>
3743template <
typename Char,
typename OutputIt,
typename T,
3746 locale_ref = {}) -> OutputIt {
3747 return write_ptr<Char>(out, bit_cast<uintptr_t>(value), &specs);
3751template <
typename Char,
typename OutputIt,
typename T,
3756 !std::is_same<T, remove_cvref_t<decltype(arg_mapper<Context>().map(
3762template <
typename Char,
typename OutputIt,
typename T,
3767 auto ctx = Context(out, {}, {});
3768 return typename Context::template formatter_type<T>().format(value, ctx);
3787 h.format(parse_ctx, format_ctx);
3788 return format_ctx.out();
3800 template <
typename T>
3826 template <
typename T, FMT_ENABLE_IF(is_
integer<T>::value)>
3829 return static_cast<unsigned long long>(
value);
3832 template <
typename T, FMT_ENABLE_IF(!is_
integer<T>::value)>
3834 handler_.on_error(
"width is not integer");
3839 ErrorHandler& handler_;
3846 template <
typename T, FMT_ENABLE_IF(is_
integer<T>::value)>
3849 return static_cast<unsigned long long>(
value);
3852 template <
typename T, FMT_ENABLE_IF(!is_
integer<T>::value)>
3854 handler_.on_error(
"precision is not integer");
3859 ErrorHandler& handler_;
3862template <
template <
typename>
class Handler,
typename FormatArg,
3863 typename ErrorHandler>
3866 if (
value >
to_unsigned(max_value<int>())) eh.on_error(
"number is too big");
3867 return static_cast<int>(
value);
3870template <
typename Context,
typename ID>
3872 auto arg = ctx.arg(
id);
3873 if (!
arg) ctx.on_error(
"argument not found");
3877template <
template <
typename>
class Handler,
typename Context>
3886 ctx.error_handler());
3890 ctx.error_handler());
3895#if FMT_USE_USER_DEFINED_LITERALS
3896# if FMT_USE_NONTYPE_TEMPLATE_ARGS
3897template <
typename T,
typename Char,
size_t N,
3898 fmt::detail_exported::fixed_string<Char, N> Str>
3899struct statically_named_arg : view {
3900 static constexpr auto name = Str.data;
3903 statically_named_arg(
const T& v) : value(v) {}
3906template <
typename T,
typename Char,
size_t N,
3907 fmt::detail_exported::fixed_string<Char, N> Str>
3908struct is_named_arg<statically_named_arg<T, Char, N, Str>> : std::true_type {};
3910template <
typename T,
typename Char,
size_t N,
3911 fmt::detail_exported::fixed_string<Char, N> Str>
3912struct is_statically_named_arg<statically_named_arg<T, Char, N, Str>>
3913 : std::true_type {};
3915template <
typename Char,
size_t N,
3916 fmt::detail_exported::fixed_string<Char, N> Str>
3918 template <
typename T>
auto operator=(T&& value)
const {
3919 return statically_named_arg<T, Char, N, Str>(std::forward<T>(value));
3923template <
typename Char>
struct udl_arg {
3926 template <
typename T>
auto operator=(T&& value)
const -> named_arg<Char, T> {
3927 return {str, std::forward<T>(value)};
3933template <
typename Locale,
typename Char>
3936 -> std::basic_string<Char> {
3939 return {buf.data(), buf.size()};
3948 const char* message)
noexcept;
3971template <
typename... T>
3994 const char* message)
noexcept;
4006 mutable char buffer_[buffer_size];
4009 template <
typename UInt>
auto format_unsigned(UInt value) ->
char* {
4014 template <
typename Int>
auto format_signed(Int value) ->
char* {
4016 bool negative = value < 0;
4017 if (negative) abs_value = 0 - abs_value;
4018 auto begin = format_unsigned(abs_value);
4019 if (negative) *--begin =
'-';
4026 explicit format_int(
long long value) : str_(format_signed(value)) {}
4027 explicit format_int(
unsigned value) : str_(format_unsigned(value)) {}
4028 explicit format_int(
unsigned long value) : str_(format_unsigned(value)) {}
4030 : str_(format_unsigned(value)) {}
4041 auto data() const -> const
char* {
return str_; }
4048 buffer_[buffer_size - 1] =
'\0';
4057 auto str() const ->
std::
string {
return std::string(str_,
size()); }
4060template <
typename T,
typename Char>
4062 :
private formatter<detail::format_as_t<T>, Char> {
4066 template <
typename FormatContext>
4067 auto format(
const T& value, FormatContext& ctx)
const ->
decltype(ctx.out()) {
4072#define FMT_FORMAT_AS(Type, Base) \
4073 template <typename Char> \
4074 struct formatter<Type, Char> : formatter<Base, Char> {}
4088template <
typename Char,
size_t N>
4100template <
typename T>
auto ptr(T p) ->
const void* {
4101 static_assert(std::is_pointer<T>::value,
"");
4102 return detail::bit_cast<const void*>(p);
4104template <
typename T,
typename Deleter>
4105auto ptr(
const std::unique_ptr<T, Deleter>& p) ->
const void* {
4108template <
typename T>
auto ptr(
const std::shared_ptr<T>& p) ->
const void* {
4122template <
typename Enum>
4128template <
typename Enum, FMT_ENABLE_IF(std::is_enum<Enum>::value)>
4148 template <
typename ParseContext>
4154 template <
typename FormatContext>
4156 detail::handle_dynamic_spec<detail::width_checker>(specs_.
width,
4158 detail::handle_dynamic_spec<detail::precision_checker>(
4189 template <
typename ParseContext>
4195 template <
typename FormatContext>
4197 ->
decltype(ctx.out()) {
4198 detail::handle_dynamic_spec<detail::width_checker>(specs_.
width,
4200 detail::handle_dynamic_spec<detail::precision_checker>(
4209template <
typename It,
typename Sentinel,
typename Char =
char>
4219template <
typename It,
typename Sentinel,
typename Char>
4223#ifdef __cpp_lib_ranges
4224 std::iter_value_t<It>;
4226 typename std::iterator_traits<It>::value_type;
4231 template <
typename ParseContext>
4233 return value_formatter_.parse(ctx);
4236 template <
typename FormatContext>
4238 FormatContext& ctx)
const ->
decltype(ctx.out()) {
4239 auto it = value.begin;
4240 auto out = ctx.out();
4241 if (it != value.end) {
4242 out = value_formatter_.format(*it, ctx);
4244 while (it != value.end) {
4245 out = detail::copy_str<Char>(value.sep.begin(), value.sep.end(), out);
4246 ctx.advance_to(out);
4247 out = value_formatter_.format(*it, ctx);
4259template <
typename It,
typename Sentinel>
4261 return {begin, end, sep};
4280template <
typename Range>
4283 return join(std::begin(range), std::end(range), sep);
4297template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value &&
4298 !detail::has_format_as<T>::value)>
4301 detail::write<char>(
appender(buffer), value);
4302 return {buffer.data(), buffer.size()};
4305template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
4309 constexpr int max_size = detail::digits10<T>() + 2;
4310 char buffer[max_size > 5 ?
static_cast<unsigned>(max_size) : 5];
4311 char* begin = buffer;
4312 return std::string(begin, detail::write<char>(begin, value));
4315template <
typename Char,
size_t SIZE>
4317 -> std::basic_string<Char> {
4318 auto size = buf.size();
4320 return std::basic_string<Char>(buf.data(), size);
4323template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value &&
4324 detail::has_format_as<T>::value)>
4325inline auto to_string(
const T& value) -> std::string {
4333template <
typename Char>
4351 : parse_context(str), context(p_out, p_args, p_loc) {}
4353 void on_text(
const Char* begin,
const Char* end) {
4365 int arg_id = context.
arg_id(
id);
4366 if (arg_id < 0) on_error(
"argument not found");
4370 FMT_INLINE void on_replacement_field(
int id,
const Char*) {
4378 auto on_format_specs(
int id,
const Char* begin,
const Char* end)
4384 return parse_context.
begin();
4388 detail::handle_dynamic_spec<detail::width_checker>(
4389 specs.
width, specs.width_ref, context);
4390 detail::handle_dynamic_spec<detail::precision_checker>(
4391 specs.
precision, specs.precision_ref, context);
4392 if (begin == end || *begin !=
'}')
4393 on_error(
"missing '}' in format string");
4399 detail::parse_format_string<false>(fmt, format_handler(out, fmt, args, loc));
4404#ifndef FMT_HEADER_ONLY
4418#if FMT_USE_USER_DEFINED_LITERALS
4430# if FMT_USE_NONTYPE_TEMPLATE_ARGS
4431template <detail_exported::fixed_
string Str>
constexpr auto operator""_a() {
4433 return detail::udl_arg<
char_t,
sizeof(Str.data) /
sizeof(
char_t), Str>();
4436constexpr auto operator"" _a(
const char* s,
size_t) -> detail::udl_arg<char> {
4443template <
typename Locale, FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
4449template <
typename Locale,
typename... T,
4456template <
typename OutputIt,
typename Locale,
4458 detail::is_locale<Locale>::value)>
4462 auto&& buf = get_buffer<char>(out);
4467template <
typename OutputIt,
typename Locale,
typename... T,
4469 detail::is_locale<Locale>::value)>
4475template <
typename Locale,
typename... T,
4479 T&&... args) ->
size_t {
4488template <
typename T,
typename Char>
4489template <
typename FormatContext>
4495 const ->
decltype(ctx.out()) {
4498 auto specs = specs_;
4499 detail::handle_dynamic_spec<detail::width_checker>(specs.
width,
4500 specs.width_ref, ctx);
4501 detail::handle_dynamic_spec<detail::precision_checker>(
4502 specs.
precision, specs.precision_ref, ctx);
4503 return detail::write<Char>(ctx.out(), val, specs, ctx.locale());
4505 return detail::write<Char>(ctx.out(), val, specs_, ctx.locale());
4510#ifdef FMT_HEADER_ONLY
4511# define FMT_FUNC inline
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 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:128
FMT_CONSTEXPR auto locale() -> detail::locale_ref
Definition: core.h:1753
auto args() const -> const format_args &
Definition: core.h:1740
FMT_CONSTEXPR auto out() -> iterator
Definition: core.h:1746
void advance_to(iterator it)
Definition: core.h:1749
FMT_CONSTEXPR auto arg_id(basic_string_view< Char > name) -> int
Definition: core.h:1737
\rst Parsing context consisting of a format string range being parsed and an argument counter for aut...
Definition: core.h:656
FMT_CONSTEXPR auto next_arg_id() -> int
Reports an error if using the manual argument indexing; otherwise returns the next argument index and...
Definition: core.h:693
FMT_CONSTEXPR void check_arg_id(int id)
Reports an error if using the automatic argument indexing; otherwise switches to the manual indexing.
Definition: core.h:708
FMT_CONSTEXPR void advance_to(iterator it)
Advances the begin iterator to it.
Definition: core.h:685
constexpr auto begin() const noexcept -> iterator
Returns an iterator to the beginning of the format string range being parsed.
Definition: core.h:675
\rst A dynamically growing memory buffer for trivially copyable/constructible types with the first SI...
Definition: format.h:918
const T & const_reference
Definition: format.h:957
FMT_CONSTEXPR20 void resize(size_t count)
Resizes the buffer to contain count elements.
Definition: format.h:1016
FMT_CONSTEXPR20 ~basic_memory_buffer()
Definition: format.h:965
auto operator=(basic_memory_buffer &&other) noexcept -> basic_memory_buffer &
\rst Moves the content of the other basic_memory_buffer object to this one.
Definition: format.h:1002
void reserve(size_t new_capacity)
Increases the buffer capacity to new_capacity.
Definition: format.h:1019
auto get_allocator() const -> Allocator
Definition: format.h:1010
FMT_CONSTEXPR20 basic_memory_buffer(const Allocator &alloc=Allocator())
Definition: format.h:959
void append(const ContiguousRange &range)
Definition: format.h:1024
FMT_CONSTEXPR20 basic_memory_buffer(basic_memory_buffer &&other) noexcept
\rst Constructs a :class:fmt::basic_memory_buffer object moving the content of the other object to it...
Definition: format.h:993
T value_type
Definition: format.h:956
An implementation of std::basic_string_view for pre-C++17.
Definition: core.h:398
constexpr auto end() const noexcept -> iterator
Definition: core.h:446
constexpr auto size() const noexcept -> size_t
Returns the string size.
Definition: core.h:443
constexpr auto data() const noexcept -> const Char *
Returns a pointer to the string data.
Definition: core.h:440
constexpr auto begin() const noexcept -> iterator
Definition: core.h:445
Definition: format.h:4134
bytes(string_view data)
Definition: format.h:4140
Definition: format.h:2806
friend FMT_CONSTEXPR20 int compare(const bigint &lhs, const bigint &rhs)
Definition: format.h:2940
FMT_CONSTEXPR20 void square()
Definition: format.h:3002
FMT_CONSTEXPR20 bigint & operator*=(Int value)
Definition: format.h:2934
FMT_CONSTEXPR20 bigint()
Definition: format.h:2896
FMT_CONSTEXPR20 int num_bigits() const
Definition: format.h:2915
void operator=(const bigint &)=delete
bigint(uint64_t n)
Definition: format.h:2897
FMT_CONSTEXPR20 void assign(const bigint &other)
Definition: format.h:2902
friend FMT_CONSTEXPR20 int add_compare(const bigint &lhs1, const bigint &lhs2, const bigint &rhs)
Definition: format.h:2957
FMT_CONSTEXPR20 void assign_pow10(int exp)
Definition: format.h:2983
FMT_CONSTEXPR20 void operator=(Int n)
Definition: format.h:2910
FMT_CONSTEXPR20 void align(const bigint &other)
Definition: format.h:3032
FMT_CONSTEXPR20 int divmod_assign(const bigint &divisor)
Definition: format.h:3045
FMT_NOINLINE FMT_CONSTEXPR20 bigint & operator<<=(int shift)
Definition: format.h:2919
bigint(const bigint &)=delete
FMT_CONSTEXPR20 void push_back(const T &value)
Definition: core.h:865
FMT_INLINE auto end() noexcept -> T *
Definition: core.h:832
FMT_CONSTEXPR20 void try_reserve(size_t new_capacity)
Definition: core.h:861
FMT_CONSTEXPR20 void try_resize(size_t count)
Definition: core.h:852
FMT_CONSTEXPR void set(T *buf_data, size_t buf_capacity) noexcept
Sets the buffer data and capacity.
Definition: core.h:816
void clear()
Clears this buffer.
Definition: core.h:848
constexpr auto size() const noexcept -> size_t
Returns the size of this buffer.
Definition: core.h:838
void append(const U *begin, const U *end)
Appends data to the end of the buffer.
constexpr auto capacity() const noexcept -> size_t
Returns the capacity of this buffer.
Definition: core.h:841
FMT_CONSTEXPR auto data() noexcept -> T *
Returns a pointer to the buffer data (not null-terminated).
Definition: core.h:844
Definition: format.h:2300
FMT_CONSTEXPR size_t count() const
Definition: format.h:2317
FMT_CONSTEXPR counting_iterator & operator++()
Definition: format.h:2319
FMT_CONSTEXPR counting_iterator operator++(int)
Definition: format.h:2323
FMT_CONSTEXPR counting_iterator()
Definition: format.h:2315
FMT_CONSTEXPR friend counting_iterator operator+(counting_iterator it, difference_type n)
Definition: format.h:2329
void pointer
Definition: format.h:2307
FMT_CONSTEXPR value_type operator*() const
Definition: format.h:2335
std::ptrdiff_t difference_type
Definition: format.h:2306
std::output_iterator_tag iterator_category
Definition: format.h:2305
void reference
Definition: format.h:2308
FMT_UNCHECKED_ITERATOR(counting_iterator)
Definition: format.h:2071
bool has_separator() const
Definition: format.h:2102
digit_grouping(locale_ref loc, bool localized=true)
Definition: format.h:2093
Out apply(Out out, basic_string_view< C > digits) const
Definition: format.h:2113
digit_grouping(std::string grouping, std::basic_string< Char > sep)
Definition: format.h:2099
int count_separators(int num_digits) const
Definition: format.h:2104
Definition: format.h:2731
constexpr int count_separators(int) const
Definition: format.h:2737
constexpr Out apply(Out out, basic_string_view< C >) const
Definition: format.h:2740
constexpr bool has_separator() const
Definition: format.h:2735
constexpr fallback_digit_grouping(locale_ref, bool)
Definition: format.h:2733
Definition: format.h:3842
FMT_CONSTEXPR auto operator()(T) -> unsigned long long
Definition: format.h:3853
FMT_CONSTEXPR precision_checker(ErrorHandler &eh)
Definition: format.h:3844
FMT_CONSTEXPR auto operator()(T value) -> unsigned long long
Definition: format.h:3847
Definition: format.h:1425
std::string str() const
Definition: format.h:1442
static bool convert(Buffer &buf, basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort)
Definition: format.h:1453
to_utf8(basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort)
Definition: format.h:1431
to_utf8()
Definition: format.h:1430
bool convert(basic_string_view< WChar > s, to_utf8_error_policy policy=to_utf8_error_policy::abort)
Definition: format.h:1447
size_t size() const
Definition: format.h:1440
const char * c_str() const
Definition: format.h:1441
FMT_CONSTEXPR auto operator>>=(int shift) -> uint128_fallback &
Definition: format.h:438
constexpr uint64_t low() const noexcept
Definition: format.h:377
constexpr uint128_fallback(uint64_t hi, uint64_t lo)
Definition: format.h:373
FMT_CONSTEXPR auto operator>>(int shift) const -> uint128_fallback
Definition: format.h:428
friend constexpr auto operator==(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition: format.h:384
friend auto operator-(const uint128_fallback &lhs, uint64_t rhs) -> uint128_fallback
Definition: format.h:424
friend constexpr auto operator|(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition: format.h:396
friend auto operator*(const uint128_fallback &lhs, uint32_t rhs) -> uint128_fallback
Definition: format.h:416
FMT_CONSTEXPR auto operator<<(int shift) const -> uint128_fallback
Definition: format.h:433
FMT_CONSTEXPR20 uint128_fallback & operator+=(uint64_t n) noexcept
Definition: format.h:453
friend constexpr auto operator!=(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition: format.h:388
friend constexpr auto operator~(const uint128_fallback &n) -> uint128_fallback
Definition: format.h:406
friend auto operator+(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition: format.h:410
friend constexpr auto operator>(const uint128_fallback &lhs, const uint128_fallback &rhs) -> bool
Definition: format.h:392
constexpr uint128_fallback(uint64_t value=0)
Definition: format.h:374
FMT_CONSTEXPR void operator+=(uint128_fallback n)
Definition: format.h:441
friend constexpr auto operator&(const uint128_fallback &lhs, const uint128_fallback &rhs) -> uint128_fallback
Definition: format.h:401
FMT_CONSTEXPR void operator&=(uint128_fallback n)
Definition: format.h:448
constexpr uint64_t high() const noexcept
Definition: format.h:376
Definition: format.h:1410
FMT_API utf8_to_utf16(string_view s)
Definition: format-inl.h:1387
auto size() const -> size_t
Definition: format.h:1417
auto c_str() const -> const wchar_t *
Definition: format.h:1418
auto str() const -> std::wstring
Definition: format.h:1419
Definition: format.h:3822
FMT_CONSTEXPR width_checker(ErrorHandler &eh)
Definition: format.h:3824
FMT_CONSTEXPR auto operator()(T) -> unsigned long long
Definition: format.h:3833
FMT_CONSTEXPR auto operator()(T value) -> unsigned long long
Definition: format.h:3827
Definition: format.h:1080
loc_value(T)
Definition: format.h:1089
loc_value(T value)
Definition: format.h:1086
auto visit(Visitor &&vis) -> decltype(vis(0))
Definition: format.h:1091
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:256
#define FMT_ASSERT(condition, message)
Definition: core.h:336
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0))
\rst Visits an argument dispatching to the appropriate visit method based on the argument type.
Definition: core.h:1665
#define FMT_END_EXPORT
Definition: core.h:185
basic_string_view< char > string_view
Definition: core.h:501
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
\rst Returns a named argument to be used in a formatting function.
Definition: core.h:1841
#define FMT_NODISCARD
Definition: core.h:154
typename std::remove_reference< T >::type remove_reference_t
Definition: core.h:261
typename detail::char_t_impl< S >::type char_t
String's character type.
Definition: core.h:646
#define FMT_CONSTEXPR
Definition: core.h:105
#define FMT_BEGIN_NAMESPACE
Definition: core.h:174
#define FMT_API
Definition: core.h:202
constexpr auto make_format_args(T &... args) -> format_arg_store< Context, remove_cvref_t< T >... >
\rst Constructs a ~fmtformat_arg_store object that contains references to arguments and can be implic...
Definition: core.h:1824
#define FMT_ENABLE_IF(...)
Definition: core.h:286
#define FMT_BEGIN_EXPORT
Definition: core.h:184
#define FMT_CONSTEXPR_CHAR_TRAITS
Definition: core.h:129
#define FMT_INLINE
Definition: core.h:162
#define FMT_MSC_WARNING(...)
Definition: core.h:58
typename type_identity< T >::type type_identity_t
Definition: core.h:267
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:258
#define FMT_CONSTEXPR20
Definition: core.h:113
sign::type sign_t
Definition: core.h:1990
typename std::remove_cv< remove_reference_t< T > >::type remove_cvref_t
Definition: core.h:265
typename std::underlying_type< T >::type underlying_t
Definition: core.h:269
#define FMT_END_NAMESPACE
Definition: core.h:177
dimensionless::scalar_t exp(const ScalarUnit x) noexcept
Compute exponential function.
Definition: math.h:332
FMT_FUNC uint128_fallback get_cached_power(int k) noexcept
Definition: format-inl.h:1115
uint32_t divisor
Definition: format-inl.h:197
int floor_log2_pow10(int e) noexcept
Definition: format.h:1528
uint64_t umul128_upper64(uint64_t x, uint64_t y) noexcept
Definition: format.h:1534
uint128_fallback umul192_upper128(uint64_t x, uint128_fallback y) noexcept
Definition: format.h:1547
int floor_log10_pow2(int e) noexcept
Definition: format.h:1522
decimal_fp< T > to_decimal(T x) noexcept
Definition: format-inl.h:1235
An error reported from a formatting function.
Definition: format.h:1054
constexpr auto compile_string_to_view(const Char(&s)[N]) -> basic_string_view< Char >
Definition: format.h:1067
detail namespace with internal helper functions
Definition: xchar.h:20
FMT_CONSTEXPR auto code_point_length(const Char *begin) -> int
Definition: core.h:2112
constexpr auto digits10< int128_opt >() noexcept -> int
Definition: format.h:1286
uint128_fallback umul128(uint64_t x, uint64_t y) noexcept
Definition: format.h:1491
FMT_CONSTEXPR auto format_uint(Char *buffer, UInt value, int num_digits, bool upper=false) -> Char *
Definition: format.h:1383
FMT_CONSTEXPR FMT_NOINLINE auto write_int_noinline(OutputIt out, write_int_arg< T > arg, const format_specs< Char > &specs, locale_ref loc) -> OutputIt
Definition: format.h:2270
FMT_FUNC bool write_console(std::FILE *, string_view)
Definition: format-inl.h:1428
FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP &f, const format_specs< Char > &specs, float_specs fspecs, locale_ref loc) -> OutputIt
Definition: format.h:2627
FMT_CONSTEXPR auto write_char(OutputIt out, Char value, const format_specs< Char > &specs) -> OutputIt
Definition: format.h:2000
constexpr auto to_ascii(Char c) -> char
Definition: core.h:2102
FMT_CONSTEXPR20 auto bit_cast(const From &from) -> To
Definition: format.h:343
FMT_CONSTEXPR auto check_char_specs(const format_specs< Char > &specs) -> bool
Definition: core.h:2558
decltype(std::end(std::declval< T & >())) sentinel_t
Definition: format.h:552
FMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, int num_digits, unsigned prefix, const format_specs< Char > &specs, W write_digits) -> OutputIt
Definition: format.h:2048
template FMT_API auto thousands_sep_impl< char >(locale_ref) -> thousands_sep_result< char >
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
Definition: format.h:811
FMT_CONSTEXPR void ignore_unused(const T &...)
Definition: core.h:302
auto decimal_point(locale_ref loc) -> Char
Definition: format.h:1308
FMT_INLINE void assume(bool condition)
Definition: format.h:540
auto get_buffer(OutputIt out) -> iterator_buffer< OutputIt, T >
Definition: core.h:1117
FMT_CONSTEXPR void handle_dynamic_spec(int &value, arg_ref< typename Context::char_type > ref, Context &ctx)
Definition: format.h:3878
constexpr auto num_bits() -> int
Definition: format.h:492
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const format_specs< Char > &specs) -> OutputIt
Definition: format.h:1819
uint128_opt
Definition: core.h:367
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition: chrono.h:419
FMT_CONSTEXPR void prefix_append(unsigned &prefix, unsigned value)
Definition: format.h:2166
auto write_loc(std::back_insert_iterator< detail::buffer< wchar_t > > out, loc_value value, const format_specs< wchar_t > &specs, locale_ref loc) -> bool
Definition: xchar.h:25
auto is_big_endian() -> bool
Definition: format.h:353
conditional_t< long_short, unsigned, unsigned long long > ulong_type
Definition: core.h:1316
FMT_CONSTEXPR auto count_digits_fallback(T n) -> int
Definition: format.h:1179
void(*)(detail::buffer< char > &, int, const char *) format_func
Definition: format.h:3942
FMT_CONSTEXPR auto write_padded(OutputIt out, const format_specs< Char > &specs, size_t size, size_t width, F &&f) -> OutputIt
Definition: format.h:1794
auto compute_width(basic_string_view< Char > s) -> size_t
Definition: format.h:738
constexpr auto num_bits< uint128_t >() -> int
Definition: format.h:497
constexpr auto digits10() noexcept -> int
Definition: format.h:1283
FMT_CONSTEXPR20 auto format_decimal(Char *out, UInt value, int size) -> format_decimal_result< Char * >
Definition: format.h:1350
dragon
Definition: format.h:3060
@ fixup
Definition: format.h:3062
@ predecessor_closer
Definition: format.h:3061
@ fixed
Definition: format.h:3063
auto reserve(std::back_insert_iterator< Container > it, size_t n) -> typename Container::value_type *
Definition: format.h:571
std::is_same< T, float128 > is_float128
Definition: format.h:851
constexpr auto digits10< uint128_t >() noexcept -> int
Definition: format.h:1287
FMT_CONSTEXPR20 void adjust_precision(int &precision, int exp10)
Definition: format.h:2798
constexpr auto max_value() -> T
Definition: format.h:489
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< Char >
Definition: core.h:517
void float128
Definition: format.h:849
int128_opt
Definition: core.h:366
@ value
the parser finished reading a JSON value
FMT_CONSTEXPR20 auto write_float(OutputIt out, const DecimalFP &f, const format_specs< Char > &specs, float_specs fspecs, locale_ref loc) -> OutputIt
Definition: format.h:2746
constexpr FMT_INLINE_VARIABLE uint32_t invalid_code_point
Definition: format.h:702
FMT_FUNC void print(std::FILE *f, string_view text)
Definition: format-inl.h:1452
FMT_CONSTEXPR auto get_arg(Context &ctx, ID id) -> decltype(ctx.arg(id))
Definition: format.h:3871
FMT_FUNC void report_error(format_func func, int error_code, const char *message) noexcept
Definition: format-inl.h:66
FMT_FUNC void throw_format_error(const char *message)
Definition: format-inl.h:39
FMT_NOINLINE FMT_CONSTEXPR auto fill(OutputIt it, size_t n, const fill_t< Char > &fill) -> OutputIt
Definition: format.h:1779
constexpr auto to_pointer(OutputIt, size_t) -> T *
Definition: format.h:596
FMT_FUNC void format_error_code(detail::buffer< char > &out, int error_code, string_view message) noexcept
Definition: format-inl.h:43
to_utf8_error_policy
Definition: format.h:1422
auto equal2(const Char *lhs, const char *rhs) -> bool
Definition: format.h:1316
constexpr bool has_implicit_bit()
Definition: format.h:1608
typename std::enable_if< B, T >::type enable_if_t
Definition: cpp_future.h:38
FMT_CONSTEXPR20 FMT_INLINE void copy2(Char *dst, const char *src)
Definition: format.h:1325
bool_constant< std::is_floating_point< T >::value||is_float128< T >::value > is_floating_point
Definition: format.h:855
auto write_ptr(OutputIt out, UIntPtr value, const format_specs< Char > *specs) -> OutputIt
Definition: format.h:1829
auto vformat(const Locale &loc, basic_string_view< Char > fmt, basic_format_args< buffer_context< type_identity_t< Char > > > args) -> std::basic_string< Char >
Definition: format.h:3934
remove_reference_t< decltype(reserve(std::declval< OutputIt & >(), 0))> reserve_iterator
Definition: format.h:593
auto decimal_point(locale_ref loc) -> wchar_t
Definition: format.h:1311
float_format
Definition: format.h:2441
decltype(std::begin(std::declval< T & >())) iterator_t
Definition: format.h:551
FMT_CONSTEXPR20 void format_hexfloat(Float value, int precision, float_specs specs, buffer< char > &buf)
Definition: format.h:3200
FMT_CONSTEXPR auto is_utf8() -> bool
Definition: core.h:380
FMT_CONSTEXPR20 auto format_float(Float value, int precision, float_specs specs, buffer< char > &buf) -> int
Definition: format.h:3287
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:1986
constexpr auto num_bits< int128_opt >() -> int
Definition: format.h:496
FMT_CONSTEXPR FMT_INLINE auto make_arg(T &val) -> value< Context >
Definition: core.h:1558
FMT_CONSTEXPR uint64_t multiply(uint64_t lhs, uint64_t rhs)
Definition: format.h:1725
auto thousands_sep(locale_ref loc) -> thousands_sep_result< Char >
Definition: format.h:1297
conditional_t< FMT_USE_INT128, uint128_opt, uint128_fallback > uint128_t
Definition: format.h:479
FMT_CONSTEXPR fp operator*(fp x, fp y)
Definition: format.h:1742
FMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
Definition: format.h:622
constexpr int num_significand_bits()
Definition: format.h:1615
std::integral_constant< bool, Value > bool_constant
Definition: type_traits.h:688
constexpr auto exponent_bias() -> int
Definition: format.h:1629
FMT_CONSTEXPR auto parse_float_type_spec(const format_specs< Char > &specs, ErrorHandler &&eh={}) -> float_specs
Definition: format.h:2459
auto get_container(std::back_insert_iterator< Container > it) -> Container &
Definition: core.h:765
constexpr Char sign(Sign s)
Definition: format.h:1172
constexpr auto count() -> size_t
Definition: core.h:1203
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T > > > buffer_appender
Definition: core.h:1113
FMT_CONSTEXPR auto utf8_decode(const char *s, uint32_t *c, int *e) -> const char *
Definition: format.h:665
FMT_CONSTEXPR void abort_fuzzing_if(bool condition)
Definition: format.h:291
constexpr auto write_significand(OutputIt out, const char *significand, int significand_size) -> OutputIt
Definition: format.h:2537
auto write_escaped_cp(OutputIt out, const find_escape_result< Char > &escape) -> OutputIt
Definition: format.h:1925
FMT_CONSTEXPR20 auto write_nonfinite(OutputIt out, bool isnan, format_specs< Char > specs, const float_specs &fspecs) -> OutputIt
Definition: format.h:2503
auto base_iterator(std::back_insert_iterator< Container > it, typename Container::value_type *) -> std::back_insert_iterator< Container >
Definition: format.h:608
constexpr auto get_significand_size(const big_decimal_fp &f) -> int
Definition: format.h:2528
FMT_CONSTEXPR auto is_supported_floating_point(T) -> bool
Definition: format.h:1139
FMT_INLINE auto get_iterator(Buf &buf, OutputIt) -> decltype(buf.out())
Definition: core.h:1127
auto needs_escape(uint32_t cp) -> bool
Definition: format.h:1845
constexpr auto convert_float(T value) -> convert_float_result< T >
Definition: format.h:1774
auto write_codepoint(OutputIt out, char prefix, uint32_t cp) -> OutputIt
Definition: format.h:1915
constexpr auto set(type rhs) -> int
Definition: core.h:610
auto code_point_index(basic_string_view< Char > s, size_t n) -> size_t
Definition: format.h:783
conditional_t< num_bits< T >()<=64, uint64_t, uint128_t > uint64_or_128_t
Definition: format.h:1154
bool isfinite(T)
Definition: chrono.h:1600
conditional_t< std::is_same< T, float >::value||doublish, double, T > convert_float_result
Definition: format.h:1771
auto get_data(std::basic_string< Char > &s) -> Char *
Definition: format.h:556
FMT_FUNC auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result< Char >
Definition: format-inl.h:93
FMT_CONSTEXPR bool isfinite(T value)
Definition: format.h:2779
auto is_printable(uint16_t x, const singleton *singletons, size_t singletons_size, const unsigned char *singleton_lowers, const unsigned char *normal, size_t normal_size) -> bool
Definition: format-inl.h:1474
constexpr bool isnan(T value)
Definition: format.h:2759
state
Definition: core.h:2271
FMT_CONSTEXPR void for_each_codepoint(string_view s, F f)
Definition: format.h:707
void vformat_to(buffer< Char > &buf, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
Definition: color.h:436
FMT_CONSTEXPR20 auto countl_zero_fallback(UInt n) -> int
Definition: format.h:519
constexpr auto is_negative(T value) -> bool
Definition: format.h:1130
type
Definition: core.h:556
constexpr FMT_INLINE auto const_check(T value) -> T
Definition: core.h:323
conditional_t< long_short, int, long long > long_type
Definition: core.h:1315
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition: core.h:374
uint128_t uintptr_t
Definition: format.h:484
auto find_escape(const Char *begin, const Char *end) -> find_escape_result< Char >
Definition: format.h:1863
FMT_CONSTEXPR auto write_exponent(int exp, It it) -> It
Definition: format.h:1637
FMT_CONSTEXPR FMT_INLINE auto parse_format_specs(const Char *begin, const Char *end, dynamic_format_specs< Char > &specs, basic_format_parse_context< Char > &ctx, type arg_type) -> const Char *
Definition: core.h:2275
FMT_CONSTEXPR auto make_write_int_arg(T value, sign_t sign) -> write_int_arg< uint32_or_64_or_128_t< T > >
Definition: format.h:2177
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:817
FMT_CONSTEXPR20 auto count_digits(uint64_t n) -> int
Definition: format.h:1222
FMT_CONSTEXPR basic_fp< F > normalize(basic_fp< F > value)
Definition: format.h:1708
constexpr FMT_INLINE auto is_constant_evaluated(bool default_value=false) noexcept -> bool
Definition: core.h:304
FMT_CONSTEXPR auto parse_align(const Char *begin, const Char *end, format_specs< Char > &specs) -> const Char *
Definition: format.h:2399
conditional_t< num_bits< T >()<=32 &&!FMT_REDUCE_INT_INSTANTIATIONS, uint32_t, conditional_t< num_bits< T >()<=64, uint64_t, uint128_t > > uint32_or_64_or_128_t
Definition: format.h:1152
FMT_FUNC Char decimal_point_impl(locale_ref loc)
Definition: format-inl.h:99
FMT_CONSTEXPR FMT_NOINLINE auto copy_str_noinline(InputIt begin, InputIt end, OutputIt out) -> OutputIt
Definition: format.h:643
constexpr auto exponent_mask() -> typename dragonbox::float_info< Float >::carrier_uint
Definition: format.h:1623
typename conditional_t< std::is_integral< Char >::value, std::make_unsigned< Char >, type_identity< uint32_t > >::type make_unsigned_char
Definition: format.h:1860
FMT_CONSTEXPR auto get_dynamic_spec(FormatArg arg, ErrorHandler eh) -> int
Definition: format.h:3864
constexpr const char * digits2(size_t value)
Definition: format.h:1162
FMT_CONSTEXPR20 auto countl_zero(uint32_t n) -> int
Definition: format.h:526
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: string_escape.h:50
char8_type
Definition: format.h:639
FMT_CONSTEXPR20 void format_dragon(basic_fp< uint128_t > value, unsigned flags, int num_digits, buffer< char > &buf, int &exp10)
Definition: format.h:3069
auto write_escaped_string(OutputIt out, basic_string_view< Char > str) -> OutputIt
Definition: format.h:1970
FMT_INLINE FMT_CONSTEXPR bool signbit(T value)
Definition: format.h:2786
Definition: format.h:4127
constexpr auto format_as(Enum e) noexcept -> underlying_t< Enum >
Definition: format.h:4129
constexpr common_return_t< T1, T2 > beta(const T1 a, const T2 b) noexcept
Compile-time beta function.
Definition: beta.hpp:42
static constexpr const unit_t< compound_unit< energy::joule, time::seconds > > h(6.626070040e-34)
Planck constant.
static constexpr const unit_t< compound_unit< charge::coulomb, inverse< substance::mol > > > F(N_A *e)
Faraday constant.
static constexpr const charge::coulomb_t e(1.6021766208e-19)
elementary charge.
static constexpr const velocity::meters_per_second_t c(299792458.0)
Speed of light in vacuum.
UnitTypeLhs() max(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3417
bits
Definition: data.h:44
arg_id_kind kind
Definition: core.h:2081
union detail::arg_ref::value val
Definition: format.h:1746
static constexpr uint32_t fractional_part_rounding_thresholds[8]
Definition: format.h:1750
Definition: format.h:1658
FMT_CONSTEXPR basic_fp(Float n)
Definition: format.h:1669
constexpr basic_fp(uint64_t f_val, int e_val)
Definition: format.h:1666
FMT_CONSTEXPR auto assign(Float n) -> bool
Definition: format.h:1673
constexpr basic_fp()
Definition: format.h:1665
int e
Definition: format.h:1660
static constexpr const int num_significand_bits
Definition: format.h:1662
F f
Definition: format.h:1659
Definition: format.h:2522
const char * significand
Definition: format.h:2523
int significand_size
Definition: format.h:2524
int exponent
Definition: format.h:2525
Definition: format.h:2311
FMT_CONSTEXPR void operator=(const T &)
Definition: format.h:2312
Definition: format.h:1762
Definition: format.h:1598
int exponent
Definition: format.h:1601
significand_type significand
Definition: format.h:1600
typename float_info< T >::carrier_uint significand_type
Definition: format.h:1599
detail::uint128_t carrier_uint
Definition: format.h:1595
detail::uint128_t carrier_uint
Definition: format.h:1588
Definition: format.h:1571
uint64_t carrier_uint
Definition: format.h:1572
uint32_t carrier_uint
Definition: format.h:1560
Definition: format.h:1557
FMT_NORETURN void on_error(const char *message)
Definition: core.h:636
Definition: format.h:1850
const Char * end
Definition: format.h:1852
const Char * begin
Definition: format.h:1851
uint32_t cp
Definition: format.h:1853
Definition: format.h:2448
int precision
Definition: format.h:2449
bool showpoint
Definition: format.h:2455
bool locale
Definition: format.h:2453
bool upper
Definition: format.h:2452
sign_t sign
Definition: format.h:2451
float_format format
Definition: format.h:2450
bool binary32
Definition: format.h:2454
Definition: format.h:2764
Definition: format.h:2192
std::string grouping
Definition: format.h:2196
auto operator()(T value) -> bool
Definition: format.h:2200
auto operator()(T) -> bool
Definition: format.h:2208
std::basic_string< Char > decimal_point
Definition: format.h:2197
buffer_appender< Char > out
Definition: format.h:2193
std::basic_string< Char > sep
Definition: format.h:2195
const format_specs< Char > & specs
Definition: format.h:2194
static constexpr CharT value[sizeof...(C)]
Definition: format.h:299
Definition: format.h:1289
Char thousands_sep
Definition: format.h:1291
std::string grouping
Definition: format.h:1290
Definition: format.h:2171
unsigned prefix
Definition: format.h:2173
UInt abs_value
Definition: format.h:2172
Definition: format.h:2023
FMT_CONSTEXPR write_int_data(int num_digits, unsigned prefix, const format_specs< Char > &specs)
Definition: format.h:2027
size_t size
Definition: format.h:2024
size_t padding
Definition: format.h:2025
Definition: format.h:4165
T value
Definition: format.h:4166
Definition: format.h:4210
It begin
Definition: format.h:4211
join_view(It b, Sentinel e, basic_string_view< Char > s)
Definition: format.h:4215
Sentinel end
Definition: format.h:4212
basic_string_view< Char > sep
Definition: format.h:4213
basic_string_view< Char > name
Definition: core.h:2087
int index
Definition: core.h:2086