[libcxx-commits] [libcxx] [libc++] `std::views::split`: fix handling of empty ranges (LWG4017) (PR #87916)

Jan Kokemüller via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 7 13:44:39 PDT 2024


jiixyj wrote:

I've implemented the alternative design in the last commit. The changes are a lot less invasive now.

The "at the end" iterators are constructed with additional constructors that are disambiguated with tag types. For example the `__outer_iterator` from `lazy_split_view`:

```c++
// constructs an iterator that is at the end of `__base_` but will still result in one empty range.
__outer_iterator<true>{*this, ranges::end(__base_)};

// constructs an iterator that is at the end of `__base` and will _not_ result in one empty range.
__outer_iterator<true>{*this, ranges::end(__base_), __outer_iterator_at_end{}};
```

`begin()` will now always return iterators of the first kind, while `end()` calls will return iterators that are "truly" at the end.

https://github.com/llvm/llvm-project/pull/87916


More information about the libcxx-commits mailing list