From Jason Turner

[basic.def]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpctyqmymu/{from.md → to.md} +51 -42
tmp/tmpctyqmymu/{from.md → to.md} RENAMED
@@ -1,49 +1,57 @@
1
  ## Declarations and definitions <a id="basic.def">[[basic.def]]</a>
2
 
3
- A declaration (Clause  [[dcl.dcl]]) may introduce one or more names into
4
- a translation unit or redeclare names introduced by previous
5
- declarations. If so, the declaration specifies the interpretation and
6
- attributes of these names. A declaration may also have effects
7
  including:
8
 
9
- - a static assertion (Clause  [[dcl.dcl]]),
10
- - controlling template instantiation ([[temp.explicit]]),
11
- - guiding template argument deduction for constructors (
12
- [[temp.deduct.guide]]),
13
- - use of attributes (Clause  [[dcl.dcl]]), and
14
  - nothing (in the case of an *empty-declaration*).
15
 
16
- A declaration is a *definition* unless
 
17
 
18
- - it declares a function without specifying the function’s body (
19
- [[dcl.fct.def]]),
20
- - it contains the `extern` specifier ([[dcl.stc]]) or a
21
- *linkage-specification*[^1] ([[dcl.link]]) and neither an
22
- *initializer* nor a *function-body*,
23
- - it declares a non-inline static data member in a class definition (
24
- [[class.mem]],  [[class.static]]),
25
  - it declares a static data member outside a class definition and the
26
  variable was defined within the class with the `constexpr` specifier
27
- (this usage is deprecated; see [[depr.static_constexpr]]),
28
- - it is a class name declaration ([[class.name]]),
29
- - it is an *opaque-enum-declaration* ([[dcl.enum]]),
30
- - it is a *template-parameter* ([[temp.param]]),
31
- - it is a *parameter-declaration* ([[dcl.fct]]) in a function
32
- declarator that is not the *declarator* of a *function-definition*,
33
- - it is a `typedef` declaration ([[dcl.typedef]]),
34
- - it is an *alias-declaration* ([[dcl.typedef]]),
35
- - it is a *using-declaration* ([[namespace.udecl]]),
36
- - it is a *deduction-guide* ([[temp.deduct.guide]]),
37
- - it is a *static_assert-declaration* (Clause  [[dcl.dcl]]),
38
- - it is an *attribute-declaration* (Clause  [[dcl.dcl]]),
39
- - it is an *empty-declaration* (Clause  [[dcl.dcl]]),
40
- - it is a *using-directive* ([[namespace.udir]]),
41
- - it is an explicit instantiation declaration ([[temp.explicit]]), or
42
- - it is an explicit specialization ([[temp.expl.spec]]) whose
 
 
 
 
43
  *declaration* is not a definition.
44
 
 
 
 
45
  [*Example 1*:
46
 
47
  All but one of the following are definitions:
48
 
49
  ``` cpp
@@ -75,25 +83,25 @@ extern X anotherX; // declares anotherX
75
  using N::d; // declares d
76
  ```
77
 
78
  — *end example*]
79
 
80
- [*Note 1*: In some circumstances, C++implementations implicitly define
81
- the default constructor ([[class.ctor]]), copy constructor (
82
- [[class.copy]]), move constructor ([[class.copy]]), copy assignment
83
- operator ([[class.copy]]), move assignment operator ([[class.copy]]),
84
- or destructor ([[class.dtor]]) member functions. — *end note*]
85
 
86
  [*Example 2*:
87
 
88
  Given
89
 
90
  ``` cpp
91
  #include <string>
92
 
93
  struct C {
94
- std::string s; // std::string is the standard library class (Clause~[strings])
95
  };
96
 
97
  int main() {
98
  C a;
99
  C b = a;
@@ -119,10 +127,11 @@ struct C {
119
  ```
120
 
121
  — *end example*]
122
 
123
  [*Note 2*: A class name can also be implicitly declared by an
124
- *elaborated-type-specifier* ([[dcl.type.elab]]). — *end note*]
125
 
126
- A program is ill-formed if the definition of any object gives the object
127
- an incomplete type ([[basic.types]]).
 
128
 
 
1
  ## Declarations and definitions <a id="basic.def">[[basic.def]]</a>
2
 
3
+ A declaration [[dcl.dcl]] may introduce one or more names into a
4
+ translation unit or redeclare names introduced by previous declarations.
5
+ If so, the declaration specifies the interpretation and semantic
6
+ properties of these names. A declaration may also have effects
7
  including:
8
 
9
+ - a static assertion [[dcl.pre]],
10
+ - controlling template instantiation [[temp.explicit]],
11
+ - guiding template argument deduction for constructors
12
+ [[temp.deduct.guide]],
13
+ - use of attributes [[dcl.attr]], and
14
  - nothing (in the case of an *empty-declaration*).
15
 
16
+ Each entity declared by a *declaration* is also *defined* by that
17
+ declaration unless:
18
 
19
+ - it declares a function without specifying the function’s body
20
+ [[dcl.fct.def]],
21
+ - it contains the `extern` specifier [[dcl.stc]] or a
22
+ *linkage-specification*[^1] [[dcl.link]] and neither an *initializer*
23
+ nor a *function-body*,
24
+ - it declares a non-inline static data member in a class definition (
25
+ [[class.mem]], [[class.static]]),
26
  - it declares a static data member outside a class definition and the
27
  variable was defined within the class with the `constexpr` specifier
28
+ (this usage is deprecated; see [[depr.static.constexpr]]),
29
+ - it is introduced by an *elaborated-type-specifier* [[class.name]],
30
+ - it is an *opaque-enum-declaration* [[dcl.enum]],
31
+ - it is a *template-parameter* [[temp.param]],
32
+ - it is a *parameter-declaration* [[dcl.fct]] in a function declarator
33
+ that is not the *declarator* of a *function-definition*,
34
+ - it is a `typedef` declaration [[dcl.typedef]],
35
+ - it is an *alias-declaration* [[dcl.typedef]],
36
+ - it is a *using-declaration* [[namespace.udecl]],
37
+ - it is a *deduction-guide* [[temp.deduct.guide]],
38
+ - it is a *static_assert-declaration* [[dcl.pre]],
39
+ - it is an *attribute-declaration* [[dcl.pre]],
40
+ - it is an *empty-declaration* [[dcl.pre]],
41
+ - it is a *using-directive* [[namespace.udir]],
42
+ - it is a *using-enum-declaration* [[enum.udecl]],
43
+ - it is a *template-declaration* [[temp.pre]] whose *template-head* is
44
+ not followed by either a *concept-definition* or a *declaration* that
45
+ defines a function, a class, a variable, or a static data member.
46
+ - it is an explicit instantiation declaration [[temp.explicit]], or
47
+ - it is an explicit specialization [[temp.expl.spec]] whose
48
  *declaration* is not a definition.
49
 
50
+ A declaration is said to be a *definition* of each entity that it
51
+ defines.
52
+
53
  [*Example 1*:
54
 
55
  All but one of the following are definitions:
56
 
57
  ``` cpp
 
83
  using N::d; // declares d
84
  ```
85
 
86
  — *end example*]
87
 
88
+ [*Note 1*: In some circumstances, C++ implementations implicitly
89
+ define the default constructor [[class.default.ctor]], copy constructor,
90
+ move constructor [[class.copy.ctor]], copy assignment operator, move
91
+ assignment operator [[class.copy.assign]], or destructor [[class.dtor]]
92
+ member functions. — *end note*]
93
 
94
  [*Example 2*:
95
 
96
  Given
97
 
98
  ``` cpp
99
  #include <string>
100
 
101
  struct C {
102
+ std::string s; // std::string is the standard library class[string.classes]
103
  };
104
 
105
  int main() {
106
  C a;
107
  C b = a;
 
127
  ```
128
 
129
  — *end example*]
130
 
131
  [*Note 2*: A class name can also be implicitly declared by an
132
+ *elaborated-type-specifier* [[dcl.type.elab]]. — *end note*]
133
 
134
+ In the definition of an object, the type of that object shall not be an
135
+ incomplete type [[basic.types]], an abstract class type
136
+ [[class.abstract]], or a (possibly multi-dimensional) array thereof.
137