Skip to content
Open
Changes from 3 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
96 changes: 94 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}.
Comment thread
notdanhan marked this conversation as resolved.
Outdated
\end{itemdescr}

\rSec3[syserr.errcat.nonvirtuals]{Non-virtual members}
Expand Down Expand Up @@ -1235,6 +1239,94 @@
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} passed by the
Comment thread
notdanhan marked this conversation as resolved.
Outdated
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 a \fmtgrammarterm{error-code-format-spec}
Comment thread
notdanhan marked this conversation as resolved.
Outdated
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 and \fmtgrammarterm{fill-and-align} and \fmtgrammarterm{width} are
Comment thread
notdanhan marked this conversation as resolved.
Outdated
described in\iref{format.string}.
Comment thread
notdanhan marked this conversation as resolved.
Outdated

\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
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,
let \tcode{msg} be \tcode{ec.message()} transcoded to UTF-8
Comment thread
notdanhan marked this conversation as resolved.
Outdated
with maximal subparts of ill-formed subsequences substituted with \unicode{fffd}{replacement character}
per the Unicode Standard, Chapter 3.9 \unicode{fffd} Substitution in Conversion.
\item
Otherwise, let \tcode{msg} be \tcode{ec.message()}
transcoded to an implementation-defined encoding.
\end{itemize}

\pnum
Otherwise, let \tcode{msg} be \tcode{std::format("{}:{}", ec.category().name(), ec.value())}.
Comment thread
notdanhan marked this conversation as resolved.
Outdated

\pnum
If the \tcode{?} option is used then \tcode{msg} is formatted as an escaped string(\iref{format.string.escaped}).
Comment thread
notdanhan marked this conversation as resolved.
Outdated
Writes \tcode{msg} into \tcode{ctx.out()}, adjusted according to the \fmtgrammarterm{error-code-format-spec}.

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?

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 don't love the use of a list with no other text before or after the list. If we went this form I think the final sentence should be its own bullet. "Writes msg into ctx.out()" applies to all cases, not only when ? is used.

We could just make it all one paragraph with no paragraph breaks, but keep the innermost list for the sub-clauses of the "If the s options is used" case. So exactly as in the incoming paper, except without a paragraph break before "If the ? option is used".


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


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

Expand Down
Loading