From f9f96ea1c0bfb8d8f2a41e0eb90a4749ed9643c8 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 25 Nov 2023 19:08:00 +0000 Subject: [PATCH] Automatic update from GitHub Actions workflow --- issue4018.html | 139 ++++++++++++++++++++++++++++ lwg-active.html | 99 +++++++++++++++++++- lwg-closed.html | 8 +- lwg-defects.html | 8 +- lwg-immediate.html | 2 +- lwg-index-open.html | 13 ++- lwg-index.html | 13 ++- lwg-ready.html | 2 +- lwg-status-date.html | 13 ++- lwg-status.html | 15 +++- lwg-tentative.html | 2 +- lwg-toc.html | 11 ++- lwg-unresolved.html | 93 ++++++++++++++++++- unresolved-index.html | 15 +++- unresolved-prioritized.html | 175 +++++++++++++++++++----------------- unresolved-status-date.html | 13 ++- unresolved-status.html | 15 +++- unresolved-toc.html | 11 ++- votable-index.html | 2 +- votable-status-date.html | 2 +- votable-status.html | 2 +- votable-toc.html | 2 +- 22 files changed, 533 insertions(+), 122 deletions(-) create mode 100644 issue4018.html diff --git a/issue4018.html b/issue4018.html new file mode 100644 index 0000000000..9db6899fdc --- /dev/null +++ b/issue4018.html @@ -0,0 +1,139 @@ + + + + +Issue 4018: ranges::to's copy branch is underconstrained + + + +
+

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.

+

4018. ranges::to's copy branch is underconstrained

+

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. +

+ +
    + +
  1. 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: +

    +
      +
    1. (2.1) — If C does not satisfy input_range or +convertible_to<range_reference_t<R>, range_value_t<C>> is true:

      +
        +
      1. (2.1.1) — […]

      2. +
      3. (2.1.2) — […]

      4. +
      5. (2.1.3) — […]

      6. +
      7. (2.1.4) — Otherwise, if

        +
          +
        1. (2.1.4.?) — move_constructible<C> is true,

        2. +
        3. (2.1.4.1) — constructible_from<C, Args...> is true, and

        4. +
        5. (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));
          +
        6. +
        +
      8. +
      9. (2.1.5) — Otherwise, the program is ill-formed.

      10. +
    2. +
    3. (2.2) — […]

    4. +
    5. (2.3) — Otherwise, the program is ill-formed.

    6. +
    + +
    +
    +
  2. + +
+ + + + + + + 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 @@

C++ Standard Library Active Issues List (Revision D125)

-

Revised 2023-11-25 at 16:27:19 UTC

+

Revised 2023-11-25 at 19:07:54 UTC

Reference ISO/IEC IS 14882:2020(E)

Also see:

@@ -182,15 +182,15 @@

Revision History