Skip to content

[LWG motion 8 2024-06] P3235R3 std::print more types faster with less memory #7103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions source/iostreams.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7746,14 +7746,14 @@
If the ordinary literal encoding\iref{lex.charset} is UTF-8, equivalent to:
\begin{codeblock}
locksafe
? vprint_unicode_locking(stream, fmt.str, make_format_args(args...))
: vprint_unicode(stream, fmt.str, make_format_args(args...));
? vprint_unicode(stream, fmt.str, make_format_args(args...))
: vprint_unicode_buffered(stream, fmt.str, make_format_args(args...));
\end{codeblock}
Otherwise, equivalent to:
\begin{codeblock}
locksafe
? vprint_nonunicode_locking(stream, fmt.str, make_format_args(args...))
: vprint_nonunicode(stream, fmt.str, make_format_args(args...));
? vprint_nonunicode(stream, fmt.str, make_format_args(args...))
: vprint_nonunicode_buffered(stream, fmt.str, make_format_args(args...));
\end{codeblock}
\end{itemdescr}

Expand Down Expand Up @@ -7829,9 +7829,9 @@
\end{codeblock}
\end{itemdescr}

\indexlibraryglobal{vprint_unicode}%
\indexlibraryglobal{vprint_unicode_buffered}%
\begin{itemdecl}
void vprint_unicode(FILE* stream, string_view fmt, format_args args);
void vprint_unicode_buffered(FILE* stream, string_view fmt, format_args args);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -7840,13 +7840,13 @@
Equivalent to:
\begin{codeblock}
string out = vformat(fmt, args);
vprint_unicode_locking(stream, "{}", make_format_args(out));
vprint_unicode(stream, "{}", make_format_args(out));
\end{codeblock}
\end{itemdescr}

\indexlibraryglobal{vprint_unicode_locking}%
\indexlibraryglobal{vprint_unicode}%
\begin{itemdecl}
void vprint_unicode_locking(FILE* stream, string_view fmt, format_args args);
void vprint_unicode(FILE* stream, string_view fmt, format_args args);
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -7912,9 +7912,9 @@
\end{codeblock}
\end{itemdescr}

\indexlibraryglobal{vprint_nonunicode}%
\indexlibraryglobal{vprint_nonunicode_buffered}%
\begin{itemdecl}
void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
void vprint_nonunicode_buffered(FILE* stream, string_view fmt, format_args args);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -7923,13 +7923,13 @@
Equivalent to:
\begin{codeblock}
string out = vformat(fmt, args);
vprint_nonunicode_locking("{}", make_format_args(out));
vprint_nonunicode("{}", make_format_args(out));
\end{codeblock}
\end{itemdescr}

\indexlibraryglobal{vprint_nonunicode_locking}%
\indexlibraryglobal{vprint_nonunicode}%
\begin{itemdecl}
void vprint_nonunicode_locking(FILE* stream, string_view fmt, format_args args);
void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
\end{itemdecl}

\begin{itemdescr}
Expand Down
2 changes: 1 addition & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@
#define @\defnlibxname{cpp_lib_out_ptr}@ 202311L // freestanding, also in \libheader{memory}
#define @\defnlibxname{cpp_lib_parallel_algorithm}@ 201603L // also in \libheader{algorithm}, \libheader{numeric}
#define @\defnlibxname{cpp_lib_polymorphic_allocator}@ 201902L // also in \libheader{memory_resource}
#define @\defnlibxname{cpp_lib_print}@ 202403L // also in \libheader{print}, \libheader{ostream}
#define @\defnlibxname{cpp_lib_print}@ 202406L // also in \libheader{print}, \libheader{ostream}
#define @\defnlibxname{cpp_lib_quoted_string_io}@ 201304L // also in \libheader{iomanip}
#define @\defnlibxname{cpp_lib_ranges}@ 202406L
// also in \libheader{algorithm}, \libheader{functional}, \libheader{iterator}, \libheader{memory}, \libheader{ranges}
Expand Down
21 changes: 21 additions & 0 deletions source/time.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10828,6 +10828,27 @@
\end{codeblock}
\end{example}

\pnum
For \tcode{chrono::duration}
the library only provides the following specialization
of \tcode{enable_nonlocking_formatter_optimization}:
\begin{codeblock}
template<class Rep, class Period>
inline constexpr bool enable_nonlocking_formatter_optimization<
chrono::duration<Rep, Period>> =
enable_nonlocking_formatter_optimization<Rep>;
\end{codeblock}

\pnum
For \tcode{chrono::zoned_time}
the library only provides the following specialization of
\tcode{enable_nonlocking_formatter_optimization}:
\begin{codeblock}
template<class Duration>
inline constexpr bool enable_nonlocking_formatter_optimization<
chrono::zoned_time<Duration, const std::chrono::time_zone*>> = true;
\end{codeblock}

\indexlibrary{\idxcode{formatter}!specializations!\idxcode{chrono::sys_time}}%
\begin{itemdecl}
template<class Duration, class charT>
Expand Down
15 changes: 12 additions & 3 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15897,6 +15897,10 @@
@\libconcept{formattable}@<ranges::range_reference_t<R>, charT>
struct formatter<R, charT> : @\exposid{range-default-formatter}@<format_kind<R>, R, charT> { };

template<ranges::input_range R>
requires (format_kind<R> != range_format::disabled)
inline constexpr bool enable_nonlocking_formatter_optimization<R> = false;

// \ref{format.arguments}, arguments
// \ref{format.arg}, class template \tcode{basic_format_arg}
template<class Context> class basic_format_arg;
Expand Down Expand Up @@ -17214,9 +17218,10 @@
interpret the format specification
as a \fmtgrammarterm{std-format-spec}
as described in \ref{format.string.std}.
In addition,
for each type \tcode{T} for which
a \tcode{formatter} specialization is provided above,

\pnum
Unless specified otherwise, for each type \tcode{T} for which
a \tcode{formatter} specialization is provided by the library,
each of the headers provides the following specialization:
\begin{codeblock}
template<> inline constexpr bool enable_nonlocking_formatter_optimization<T> = true;
Expand Down Expand Up @@ -18795,6 +18800,10 @@
typename FormatContext::iterator
format(@\seebelow@& elems, FormatContext& ctx) const;
};

template<class... Ts>
inline constexpr bool enable_nonlocking_formatter_optimization<@\placeholder{pair-or-tuple}@<Ts...>> =
(enable_nonlocking_formatter_optimization<Ts> && ...);
}
\end{codeblock}

Expand Down
Loading