Skip to content

Commit 763932b

Browse files
committed
FIXUP: Move [ostream.formatted.print] to the end of [ostream.formatted]; add reference in [ostream.syn]
1 parent 30f3395 commit 763932b

File tree

1 file changed

+87
-86
lines changed

1 file changed

+87
-86
lines changed

source/iostreams.tex

Lines changed: 87 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -4163,6 +4163,7 @@
41634163
template<class Ostream, class T>
41644164
Ostream&& operator<<(Ostream&& os, const T& x);
41654165

4166+
// \ref{ostream.formatted.print}, print functions
41664167
template<class... Args>
41674168
void print(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
41684169
template<class... Args>
@@ -6688,6 +6689,92 @@
66886689
\tcode{out}.
66896690
\end{itemdescr}
66906691

6692+
\rSec4[ostream.formatted.print]{Print}
6693+
6694+
\indexlibraryglobal{print}%
6695+
\begin{itemdecl}
6696+
template<class... Args>
6697+
void print(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
6698+
\end{itemdecl}
6699+
6700+
\begin{itemdescr}
6701+
\pnum
6702+
\effects
6703+
If the ordinary literal encoding\iref{lex.charset} is UTF-8, equivalent to:
6704+
\begin{codeblock}
6705+
vprint_unicode(os, fmt.@\exposid{str}@, make_format_args(std::forward<Args>(args)...));
6706+
\end{codeblock}
6707+
Otherwise, equivalent to:
6708+
\begin{codeblock}
6709+
vprint_nonunicode(os, fmt.@\exposid{str}@, make_format_args(std::forward<Args>(args)...));
6710+
\end{codeblock}
6711+
\end{itemdescr}
6712+
6713+
\indexlibraryglobal{println}%
6714+
\begin{itemdecl}
6715+
template<class... Args>
6716+
void println(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
6717+
\end{itemdecl}
6718+
6719+
\begin{itemdescr}
6720+
\pnum
6721+
\effects
6722+
Equivalent to:
6723+
\begin{codeblock}
6724+
print(os, "{}\n", format(fmt, std::forward<Args>(args)...));
6725+
\end{codeblock}
6726+
\end{itemdescr}
6727+
6728+
\indexlibraryglobal{vprint_unicode}%
6729+
\indexlibraryglobal{vprint_nonunicode}%
6730+
\begin{itemdecl}
6731+
void vprint_unicode(ostream& os, string_view fmt, format_args args);
6732+
void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
6733+
\end{itemdecl}
6734+
6735+
\begin{itemdescr}
6736+
\pnum
6737+
\effects
6738+
Behaves as a formatted output function\iref{ostream.formatted.reqmts}
6739+
of \tcode{os}, except that:
6740+
\begin{itemize}
6741+
\item
6742+
failure to generate output is reported as specified below, and
6743+
\item
6744+
any exception thrown by the call to \tcode{vformat} is propagated
6745+
without regard to the value of \tcode{os.exceptions()} and
6746+
without turning on \tcode{ios_base::badbit} in the error state of \tcode{os}.
6747+
\end{itemize}
6748+
After constructing a \tcode{sentry} object,
6749+
the function initializes an automatic variable via
6750+
\begin{codeblock}
6751+
string out = vformat(os.getloc(), fmt, args);
6752+
\end{codeblock}
6753+
If the function is \tcode{vprint_unicode} and
6754+
\tcode{os} is a stream that refers to a terminal capable of displaying Unicode
6755+
which is determined in an implementation-defined manner,
6756+
writes \tcode{out} to the terminal using the native Unicode API;
6757+
if \tcode{out} contains invalid code units,
6758+
\indextext{undefined}%
6759+
the behavior is undefined and
6760+
implementations are encouraged to diagnose it.
6761+
Otherwise (if \tcode{os} is not such a stream or
6762+
the function is \tcode{vprint_nonunicode}),
6763+
inserts the character sequence
6764+
\range{out.begin()}{out.end()} into \tcode{os}.
6765+
If writing to the terminal or inserting into \tcode{os} fails,
6766+
calls \tcode{os.setstate(ios_base::badbit)}
6767+
(which may throw \tcode{ios_base::failure}).
6768+
6769+
\pnum
6770+
\recommended
6771+
For \tcode{vprint_unicode},
6772+
if invoking the native Unicode API requires transcoding,
6773+
implementations should substitute invalid code units
6774+
with \unicode{fffd}{replacement character} per
6775+
The Unicode Standard Version 14.0 - Core Specification, Chapter 3.9.
6776+
\end{itemdescr}
6777+
66916778
\rSec3[ostream.unformatted]{Unformatted output functions}
66926779

66936780
\pnum
@@ -7657,92 +7744,6 @@
76577744
May throw \tcode{bad_alloc}.
76587745
\end{itemdescr}
76597746

7660-
\rSec2[ostream.formatted.print]{Print}
7661-
7662-
\indexlibraryglobal{print}%
7663-
\begin{itemdecl}
7664-
template<class... Args>
7665-
void print(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
7666-
\end{itemdecl}
7667-
7668-
\begin{itemdescr}
7669-
\pnum
7670-
\effects
7671-
If the ordinary literal encoding\iref{lex.charset} is UTF-8, equivalent to:
7672-
\begin{codeblock}
7673-
vprint_unicode(os, fmt.@\exposid{str}@, make_format_args(std::forward<Args>(args)...));
7674-
\end{codeblock}
7675-
Otherwise, equivalent to:
7676-
\begin{codeblock}
7677-
vprint_nonunicode(os, fmt.@\exposid{str}@, make_format_args(std::forward<Args>(args)...));
7678-
\end{codeblock}
7679-
\end{itemdescr}
7680-
7681-
\indexlibraryglobal{println}%
7682-
\begin{itemdecl}
7683-
template<class... Args>
7684-
void println(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
7685-
\end{itemdecl}
7686-
7687-
\begin{itemdescr}
7688-
\pnum
7689-
\effects
7690-
Equivalent to:
7691-
\begin{codeblock}
7692-
print(os, "{}\n", format(fmt, std::forward<Args>(args)...));
7693-
\end{codeblock}
7694-
\end{itemdescr}
7695-
7696-
\indexlibraryglobal{vprint_unicode}%
7697-
\indexlibraryglobal{vprint_nonunicode}%
7698-
\begin{itemdecl}
7699-
void vprint_unicode(ostream& os, string_view fmt, format_args args);
7700-
void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
7701-
\end{itemdecl}
7702-
7703-
\begin{itemdescr}
7704-
\pnum
7705-
\effects
7706-
Behaves as a formatted output function\iref{ostream.formatted.reqmts}
7707-
of \tcode{os}, except that:
7708-
\begin{itemize}
7709-
\item
7710-
failure to generate output is reported as specified below, and
7711-
\item
7712-
any exception thrown by the call to \tcode{vformat} is propagated
7713-
without regard to the value of \tcode{os.exceptions()} and
7714-
without turning on \tcode{ios_base::badbit} in the error state of \tcode{os}.
7715-
\end{itemize}
7716-
After constructing a \tcode{sentry} object,
7717-
the function initializes an automatic variable via
7718-
\begin{codeblock}
7719-
string out = vformat(os.getloc(), fmt, args);
7720-
\end{codeblock}
7721-
If the function is \tcode{vprint_unicode} and
7722-
\tcode{os} is a stream that refers to a terminal capable of displaying Unicode
7723-
which is determined in an implementation-defined manner,
7724-
writes \tcode{out} to the terminal using the native Unicode API;
7725-
if \tcode{out} contains invalid code units,
7726-
\indextext{undefined}%
7727-
the behavior is undefined and
7728-
implementations are encouraged to diagnose it.
7729-
Otherwise (if \tcode{os} is not such a stream or
7730-
the function is \tcode{vprint_nonunicode}),
7731-
inserts the character sequence
7732-
\range{out.begin()}{out.end()} into \tcode{os}.
7733-
If writing to the terminal or inserting into \tcode{os} fails,
7734-
calls \tcode{os.setstate(ios_base::badbit)}
7735-
(which may throw \tcode{ios_base::failure}).
7736-
7737-
\pnum
7738-
\recommended
7739-
For \tcode{vprint_unicode},
7740-
if invoking the native Unicode API requires transcoding,
7741-
implementations should substitute invalid code units
7742-
with \unicode{fffd}{replacement character} per
7743-
The Unicode Standard Version 14.0 - Core Specification, Chapter 3.9.
7744-
\end{itemdescr}
7745-
77467747
\rSec1[string.streams]{String-based streams}
77477748

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

0 commit comments

Comments
 (0)