[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 12:18:36 PDT 2024
jiixyj wrote:
I'm thinking about an alternative design, where:
- `optional` is not used
- the `trailing_empty_` boolean is repurposed as `has_more_`, which is true if and only if the `split_view` has more elements
- all constructors of the `iterators` returned from the `begin()` function of the `split_view` stay as they are -- with the semantics, that if constructed with an "end" iterator, they will still return one empty range.
- the `end()` function of the `split_view` will call new constructor overload(s) of `iterator` as needed. Those constructor overloads are libc++ vendor extensions.
This has the following advantages:
- `optional` machinery is not pulled in
- the data layouts stay exactly the same
- the currently specified iterator constructor overloads are not touched
https://github.com/llvm/llvm-project/pull/87916
More information about the libcxx-commits
mailing list