C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Attribute [[discard]] and attributes on expressions

From: Julien Jorge <julien.jorge_at_[hidden]>
Date: Fri, 6 Oct 2023 07:54:16 +0200
On 06/10/2023 01:06, Giuseppe D'Angelo via Std-Proposals wrote:
> Il 05/10/23 23:39, Julien Jorge via Std-Proposals ha scritto:
>> Attributes can be safely ignored without changing the semantics of
>> the program, so what does it means to have a statement like `int a =
>> foo(), [[discard]] bar()`? In any case `a` must receive the result of
>> `foo()`, isn't it?
>
> I'm not sure how to read this question:
>
Well, another sign that I should not be commenting while I am falling
asleep on my phone :D My example was clearly badly written.

Back to the proposal, I was confused by examples like:

    a[4] = (x+y [[attr]]); // attr applies to `x+y`

I was wondering what does it mean to discard x+y here? From your
explanations I understand that the attribute would be ignored here, and
that a[4] would be assigned x+y. Which is okay for me.

Best regards,

Julien

Received on 2023-10-06 05:54:21