forked from lwg/issues
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue: "Skipping indirection is not allowed for function_ref" #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,68 @@ | ||
| <?xml version='1.0' encoding='utf-8' standalone='no'?> | ||
| <!DOCTYPE issue SYSTEM "lwg-issue.dtd"> | ||
|
|
||
| <issue num="4257" status="New"> | ||
| <title>Skipping indirection is not allowed for <code>function_ref</code></title> | ||
| <section><sref ref="[func.wrap.general]"/></section> | ||
| <submitter>Tomasz Kamiński</submitter> | ||
| <date>15 May 2025</date> | ||
| <priority>99</priority> | ||
|
|
||
| <discussion> | ||
| <p> | ||
| Currently the wording in <sref ref="[func.wrap.general]"/> allows implementation | ||
| to avoid double indirection when onstructing owning functions wrappers from another one: | ||
| </p> | ||
| <blockquote> | ||
| <p> 2- Let <tt>t</tt> be an object of a type that is a specialization of <tt>function</tt>, | ||
| <tt>copyable_function</tt>, or <tt>move_only_function</tt>, such that the target object | ||
| <tt>x</tt> of <tt>t</tt> has a type that is a specialization of <tt>function</tt>, | ||
| <tt>copyable_function</tt>, or <tt>move_only_function</tt> | ||
| Each argument of the invocation of <tt>x</tt> evaluated as part of the invocation of <tt>t</tt> | ||
| may alias an argument in the same position in the invocation of <tt>t</tt> that has the same type, | ||
| even if the corresponding parameter is not of reference type.</p> | ||
| </blockquote> | ||
|
|
||
| <p> | ||
| However, the wording does not cover a <code>function_ref</code>, disallowing implementation to perform | ||
| this optimization when signatures are compatible, for example: | ||
| </p> | ||
| <pre> | ||
| std::function_ref<void() noexcept> f1(ptr); | ||
| std::function_ref<void()> f1(f2); | ||
| </pre> | ||
|
|
||
| <p> | ||
| We should include specialization of the function_ref in the list. Note that this allows, | ||
| but does not require implementation to perform such optimization. As consequence it is acceptable | ||
| to specifiy the allowance for all combinations of polymorphic wrappers, even for creating | ||
| owning wrapper from non-owning one, even if implementing such optimization may not be possible. | ||
tomaszkam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </p> | ||
|
|
||
| </discussion> | ||
|
|
||
| <resolution> | ||
| <p> | ||
| This wording is relative to <paper num="N5008"/>. | ||
| </p> | ||
| <ol> | ||
|
|
||
| <li><p>Modify <sref ref="[func.wrap.general]"/> as indicated:</p> | ||
|
|
||
| <blockquote> | ||
| <p> 2- Let <tt>t</tt> be an object of a type that is a specialization of <tt>function</tt>, | ||
| <tt>copyable_function</tt>,<del> or</del> <tt>move_only_function</tt><ins>, or <tt>function_ref</tt></ins>, | ||
| such that the target object <tt>x</tt> of <tt>t</tt> has a type that is a specialization of <tt>function</tt>, | ||
| <tt>copyable_function</tt>, <del>or </del><tt>move_only_function</tt><ins>, or <tt>function_ref</tt></ins>. | ||
| Each argument of the invocation of <tt>x</tt> evaluated as part of the invocation of <tt>t</tt> | ||
| may alias an argument in the same position in the invocation of <tt>t</tt> that has the same type, | ||
| even if the corresponding parameter is not of reference type.</p> | ||
|
|
||
| </blockquote> | ||
|
|
||
| </li> | ||
| </ol> | ||
|
|
||
| </resolution> | ||
|
|
||
| </issue> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.