C++ Logo

std-proposals

Advanced search

Re: [std-proposals] New function attribute [[nodiscard_scope]]

From: Andrew Tomazos <andrewtomazos_at_[hidden]>
Date: Fri, 30 Jun 2023 17:28:13 +1000
On Fri, Jun 30, 2023 at 5:19 PM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:

> With regard to terminology, I think many people including myself
> define the word 'object' as a synonym for 'variable'


"Object" and "variable" are not synonyms:

[basic.pre]/6:
> A variable is introduced by the declaration of a reference other than a
non-static data member or of an object. The variable's name, if any,
denotes the reference or object.

So:

* A variable has a declaration and a name.

* It's name denotes either an object or a reference.

* You can have objects that are not denoted by any variable names:

   f(T())

* You can have variables that do not denote an object:

    int& r = /*...*/;

I suggest studying [basic] from the standard here:
https://eel.is/c++draft/basic

Received on 2023-06-30 07:28:25