|
4163 | 4163 | template<class Ostream, class T>
|
4164 | 4164 | Ostream&& operator<<(Ostream&& os, const T& x);
|
4165 | 4165 |
|
| 4166 | + // \ref{ostream.formatted.print}, print functions |
4166 | 4167 | template<class... Args>
|
4167 | 4168 | void print(ostream& os, @\exposid{format-string}@<Args...> fmt, Args&&... args);
|
4168 | 4169 | template<class... Args>
|
|
6688 | 6689 | \tcode{out}.
|
6689 | 6690 | \end{itemdescr}
|
6690 | 6691 |
|
| 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 | + |
6691 | 6778 | \rSec3[ostream.unformatted]{Unformatted output functions}
|
6692 | 6779 |
|
6693 | 6780 | \pnum
|
|
7657 | 7744 | May throw \tcode{bad_alloc}.
|
7658 | 7745 | \end{itemdescr}
|
7659 | 7746 |
|
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 |
| - |
7746 | 7747 | \rSec1[string.streams]{String-based streams}
|
7747 | 7748 |
|
7748 | 7749 | \rSec2[sstream.syn]{Header \tcode{<sstream>} synopsis}
|
|
0 commit comments