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: "Should we reject std::bind_front<42>() and …
…its friends?"
- Loading branch information
Showing
1 changed file
with
81 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,81 @@ | ||
<?xml version='1.0' encoding='utf-8' standalone='no'?> | ||
<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> | ||
|
||
<issue num="3979" status="New"> | ||
<title>Should we reject <tt>std::bind_front<42>()</tt> and its friends?</title> | ||
<section><sref ref="[func.not.fn]"/><sref ref="[func.bind.partial]"/></section> | ||
<submitter>Jiang An</submitter> | ||
<date>22 Aug 2023</date> | ||
<priority>99</priority> | ||
|
||
<discussion> | ||
<p> | ||
<tt>std::bind_front<42>()</tt> seems to be currently well-formed, but the result isn't invocable with any arguments. | ||
Given we are already detecting types and values of the NTTP for new overloads of <tt>std::bind_front</tt>, | ||
<tt>std::bind_back</tt>, and <tt>std::not_fn</tt>, it might be better to diagnose such cases when NTTP is of a scalar type. | ||
<p/> | ||
Note that we might need to separately handle NTTP of scalar and class types for these functions when | ||
<a href="https://wg21.link/CWG2459">CWG2459</a> is not resolved, because it might be necessary to avoid copying a | ||
template parameter object. | ||
</p> | ||
</discussion> | ||
|
||
<resolution> | ||
<p> | ||
This wording is relative to <paper num="N4958"/>. | ||
</p> | ||
|
||
<ol> | ||
|
||
<li><p>Modify the <sref ref="[func.not.fn]"/> as indicated:</p> | ||
|
||
<blockquote> | ||
<pre> | ||
template<auto f> constexpr <i>unspecified</i> not_fn() noexcept; | ||
</pre> | ||
<blockquote> | ||
<p> | ||
-6- […] | ||
<p/> | ||
-7- <i>Mandates</i>: If <del><tt>is_pointer_v<F> || is_member_pointer_v<F></tt> is <tt>true</tt>, then | ||
<tt>f != nullptr</tt> is <tt>true</tt></del><ins><tt>is_scalar_v<F></tt> is <tt>true</tt>, then either | ||
<tt>is_pointer_v<F> && is_function_v<remove_pointer_t<F>></tt> is <tt>true</tt> or | ||
<tt>is_member_pointer_v<F></tt> is <tt>true</tt>, and <tt>f != nullptr</tt> is <tt>true</tt> in either case</ins>. | ||
</p> | ||
</blockquote> | ||
</blockquote> | ||
|
||
</li> | ||
|
||
<li><p>Modify the <sref ref="[func.bind.partial]"/> as indicated:</p> | ||
|
||
<blockquote> | ||
<pre> | ||
template<auto f, class... Args> | ||
constexpr <i>unspecified</i> bind_front(Args&&... args); | ||
template<auto f, class... Args> | ||
constexpr <i>unspecified</i> bind_back(Args&&... args); | ||
</pre> | ||
<blockquote> | ||
<p> | ||
-6- […] | ||
<p/> | ||
-7- <i>Mandates</i>: | ||
</p> | ||
<ol style="list-style-type: none"> | ||
<li><p>(7.1) — […]</p></li> | ||
<li><p>(7.2) — […]</p></li> | ||
<li><p>(7.3) — if <del><tt>is_pointer_v<F> || is_member_pointer_v<F></tt> is <tt>true</tt>, then | ||
<tt>f != nullptr</tt> is <tt>true</tt></del><ins><tt>is_scalar_v<F></tt> is <tt>true</tt>, then either | ||
<tt>is_pointer_v<F> && is_function_v<remove_pointer_t<F>></tt> is <tt>true</tt> or | ||
<tt>is_member_pointer_v<F></tt> is <tt>true</tt>, and <tt>f != nullptr</tt> is <tt>true</tt> in either case</ins>.</p></li> | ||
</ol> | ||
</blockquote> | ||
</blockquote> | ||
|
||
</li> | ||
|
||
</ol> | ||
</resolution> | ||
|
||
</issue> |