C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[nodiscard]] friend

From: Andrew Tomazos <andrewtomazos_at_[hidden]>
Date: Thu, 19 Jan 2023 13:04:45 +1100
You can see the grammar here:

https://eel.is/c++draft/gram

The relevant productions are attribute-specifier-seq (which [[nodiscard]]
matches) and decl-specifier (which friend matches).

For each attribute-specifier-seq there is also corresponding prose that
states what entity the attributes pertain to.

So your proposal would need to specify what changes to the grammar you
propose, and you would have to test that those changes don't create any new
ambiguities (or if they do, you need to add a disambiguation rule which
states which branch of the grammar is taken in the case of an ambiguity.
Search for "resolved in favor of" for examples.)




On Thu, Jan 19, 2023 at 3:51 AM Robert Allan Schwartz via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Hello,
>
> Today I am making my first posts to this group. Please forgive me if I
> make mistakes. Thank you.
>
> Here is the context:
>
> Header <stop_token>:
>
> [[nodiscard]] friend bool operator==(const stop_token& lhs, const
> stop_token& rhs) noexcept;
>
> I would have thought that this should be:
>
> friend [[nodiscard]] bool operator==(const stop_token& lhs, const
> stop_token& rhs) noexcept;
>
> i.e. the attribute pertains to the function, not to the friend declaration,
> but I was told that an attribute cannot appear in this position,
> hence it must be as it is in <stop_token>.
>
> Perhaps the grammar should be amended to allow an attribute in this
> position?
>
> What do you think?
>
> Thank you,
>
> Robert Schwartz
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-01-19 02:04:59