C++ Logo

std-proposals

Advanced search

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

From: Robert Allan Schwartz <notbob_at_[hidden]>
Date: Wed, 18 Jan 2023 18:43:42 +0000
Hi Jason,

I was referring to Giuseppe's comment: "Interestingly enough (but unrelated), both declarations as written are ill-formed as per https://eel.is/c++draft/dcl.attr#grammar-5.sentence-3 ." [emphasis mine].

Thanks,

Robert

On Jan 18, 2023, at 1:36 PM, Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> wrote:

On Wed, Jan 18, 2023 at 1:28 PM Robert Allan Schwartz via
Std-Proposals <std-proposals_at_[hidden]> wrote:

Giuseppe,

Does that mean the current code in <stop_token> will not compile under that draft?

Code in the standard isn't supposed to compile by itself.

The implementation must behave "as if" it were equivalent to the
declarations and behaviors specified by the standard. This means that
if you call `operator==` on `stop_token` and discard the result, the
behavior identified by the `[[nodiscard]]` attribute must happen.
Exactly how an implementation accomplishes that is up to themselves.

For example, the implementation could define the `operator==` function
at the cite of the declaration in `stop_token`. Or the declaration
could lack `[[nodiscard]]`, but the definition could have it (and the
standard is 100% fine with that; the behavior will happen so long as
the compiler can see it on one of the declarations).
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-01-18 18:43:44