From Jason Turner

[basic.def]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpaz9qsj0v/{from.md → to.md} +19 -10
tmp/tmpaz9qsj0v/{from.md → to.md} RENAMED
@@ -1,22 +1,28 @@
1
  ## Declarations and definitions <a id="basic.def">[[basic.def]]</a>
2
 
3
- A declaration [[dcl.dcl]] may (re)introduce one or more names and/or
4
  entities into a translation unit. If so, the declaration specifies the
5
  interpretation and semantic properties of these names. A declaration of
6
- an entity or *typedef-name* X is a redeclaration of X if another
7
- declaration of X is reachable from it [[module.reach]]. A declaration
8
- may also have effects including:
 
 
 
 
9
 
10
  - a static assertion [[dcl.pre]],
11
  - controlling template instantiation [[temp.explicit]],
12
  - guiding template argument deduction for constructors
13
  [[temp.deduct.guide]],
14
  - use of attributes [[dcl.attr]], and
15
  - nothing (in the case of an *empty-declaration*).
16
 
17
- Each entity declared by a *declaration* is also *defined* by that
 
 
18
  declaration unless:
19
 
20
  - it declares a function without specifying the function’s body
21
  [[dcl.fct.def]],
22
  - it contains the `extern` specifier [[dcl.stc]] or a
@@ -24,28 +30,31 @@ declaration unless:
24
  nor a *function-body*,
25
  - it declares a non-inline static data member in a class definition
26
  [[class.mem]], [[class.static]],
27
  - it declares a static data member outside a class definition and the
28
  variable was defined within the class with the `constexpr` specifier
29
- (this usage is deprecated; see [[depr.static.constexpr]]),
 
30
  - it is an *elaborated-type-specifier* [[class.name]],
31
  - it is an *opaque-enum-declaration* [[dcl.enum]],
32
  - it is a *template-parameter* [[temp.param]],
33
  - it is a *parameter-declaration* [[dcl.fct]] in a function declarator
34
  that is not the *declarator* of a *function-definition*,
35
  - it is a `typedef` declaration [[dcl.typedef]],
36
  - it is an *alias-declaration* [[dcl.typedef]],
 
37
  - it is a *using-declaration* [[namespace.udecl]],
38
  - it is a *deduction-guide* [[temp.deduct.guide]],
39
  - it is a *static_assert-declaration* [[dcl.pre]],
 
40
  - it is an *attribute-declaration* [[dcl.pre]],
41
  - it is an *empty-declaration* [[dcl.pre]],
42
  - it is a *using-directive* [[namespace.udir]],
43
  - it is a *using-enum-declaration* [[enum.udecl]],
44
  - it is a *template-declaration* [[temp.pre]] whose *template-head* is
45
  not followed by either a *concept-definition* or a *declaration* that
46
- defines a function, a class, a variable, or a static data member.
47
  - it is an explicit instantiation declaration [[temp.explicit]], or
48
  - it is an explicit specialization [[temp.expl.spec]] whose
49
  *declaration* is not a definition.
50
 
51
  A declaration is said to be a *definition* of each entity that it
@@ -66,11 +75,10 @@ struct X { // defines X
66
  X(): x(0) { } // defines a constructor of X
67
  };
68
  int X::y = 1; // defines X::y
69
  enum { up, down }; // defines up and down
70
  namespace N { int d; } // defines N and N::d
71
- namespace N1 = N; // defines N1
72
  X anX; // defines anX
73
  ```
74
 
75
  whereas these are just declarations:
76
 
@@ -78,17 +86,18 @@ whereas these are just declarations:
78
  extern int a; // declares a
79
  extern const int c; // declares c
80
  int f(int); // declares f
81
  struct S; // declares S
82
  typedef int Int; // declares Int
 
83
  extern X anotherX; // declares anotherX
84
  using N::d; // declares d
85
  ```
86
 
87
  — *end example*]
88
 
89
- [*Note 1*: In some circumstances, C++ implementations implicitly
90
  define the default constructor [[class.default.ctor]], copy constructor,
91
  move constructor [[class.copy.ctor]], copy assignment operator, move
92
  assignment operator [[class.copy.assign]], or destructor [[class.dtor]]
93
  member functions. — *end note*]
94
 
@@ -127,11 +136,11 @@ struct C {
127
  };
128
  ```
129
 
130
  — *end example*]
131
 
132
- [*Note 2*: A class name can also be implicitly declared by an
133
  *elaborated-type-specifier* [[dcl.type.elab]]. — *end note*]
134
 
135
  In the definition of an object, the type of that object shall not be an
136
  incomplete type [[term.incomplete.type]], an abstract class type
137
  [[class.abstract]], or a (possibly multidimensional) array thereof.
 
1
  ## Declarations and definitions <a id="basic.def">[[basic.def]]</a>
2
 
3
+ A declaration [[basic.pre]] may (re)introduce one or more names and/or
4
  entities into a translation unit. If so, the declaration specifies the
5
  interpretation and semantic properties of these names. A declaration of
6
+ an entity X is a redeclaration of X if another declaration of X is
7
+ reachable from it [[module.reach]]; otherwise, it is a
8
+ *first declaration*.
9
+
10
+ [*Note 1*:
11
+
12
+ A declaration can also have effects including:
13
 
14
  - a static assertion [[dcl.pre]],
15
  - controlling template instantiation [[temp.explicit]],
16
  - guiding template argument deduction for constructors
17
  [[temp.deduct.guide]],
18
  - use of attributes [[dcl.attr]], and
19
  - nothing (in the case of an *empty-declaration*).
20
 
21
+ *end note*]
22
+
23
+ Each entity declared by a declaration is also *defined* by that
24
  declaration unless:
25
 
26
  - it declares a function without specifying the function’s body
27
  [[dcl.fct.def]],
28
  - it contains the `extern` specifier [[dcl.stc]] or a
 
30
  nor a *function-body*,
31
  - it declares a non-inline static data member in a class definition
32
  [[class.mem]], [[class.static]],
33
  - it declares a static data member outside a class definition and the
34
  variable was defined within the class with the `constexpr` specifier
35
+ [[class.static.data]] (this usage is deprecated; see
36
+ [[depr.static.constexpr]]),
37
  - it is an *elaborated-type-specifier* [[class.name]],
38
  - it is an *opaque-enum-declaration* [[dcl.enum]],
39
  - it is a *template-parameter* [[temp.param]],
40
  - it is a *parameter-declaration* [[dcl.fct]] in a function declarator
41
  that is not the *declarator* of a *function-definition*,
42
  - it is a `typedef` declaration [[dcl.typedef]],
43
  - it is an *alias-declaration* [[dcl.typedef]],
44
+ - it is a *namespace-alias-definition* [[namespace.alias]],
45
  - it is a *using-declaration* [[namespace.udecl]],
46
  - it is a *deduction-guide* [[temp.deduct.guide]],
47
  - it is a *static_assert-declaration* [[dcl.pre]],
48
+ - it is a *consteval-block-declaration*,
49
  - it is an *attribute-declaration* [[dcl.pre]],
50
  - it is an *empty-declaration* [[dcl.pre]],
51
  - it is a *using-directive* [[namespace.udir]],
52
  - it is a *using-enum-declaration* [[enum.udecl]],
53
  - it is a *template-declaration* [[temp.pre]] whose *template-head* is
54
  not followed by either a *concept-definition* or a *declaration* that
55
+ defines a function, a class, a variable, or a static data member,
56
  - it is an explicit instantiation declaration [[temp.explicit]], or
57
  - it is an explicit specialization [[temp.expl.spec]] whose
58
  *declaration* is not a definition.
59
 
60
  A declaration is said to be a *definition* of each entity that it
 
75
  X(): x(0) { } // defines a constructor of X
76
  };
77
  int X::y = 1; // defines X::y
78
  enum { up, down }; // defines up and down
79
  namespace N { int d; } // defines N and N::d
 
80
  X anX; // defines anX
81
  ```
82
 
83
  whereas these are just declarations:
84
 
 
86
  extern int a; // declares a
87
  extern const int c; // declares c
88
  int f(int); // declares f
89
  struct S; // declares S
90
  typedef int Int; // declares Int
91
+ namespace N1 = N; // declares N1
92
  extern X anotherX; // declares anotherX
93
  using N::d; // declares d
94
  ```
95
 
96
  — *end example*]
97
 
98
+ [*Note 2*: In some circumstances, C++ implementations implicitly
99
  define the default constructor [[class.default.ctor]], copy constructor,
100
  move constructor [[class.copy.ctor]], copy assignment operator, move
101
  assignment operator [[class.copy.assign]], or destructor [[class.dtor]]
102
  member functions. — *end note*]
103
 
 
136
  };
137
  ```
138
 
139
  — *end example*]
140
 
141
+ [*Note 3*: A class name can also be implicitly declared by an
142
  *elaborated-type-specifier* [[dcl.type.elab]]. — *end note*]
143
 
144
  In the definition of an object, the type of that object shall not be an
145
  incomplete type [[term.incomplete.type]], an abstract class type
146
  [[class.abstract]], or a (possibly multidimensional) array thereof.