diff --git a/include/fmt/printf.h b/include/fmt/printf.h index c65fe404..e16d0b4f 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -15,6 +15,16 @@ #include "format.h" FMT_BEGIN_NAMESPACE +FMT_MODULE_EXPORT_BEGIN + +template +class basic_printf_parse_context : public basic_format_parse_context { + using basic_format_parse_context::basic_format_parse_context; +}; +template class basic_printf_context; + +FMT_MODULE_EXPORT_END + namespace detail { // Checks if a value fits in int - used to avoid warnings about comparing @@ -179,37 +189,7 @@ template class printf_width_handler { } }; -template -void vprintf(buffer& buf, basic_string_view format, - basic_format_args args) { - Context(buffer_appender(buf), format, args).format(); -} -} // namespace detail - -// For printing into memory_buffer. -template -FMT_DEPRECATED void printf(detail::buffer& buf, - basic_string_view format, - basic_format_args args) { - return detail::vprintf(buf, format, args); -} -using detail::vprintf; - -FMT_MODULE_EXPORT_BEGIN - -template -class basic_printf_parse_context : public basic_format_parse_context { - using basic_format_parse_context::basic_format_parse_context; -}; -template class basic_printf_context; - -FMT_MODULE_EXPORT_END - -/** - \rst - The ``printf`` argument formatter. - \endrst - */ +// The ``printf`` argument formatter. template class printf_arg_formatter : public detail::arg_formatter_base { private: @@ -286,6 +266,22 @@ class printf_arg_formatter : public detail::arg_formatter_base { } }; +template +void vprintf(buffer& buf, basic_string_view format, + basic_format_args args) { + Context(buffer_appender(buf), format, args).format(); +} +} // namespace detail + +// For printing into memory_buffer. +template +FMT_DEPRECATED void printf(detail::buffer& buf, + basic_string_view format, + basic_format_args args) { + return detail::vprintf(buf, format, args); +} +using detail::vprintf; + template struct printf_formatter { printf_formatter() = delete; @@ -354,7 +350,6 @@ template class basic_printf_context { } /** Formats stored arguments and writes the output to the range. */ - template > OutputIt format(); }; @@ -437,7 +432,6 @@ int basic_printf_context::parse_header(const Char*& it, } template -template OutputIt basic_printf_context::format() { auto out = this->out(); const Char* start = parse_ctx_.begin(); @@ -566,7 +560,8 @@ OutputIt basic_printf_context::format() { start = it; // Format argument. - out = visit_format_arg(ArgFormatter(out, specs, *this), arg); + out = visit_format_arg( + detail::printf_arg_formatter(out, specs, *this), arg); } return detail::write( out, basic_string_view(start, detail::to_unsigned(it - start)));