tmp/tmpss2qqkqg/{from.md → to.md}
RENAMED
|
@@ -11,17 +11,14 @@ member shall not be a direct member [[class.mem]] of an unnamed
|
|
| 11 |
[[class.pre]] or local [[class.local]] class or of a (possibly
|
| 12 |
indirectly) nested class [[class.nest]] thereof.
|
| 13 |
|
| 14 |
The declaration of a non-inline static data member in its class
|
| 15 |
definition is not a definition and may be of an incomplete type other
|
| 16 |
-
than cv `void`.
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
class name using the `::` operator. The *initializer* expression in the
|
| 21 |
-
definition of a static data member is in the scope of its class
|
| 22 |
-
[[basic.scope.class]].
|
| 23 |
|
| 24 |
[*Example 1*:
|
| 25 |
|
| 26 |
``` cpp
|
| 27 |
class process {
|
|
@@ -31,20 +28,20 @@ class process {
|
|
| 31 |
|
| 32 |
process* process::running = get_main();
|
| 33 |
process* process::run_chain = running;
|
| 34 |
```
|
| 35 |
|
| 36 |
-
The static data member `run_chain` of class `process`
|
| 37 |
-
global scope; the notation `process::run_chain`
|
| 38 |
-
member `run_chain` is a member of class `process` and in the
|
| 39 |
-
class `process`. In the static data member definition, the
|
| 40 |
-
expression refers to the static data member `running` of
|
| 41 |
-
`process`.
|
| 42 |
|
| 43 |
— *end example*]
|
| 44 |
|
| 45 |
-
[*Note
|
| 46 |
|
| 47 |
Once the static data member has been defined, it exists even if no
|
| 48 |
objects of its class have been created.
|
| 49 |
|
| 50 |
[*Example 2*:
|
|
@@ -52,31 +49,31 @@ objects of its class have been created.
|
|
| 52 |
In the example above, `run_chain` and `running` exist even if no objects
|
| 53 |
of class `process` are created by the program.
|
| 54 |
|
| 55 |
— *end example*]
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
— *end note*]
|
| 58 |
|
| 59 |
If a non-volatile non-inline `const` static data member is of integral
|
| 60 |
or enumeration type, its declaration in the class definition can specify
|
| 61 |
a *brace-or-equal-initializer* in which every *initializer-clause* that
|
| 62 |
is an *assignment-expression* is a constant expression [[expr.const]].
|
| 63 |
The member shall still be defined in a namespace scope if it is odr-used
|
| 64 |
-
[[
|
| 65 |
-
|
| 66 |
-
|
| 67 |
*brace-or-equal-initializer*. If the member is declared with the
|
| 68 |
`constexpr` specifier, it may be redeclared in namespace scope with no
|
| 69 |
initializer (this usage is deprecated; see [[depr.static.constexpr]]).
|
| 70 |
Declarations of other static data members shall not specify a
|
| 71 |
*brace-or-equal-initializer*.
|
| 72 |
|
| 73 |
-
[*Note
|
| 74 |
-
is odr-used [[
|
| 75 |
|
| 76 |
-
[*Note
|
| 77 |
linkage of the name of the class [[basic.link]]. — *end note*]
|
| 78 |
|
| 79 |
-
Static data members are initialized and destroyed exactly like non-local
|
| 80 |
-
variables ([[basic.start.static]], [[basic.start.dynamic]],
|
| 81 |
-
[[basic.start.term]]).
|
| 82 |
-
|
|
|
|
| 11 |
[[class.pre]] or local [[class.local]] class or of a (possibly
|
| 12 |
indirectly) nested class [[class.nest]] thereof.
|
| 13 |
|
| 14 |
The declaration of a non-inline static data member in its class
|
| 15 |
definition is not a definition and may be of an incomplete type other
|
| 16 |
+
than cv `void`.
|
| 17 |
+
|
| 18 |
+
[*Note 1*: The *initializer* in the definition of a static data member
|
| 19 |
+
is in the scope of its class [[basic.scope.class]]. — *end note*]
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
[*Example 1*:
|
| 22 |
|
| 23 |
``` cpp
|
| 24 |
class process {
|
|
|
|
| 28 |
|
| 29 |
process* process::running = get_main();
|
| 30 |
process* process::run_chain = running;
|
| 31 |
```
|
| 32 |
|
| 33 |
+
The definition of the static data member `run_chain` of class `process`
|
| 34 |
+
inhabits the global scope; the notation `process::run_chain` indicates
|
| 35 |
+
that the member `run_chain` is a member of class `process` and in the
|
| 36 |
+
scope of class `process`. In the static data member definition, the
|
| 37 |
+
*initializer* expression refers to the static data member `running` of
|
| 38 |
+
class `process`.
|
| 39 |
|
| 40 |
— *end example*]
|
| 41 |
|
| 42 |
+
[*Note 2*:
|
| 43 |
|
| 44 |
Once the static data member has been defined, it exists even if no
|
| 45 |
objects of its class have been created.
|
| 46 |
|
| 47 |
[*Example 2*:
|
|
|
|
| 49 |
In the example above, `run_chain` and `running` exist even if no objects
|
| 50 |
of class `process` are created by the program.
|
| 51 |
|
| 52 |
— *end example*]
|
| 53 |
|
| 54 |
+
The initialization and destruction of static data members is described
|
| 55 |
+
in [[basic.start.static]], [[basic.start.dynamic]], and
|
| 56 |
+
[[basic.start.term]].
|
| 57 |
+
|
| 58 |
— *end note*]
|
| 59 |
|
| 60 |
If a non-volatile non-inline `const` static data member is of integral
|
| 61 |
or enumeration type, its declaration in the class definition can specify
|
| 62 |
a *brace-or-equal-initializer* in which every *initializer-clause* that
|
| 63 |
is an *assignment-expression* is a constant expression [[expr.const]].
|
| 64 |
The member shall still be defined in a namespace scope if it is odr-used
|
| 65 |
+
[[term.odr.use]] in the program and the namespace scope definition shall
|
| 66 |
+
not contain an *initializer*. The declaration of an inline static data
|
| 67 |
+
member (which is a definition) may specify a
|
| 68 |
*brace-or-equal-initializer*. If the member is declared with the
|
| 69 |
`constexpr` specifier, it may be redeclared in namespace scope with no
|
| 70 |
initializer (this usage is deprecated; see [[depr.static.constexpr]]).
|
| 71 |
Declarations of other static data members shall not specify a
|
| 72 |
*brace-or-equal-initializer*.
|
| 73 |
|
| 74 |
+
[*Note 3*: There is exactly one definition of a static data member that
|
| 75 |
+
is odr-used [[term.odr.use]] in a valid program. — *end note*]
|
| 76 |
|
| 77 |
+
[*Note 4*: Static data members of a class in namespace scope have the
|
| 78 |
linkage of the name of the class [[basic.link]]. — *end note*]
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|