diff --git a/issue4013.html b/issue4013.html new file mode 100644 index 0000000000..3234df14ba --- /dev/null +++ b/issue4013.html @@ -0,0 +1,116 @@ + + + + +Issue 4013: lazy_split_view::outer-iterator::value_type should not provide default constructor + + + +
+

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.

+

4013. lazy_split_view::outer-iterator::value_type should not provide default constructor

+

Section: 26.7.16.4 [range.lazy.split.outer.value] Status: New + Submitter: Hewill Kang Opened: 2023-11-11 Last modified: 2023-11-18

+

Priority: Not Prioritized +

+

View all other issues in [range.lazy.split.outer.value].

+

View all issues with New status.

+

Discussion:

+

+After P2325, there is no reason for lazy_split_view::outer-iterator::value_type +to provide a default constructor, which only leads to unexpected behavior: +

+
+#include <ranges>
+
+constexpr int arr[] = {42};
+constexpr auto split = arr | std::views::lazy_split(0);
+static_assert(!std::ranges::range_value_t<decltype(split)>{});  // UB, dereferencing a null pointer
+
+

+Also, the other constructor should be private because it makes no sense for the user to construct it arbitrarily, +which is not the intention. +

+ + +

Proposed resolution:

+

+This wording is relative to N4964. +

+ +
    + +
  1. Modify 26.7.16.4 [range.lazy.split.outer.value], class split_view::outer-iterator::value_type synopsis, +as indicated:

    + +
    +namespace std::ranges {
    +  template<input_range V, forward_range Pattern>
    +    requires view<V> && view<Pattern> &&
    +             indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> &&
    +             (forward_range<V> || tiny-range<Pattern>)
    +  template<bool Const>
    +  struct lazy_split_view<V, Pattern>::outer-iterator<Const>::value_type
    +    : view_interface<value_type> {
    +  private:
    +    outer-iterator i_ = outer-iterator();               // exposition only
    +  
    +    constexpr explicit value_type(outer-iterator i);    // exposition only
    +
    +  public:
    +    value_type() = default;
    +    constexpr explicit value_type(outer-iterator i);
    +
    +    constexpr inner-iterator<Const> begin() const;
    +    constexpr default_sentinel_t end() const noexcept;
    +  };
    +}
    +
    + +
  2. + +
+ + + + + + + diff --git a/lwg-active.html b/lwg-active.html index 3d3337002e..2b48cf0fbe 100644 --- a/lwg-active.html +++ b/lwg-active.html @@ -62,7 +62,7 @@

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

-

Revised 2023-11-18 at 12:52:04 UTC

+

Revised 2023-11-18 at 13:06:00 UTC

Reference ISO/IEC IS 14882:2020(E)

Also see:

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

Revision History