C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 25 Oct 2022 12:57:18 -0700
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.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

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