1+ <?xml version =' 1.0' encoding =' utf-8' standalone =' no' ?>
2+ <!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+ <issue num =" 4264" status =" New" >
5+ <title >Skipping indirection is not allowed for <code >function_ref</code ></title >
6+ <section ><sref ref =" [func.wrap.general]" /></section >
7+ <submitter >Tomasz Kamiń ski</submitter >
8+ <date >15 May 2025</date >
9+ <priority >99</priority >
10+
11+ <discussion >
12+ <p >
13+ Currently the wording in <sref ref =" [func.wrap.general]" /> allows implementation
14+ to avoid double indirection when constructing owning functions wrappers from another one:
15+ </p >
16+ <blockquote >
17+ <p >
18+ -2- Let <tt >t</tt > be an object of a type that is a specialization of <tt >function</tt >,
19+ <tt >copyable_function</tt >, or <tt >move_only_function</tt >, such that the target object
20+ <tt >x</tt > of <tt >t</tt > has a type that is a specialization of <tt >function</tt >,
21+ <tt >copyable_function</tt >, or <tt >move_only_function</tt >.
22+ Each argument of the invocation of <tt >x</tt > evaluated as part of the invocation of <tt >t</tt >
23+ may alias an argument in the same position in the invocation of <tt >t</tt > that has the same type,
24+ even if the corresponding parameter is not of reference type.
25+ </p >
26+ </blockquote >
27+ <p >
28+ However, the wording does not cover a <code >function_ref</code >, disallowing implementation to perform
29+ this optimization when signatures are compatible, for example:
30+ </p >
31+ <blockquote ><pre >
32+ std::function_ref< void() noexcept> f1(ptr);
33+ std::function_ref< void()> f1(f2);
34+ </pre ></blockquote >
35+ <p >
36+ We should include <tt >function_ref</tt > in the list. Note that this allows, but does not require,
37+ an implementation to perform such an optimization. As a consequence, it is acceptable
38+ to specify the allowance for all combinations of polymorphic wrappers, even for creating an
39+ owning wrapper from a non-owning one, where implementing such an optimization may not be possible.
40+ </p >
41+ </discussion >
42+
43+ <resolution >
44+ <p >
45+ This wording is relative to <paper num =" N5008" />.
46+ </p >
47+ <ol >
48+
49+ <li ><p >Modify <sref ref =" [func.wrap.general]" /> as indicated:</p >
50+
51+ <blockquote >
52+ <p >
53+ -2- Let <tt >t</tt > be an object of a type that is a specialization of <tt >function</tt >,
54+ <tt >copyable_function</tt >, <del >or</del > <tt >move_only_function</tt ><ins >, or <tt >function_ref</tt ></ins >,
55+ such that the target object <tt >x</tt > of <tt >t</tt > has a type that is a specialization of <tt >function</tt >,
56+ <tt >copyable_function</tt >, <del >or</del ><tt >move_only_function</tt ><ins >, or <tt >function_ref</tt ></ins >.
57+ Each argument of the invocation of <tt >x</tt > evaluated as part of the invocation of <tt >t</tt >
58+ may alias an argument in the same position in the invocation of <tt >t</tt > that has the same type,
59+ even if the corresponding parameter is not of reference type.
60+ </p >
61+ </blockquote >
62+
63+ </li >
64+ </ol >
65+
66+ </resolution >
67+
68+ </issue >
0 commit comments