diff --git a/source/diagnostics.tex b/source/diagnostics.tex index d842475bd9..1ee40cad6d 100644 --- a/source/diagnostics.tex +++ b/source/diagnostics.tex @@ -764,6 +764,9 @@ constexpr bool @\libglobal{is_error_code_enum_v}@ = is_error_code_enum::value; template constexpr bool @\libglobal{is_error_condition_enum_v}@ = is_error_condition_enum::value; + + // \ref{syserr.fmt}, formatter + template struct formatter; } \end{codeblock} @@ -836,7 +839,7 @@ \begin{itemdescr} \pnum \returns -A string naming the error category. +A string in the ordinary literal encoding naming the error category. \end{itemdescr} \indexlibrarymember{default_error_condition}{error_category}% @@ -880,7 +883,8 @@ \begin{itemdescr} \pnum \returns -A string that describes the error condition denoted by \tcode{ev}. +A string of multibyte characters in the execution character set +that describes the error condition denoted by \tcode{ev}. \end{itemdescr} \rSec3[syserr.errcat.nonvirtuals]{Non-virtual members} @@ -1235,6 +1239,98 @@ Equivalent to: \tcode{return os << ec.category().name() << ':' << ec.value();} \end{itemdescr} +\rSec3[syserr.fmt]{Formatting} +\pnum +\indexlibraryglobal{formatter}% +\begin{codeblock} +template struct formatter { + constexpr void set_debug_format(); + + constexpr typename basic_format_parse_context::iterator + parse(basic_format_parse_context& ctx); + + template + typename basic_format_context::iterator + format(const error_code& ec, basic_format_context& ctx) const; +}; +\end{codeblock} + +\indexlibrarymember{set_debug_format}{formatter}% +\begin{itemdecl} +constexpr void set_debug_format(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Modifies the state of the \tcode{formatter} to be as if the +\fmtgrammarterm{error-code-format-spec} parsed by the +last call to \tcode{parse} contained the \tcode{?} option. +\end{itemdescr} + +\indexlibrarymember{parse}{formatter}% +\begin{itemdecl} +constexpr typename basic_format_parse_context::iterator + parse(basic_format_parse_context& ctx); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Parses the format specifier as an \fmtgrammarterm{error-code-format-spec} +and stores the parsed specifiers in \tcode{*this}. + +\begin{ncbnf} +\fmtnontermdef{error-code-format-spec}\br + \opt{fill-and-align} \opt{width} \opt{\tcode{?}} \opt{\tcode{s}} +\end{ncbnf} + +where the productions \fmtgrammarterm{fill-and-align} and \fmtgrammarterm{width} are +described in \ref{format.string}. + +\pnum +\returns +An iterator past the end of the \fmtgrammarterm{error-code-format-spec}. +\end{itemdescr} + +\indexlibrarymember{format}{formatter}% +\begin{itemdecl} +template + typename basic_format_context::iterator + format(const error_code& ec, basic_format_context& ctx) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +\begin{itemize} +\item +If the \tcode{s} option is used, then: +\begin{itemize} +\item +If \tcode{charT} is \tcode{char} and the ordinary literal encoding is UTF-8, +then let \tcode{msg} be \tcode{ec.message()} transcoded to UTF-8 +with maximal subparts of ill-formed subsequences substituted with \unicode{fffd}{replacement character} +per the Unicode Standard, Chapter 3.9 \unicode{fffd} Substi\-tution in Conversion. +\item +Otherwise, let \tcode{msg} be \tcode{ec.message()} +transcoded to an implementation-defined encoding. +\end{itemize} + +\item +Otherwise, let \tcode{msg} be \tcode{std::format("{}:{}", ec.category().name(), ec.value())}. + +\item +If the \tcode{?} option is used +then \tcode{msg} is formatted as an escaped string\iref{format.string.escaped}. +Writes \tcode{msg} into \tcode{ctx.out()}, adjusted according to the \fmtgrammarterm{error-code-format-spec}. +\end{itemize} + +\pnum +\returns +An iterator past the end of the output range. +\end{itemdescr} + \rSec2[syserr.errcondition]{Class \tcode{error_condition}}