C++ Logo

std-proposals

Advanced search

Re: [std-proposals] A new C++ keyword: forget

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Wed, 12 Aug 2026 03:14:59 +0300
On Wed, 12 Aug 2026 at 03:08, Marcin Jaczewski
<marcinjaczewski86_at_[hidden]> wrote:
> if this is `std::redact` this means its normal function as it can't be
> a keyword, right?

It's not a normal function. It's a language construct recognized by
the compiler. And despite
being spelled like a function, it can be a declaration, like static_assert is.

> This means it will need some tag to mark this behavior like:
> void redact([[redact]] auto& val) {}

No.

> class Foo
> {
> int i;
> void dispose() [[redact]]; //as it refer to `this`
> }
> int main()
> {
> Foo a;
> a.i = 1;
> a.dispose();
> //a..i = 2; //error
> }

Well.. the idea here is to redact names. Not objects. Now you're
entering a territory
where we need some sort of flow analysis.

> Another thing we could simply use:
> int a = 3;
> [[redact]] a;

If our construct is a declaration, you can just do

int a = 3;
std::redact(a);

regardless of what the scope of a is.

Received on 2026-08-12 00:15:21