C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Mandate layout of std::array

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Fri, 30 Jun 2023 21:04:54 -0400
On Fri, Jun 30, 2023 at 8:59 PM Tony Basch via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Wouldn't that then just make it std::span without the benefit of being able to use std::dynamic_extent ?

Span doesn't contain the elements; array does.

> If contiguous memory is required, std::span would be better to use.
>
> I also didn't know until your email just now, so color me surprised. What about augmenting to take two more arguments: std::array<T,N,O,S>
> T - type
> N - number of elements (or std::dynamic_extent like std::span takes)
> O - offset of first element
> S - stride (where S >= sizeof(T))

That should be some other type. `std::array` is supposed to replace
language-level arrays. It doesn't need to provide more functionality
than them; it needs to provide *equivalent* functionality to them.

> Then we can axe std::span and use std::array as the ur-array.

`array` contains the elements; `span` does not. I can get a span to a
`vector` or any other contiguous source of elements. The two types are
orthogonal, for different purposes.

Received on 2023-07-01 01:05:04