diff --git a/src/fmt/core.h b/src/fmt/core.h index b4fc461011..49743efc0b 100644 --- a/src/fmt/core.h +++ b/src/fmt/core.h @@ -18,7 +18,7 @@ #include // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 70102 +#define FMT_VERSION 70103 #ifdef __clang__ # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) @@ -769,7 +769,7 @@ class fixed_buffer_traits { explicit fixed_buffer_traits(size_t limit) : limit_(limit) {} size_t count() const { return count_; } size_t limit(size_t size) { - size_t n = limit_ - count_; + size_t n = limit_ > count_ ? limit_ - count_ : 0; count_ += size; return size < n ? size : n; } @@ -792,7 +792,7 @@ class iterator_buffer final : public Traits, public buffer { public: explicit iterator_buffer(OutputIt out, size_t n = buffer_size) : Traits(n), - buffer(data_, 0, n < size_t(buffer_size) ? n : size_t(buffer_size)), + buffer(data_, 0, buffer_size), out_(out) {} ~iterator_buffer() { flush(); } diff --git a/src/fmt/format.h b/src/fmt/format.h index 13b8da3028..1a037b02b7 100644 --- a/src/fmt/format.h +++ b/src/fmt/format.h @@ -1145,8 +1145,8 @@ template struct null {}; template struct fill_t { private: enum { max_size = 4 }; - Char data_[max_size]; - unsigned char size_; + Char data_[max_size] = {Char(' '), Char(0), Char(0), Char(0)}; + unsigned char size_ = 1; public: FMT_CONSTEXPR void operator=(basic_string_view s) { @@ -1166,13 +1166,6 @@ template struct fill_t { FMT_CONSTEXPR const Char& operator[](size_t index) const { return data_[index]; } - - static FMT_CONSTEXPR fill_t make() { - auto fill = fill_t(); - fill[0] = Char(' '); - fill.size_ = 1; - return fill; - } }; } // namespace detail @@ -1204,8 +1197,7 @@ template struct basic_format_specs { type(0), align(align::none), sign(sign::none), - alt(false), - fill(detail::fill_t::make()) {} + alt(false) {} }; using format_specs = basic_format_specs; @@ -1274,7 +1266,7 @@ template struct decimal_fp { int exponent; }; -template decimal_fp to_decimal(T x) FMT_NOEXCEPT; +template FMT_API decimal_fp to_decimal(T x) FMT_NOEXCEPT; } // namespace dragonbox template diff --git a/src/fmt/os.h b/src/fmt/os.h index 881510065a..d44ea0c904 100644 --- a/src/fmt/os.h +++ b/src/fmt/os.h @@ -388,7 +388,7 @@ class ostream final : private detail::buffer { clear(); } - void grow(size_t) final; + FMT_API void grow(size_t) override final; ostream(cstring_view path, const detail::ostream_params& params) : file_(path, params.oflag) { diff --git a/src/fmt/ranges.h b/src/fmt/ranges.h index b603d637d7..632f04949c 100644 --- a/src/fmt/ranges.h +++ b/src/fmt/ranges.h @@ -254,7 +254,10 @@ struct formatter< enable_if_t::value // Workaround a bug in MSVC 2017 and earlier. #if !FMT_MSC_VER || FMT_MSC_VER >= 1927 - && has_formatter, format_context>::value + && + (has_formatter, format_context>::value || + detail::has_fallback_formatter, + format_context>::value) #endif >> { formatting_range formatting; diff --git a/src/fmtlib_format.cpp b/src/fmtlib_format.cpp index bca87b033b..6141d964a7 100644 --- a/src/fmtlib_format.cpp +++ b/src/fmtlib_format.cpp @@ -24,9 +24,9 @@ int format_float(char* buf, std::size_t size, const char* format, int precision, : snprintf_ptr(buf, size, format, precision, value); } -template dragonbox::decimal_fp dragonbox::to_decimal(float x) +template FMT_API dragonbox::decimal_fp dragonbox::to_decimal(float x) FMT_NOEXCEPT; -template dragonbox::decimal_fp dragonbox::to_decimal(double x) +template FMT_API dragonbox::decimal_fp dragonbox::to_decimal(double x) FMT_NOEXCEPT; // DEPRECATED! This function exists for ABI compatibility. diff --git a/src/fmtlib_os.cpp b/src/fmtlib_os.cpp index a07e782441..6850024588 100644 --- a/src/fmtlib_os.cpp +++ b/src/fmtlib_os.cpp @@ -315,7 +315,7 @@ long getpagesize() { # endif } -void ostream::grow(size_t) { +FMT_API void ostream::grow(size_t) { if (this->size() == this->capacity()) flush(); } #endif // FMT_USE_FCNTL