0

First of all, sorry for my English.

According to the C++11 Standard:

§[basic].3: An entity is a value, object, reference, function, enumerator, type, class member, template, template specialization, namespace, parameter pack, or this.

Isn't it each value and object? For example, nullptr identifies a "value" of type nullptr_t, but, since nullptr_t is a scalar type, it is also an object type, and nullptr is thus an object.

With this I've the same controversy: when this is used in correct situations (in non-static member functions or data member initializers) is a pointer prvalue and thus of scalar/object type, and in consequence an object.

Isn't it?

Charles
  • 50,943
  • 13
  • 104
  • 142
ABu
  • 10,423
  • 6
  • 52
  • 103
  • 1
    `this` is a keyword. *Evaluating* `this` produces a pointer prvalue. – Kerrek SB Feb 09 '14 at 17:54
  • @KerrekSB I've seen this question but the focus of the question is different, and doesn't solve my dubt. – ABu Feb 09 '14 at 17:55
  • @KerrekSB `nullptr` and `true` are also keywords and don't appear in the list of entities, contrary to `this`. – ABu Feb 09 '14 at 17:55
  • Good point. I suppose `this` is non-trivial because it is subject to scoping and hiding rules, unlike `true` and `nullptr`. The term "entity" is presumably just an auxiliary construct used to structure the rules. – Kerrek SB Feb 09 '14 at 18:05
  • @KerrekSB I don't understand either why a value is defined as a entity, since I don't see under which situations you can defined a name for a value, since, other time, all value is an object (or requires the creation of a temporary object to work with it). So, you define names for object as a tool for manipulate values, and never values directly. – ABu Feb 09 '14 at 23:18
  • "Object" is something that occupies storage. `nullptr` is not an object but a value of type `nullptr_t`, in the same way that `1` is not an object but a value of type `int`. – Igor Tandetnik Feb 10 '14 at 02:57

1 Answers1

1

1.8/1 ...An object is a region of storage...

nullptr is to nullptr_t what 1 is to int - it names a value of the type, but it doesn't occupy storage and is therefore not an object.

Neither is this. What makes this different from nullptr_t or true is that you can't, taken in isolation, tell which type it's a value of. So in order to describe its behavior in an expression, one needs to consider the context in which said expression appears. This requires some additional gymnastics in the standard text; for this reason, this is specifically called out in a few places.

Igor Tandetnik
  • 50,461
  • 4
  • 56
  • 85
  • Thanks for your acclaration about `this` but I think I've not express very well my question. I will make other question with a different focus. – ABu Feb 10 '14 at 12:29