diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index c93123fd..723b1f00 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -2279,7 +2279,7 @@ struct formatter, Char> { // As a possible future optimization, we could avoid extra copying if width // is not specified. auto buf = basic_memory_buffer(); - auto out = std::back_inserter(buf); + auto out = basic_appender(buf); detail::handle_dynamic_spec(specs.width, width_ref_, ctx); detail::handle_dynamic_spec(precision, @@ -2388,7 +2388,7 @@ template struct formatter { const Duration* subsecs) const -> decltype(ctx.out()) { auto specs = specs_; auto buf = basic_memory_buffer(); - auto out = std::back_inserter(buf); + auto out = basic_appender(buf); detail::handle_dynamic_spec(specs.width, width_ref_, ctx); diff --git a/include/fmt/compile.h b/include/fmt/compile.h index b2afc2c3..b33a40db 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -494,9 +494,9 @@ auto format_to_n(OutputIt out, size_t n, const S& fmt, Args&&... args) template ::value)> -FMT_CONSTEXPR20 auto formatted_size(const S& fmt, const Args&... args) - -> size_t { - return fmt::format_to(detail::counting_iterator(), fmt, args...).count(); +auto formatted_size(const S& fmt, const Args&... args) -> size_t { + auto buf = detail::counting_buffer<>(); + return fmt::format_to(fmt::appender(buf), fmt, args...).count(); } template >::value)> -FMT_CONSTEXPR inline auto format_decimal(Iterator out, UInt value, int size) - -> format_decimal_result { +template ::value)> +FMT_CONSTEXPR inline auto format_decimal(OutputIt out, UInt value, int size) + -> format_decimal_result { // Buffer is large enough to hold all digits (digits10 + 1). Char buffer[digits10() + 1] = {}; auto end = format_decimal(buffer, value, size).end; diff --git a/test/compile-test.cc b/test/compile-test.cc index a4c350bc..ff2d573b 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -206,7 +206,7 @@ TEST(compile_test, format_to_n) { EXPECT_STREQ("2a", buffer); } -# ifdef __cpp_lib_bit_cast +# if 0 TEST(compile_test, constexpr_formatted_size) { FMT_CONSTEXPR20 size_t size = fmt::formatted_size(FMT_COMPILE("{}"), 42); EXPECT_EQ(size, 2);