Skip to content

Commit 95979bf

Browse files
authored
Merge 2024-06 LWG Motion 8
P3235R3 std::print more types faster with less memory
2 parents 773c18a + 24037c7 commit 95979bf

File tree

4 files changed

+48
-18
lines changed

4 files changed

+48
-18
lines changed

source/iostreams.tex

+14-14
Original file line numberDiff line numberDiff line change
@@ -7746,14 +7746,14 @@
77467746
If the ordinary literal encoding\iref{lex.charset} is UTF-8, equivalent to:
77477747
\begin{codeblock}
77487748
locksafe
7749-
? vprint_unicode_locking(stream, fmt.str, make_format_args(args...))
7750-
: vprint_unicode(stream, fmt.str, make_format_args(args...));
7749+
? vprint_unicode(stream, fmt.str, make_format_args(args...))
7750+
: vprint_unicode_buffered(stream, fmt.str, make_format_args(args...));
77517751
\end{codeblock}
77527752
Otherwise, equivalent to:
77537753
\begin{codeblock}
77547754
locksafe
7755-
? vprint_nonunicode_locking(stream, fmt.str, make_format_args(args...))
7756-
: vprint_nonunicode(stream, fmt.str, make_format_args(args...));
7755+
? vprint_nonunicode(stream, fmt.str, make_format_args(args...))
7756+
: vprint_nonunicode_buffered(stream, fmt.str, make_format_args(args...));
77577757
\end{codeblock}
77587758
\end{itemdescr}
77597759

@@ -7829,9 +7829,9 @@
78297829
\end{codeblock}
78307830
\end{itemdescr}
78317831

7832-
\indexlibraryglobal{vprint_unicode}%
7832+
\indexlibraryglobal{vprint_unicode_buffered}%
78337833
\begin{itemdecl}
7834-
void vprint_unicode(FILE* stream, string_view fmt, format_args args);
7834+
void vprint_unicode_buffered(FILE* stream, string_view fmt, format_args args);
78357835
\end{itemdecl}
78367836

78377837
\begin{itemdescr}
@@ -7840,13 +7840,13 @@
78407840
Equivalent to:
78417841
\begin{codeblock}
78427842
string out = vformat(fmt, args);
7843-
vprint_unicode_locking(stream, "{}", make_format_args(out));
7843+
vprint_unicode(stream, "{}", make_format_args(out));
78447844
\end{codeblock}
78457845
\end{itemdescr}
78467846

7847-
\indexlibraryglobal{vprint_unicode_locking}%
7847+
\indexlibraryglobal{vprint_unicode}%
78487848
\begin{itemdecl}
7849-
void vprint_unicode_locking(FILE* stream, string_view fmt, format_args args);
7849+
void vprint_unicode(FILE* stream, string_view fmt, format_args args);
78507850
\end{itemdecl}
78517851

78527852
\begin{itemdescr}
@@ -7912,9 +7912,9 @@
79127912
\end{codeblock}
79137913
\end{itemdescr}
79147914

7915-
\indexlibraryglobal{vprint_nonunicode}%
7915+
\indexlibraryglobal{vprint_nonunicode_buffered}%
79167916
\begin{itemdecl}
7917-
void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
7917+
void vprint_nonunicode_buffered(FILE* stream, string_view fmt, format_args args);
79187918
\end{itemdecl}
79197919

79207920
\begin{itemdescr}
@@ -7923,13 +7923,13 @@
79237923
Equivalent to:
79247924
\begin{codeblock}
79257925
string out = vformat(fmt, args);
7926-
vprint_nonunicode_locking("{}", make_format_args(out));
7926+
vprint_nonunicode("{}", make_format_args(out));
79277927
\end{codeblock}
79287928
\end{itemdescr}
79297929

7930-
\indexlibraryglobal{vprint_nonunicode_locking}%
7930+
\indexlibraryglobal{vprint_nonunicode}%
79317931
\begin{itemdecl}
7932-
void vprint_nonunicode_locking(FILE* stream, string_view fmt, format_args args);
7932+
void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
79337933
\end{itemdecl}
79347934

79357935
\begin{itemdescr}

source/support.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@
732732
#define @\defnlibxname{cpp_lib_out_ptr}@ 202311L // freestanding, also in \libheader{memory}
733733
#define @\defnlibxname{cpp_lib_parallel_algorithm}@ 201603L // also in \libheader{algorithm}, \libheader{numeric}
734734
#define @\defnlibxname{cpp_lib_polymorphic_allocator}@ 201902L // also in \libheader{memory_resource}
735-
#define @\defnlibxname{cpp_lib_print}@ 202403L // also in \libheader{print}, \libheader{ostream}
735+
#define @\defnlibxname{cpp_lib_print}@ 202406L // also in \libheader{print}, \libheader{ostream}
736736
#define @\defnlibxname{cpp_lib_quoted_string_io}@ 201304L // also in \libheader{iomanip}
737737
#define @\defnlibxname{cpp_lib_ranges}@ 202406L
738738
// also in \libheader{algorithm}, \libheader{functional}, \libheader{iterator}, \libheader{memory}, \libheader{ranges}

source/time.tex

+21
Original file line numberDiff line numberDiff line change
@@ -10828,6 +10828,27 @@
1082810828
\end{codeblock}
1082910829
\end{example}
1083010830

10831+
\pnum
10832+
For \tcode{chrono::duration}
10833+
the library only provides the following specialization
10834+
of \tcode{enable_nonlocking_formatter_optimization}:
10835+
\begin{codeblock}
10836+
template<class Rep, class Period>
10837+
inline constexpr bool enable_nonlocking_formatter_optimization<
10838+
chrono::duration<Rep, Period>> =
10839+
enable_nonlocking_formatter_optimization<Rep>;
10840+
\end{codeblock}
10841+
10842+
\pnum
10843+
For \tcode{chrono::zoned_time}
10844+
the library only provides the following specialization of
10845+
\tcode{enable_nonlocking_formatter_optimization}:
10846+
\begin{codeblock}
10847+
template<class Duration>
10848+
inline constexpr bool enable_nonlocking_formatter_optimization<
10849+
chrono::zoned_time<Duration, const std::chrono::time_zone*>> = true;
10850+
\end{codeblock}
10851+
1083110852
\indexlibrary{\idxcode{formatter}!specializations!\idxcode{chrono::sys_time}}%
1083210853
\begin{itemdecl}
1083310854
template<class Duration, class charT>

source/utilities.tex

+12-3
Original file line numberDiff line numberDiff line change
@@ -15897,6 +15897,10 @@
1589715897
@\libconcept{formattable}@<ranges::range_reference_t<R>, charT>
1589815898
struct formatter<R, charT> : @\exposid{range-default-formatter}@<format_kind<R>, R, charT> { };
1589915899

15900+
template<ranges::input_range R>
15901+
requires (format_kind<R> != range_format::disabled)
15902+
inline constexpr bool enable_nonlocking_formatter_optimization<R> = false;
15903+
1590015904
// \ref{format.arguments}, arguments
1590115905
// \ref{format.arg}, class template \tcode{basic_format_arg}
1590215906
template<class Context> class basic_format_arg;
@@ -17214,9 +17218,10 @@
1721417218
interpret the format specification
1721517219
as a \fmtgrammarterm{std-format-spec}
1721617220
as described in \ref{format.string.std}.
17217-
In addition,
17218-
for each type \tcode{T} for which
17219-
a \tcode{formatter} specialization is provided above,
17221+
17222+
\pnum
17223+
Unless specified otherwise, for each type \tcode{T} for which
17224+
a \tcode{formatter} specialization is provided by the library,
1722017225
each of the headers provides the following specialization:
1722117226
\begin{codeblock}
1722217227
template<> inline constexpr bool enable_nonlocking_formatter_optimization<T> = true;
@@ -18795,6 +18800,10 @@
1879518800
typename FormatContext::iterator
1879618801
format(@\seebelow@& elems, FormatContext& ctx) const;
1879718802
};
18803+
18804+
template<class... Ts>
18805+
inline constexpr bool enable_nonlocking_formatter_optimization<@\placeholder{pair-or-tuple}@<Ts...>> =
18806+
(enable_nonlocking_formatter_optimization<Ts> && ...);
1879818807
}
1879918808
\end{codeblock}
1880018809

0 commit comments

Comments
 (0)