C++ Logo

std-proposals

Advanced search

[std-proposals] [[nodiscard]] friend

From: Robert Allan Schwartz <notbob_at_[hidden]>
Date: Wed, 18 Jan 2023 16:51:26 +0000
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

Received on 2023-01-18 16:51:30