From f9f96ea1c0bfb8d8f2a41e0eb90a4749ed9643c8 Mon Sep 17 00:00:00 2001
From: github-actions This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status. Section: 26.5.7.2 [range.utility.conv.to] Status: New
+ Submitter: Hewill Kang Opened: 2023-11-25 Last modified: 2023-11-25 Priority: Not Prioritized
+ View other active issues in [range.utility.conv.to]. View all other issues in [range.utility.conv.to]. View all issues with New status. Discussion:
+Unlike other branches that return a prvalue C, this branch's C is returned by elidable move,
+indicating that C needs to be move constructible (demo):
+ Proposed resolution:
+This wording is relative to N4964.
+ Modify 26.5.7.2 [range.utility.conv.to] as indicated:
+-1- Mandates: C is a cv-unqualified class type.
+
+-2- Returns: An object of type C constructed from the elements of r in the following manner:
+ (2.1) — If C does not satisfy input_range or
+convertible_to<range_reference_t<R>, range_value_t<C>> is true: (2.1.1) — […] (2.1.2) — […] (2.1.3) — […] (2.1.4) — Otherwise, if (2.1.4.?) — move_constructible<C> is true, (2.1.4.1) — constructible_from<C, Args...> is true, and (2.1.4.2) — container-insertable<C, range_reference_t<R>> is true: (2.1.5) — Otherwise, the program is ill-formed. (2.2) — […] (2.3) — Otherwise, the program is ill-formed. Revised 2023-11-25 at 16:27:19 UTC Revised 2023-11-25 at 19:07:54 UTC
+4018. ranges::to's copy branch is underconstrained
+
+
+
+
+#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); // hard error
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/lwg-active.html b/lwg-active.html
index 41098d8bae..3160934182 100644
--- a/lwg-active.html
+++ b/lwg-active.html
@@ -62,7 +62,7 @@
+
+
+template<class C, input_range R, class... Args> requires (!view<C>)
+ constexpr C to(R&& r, Args&&... args);
+
+
+
+
+
+
+
+
+
+
+C c(std::forward<Args>(args)...);
+if constexpr (sized_range<R> && reservable-container<C>)
+ c.reserve(static_cast<range_size_t<C>>(ranges::size(r)));
+ranges::copy(r, container-inserter<range_reference_t<R>>(c));
+
C++ Standard Library Active Issues List (Revision D125)
-
Reference ISO/IEC IS 14882:2020(E)
Also see:
@@ -182,15 +182,15 @@Section: 26.5.7.2 [range.utility.conv.to] Status: New + Submitter: Hewill Kang Opened: 2023-11-25 Last modified: 2023-11-25
+Priority: Not Prioritized +
+View other active issues in [range.utility.conv.to].
+View all other issues in [range.utility.conv.to].
+View all issues with New status.
+Discussion:
++Unlike other branches that return a prvalue C, this branch's C is returned by elidable move, +indicating that C needs to be move constructible (demo): +
+
+#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); // hard error
+}
+
+
+
+Proposed resolution:
++This wording is relative to N4964. +
+ +Modify 26.5.7.2 [range.utility.conv.to] as indicated:
+ ++++template<class C, input_range R, class... Args> requires (!view<C>) + constexpr C to(R&& r, Args&&... args); +++++-1- Mandates: C is a cv-unqualified class type. +
++-2- Returns: An object of type C constructed from the elements of r in the following manner: +
++
+ +- +
(2.1) — If C does not satisfy input_range or +convertible_to<range_reference_t<R>, range_value_t<C>> is true:
++
- +
(2.1.1) — […]
- +
(2.1.2) — […]
- +
(2.1.3) — […]
- +
(2.1.4) — Otherwise, if
++
+- +
(2.1.4.?) — move_constructible<C> is true,
- +
(2.1.4.1) — constructible_from<C, Args...> is true, and
- +
(2.1.4.2) — container-insertable<C, range_reference_t<R>> is true:
++C c(std::forward<Args>(args)...); +if constexpr (sized_range<R> && reservable-container<C>) + c.reserve(static_cast<range_size_t<C>>(ranges::size(r))); +ranges::copy(r, container-inserter<range_reference_t<R>>(c)); +- +
(2.1.5) — Otherwise, the program is ill-formed.
- +
(2.2) — […]
- +
(2.3) — Otherwise, the program is ill-formed.