C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Function only accepts parameter that will persist

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 06 May 2024 11:18:29 -0700
On Monday 6 May 2024 10:19:23 GMT-7 Frederick Virchanza Gotham via Std-
Proposals wrote:
> Furthermore, the following consteval function:
>
> template<size_t n>
> consteval bool Func(char const (&arg)[n])
> {
> return true;
> }
>
> can be invoked with a non-const char array that may later change. We need a
> way to specify, that not only is the argument consteval, but the object
> referred to by the argument is also consteval.

There's no such thing as a pointer-or-reference to static-storage only in the
core language. I can find a couple of use-cases for that, usually related to
strings, but they're few. Most of those can also be worked around by simply
documenting the expectation.

Adding such a type would be a major core language update.

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

Received on 2024-05-06 18:18:32