|
67 | 67 | </tr> |
68 | 68 | <tr> |
69 | 69 | <td align="left">Date:</td> |
70 | | - <td align="left">2025-03-16</td> |
| 70 | + <td align="left">2025-03-17</td> |
71 | 71 | </tr> |
72 | 72 | <tr> |
73 | 73 | <td align="left">Project:</td> |
|
79 | 79 | </tr> |
80 | 80 | </table> |
81 | 81 | <h1>C++ Standard Library Active Issues List (Revision D125)</h1> |
82 | | -<p>Revised 2025-03-16 at 09:09:08 UTC |
| 82 | +<p>Revised 2025-03-17 at 15:39:10 UTC |
83 | 83 | </p> |
84 | 84 | <p>Reference ISO/IEC IS 14882:2020(E)</p> |
85 | 85 | <p>Also see:</p> |
@@ -62330,7 +62330,7 @@ <h3 id="4120"><a href="#4120">4120</a><sup><a href="https://cplusplus.github.io/ |
62330 | 62330 | <hr> |
62331 | 62331 | <h3 id="4121"><a href="#4121">4121</a><sup><a href="https://cplusplus.github.io/LWG/issue4121">(i)</a></sup>. <code>ranges::to</code> constructs associative containers via <code>c.emplace(c.end(), *it)</code></h3> |
62332 | 62332 | <p><b>Section:</b> 25.5.7.1 <a href="https://wg21.link/range.utility.conv.general">[range.utility.conv.general]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a> |
62333 | | - <b>Submitter:</b> Hewill Kang <b>Opened:</b> 2024-07-16 <b>Last modified:</b> 2024-08-02</p> |
| 62333 | + <b>Submitter:</b> Hewill Kang <b>Opened:</b> 2024-07-16 <b>Last modified:</b> 2025-03-17</p> |
62334 | 62334 | <p><b>Priority: </b>2 |
62335 | 62335 | </p> |
62336 | 62336 | <p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p> |
@@ -62378,9 +62378,9 @@ <h3 id="4121"><a href="#4121">4121</a><sup><a href="https://cplusplus.github.io/ |
62378 | 62378 | "It might be suboptimal, but it still works." |
62379 | 62379 | </p> |
62380 | 62380 |
|
| 62381 | +<p><strong>Previous resolution [SUPERSEDED]:</strong></p> |
| 62382 | +<blockquote class="note"> |
62381 | 62383 |
|
62382 | | - |
62383 | | -<p id="res-4121"><b>Proposed resolution:</b></p> |
62384 | 62384 | <p> |
62385 | 62385 | This wording is relative to <a href="https://wg21.link/N4986" title=" Working Draft, Programming Languages — C++">N4986</a>. |
62386 | 62386 | </p> |
@@ -62424,6 +62424,88 @@ <h3 id="4121"><a href="#4121">4121</a><sup><a href="https://cplusplus.github.io/ |
62424 | 62424 |
|
62425 | 62425 | </li> |
62426 | 62426 | </ol> |
| 62427 | +</blockquote> |
| 62428 | + |
| 62429 | +<p><i>[2025-03-13; Jonathan provides improved wording for Tim's suggestion]</i></p> |
| 62430 | + |
| 62431 | +<p> |
| 62432 | +It's true that for some cases it might be optimal to use <code class='backtick'>c.emplace(ref)</code> |
| 62433 | +instead of <code class='backtick'>c.emplace_hint(c.end(), ref)</code> but I don't think I care. |
| 62434 | +A bad hint is not expensive, it's just an extra comparison then the hint |
| 62435 | +is ignored. |
| 62436 | +And this code path isn't going to be used for <code class='backtick'>std::set</code> or <code class='backtick'>std::map</code>, |
| 62437 | +only for user-defined associative containers that don't have a <code class='backtick'>from_range_t</code> |
| 62438 | +constructor or a <code class='backtick'>C(Iter,Sent)</code> constructor. |
| 62439 | +I think just fixing the original issue is all we need, |
| 62440 | +rather than trying to handle every possible way to insert elements. |
| 62441 | +</p> |
| 62442 | +<p> |
| 62443 | +This is a simpler, portable reproducer that doesn't depend on the current |
| 62444 | +implementation status of <code class='backtick'>std::set</code> in libstdc++: |
| 62445 | +</p> |
| 62446 | +<blockquote><pre><code> |
| 62447 | +#include <ranges> |
| 62448 | +#include <set> |
| 62449 | +struct Set : std::set<int> { |
| 62450 | + Set() { }; // No other constructors |
| 62451 | +}; |
| 62452 | +int main() { |
| 62453 | + int a[1]; |
| 62454 | + auto okay = std::ranges::to<std::set<int>>(a); |
| 62455 | + auto ohno = std::ranges::to<Set>(a); |
| 62456 | +} |
| 62457 | +</code></pre></blockquote> |
| 62458 | + |
| 62459 | + |
| 62460 | + |
| 62461 | +<p id="res-4121"><b>Proposed resolution:</b></p> |
| 62462 | +<p> |
| 62463 | +This wording is relative to <a href="https://wg21.link/N5001">N5001</a>. |
| 62464 | +</p> |
| 62465 | + |
| 62466 | +<ol> |
| 62467 | +<li><p>Modify 25.5.7.1 <a href="https://wg21.link/range.utility.conv.general">[range.utility.conv.general]</a> as indicated:</p> |
| 62468 | + |
| 62469 | +<blockquote> |
| 62470 | +<p> |
| 62471 | +-4- Let <code><i>container-appendable</i></code> be defined as follows: |
| 62472 | +</p> |
| 62473 | +<blockquote><pre> |
| 62474 | +template<class Container, class Ref> |
| 62475 | +constexpr bool <i>container-appendable</i> = <i>// exposition only</i> |
| 62476 | + requires(Container& c, Ref&& ref) { |
| 62477 | + requires (requires { c.emplace_back(std::forward<Ref>(ref)); } || |
| 62478 | + requires { c.push_back(std::forward<Ref>(ref)); } || |
| 62479 | + <ins>requires { c.emplace_hint(c.end(), std::forward<Ref>(ref)); } ||</ins> |
| 62480 | + requires { c.emplace(c.end(), std::forward<Ref>(ref)); } || |
| 62481 | + requires { c.insert(c.end(), std::forward<Ref>(ref)); }); |
| 62482 | +}; |
| 62483 | +</pre></blockquote> |
| 62484 | +<p> |
| 62485 | +-5- Let <code><i>container-append</i></code> be defined as follows: |
| 62486 | +</p> |
| 62487 | +<blockquote><pre> |
| 62488 | +template<class Container> |
| 62489 | +constexpr auto <i>container-append</i>(Container& c) { <i>// exposition only</i> |
| 62490 | + return [&c]<class Ref>(Ref&& ref) { |
| 62491 | + if constexpr (requires { c.emplace_back(declval<Ref>()); }) |
| 62492 | + c.emplace_back(std::forward<Ref>(ref)); |
| 62493 | + else if constexpr (requires { c.push_back(declval<Ref>()); }) |
| 62494 | + c.push_back(std::forward<Ref>(ref)); |
| 62495 | + <ins>else if constexpr (requires { c.emplace_hint(c.end(), declval<Ref>()); }) |
| 62496 | + c.emplace_hint(c.end(), std::forward<Ref>(ref));</ins> |
| 62497 | + else if constexpr (requires { c.emplace(c.end(), declval<Ref>()); }) |
| 62498 | + c.emplace(c.end(), std::forward<Ref>(ref)); |
| 62499 | + else |
| 62500 | + c.insert(c.end(), std::forward<Ref>(ref)); |
| 62501 | + }; |
| 62502 | +}; |
| 62503 | +</pre></blockquote> |
| 62504 | +</blockquote> |
| 62505 | + |
| 62506 | +</li> |
| 62507 | +</ol> |
| 62508 | + |
62427 | 62509 |
|
62428 | 62510 |
|
62429 | 62511 |
|
|
0 commit comments