10 KiB
[basic.pre]
6 Basics [basic]
6.1 Preamble [basic.pre]
[Note 1:
This Clause presents the basic concepts of the C++ language.
It explains the difference between an object and a name and how they relate to the value categories for expressions.
It introduces the concepts of a declaration and a definition and presents C++'s notion of type, scope, linkage, and storage duration.
The mechanisms for starting and terminating a program are discussed.
Finally, this Clause presents the fundamental types of the language and lists the ways of constructing compound types from these.
â end note]
[Note 2:
This Clause does not cover concepts that affect only a single part of the language.
Such concepts are discussed in the relevant Clauses.
â end note]
A name is an identifier ([lex.name]),conversion-function-id ([class.conv.fct]),operator-function-id ([over.oper]), orliteral-operator-id ([over.literal]).
Two names are the same if
they are identifiers composed of the same character sequence, or
they are conversion-function-ids formed with equivalent ([temp.over.link]) types, or
they are operator-function-ids formed with the same operator, or
they are literal-operator-ids formed with the same literal suffix identifier.
Every name is introduced by a declaration, which is a
name-declaration,block-declaration, ormember-declaration ([dcl.pre], [class.mem]),
identifier in a structured binding declaration ([dcl.struct.bind]),
identifier in a result-name-introducer in a postcondition assertion ([dcl.contract.res]),
init-capture ([expr.prim.lambda.capture]),
condition with a declarator ([stmt.pre]),
member-declarator ([class.mem]),
using-declarator ([namespace.udecl]),
parameter-declaration ([dcl.fct], [temp.param]),
type-parameter ([temp.param]),
type-tt-parameter ([temp.param]),
variable-tt-parameter ([temp.param]),
concept-tt-parameter ([temp.param]),
elaborated-type-specifier that introduces a name ([dcl.type.elab]),
class-specifier ([class.pre]),
enum-specifier orenumerator-definition ([dcl.enum]),
exception-declaration ([except.pre]), or
implicit declaration of an injected-class-name ([class.pre]).
[Note 3:
The term declaration is not a synonym for the grammar non-terminal declaration ([dcl.pre]).
â end note]
[Note 4:
The interpretation of a for-range-declaration produces one or more of the above ([stmt.ranged]).
â end note]
[Note 5:
Some names denote types or templates.
In general, whenever a name is encountered it is necessary to look it up ([basic.lookup]) to determine whether that name denotes one of these entities before continuing to parse the program that contains it.
â end note]
A variable is introduced by the declaration of a reference other than a non-static data member or of an object.
An entity is a variable, structured binding, result binding, function, enumerator, type, type alias, non-static data member, bit-field, template, namespace, namespace alias, template parameter, function parameter, orinit-capture.
The underlying entity of an entity is that entity unless otherwise specified.
A name denotes the underlying entity of the entity declared by each declaration that introduces the name.
[Note 6:
Type aliases and namespace aliases have underlying entities that are distinct from themselves.
â end note]
A local entity is a variable with automatic storage duration ([basic.stc.auto]), a structured binding ([dcl.struct.bind]) whose corresponding variable is such an entity, a result binding ([dcl.contract.res]), or the *this object ([expr.prim.this]).
A name used in more than one translation unit can potentially refer to the same entity in these translation units depending on thelinkage of the name specified in each translation unit.