C++ Logo

std-proposals

Advanced search

Re: [std-proposals] : std::views::slice

From: Hewill Kang <hewillk_at_[hidden]>
Date: Mon, 1 Apr 2024 22:37:49 +0800
Hi all,

I'm wondering if we should also support slice(1) or slice(1, 10, 3), i.e.:

views::slice(1) -> views::drop(1)
views::slice(1, 10) -> views::drop(1) | views::take(9)
views::slice(1, 10, 3) -> views::drop(1) | views::take(9) | views::strde(3)

Although this may be confused with std::strided_slice
([mdspan.submdspan.strided.slice])
(or std::slice [class.slice.overview]), because the second argument of the
latter is *not* the end but the *extent*, so views::slice(1, 10, 3) will
get 1, 4, 7, while strided_slice(1, 10, 3) will get 1, 4, 7, 10.

What do you think? Would it make sense to provide two more variants for
views::slice?


Hewill

Hewill Kang <hewillk_at_[hidden]> 於 2024年4月1日 週一 下午7:57寫道:

> Hi all,
>
> I wrote a draft for C++26 range adaptor views::slice, you can see it here
> https://isocpp.org/files/papers/D3216R0.html
> Since this is a draft, there may be some missing points that have not been
> considered, or there is room for improvement in wording.
> Comments are welcome.
>
> Thanks,
> Hewill
>

Received on 2024-04-01 14:38:01