Skip to content

Commit

Permalink
Automatic update from GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Aug 4, 2024
1 parent 406ec69 commit fa11318
Show file tree
Hide file tree
Showing 22 changed files with 829 additions and 212 deletions.
219 changes: 219 additions & 0 deletions issue4132.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 4132: Throws specifications need to include boolean-testable operations</title>
<meta property="og:title" content="Issue 4132: Throws specifications need to include boolean-testable operations">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4132.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
p {text-align:justify}
li {text-align:justify}
pre code.backtick::before { content: "`" }
pre code.backtick::after { content: "`" }
blockquote.note
{
background-color:#E0E0E0;
padding-left: 15px;
padding-right: 15px;
padding-top: 1px;
padding-bottom: 1px;
}
ins {background-color:#A0FFA0}
del {background-color:#FFA0A0}
table.issues-index { border: 1px solid; border-collapse: collapse; }
table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
table.issues-index td { padding: 4px; border: 1px solid; }
table.issues-index td:nth-child(1) { text-align: right; }
table.issues-index td:nth-child(2) { text-align: left; }
table.issues-index td:nth-child(3) { text-align: left; }
table.issues-index td:nth-child(4) { text-align: left; }
table.issues-index td:nth-child(5) { text-align: center; }
table.issues-index td:nth-child(6) { text-align: center; }
table.issues-index td:nth-child(7) { text-align: left; }
table.issues-index td:nth-child(5) span.no-pr { color: red; }
@media (prefers-color-scheme: dark) {
html {
color: #ddd;
background-color: black;
}
ins {
background-color: #225522
}
del {
background-color: #662222
}
a {
color: #6af
}
a:visited {
color: #6af
}
blockquote.note
{
background-color: rgba(255, 255, 255, .10)
}
}
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p>
<h3 id="4132"><a href="lwg-active.html#4132">4132</a>. <i>Throws</i> specifications need to include <code><i>boolean-testable</i></code> operations</h3>
<p><b>Section:</b> 24.2.7.1 <a href="https://wg21.link/associative.reqmts.general">[associative.reqmts.general]</a>, 24.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a>, 24.3.10.6 <a href="https://wg21.link/forward.list.ops">[forward.list.ops]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
<b>Submitter:</b> Daniel Krügler <b>Opened:</b> 2024-08-03 <b>Last modified:</b> 2024-08-04</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#associative.reqmts.general">active issues</a> in [associative.reqmts.general].</p>
<p><b>View all other</b> <a href="lwg-index.html#associative.reqmts.general">issues</a> in [associative.reqmts.general].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The standard provides various <i>Throws</i>: elements whose specification refers to boolean-like
expressions, for example 24.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> says:
</p>
<blockquote><p>
-17- <i>Throws</i>: Nothing unless an exception is thrown by <code>*i == value</code> or
<code>pred(*i) != false</code>.
</p></blockquote>
<p>
The expressions <code>*i == value</code> (by [tab:cpp17.equalitycomparable]) and <code>pred(*i)</code>
(by 27.2 <a href="https://wg21.link/algorithms.requirements">[algorithms.requirements]</a>) both require to have a type that models
<code><i>boolean-testable</i></code>, so their actual evaluation potentially requires an additional
conversion to <code>bool</code> (The part "<code>!= false</code>" was not guaranteed to realize that as
pointed out by LWG <a href="lwg-active.html#4127" title="The Standard Library should not use predicates of the form pred(*i) != false (Status: New)">4127</a> and will therefore be removed by that issue).
<p/>
The <code><i>boolean-testable</i></code> requirements (18.5.2 <a href="https://wg21.link/concept.booleantestable">[concept.booleantestable]</a>) doesn't
say anything about potential exceptions thrown by this conversion, so we must assume that this
conversion allows an exception to be thrown.
<p/>
An additional problem arises by the fact that the <code><i>boolean-testable</i></code> requirements
do not require that the implicit and explicit conversion to <code>bool</code> have to behave
consistently in regard to exceptions. 18.4.4 <a href="https://wg21.link/concept.convertible">[concept.convertible]</a> only says
that "The implicit and explicit conversions are required to produce equal results". But
since we don't want to restrict implementations to a specific <code>bool</code> conversion,
the <i>Throws</i> wording should include it in a manner that applies to any form.
<p/>
Besides the obviously necessary conversion to <code>bool</code> we should not restrict
implementations in regard to the potential usage of other <code><i>boolean-testable</i></code>
operations, e.g. negation, which could potentially also throw an exception.
<p/>
Therefore the wording for the affected <i>Throws</i>: elements somehow needs to mention
<code><i>boolean-testable</i></code> operations to cover the effective operation that is
involved here without actually restricting existing implementations unnecessarily.
</p>


<p id="res-4132"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4986" title=" Working Draft, Programming Languages — C++">N4986</a>.
</p>

<ol>
<li><p>Modify 24.2.7.1 <a href="https://wg21.link/associative.reqmts.general">[associative.reqmts.general]</a> as indicated:</p>

<blockquote>
<pre>
a.merge(a2)
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-116- <i>Throws</i>: Nothing unless the <ins>evaluation of the</ins> comparison object
<ins>including all selected <code><i>boolean-testable</i></code> (18.5.2 <a href="https://wg21.link/concept.booleantestable">[concept.booleantestable]</a>)
operations</ins> throws.
</p>
</blockquote>
</blockquote>
</li>

<li><p>Modify 24.3.10.6 <a href="https://wg21.link/forward.list.ops">[forward.list.ops]</a> as indicated:</p>

<blockquote>
<pre>
size_type remove(const T&amp; value);
template&lt;class Predicate&gt; size_type remove_if(Predicate pred);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-15- <i>Throws</i>: Nothing unless an exception is thrown by the equality comparison or the
predicate <ins>evaluation including all selected <code><i>boolean-testable</i></code>
(18.5.2 <a href="https://wg21.link/concept.booleantestable">[concept.booleantestable]</a>) operations</ins>.
</p>
</blockquote>
<p>
[&hellip;]
</p>
<pre>
size_type unique();
template&lt;class BinaryPredicate&gt; size_type unique(BinaryPredicate binary_pred);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-22- <i>Throws</i>: Nothing unless an exception is thrown by the predicate
<ins>evaluation including all selected <code><i>boolean-testable</i></code>
(18.5.2 <a href="https://wg21.link/concept.booleantestable">[concept.booleantestable]</a>) operations</ins>.
</p>
</blockquote>
</blockquote>
</li>

<li><p>Modify 24.3.11.5 <a href="https://wg21.link/list.ops">[list.ops]</a> as indicated:</p>

<blockquote class="note">
<p>
[<i>Drafting note</i>: The adjustment of p17 is presented as if issue LWG <a href="lwg-active.html#4127" title="The Standard Library should not use predicates of the form pred(*i) != false (Status: New)">4127</a>
proposed wording has already been applied]
</p>
</blockquote>

<blockquote>
<pre>
size_type remove(const T&amp; value);
template&lt;class Predicate&gt; size_type remove_if(Predicate pred);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-17- <i>Throws</i>: Nothing unless an exception is thrown by <code>*i == value</code> or
<code>pred(*i)</code> <ins>including all selected <code><i>boolean-testable</i></code>
(18.5.2 <a href="https://wg21.link/concept.booleantestable">[concept.booleantestable]</a>) operations</ins>.
<p/>
[&hellip;]
</p>
</blockquote>
<pre>
size_type unique();
template&lt;class BinaryPredicate&gt; size_type unique(BinaryPredicate binary_pred);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-24- <i>Throws</i>: Nothing unless an exception is thrown by the predicate
<ins>evaluation including all selected <code><i>boolean-testable</i></code>
(18.5.2 <a href="https://wg21.link/concept.booleantestable">[concept.booleantestable]</a>) operations</ins>.
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>

</ol>





</body>
</html>
Loading

0 comments on commit fa11318

Please sign in to comment.