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.
Automatic update from GitHub Actions workflow
- Loading branch information
github-actions
committed
Nov 25, 2023
1 parent
6b06ccb
commit f9f96ea
Showing
22 changed files
with
533 additions
and
122 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,139 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | ||
"http://www.w3.org/TR/html4/strict.dtd"> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Issue 4018: ranges::to's copy branch is underconstrained</title> | ||
<style type="text/css"> | ||
p {text-align:justify} | ||
li {text-align:justify} | ||
blockquote.note | ||
{ | ||
background-color:#E0E0E0; | ||
padding-left: 15px; | ||
padding-right: 15px; | ||
padding-top: 1px; | ||
padding-bottom: 1px; | ||
} | ||
ins {background-color:#A0FFA0} | ||
del {background-color:#FFA0A0} | ||
table {border-collapse: collapse;} | ||
@media (prefers-color-scheme: dark) { | ||
html { | ||
color: #ddd; | ||
background-color: black; | ||
} | ||
ins { | ||
background-color: #225522 | ||
} | ||
del { | ||
background-color: #662222 | ||
} | ||
a { | ||
color: #6af | ||
} | ||
a:visited { | ||
color: #6af | ||
} | ||
blockquote.note | ||
{ | ||
background-color: rgba(255, 255, 255, .10) | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<hr> | ||
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p> | ||
<h3><a name="4018" href="lwg-active.html#4018">4018</a>. <tt>ranges::to</tt>'s copy branch is underconstrained</h3> | ||
<p><b>Section:</b> 26.5.7.2 <a href="https://wg21.link/range.utility.conv.to">[range.utility.conv.to]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a> | ||
<b>Submitter:</b> Hewill Kang <b>Opened:</b> 2023-11-25 <b>Last modified:</b> 2023-11-25</p> | ||
<p><b>Priority: </b>Not Prioritized | ||
</p> | ||
<p><b>View other</b> <a href="lwg-index-open.html#range.utility.conv.to">active issues</a> in [range.utility.conv.to].</p> | ||
<p><b>View all other</b> <a href="lwg-index.html#range.utility.conv.to">issues</a> in [range.utility.conv.to].</p> | ||
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p> | ||
<p><b>Discussion:</b></p> | ||
<p> | ||
Unlike other branches that return a prvalue <tt>C</tt>, this branch's <tt>C</tt> is returned by elidable move, | ||
indicating that <tt>C</tt> needs to be move constructible (<a href="https://godbolt.org/z/dfqnx6Txq">demo</a>): | ||
</p> | ||
<blockquote><pre> | ||
#include <ranges> | ||
#include <vector> | ||
|
||
struct nonmovable { | ||
nonmovable() = default; | ||
nonmovable(const nonmovable&) = delete; | ||
nonmovable& operator=(const nonmovable&) = delete; | ||
}; | ||
|
||
template<class T> | ||
struct nonmovable_vector : std::vector<T>, nonmovable { }; | ||
|
||
int main() { | ||
int arr[] = {42}; | ||
auto v = std::ranges::to<nonmovable_vector<int>>(arr); // <span style="color:red;font-weight:bolder">hard error</span> | ||
} | ||
</pre></blockquote> | ||
|
||
|
||
<p id="res-4018"><b>Proposed resolution:</b></p> | ||
<p> | ||
This wording is relative to <a href="https://wg21.link/N4964">N4964</a>. | ||
</p> | ||
|
||
<ol> | ||
|
||
<li><p>Modify 26.5.7.2 <a href="https://wg21.link/range.utility.conv.to">[range.utility.conv.to]</a> as indicated:</p> | ||
|
||
<blockquote> | ||
<pre> | ||
template<class C, input_range R, class... Args> requires (!view<C>) | ||
constexpr C to(R&& r, Args&&... args); | ||
</pre> | ||
<blockquote> | ||
<p> | ||
-1- <i>Mandates</i>: <tt>C</tt> is a cv-unqualified class type. | ||
</p> | ||
<p> | ||
-2- <i>Returns</i>: An object of type <tt>C</tt> constructed from the elements of <tt>r</tt> in the following manner: | ||
</p> | ||
<ol style="list-style-type: none"> | ||
<li><p>(2.1) — If <tt>C</tt> does not satisfy <tt>input_range</tt> or | ||
<tt>convertible_to<range_reference_t<R>, range_value_t<C>></tt> is <tt>true</tt>:</p> | ||
<ol style="list-style-type: none"> | ||
<li><p>(2.1.1) — […]</p></li> | ||
<li><p>(2.1.2) — […]</p></li> | ||
<li><p>(2.1.3) — […]</p></li> | ||
<li><p>(2.1.4) — Otherwise, if</p> | ||
<ol style="list-style-type: none"> | ||
<li><p><ins>(2.1.4.?) — <tt>move_constructible<C></tt> is <tt>true</tt>,</ins></p></li> | ||
<li><p>(2.1.4.1) — <tt>constructible_from<C, Args...></tt> is <tt>true</tt>, and</p></li> | ||
<li><p>(2.1.4.2) — <tt><i>container-insertable</i><C, range_reference_t<R>></tt> is <tt>true</tt>:</p> | ||
<blockquote><pre> | ||
C c(std::forward<Args>(args)...); | ||
if constexpr (sized_range<R> && <i>reservable-container</i><C>) | ||
c.reserve(static_cast<range_size_t<C>>(ranges::size(r))); | ||
ranges::copy(r, <i>container-inserter</i><range_reference_t<R>>(c)); | ||
</pre></blockquote></li> | ||
</ol> | ||
</li> | ||
<li><p>(2.1.5) — Otherwise, the program is ill-formed.</p></li> | ||
</ol></li> | ||
<li><p>(2.2) — […]</p></li> | ||
<li><p>(2.3) — Otherwise, the program is ill-formed.</p></li> | ||
</ol> | ||
|
||
</blockquote> | ||
</blockquote> | ||
</li> | ||
|
||
</ol> | ||
|
||
|
||
|
||
|
||
|
||
</body> | ||
</html> |
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
Oops, something went wrong.