Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 98 additions & 2 deletions source/diagnostics.tex
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,9 @@
constexpr bool @\libglobal{is_error_code_enum_v}@ = is_error_code_enum<T>::value;
template<class T>
constexpr bool @\libglobal{is_error_condition_enum_v}@ = is_error_condition_enum<T>::value;

// \ref{syserr.fmt}, formatter
template<class T> struct formatter<error_code, charT>;
}
\end{codeblock}

Expand Down Expand Up @@ -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}%
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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<class charT> struct formatter<error_code, charT> {
Comment thread
notdanhan marked this conversation as resolved.
constexpr void set_debug_format();

constexpr typename basic_format_parse_context<charT>::iterator
parse(basic_format_parse_context<charT>& ctx);

template<class Out>
typename basic_format_context<Out, charT>::iterator
format(const error_code& ec, basic_format_context<Out, charT>& 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<charT>::iterator
parse(basic_format_parse_context<charT>& 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<class Out>
typename basic_format_context<Out, charT>::iterator
format(const error_code& ec, basic_format_context<Out, charT>& 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}.
Comment on lines +1319 to +1326

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all seems to be a scription of Effects to me, not separate paragraphs, but maybe I'm missing something. The paper does put gaps here, but idk, this is weird.

Suggested change
\pnum
Otherwise, let \tcode{msg} be \tcode{std::format("{}:{}", ec.category().name(), ec.value())}.
\pnum
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}.
Otherwise, let \tcode{msg} be \tcode{std::format("{}:{}", ec.category().name(), ec.value())}.
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}.

@jensmaurer jensmaurer Jun 20, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do have multi-paragraph \effects in some places, but having a separate numbered paragraph for every sentence is certainly non-optimal.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an idea

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image I think this works?

\end{itemize}

\pnum
\returns
An iterator past the end of the output range.
\end{itemdescr}


\rSec2[syserr.errcondition]{Class \tcode{error_condition}}

Expand Down
Loading