Files
cppdraft_translate/cppdraft/basic/pre.md
2025-10-25 03:02:53 +03:00

10 KiB

[basic.pre]

6 Basics [basic]

6.1 Preamble [basic.pre]

1

#

[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]

2

#

[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]

3

#

A name is an identifier ([lex.name]),conversion-function-id ([class.conv.fct]),operator-function-id ([over.oper]), orliteral-operator-id ([over.literal]).

4

#

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.

5

#

Every name is introduced by a declaration, which is a

name-declaration,block-declaration, ormember-declaration ([dcl.pre], [class.mem]),

init-declarator ([dcl.decl]),

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]

6

#

[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]

7

#

A variable is introduced by the declaration of a reference other than a non-static data member or of an object.

8

#

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]

9

#

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]).

10

#

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.