Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3bb420d

Browse filesBrowse files
committed
P2093R14 Formatted output
1 parent d59a4f3 commit 3bb420d
Copy full SHA for 3bb420d

File tree

4 files changed

+287
-0
lines changed
Filter options

4 files changed

+287
-0
lines changed

‎source/back.tex

Copy file name to clipboardExpand all lines: source/back.tex
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ \chapter{Bibliography}
2929
Edited by Mark Davis. Revision 33; issued for Unicode 13.0.0.
3030
2020-02-13 [viewed 2021-06-08].
3131
Available from: \url{https://www.unicode.org/reports/tr31/tr31-33.html}
32+
\item
33+
The Unicode Standard Version 14.0,
34+
\doccite{Core Specification}, Chapter 3.9.
35+
Unicode Consortium, ISBN 978-1-936213-29-0, copyright \copyright 2021 Unicode, Inc.
36+
Available from: \url{https://www.unicode.org/versions/Unicode14.0.0/UnicodeStandard-14.0.pdf}
3237
\item
3338
IANA Time Zone Database.
3439
Available from: \url{https://www.iana.org/time-zones}

‎source/iostreams.tex

Copy file name to clipboardExpand all lines: source/iostreams.tex
+280Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4162,6 +4162,14 @@
41624162

41634163
template<class Ostream, class T>
41644164
Ostream&& operator<<(Ostream&& os, const T& x);
4165+
4166+
template<class... Args>
4167+
void print(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
4168+
template<class... Args>
4169+
void println(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
4170+
4171+
void vprint_unicode(ostream& os, string_view fmt, format_args args);
4172+
void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
41654173
}
41664174
\end{codeblock}
41674175

@@ -4203,6 +4211,29 @@
42034211
}
42044212
\end{codeblock}
42054213

4214+
\rSec2[print.syn]{Header \tcode{<print>} synopsis}
4215+
4216+
\indexheader{print}%
4217+
\begin{codeblock}
4218+
namespace std {
4219+
template<class... Args>
4220+
void print(@\exposid{format-string}@<Args...> fmt, Args&&... args);
4221+
template<class... Args>
4222+
void print(FILE* stream, @\exposid{format-string}@<Args...> fmt, Args&&... args);
4223+
4224+
template<class... Args>
4225+
void println(@\exposid{format-string}@<Args...> fmt, Args&&... args);
4226+
template<class... Args>
4227+
void println(FILE* stream, @\exposid{format-string}@<Args...> fmt, Args&&... args);
4228+
4229+
void vprint_unicode(string_view fmt, format_args args);
4230+
void vprint_unicode(FILE* stream, string_view fmt, format_args args);
4231+
4232+
void vprint_nonunicode(string_view fmt, format_args args);
4233+
void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
4234+
}
4235+
\end{codeblock}
4236+
42064237
\rSec2[input.streams]{Input streams}
42074238

42084239
\rSec3[input.streams.general]{General}
@@ -7462,6 +7493,255 @@
74627493
\end{itemize}
74637494
\end{itemdescr}
74647495

7496+
\rSec2[print.fun]{Print functions}
7497+
7498+
\indexlibraryglobal{print}%
7499+
\begin{itemdecl}
7500+
template<class... Args>
7501+
void print(@\exposid{format-string}@<Args...> fmt, Args&&... args);
7502+
\end{itemdecl}
7503+
7504+
\begin{itemdescr}
7505+
\pnum
7506+
\effects
7507+
Equivalent to:
7508+
\begin{codeblock}
7509+
print(stdout, fmt, std::forward<Args>(args)...);
7510+
\end{codeblock}
7511+
\end{itemdescr}
7512+
7513+
\indexlibraryglobal{print}%
7514+
\begin{itemdecl}
7515+
template<class... Args>
7516+
void print(FILE* stream, @\exposid{format-string}@<Args...> fmt, Args&&... args);
7517+
\end{itemdecl}
7518+
7519+
\begin{itemdescr}
7520+
\pnum
7521+
\effects
7522+
If the ordinary literal encoding ([lex.charset]) is UTF-8, equivalent to:
7523+
\begin{codeblock}
7524+
vprint_unicode(stream, fmt.@\exposid{str}@, make_format_args(std::forward<Args>(args)...));
7525+
\end{codeblock}
7526+
Otherwise, equivalent to:
7527+
\begin{codeblock}
7528+
vprint_nonunicode(stream, fmt.@\exposid{str}@, make_format_args(std::forward<Args>(args)...));
7529+
\end{codeblock}
7530+
\end{itemdescr}
7531+
7532+
\indexlibraryglobal{println}%
7533+
\begin{itemdecl}
7534+
template<class... Args>
7535+
void println(@\exposid{format-string}@<Args...> fmt, Args&&... args);
7536+
\end{itemdecl}
7537+
7538+
\begin{itemdescr}
7539+
\pnum
7540+
\effects
7541+
Equivalent to:
7542+
\begin{codeblock}
7543+
println(stdout, fmt, std::forward<Args>(args)...);
7544+
\end{codeblock}
7545+
\end{itemdescr}
7546+
7547+
\indexlibraryglobal{println}%
7548+
\begin{itemdecl}
7549+
template<class... Args>
7550+
void println(FILE* stream, @\exposid{format-string}@<Args...> fmt, Args&&... args);
7551+
\end{itemdecl}
7552+
7553+
\begin{itemdescr}
7554+
\pnum
7555+
\effects
7556+
Equivalent to:
7557+
\begin{codeblock}
7558+
print(stream, "{}\n", format(fmt, std::forward<Args>(args)...));
7559+
\end{codeblock}
7560+
\end{itemdescr}
7561+
7562+
\indexlibraryglobal{vprint_unicode}%
7563+
\begin{itemdecl}
7564+
void vprint_unicode(string_view fmt, format_args args);
7565+
\end{itemdecl}
7566+
7567+
\begin{itemdescr}
7568+
\pnum
7569+
\effects
7570+
Equivalent to:
7571+
\begin{codeblock}
7572+
vprint_unicode(stdout, fmt, args);
7573+
\end{codeblock}
7574+
\end{itemdescr}
7575+
7576+
\indexlibraryglobal{vprint_unicode}%
7577+
\begin{itemdecl}
7578+
void vprint_unicode(FILE* stream, string_view fmt, format_args args);
7579+
\end{itemdecl}
7580+
7581+
\begin{itemdescr}
7582+
\pnum
7583+
\expects
7584+
\tcode{stream} is a valid pointer to an output C stream.
7585+
7586+
\pnum
7587+
\effects
7588+
The function initializes an automatic variable via
7589+
\begin{codeblock}
7590+
string out = vformat(fmt, args);
7591+
\end{codeblock}
7592+
If \tcode{stream} refers to a terminal capable of displaying Unicode,
7593+
writes \tcode{out} to the terminal using the native Unicode API;
7594+
if \tcode{out} contains invalid code units,
7595+
\indextext{undefined}%
7596+
the behavior is undefined and
7597+
implementations are encouraged to diagnose it.
7598+
Otherwise writes \tcode{out} to \tcode{stream} unchanged.
7599+
\begin{note}
7600+
On POSIX and Windows, \tcode{stream} referring to a terminal means that,
7601+
respectively,
7602+
\tcode{isatty(fileno(\linebreak{}stream))} and
7603+
\tcode{GetConsoleMode(_get_osfhandle(_fileno(stream)), ...)}
7604+
return nonzero.
7605+
\end{note}
7606+
\begin{note}
7607+
On Windows, the native Unicode API is \tcode{WriteConsoleW}.
7608+
\end{note}
7609+
7610+
\pnum
7611+
\throws
7612+
Any exception thrown by the call to \tcode{vformat}\iref{format.err.report}.
7613+
\tcode{system_error} if writing to the terminal or \tcode{stream} fails.
7614+
May throw \tcode{bad_alloc}.
7615+
7616+
\pnum
7617+
\recommended
7618+
If invoking the native Unicode API requires transcoding,
7619+
implementations should substitute invalid code units
7620+
with \unicode{fffd}{replacement character} per
7621+
The Unicode Standard Version 14.0 - Core Specification, Chapter 3.9.
7622+
\end{itemdescr}
7623+
7624+
\indexlibraryglobal{vprint_nonunicode}%
7625+
\begin{itemdecl}
7626+
void vprint_nonunicode(string_view fmt, format_args args);
7627+
\end{itemdecl}
7628+
7629+
\begin{itemdescr}
7630+
\pnum
7631+
\effects
7632+
Equivalent to:
7633+
\begin{codeblock}
7634+
vprint_nonunicode(stdout, fmt, args);
7635+
\end{codeblock}
7636+
\end{itemdescr}
7637+
7638+
\indexlibraryglobal{vprint_nonunicode}%
7639+
\begin{itemdecl}
7640+
void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
7641+
\end{itemdecl}
7642+
7643+
\begin{itemdescr}
7644+
\pnum
7645+
\expects
7646+
\tcode{stream} is a valid pointer to an output C stream.
7647+
7648+
\pnum
7649+
\effects
7650+
Writes the result of \tcode{vformat(fmt, args)} to \tcode{stream}.
7651+
7652+
\pnum
7653+
\throws
7654+
Any exception thrown by the call to \tcode{vformat}\iref{format.err.report}.
7655+
\tcode{system_error} if writing to \tcode{stream} fails.
7656+
May throw \tcode{bad_alloc}.
7657+
\end{itemdescr}
7658+
7659+
\rSec2[ostream.formatted.print]{Print}
7660+
7661+
\indexlibraryglobal{print}%
7662+
\begin{itemdecl}
7663+
template<class... Args>
7664+
void print(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
7665+
\end{itemdecl}
7666+
7667+
\begin{itemdescr}
7668+
\pnum
7669+
\effects
7670+
If the ordinary literal encoding\iref{lex.charset} is UTF-8, equivalent to:
7671+
\begin{codeblock}
7672+
vprint_unicode(os, fmt.@\exposid{str}@, make_format_args(std::forward<Args>(args)...));
7673+
\end{codeblock}
7674+
Otherwise, equivalent to:
7675+
\begin{codeblock}
7676+
vprint_nonunicode(os, fmt.@\exposid{str}@, make_format_args(std::forward<Args>(args)...));
7677+
\end{codeblock}
7678+
\end{itemdescr}
7679+
7680+
\indexlibraryglobal{println}%
7681+
\begin{itemdecl}
7682+
template<class... Args>
7683+
void println(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
7684+
\end{itemdecl}
7685+
7686+
\begin{itemdescr}
7687+
\pnum
7688+
\effects
7689+
Equivalent to:
7690+
\begin{codeblock}
7691+
print(os, "{}\n", format(fmt, std::forward<Args>(args)...));
7692+
\end{codeblock}
7693+
\end{itemdescr}
7694+
7695+
\indexlibraryglobal{vprint_unicode}%
7696+
\indexlibraryglobal{vprint_nonunicode}%
7697+
\begin{itemdecl}
7698+
void vprint_unicode(ostream& os, string_view fmt, format_args args);
7699+
void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
7700+
\end{itemdecl}
7701+
7702+
\begin{itemdescr}
7703+
\pnum
7704+
\effects
7705+
Behaves as a formatted output function\iref{ostream.formatted.reqmts}
7706+
of \tcode{os}, except that:
7707+
\begin{itemize}
7708+
\item
7709+
failure to generate output is reported as specified below, and
7710+
\item
7711+
any exception thrown by the call to \tcode{vformat} is propagated
7712+
without regard to the value of \tcode{os.exceptions()} and
7713+
without turning on \tcode{ios_base::badbit} in the error state of \tcode{os}.
7714+
\end{itemize}
7715+
After constructing a \tcode{sentry} object,
7716+
the function initializes an automatic variable via
7717+
\begin{codeblock}
7718+
string out = vformat(os.getloc(), fmt, args);
7719+
\end{codeblock}
7720+
If the function is \tcode{vprint_unicode} and
7721+
\tcode{os} is a stream that refers to a terminal capable of displaying Unicode
7722+
which is determined in an implementation-defined manner,
7723+
writes \tcode{out} to the terminal using the native Unicode API;
7724+
if \tcode{out} contains invalid code units,
7725+
\indextext{undefined}%
7726+
the behavior is undefined and
7727+
implementations are encouraged to diagnose it.
7728+
Otherwise (if \tcode{os} is not such a stream or
7729+
the function is \tcode{vprint_nonunicode}),
7730+
inserts the character sequence
7731+
\tcode{[out.begin(), out.end())} into \tcode{os}.
7732+
If writing to the terminal or inserting into \tcode{os} fails,
7733+
calls \tcode{os.setstate(ios_base::badbit)}
7734+
(which may throw \tcode{ios_base::failure}).
7735+
7736+
\pnum
7737+
\recommended
7738+
For \tcode{vprint_unicode},
7739+
if invoking the native Unicode API requires transcoding,
7740+
implementations should substitute invalid code units
7741+
with \unicode{fffd}{replacement character} per
7742+
The Unicode Standard Version 14.0 - Core Specification, Chapter 3.9.
7743+
\end{itemdescr}
7744+
74657745
\rSec1[string.streams]{String-based streams}
74667746

74677747
\rSec2[sstream.syn]{Header \tcode{<sstream>} synopsis}

‎source/lib-intro.tex

Copy file name to clipboardExpand all lines: source/lib-intro.tex
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@
10561056
\tcode{<numeric>} \\
10571057
\tcode{<optional>} \\
10581058
\tcode{<ostream>} \\
1059+
\tcode{<print>} \\
10591060
\tcode{<queue>} \\
10601061
\tcode{<random>} \\
10611062
\tcode{<ranges>} \\

‎source/support.tex

Copy file name to clipboardExpand all lines: source/support.tex
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@
668668
#define @\defnlibxname{cpp_lib_out_ptr}@ 202106L // also in \libheader{memory}
669669
#define @\defnlibxname{cpp_lib_parallel_algorithm}@ 201603L // also in \libheader{algorithm}, \libheader{numeric}
670670
#define @\defnlibxname{cpp_lib_polymorphic_allocator}@ 201902L // also in \libheader{memory_resource}
671+
#define @\defnlibxname{cpp_lib_print}@ 202207L // also in \libheader{print}, \libheader{ostream}
671672
#define @\defnlibxname{cpp_lib_quoted_string_io}@ 201304L // also in \libheader{iomanip}
672673
#define @\defnlibxname{cpp_lib_ranges}@ 202202L
673674
// also in \libheader{algorithm}, \libheader{functional}, \libheader{iterator}, \libheader{memory}, \libheader{ranges}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.