From d79f5b7a6eea858805a59437b02d14b4562a8000 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 25 Nov 2023 13:21:31 +0000 Subject: [PATCH] Automatic update from GitHub Actions workflow --- issue4017.html | 133 ++++++++++++++++++++++++++++++++++++ lwg-active.html | 95 ++++++++++++++++++++++++-- lwg-closed.html | 10 +-- lwg-defects.html | 10 +-- 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 | 13 +++- lwg-tentative.html | 2 +- lwg-toc.html | 11 ++- lwg-unresolved.html | 87 ++++++++++++++++++++++- unresolved-index.html | 13 +++- unresolved-prioritized.html | 125 +++++++++++++++++---------------- unresolved-status-date.html | 13 +++- unresolved-status.html | 13 +++- unresolved-toc.html | 11 ++- votable-index.html | 2 +- votable-status-date.html | 2 +- votable-status.html | 2 +- votable-toc.html | 2 +- 22 files changed, 490 insertions(+), 97 deletions(-) create mode 100644 issue4017.html diff --git a/issue4017.html b/issue4017.html new file mode 100644 index 0000000000..04f292a738 --- /dev/null +++ b/issue4017.html @@ -0,0 +1,133 @@ + + + + +Issue 4017: Behavior of std::views::split on an empty range + + + +
+

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.

+

4017. Behavior of std::views::split on an empty range

+

Section: 26.7.17.3 [range.split.iterator] Status: New + Submitter: Barry Revzin Opened: 2023-11-19 Last modified: 2023-11-25

+

Priority: Not Prioritized +

+

View all issues with New status.

+

Discussion:

+

+Consider the following example (which uses fmt::println instead of std::println, +but they do the same thing in C++23): +

+
+#include <iostream>
+#include <string>
+#include <ranges>
+#include <fmt/ranges.h>
+
+int main()
+{
+  fmt::println("{}", std::views::split(std::string(" x "), ' '));
+  fmt::println("{}", std::views::split(std::string(" "), ' '));
+  fmt::println("{}", std::views::split(std::string("x"), ' '));
+  fmt::println("{}", std::views::split(std::string(""), ' '));
+}
+
+

+The output of this program (as specified today) is +

+
+[[], ['x'], []]
+[[], []]
+[['x']]
+[]
+
+

+The principle set out in LWG 3478 is that splitting a sequence containing N +delimiters should lead to N+1 subranges. That principle was broken if the N-th +delimiter was at the end of the sequence, which was fixed by P2210. +

+However, the principle is still broken if the sequence contains zero delimiters. A non-empty sequence +will split into one range, but an empty sequence will split into zero ranges. That last line is incorrect +— splitting an empty range on a delimiter should yield a range of an empty range — not +simply an empty range. +

+Proposed Resolution: Currently, split_view::iterator's constructor unconditionally initializes +trailing_empty_ to false. Instead, change 26.7.17.3 [range.split.iterator]/1 +to initialize trailing_empty_ to cur_ == next_.begin() (i.e. +trailing_empty_ is typically false, but if we're empty on initialization then we +have to have a trailing empty range). +

+The following demo shows my implementation from P2210, adjusted to fix this: +godbolt.org/z/axWb64j9f +

+ + +

Proposed resolution:

+

+This wording is relative to N4964. +

+ +
    + +
  1. Modify 26.7.17.3 [range.split.iterator] as indicated:

    + +
    +
    +constexpr iterator(split_view& parent, iterator_t<V> current, subrange<iterator_t<V>> next);
    +
    +
    +

    +-1- Effects: Initializes parent_ with addressof(parent), cur_ with +std::move(current), and next_ with std::move(next), and +trailing_empty_ with cur_ == next_.begin(). +

    +
    +
    +
  2. + +
+ + + + + + + diff --git a/lwg-active.html b/lwg-active.html index c2e50dad68..05bf5e737b 100644 --- a/lwg-active.html +++ b/lwg-active.html @@ -50,7 +50,7 @@ Date: - 2023-11-24 + 2023-11-25 Project: @@ -62,7 +62,7 @@

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

-

Revised 2023-11-24 at 17:56:34 UTC

+

Revised 2023-11-25 at 13:21:24 UTC

Reference ISO/IEC IS 14882:2020(E)

Also see:

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

Revision History