Skip to content

Commit

Permalink
New issue from Jiang An: "The parse function of a BasicFormatter type…
Browse files Browse the repository at this point in the history
… needs to be constexpr"
  • Loading branch information
Dani-Hub committed Oct 14, 2023
1 parent 21ad1b2 commit 955cc46
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions xml/issue3993.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version='1.0' encoding='utf-8' standalone='no'?>
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">

<issue num="3993" status="New">
<title>The <tt>parse</tt> function of a <i>BasicFormatter</i> type needs to be <tt>constexpr</tt></title>
<section><sref ref="[formatter.requirements]"/></section>
<submitter>Jiang An</submitter>
<date>10 Oct 2023</date>
<priority>99</priority>

<discussion>
<p>
Format strings need to be checkable at compile-time since <paper num="P2216R3"/>. In order to check a
compile-time format string, the <tt>parse</tt> functions of the formatters need to be called. However,
currently there is seemingly no requirement for the <tt>parse</tt> function to be <tt>constexpr</tt>,
and hence whether a format string is correct for formatted types may be not well-defined at compile-time.
</p>
</discussion>

<resolution>
<p>
This wording is relative to <paper num="N4958"/>.
</p>

<ol>

<li><p>Modify <sref ref="[formatter.requirements]"/>, Table 73, <i>BasicFormatter</i> requirements [tab:formatter.basic] as indicated:</p>

<blockquote>
<table border="1">
<caption>Table 73: <i>BasicFormatter</i> requirements [tab:formatter.basic]</caption>
<tr>
<th align="center">Expression</th>
<th align="center">Return type</th>
<th align="center">Requirement</th>
</tr>

<tr>
<td>
<tt>g.parse(pc)</tt>
</td>
<td>
<tt>PC::iterator</tt>
</td>
<td>
Parses <i>format-spec</i> (<sref ref="[format.string]"/>) for type <tt>T</tt> in the<br/>
range <tt>[pc.begin(), pc.end())</tt> until the first unmatched<br/>
character. Throws <tt>format_error</tt> unless<br/>
the whole range is parsed or the unmatched<br/>
character is <tt>}</tt>.<br/>
[<i>Note 1</i>: This allows formatters to emit meaningful<br/>
error messages. &mdash; <i>end note</i>]<br/>
Stores the parsed format specifiers in <tt>*this</tt> and<br/>
returns an iterator past the end of the parsed<br/>
range.
<ins>The expression shall be a core constant expression if <tt>g</tt>,<br/>
<tt>pc.begin()</tt>, <tt>pc.end()</tt>, and lvalue-to-rvalue conversion<br/>
for each element in <tt>[pc.begin(), pc.end())</tt> are core constant<br/>
expressions, and no exception is thrown.</ins>
</td>
</tr>

<tr>
<td colspan="3" align="center">
<tt>&hellip;</tt>
</td>
</tr>

</table>
</blockquote>


</li>

</ol>
</resolution>

</issue>

0 comments on commit 955cc46

Please sign in to comment.