|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4499" status="New"> |
| 5 | +<title>`flat_set::insert_range` specification may be problematic</title> |
| 6 | +<section><sref ref="[flat.set.modifiers]"/><sref ref="[flat.multiset.modifiers]"/></section> |
| 7 | +<submitter>Hewill Kang</submitter> |
| 8 | +<date>22 Dec 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +The function adds elements via: |
| 14 | +</p> |
| 15 | +<blockquote><pre> |
| 16 | +ranges::for_each(rg, [&](auto&& e) { |
| 17 | + <i>c</i>.insert(<i>c</i>.end(), std::forward<decltype(e)>(e)); |
| 18 | +}); |
| 19 | +</pre></blockquote> |
| 20 | +<p> |
| 21 | +Here, `e` is an element of the input range. |
| 22 | +<p/> |
| 23 | +However, this can lead to ambiguity when `e` can also be converted to `initializer_list`, |
| 24 | +as `vector::insert` has an overload of <code>insert(const_iterator, initializer_list<T>)</code>. |
| 25 | +</p> |
| 26 | +</discussion> |
| 27 | + |
| 28 | +<resolution> |
| 29 | +<p> |
| 30 | +This wording is relative to <paper num="N5032"/>. |
| 31 | +</p> |
| 32 | + |
| 33 | +<ol> |
| 34 | + |
| 35 | +<li><p>Modify <sref ref="[flat.set.modifiers]"/> as indicated:</p> |
| 36 | + |
| 37 | +<blockquote> |
| 38 | +<pre> |
| 39 | +template<<i>container-compatible-range</i><value_type> R> |
| 40 | + constexpr void insert_range(R&& rg); |
| 41 | +</pre> |
| 42 | +<blockquote> |
| 43 | +<p> |
| 44 | +-10- <i>Effects</i>: Adds elements to <code><i>c</i></code> as if by: |
| 45 | +</p> |
| 46 | +<blockquote><pre> |
| 47 | +ranges::for_each(rg, [&](<ins>value_type</ins><del>auto&&</del> e) { |
| 48 | + <i>c</i>.insert(<i>c</i>.end(), <ins>std::move</ins><del>std::forward<decltype(e)></del>(e)); |
| 49 | +}); |
| 50 | +</pre></blockquote> |
| 51 | +</blockquote> |
| 52 | +</blockquote> |
| 53 | +</li> |
| 54 | + |
| 55 | +<li><p>Modify <sref ref="[flat.multiset.modifiers]"/> as indicated:</p> |
| 56 | + |
| 57 | +<blockquote> |
| 58 | +<pre> |
| 59 | +template<<i>container-compatible-range</i><value_type> R> |
| 60 | + void insert_range(R&& rg); |
| 61 | +</pre> |
| 62 | +<blockquote> |
| 63 | +<p> |
| 64 | +-9- <i>Effects</i>: Adds elements to <code><i>c</i></code> as if by: |
| 65 | +</p> |
| 66 | +<blockquote><pre> |
| 67 | +ranges::for_each(rg, [&](<ins>value_type</ins><del>auto&&</del> e) { |
| 68 | + <i>c</i>.insert(<i>c</i>.end(), <ins>std::move</ins><del>std::forward<decltype(e)></del>(e)); |
| 69 | +}); |
| 70 | +</pre></blockquote> |
| 71 | +</blockquote> |
| 72 | +</blockquote> |
| 73 | +</li> |
| 74 | + |
| 75 | +</ol> |
| 76 | +</resolution> |
| 77 | + |
| 78 | +</issue> |
0 commit comments