forked from lwg/issues
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New issue from Jiang An: "The parse function of a BasicFormatter type…
… needs to be constexpr"
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. — <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>…</tt> | ||
</td> | ||
</tr> | ||
|
||
</table> | ||
</blockquote> | ||
|
||
|
||
</li> | ||
|
||
</ol> | ||
</resolution> | ||
|
||
</issue> |