C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Small C compatibility extensions for array

From: Federico Kircheis <federico_at_[hidden]>
Date: Tue, 25 Oct 2022 22:15:14 +0200
On 25/10/2022 21.57, Thiago Macieira via Std-Proposals wrote:
> On Sunday, 23 October 2022 12:28:41 PDT Bo Persson via Std-Proposals wrote:
>> So instead of f(int [static 42]) you could use f(std::array<int, 42>&).
>>
>> Being C compatible is a very minor convenience here.
>
> Strictly speaking, that's not the same thing. The "static 42' means "at least
> 42", not "exactly 42". See https://cigix.me/c17#6.7.6.3.p7
>
> To declare "exactly 42", the C standard decided to overload yet another
> keyword: restrict. You write:
>
> f(int [static restrict 42]);
>
> C++ does not want this.
>

We already have span that covers this (and other) use-cases, even if you
cannot write f({1,2,3, ...,42})

(and https://wg21.link/P2447 did not get accepted, so it is not going to
change)

Received on 2022-10-25 20:15:19