C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Add `.at()` for `view_interface` (also along with `mdspan`)?

From: Hewill Kang <hewillk_at_[hidden]>
Date: Thu, 16 Nov 2023 11:54:24 +0800
>
> I'd like to see concrete discussion of the fact(?) that all view-adaptors
> currently inherit from view_interface. Is that an accident of
> vendor-implementation? or an accident of specification? or is it really
> deliberate and we can rely on it not to change in the future?


This should definitely be worth discussing.
It seems LWG 3549 <https://cplusplus.github.io/LWG/issue3549> needs to be
mentioned (even though I didn't initially intend to do so), after which I
think inheriting `view_interface` may be an option over inheriting
`view_base` *in any way*, even though the former may not currently be able
to synthesize any functions through the base class (also see my naive SO
question back in the day: Why does `basic_istream_view` inherit
`view_interface?`
<https://stackoverflow.com/questions/69303724/why-does-basic-istream-view-inherit-view-interface>,
and ironically, my LWG 3715 <https://cplusplus.github.io/LWG/issue3715> proved
the answer. :) )

In the proposed wording, `ranges::distance` should be `ranges::size`. (They
> do the same physical thing in this case, but the latter better reflects
> your intent.)


I personally prefer `ranges::distance`, which avoids the implicit
conversion (i.e. difference type) before comparing with an index value, but
`ranges::size` definitely sounds reasonable, and perhaps this should be
decided by the LWG. I'll add a discussion for this.

Thanks again for the valuable feedback!

Hewill

Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]> 於 2023年11月16日 週四 上午10:41寫道:

> On Wed, Nov 15, 2023 at 8:42 PM Hewill Kang via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> I've written a draft proposal for `view_interface::at` in
>>
>> https://htmlpreview.github.io/?https://github.com/hewillk/view_interface-at/blob/main/view-at.html
>>
>
> I suggest that the first word of the proposal shouldn't be "Finally". :)
>
> I'd like to see concrete discussion of the fact(?) that all view-adaptors
> currently inherit from view_interface. Is that an accident of
> vendor-implementation? or an accident of specification? or is it really
> deliberate and we can rely on it not to change in the future?
> I.e., I'd like you to list out a bunch of view-adaptors and view-factories
> (at least these four: *take_while_view, iota_view, subrange, common_view*)
> and show how deliberate is the wording that makes them inherit from
> view_interface. Or if there's already some kind of blanket wording that
> says "All standard view adaptors inherit from view_interface...", that's
> even better, and should be mentioned.
>
> In the proposed wording, `ranges::distance` should be `ranges::size`.
> (They do the same physical thing in this case, but the latter better
> reflects your intent.)
>
> Other than that, seems reasonable to me.
>
> Cheers,
> Arthur
>

Received on 2023-11-16 03:54:36