C++ Logo


Advanced search

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

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Mon, 1 Apr 2024 18:22:13 -0400
On Mon, Apr 1, 2024 at 6:11 PM Zhihao Yuan <zy_at_[hidden]> wrote:

> On Monday, April 1st, 2024 at 8:35 AM, Arthur O'Dwyer via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
> What do you think? Would it make sense to provide two more variants for
>> views::slice?
> If you do, they should certainly have "extent" not "end" semantics. This
> also matches `substr`.
> Absolutely no. Paired, consecutive parameters of the same type but
> different meanings are hostile; we must not repeat this mistake. The
> consistency argument picked something similar out of context but missed the
> picture of a consistent expectation. I have no idea how to convince myself
> that views::indices(3, 10) means {3, 4, ..., 9} but views::slice(3, 10)
> takes {3, 4, ..., 10, 11, 12}.

I don't see a proposal for views::indices (nor do I know from the name what
it would do), but I'd probably have the same consistency argument for it.
If we were inventing the entire STL from scratch, then I'd definitely agree
with the principle that "Paired, consecutive parameters of the same type
but different meanings are hostile" — but that ship sailed in 1998 and so
for me the "consistency" principle takes precedence. If you keep "not
repeating" a mistake off and on every few years, you end up with PHP, where
there's no consistency between various library functions at all.



Received on 2024-04-01 22:22:27