diff --git a/include/fmt/core.h b/include/fmt/core.h index a9a5527e..d6c941fa 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1160,8 +1160,6 @@ constexpr auto has_const_formatter() -> bool { return has_const_formatter_impl(static_cast(nullptr)); } -template using buffer_appender = basic_appender; - // Maps an output iterator to a buffer. template auto get_buffer(OutputIt out) -> iterator_buffer { @@ -1787,8 +1785,7 @@ template class basic_format_context { }; template -using buffer_context = - basic_format_context, Char>; +using buffer_context = basic_format_context, Char>; using format_context = basic_format_context; template diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 8da1c17f..00d77d54 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -52,7 +52,7 @@ FMT_FUNC void format_error_code(detail::buffer& out, int error_code, ++error_code_size; } error_code_size += detail::to_unsigned(detail::count_digits(abs_value)); - auto it = buffer_appender(out); + auto it = appender(out); if (message.size() <= inline_buffer_size - error_code_size) fmt::format_to(it, FMT_STRING("{}{}"), message, SEP); fmt::format_to(it, FMT_STRING("{}{}"), ERROR_STR, error_code); diff --git a/include/fmt/format.h b/include/fmt/format.h index 6f4312f5..282aeae1 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -582,7 +582,7 @@ reserve(std::back_insert_iterator it, size_t n) -> } template -inline auto reserve(buffer_appender it, size_t n) -> buffer_appender { +inline auto reserve(basic_appender it, size_t n) -> basic_appender { buffer& buf = get_container(it); buf.try_reserve(buf.size() + n); return it; @@ -601,7 +601,7 @@ template constexpr auto to_pointer(OutputIt, size_t) -> T* { return nullptr; } -template auto to_pointer(buffer_appender it, size_t n) -> T* { +template auto to_pointer(basic_appender it, size_t n) -> T* { buffer& buf = get_container(it); auto size = buf.size(); if (buf.capacity() < size + n) return nullptr; @@ -2190,7 +2190,7 @@ FMT_CONSTEXPR auto make_write_int_arg(T value, sign_t sign) } template struct loc_writer { - buffer_appender out; + basic_appender out; const format_specs& specs; std::basic_string sep; std::string grouping; @@ -2275,7 +2275,7 @@ FMT_CONSTEXPR FMT_NOINLINE auto write_int_noinline( template ::value && !std::is_same::value && - std::is_same>::value)> + std::is_same>::value)> FMT_CONSTEXPR FMT_INLINE auto write(OutputIt out, T value, const format_specs& specs, locale_ref loc) -> OutputIt { @@ -2287,7 +2287,7 @@ FMT_CONSTEXPR FMT_INLINE auto write(OutputIt out, T value, template ::value && !std::is_same::value && - !std::is_same>::value)> + !std::is_same>::value)> FMT_CONSTEXPR FMT_INLINE auto write(OutputIt out, T value, const format_specs& specs, locale_ref loc) -> OutputIt { @@ -2614,8 +2614,8 @@ FMT_CONSTEXPR20 auto write_significand(OutputIt out, T significand, decimal_point); } auto buffer = basic_memory_buffer(); - write_significand(buffer_appender(buffer), significand, - significand_size, integral_size, decimal_point); + write_significand(basic_appender(buffer), significand, significand_size, + integral_size, decimal_point); grouping.apply( out, basic_string_view(buffer.data(), to_unsigned(integral_size))); return detail::copy_str_noinline(buffer.data() + integral_size, @@ -3337,11 +3337,11 @@ FMT_CONSTEXPR20 auto format_float(Float value, int precision, float_specs specs, // Use Dragonbox for the shortest format. if (specs.binary32) { auto dec = dragonbox::to_decimal(static_cast(value)); - write(buffer_appender(buf), dec.significand); + write(appender(buf), dec.significand); return dec.exponent; } auto dec = dragonbox::to_decimal(static_cast(value)); - write(buffer_appender(buf), dec.significand); + write(appender(buf), dec.significand); return dec.exponent; } else { // Extract significand bits and exponent bits. @@ -3789,7 +3789,7 @@ FMT_CONSTEXPR auto write(OutputIt out, const T& value) // An argument visitor that formats the argument and writes it via the output // iterator. It's a class and not a generic lambda for compatibility with C++11. template struct default_arg_formatter { - using iterator = buffer_appender; + using iterator = basic_appender; using context = buffer_context; iterator out; @@ -3808,7 +3808,7 @@ template struct default_arg_formatter { }; template struct arg_formatter { - using iterator = buffer_appender; + using iterator = basic_appender; using context = buffer_context; iterator out; @@ -4299,7 +4299,7 @@ namespace detail { template void vformat_to(buffer& buf, basic_string_view fmt, typename vformat_args::type args, locale_ref loc) { - auto out = buffer_appender(buf); + auto out = basic_appender(buf); if (fmt.size() == 2 && equal2(fmt.data(), "{}")) { auto arg = args.get(0); if (!arg) throw_format_error("argument not found"); @@ -4311,7 +4311,7 @@ void vformat_to(buffer& buf, basic_string_view fmt, basic_format_parse_context parse_context; buffer_context context; - format_handler(buffer_appender p_out, basic_string_view str, + format_handler(basic_appender p_out, basic_string_view str, basic_format_args> p_args, locale_ref p_loc) : parse_context(str), context(p_out, p_args, p_loc) {} diff --git a/include/fmt/printf.h b/include/fmt/printf.h index b270dcf4..fbf3f6f1 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -22,7 +22,7 @@ template struct printf_formatter { template class basic_printf_context { private: - detail::buffer_appender out_; + basic_appender out_; basic_format_args args_; static_assert(std::is_same::value || @@ -40,12 +40,12 @@ template class basic_printf_context { stored in the context object so make sure they have appropriate lifetimes. \endrst */ - basic_printf_context(detail::buffer_appender out, + basic_printf_context(basic_appender out, basic_format_args args) : out_(out), args_(args) {} - auto out() -> detail::buffer_appender { return out_; } - void advance_to(detail::buffer_appender) {} + auto out() -> basic_appender { return out_; } + void advance_to(basic_appender) {} auto locale() -> detail::locale_ref { return {}; } @@ -222,7 +222,7 @@ template class printf_width_handler { // Workaround for a bug with the XL compiler when initializing // printf_arg_formatter's base class. template -auto make_arg_formatter(buffer_appender iter, format_specs& s) +auto make_arg_formatter(basic_appender iter, format_specs& s) -> arg_formatter { return {iter, s, locale_ref()}; } @@ -243,7 +243,7 @@ class printf_arg_formatter : public arg_formatter { } public: - printf_arg_formatter(buffer_appender iter, format_specs& s, + printf_arg_formatter(basic_appender iter, format_specs& s, context_type& ctx) : base(make_arg_formatter(iter, s)), context_(ctx) {} @@ -416,7 +416,7 @@ inline auto parse_printf_presentation_type(char c, type t) template void vprintf(buffer& buf, basic_string_view format, basic_format_args args) { - using iterator = buffer_appender; + using iterator = basic_appender; auto out = iterator(buf); auto context = basic_printf_context(out, args); auto parse_ctx = basic_format_parse_context(format); diff --git a/test/core-test.cc b/test/core-test.cc index 804d5a53..3ebe3ee7 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -114,7 +114,7 @@ TEST(core_test, is_back_insert_iterator) { TEST(core_test, buffer_appender) { #ifdef __cpp_lib_ranges - static_assert(std::output_iterator, char>); + static_assert(std::output_iterator); #endif } @@ -449,8 +449,7 @@ struct check_custom { 10) {} } buffer; auto parse_ctx = fmt::format_parse_context(""); - auto ctx = fmt::format_context(fmt::detail::buffer_appender(buffer), - fmt::format_args()); + auto ctx = fmt::format_context(fmt::appender(buffer), fmt::format_args()); h.format(parse_ctx, ctx); EXPECT_EQ("test", std::string(buffer.data, buffer.size())); return test_result();