diff --git a/include/fmt/format.h b/include/fmt/format.h index 45cab4cd..37223f2d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -67,6 +67,10 @@ # include # define FMT_USE_STRING_VIEW # endif + +# if FMT_MSC_VERSION +# include // _BitScanReverse[64], _BitScanForward[64], _umul128 +# endif #endif // FMT_MODULE #if defined(FMT_USE_NONTYPE_TEMPLATE_ARGS) @@ -119,7 +123,7 @@ template <> struct iterator_traits { using iterator_category = output_iterator_tag; using value_type = char; using reference = char&; - using difference_type = ptrdiff_t; + using difference_type = fmt::appender::difference_type; }; } // namespace std @@ -168,7 +172,7 @@ FMT_END_NAMESPACE # define FMT_REDUCE_INT_INSTANTIATIONS 0 #endif -// __builtin_clz is broken in clang with Microsoft CodeGen: +// __builtin_clz is broken in clang with Microsoft codegen: // https://github.com/fmtlib/fmt/issues/519. #if !FMT_MSC_VERSION # if FMT_HAS_BUILTIN(__builtin_clz) || FMT_GCC_VERSION || FMT_ICC_VERSION @@ -192,10 +196,6 @@ FMT_END_NAMESPACE # endif #endif -#if FMT_MSC_VERSION && !defined(FMT_MODULE) -# include // _BitScanReverse[64], _BitScanForward[64], _umul128 -#endif - // Some compilers masquerade as both MSVC and GCC-likes or otherwise support // __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the // MSVC intrinsics if the clz and clzll builtins are not available. @@ -2287,8 +2287,7 @@ FMT_CONSTEXPR auto write(OutputIt out, basic_string_view s, }); } template -FMT_CONSTEXPR auto write(OutputIt out, - basic_string_view> s, +FMT_CONSTEXPR auto write(OutputIt out, basic_string_view s, const format_specs& specs, locale_ref) -> OutputIt { return write(out, s, specs); } @@ -3888,6 +3887,11 @@ template struct formatter, Char> : formatter {}; +template +struct formatter + : detail::native_formatter {}; + /** * Converts `p` to `const void*` for pointer formatting. * @@ -3932,13 +3936,10 @@ template <> struct formatter : formatter { }; #endif -class bytes { - private: - string_view data_; - friend struct formatter; +struct bytes { + string_view data; - public: - explicit bytes(string_view data) : data_(data) {} + explicit bytes(string_view s) : data(s) {} }; template <> struct formatter { @@ -3958,7 +3959,7 @@ template <> struct formatter { specs.width_ref, ctx); detail::handle_dynamic_spec(specs.dynamic_precision(), specs.precision, specs.precision_ref, ctx); - return detail::write_bytes(ctx.out(), b.data_, specs); + return detail::write_bytes(ctx.out(), b.data, specs); } }; @@ -4066,11 +4067,6 @@ template struct nested_formatter { } }; -template -struct formatter - : detail::native_formatter {}; - inline namespace literals { #if FMT_USE_NONTYPE_TEMPLATE_ARGS template constexpr auto operator""_a() {