From Jason Turner

[class.static.data]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpyx3btwmt/{from.md → to.md} +16 -18
tmp/tmpyx3btwmt/{from.md → to.md} RENAMED
@@ -4,19 +4,24 @@ A static data member is not part of the subobjects of a class. If a
4
  static data member is declared `thread_local` there is one copy of the
5
  member per thread. If a static data member is not declared
6
  `thread_local` there is one copy of the data member that is shared by
7
  all the objects of the class.
8
 
 
 
 
 
 
9
  The declaration of a non-inline static data member in its class
10
  definition is not a definition and may be of an incomplete type other
11
  than cv `void`. The definition for a static data member that is not
12
  defined inline in the class definition shall appear in a namespace scope
13
  enclosing the member’s class definition. In the definition at namespace
14
  scope, the name of the static data member shall be qualified by its
15
  class name using the `::` operator. The *initializer* expression in the
16
- definition of a static data member is in the scope of its class (
17
- [[basic.scope.class]]).
18
 
19
  [*Example 1*:
20
 
21
  ``` cpp
22
  class process {
@@ -52,33 +57,26 @@ of class `process` are created by the program.
52
  — *end note*]
53
 
54
  If a non-volatile non-inline `const` static data member is of integral
55
  or enumeration type, its declaration in the class definition can specify
56
  a *brace-or-equal-initializer* in which every *initializer-clause* that
57
- is an *assignment-expression* is a constant expression (
58
- [[expr.const]]). The member shall still be defined in a namespace scope
59
- if it is odr-used ([[basic.def.odr]]) in the program and the namespace
60
- scope definition shall not contain an *initializer*. An inline static
61
- data member may be defined in the class definition and may specify a
62
  *brace-or-equal-initializer*. If the member is declared with the
63
  `constexpr` specifier, it may be redeclared in namespace scope with no
64
- initializer (this usage is deprecated; see [[depr.static_constexpr]]).
65
  Declarations of other static data members shall not specify a
66
  *brace-or-equal-initializer*.
67
 
68
- [*Note 2*: There shall be exactly one definition of a static data
69
- member that is odr-used ([[basic.def.odr]]) in a program; no diagnostic
70
- is required. — *end note*]
71
-
72
- Unnamed classes and classes contained directly or indirectly within
73
- unnamed classes shall not contain static data members.
74
 
75
  [*Note 3*: Static data members of a class in namespace scope have the
76
- linkage of that class ([[basic.link]]). A local class cannot have
77
- static data members ([[class.local]]). — *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
 
83
- A static data member shall not be `mutable` ([[dcl.stc]]).
84
-
 
4
  static data member is declared `thread_local` there is one copy of the
5
  member per thread. If a static data member is not declared
6
  `thread_local` there is one copy of the data member that is shared by
7
  all the objects of the class.
8
 
9
+ A static data member shall not be `mutable` [[dcl.stc]]. A static data
10
+ 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`. The definition for a static data member that is not
17
  defined inline in the class definition shall appear in a namespace scope
18
  enclosing the member’s class definition. In the definition at namespace
19
  scope, the name of the static data member shall be qualified by its
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 {
 
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
+ [[basic.def.odr]] in the program and the namespace scope definition
65
+ shall not contain an *initializer*. An inline static data member may be
66
+ defined in the class definition and may specify a
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 2*: There is exactly one definition of a static data member that
74
+ is odr-used [[basic.def.odr]] in a valid program. *end note*]
 
 
 
 
75
 
76
  [*Note 3*: Static data members of a class in namespace scope have the
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