From Jason Turner

[basic.def.odr]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpzx25nqyl/{from.md → to.md} +134 -58
tmp/tmpzx25nqyl/{from.md → to.md} RENAMED
@@ -18,11 +18,12 @@ An expression or conversion is *potentially evaluated* unless it is an
18
  unevaluated operand [[expr.context]], a subexpression thereof, or a
19
  conversion in an initialization or conversion sequence in such a
20
  context. The set of *potential results* of an expression E is defined as
21
  follows:
22
 
23
- - If E is an *id-expression* [[expr.prim.id]], the set contains only E.
 
24
  - If E is a subscripting operation [[expr.sub]] with an array operand,
25
  the set contains the potential results of that operand.
26
  - If E is a class member access expression [[expr.ref]] of the form E₁
27
  `.` `template`ₒₚₜ E₂ naming a non-static data member, the set
28
  contains the potential results of E₁.
@@ -39,24 +40,26 @@ follows:
39
  potential results of the right operand.
40
  - Otherwise, the set is empty.
41
 
42
  [*Note 1*:
43
 
44
- This set is a (possibly-empty) set of *id-expression*s, each of which is
45
- either E or a subexpression of E.
46
 
47
  [*Example 1*:
48
 
49
  In the following example, the set of potential results of the
50
  initializer of `n` contains the first `S::x` subexpression, but not the
51
- second `S::x` subexpression.
 
52
 
53
  ``` cpp
54
  struct S { static const int x = 0; };
55
  const int &f(const int &r);
56
  int n = b ? (1, S::x) // S::x is not odr-used here
57
  : f(S::x); // S::x is odr-used here, so a definition is required
 
58
  ```
59
 
60
  — *end example*]
61
 
62
  — *end note*]
@@ -65,13 +68,13 @@ A function is *named by* an expression or conversion as follows:
65
 
66
  - A function is named by an expression or conversion if it is the
67
  selected member of an overload set
68
  [[basic.lookup]], [[over.match]], [[over.over]] in an overload
69
  resolution performed as part of forming that expression or conversion,
70
- unless it is a pure virtual function and either the expression is not
71
- an *id-expression* naming the function with an explicitly qualified
72
- name or the expression forms a pointer to member [[expr.unary.op]].
73
  \[*Note 2*: This covers taking the address of functions
74
  [[conv.func]], [[expr.unary.op]], calls to named functions
75
  [[expr.call]], operator overloading [[over]], user-defined conversions
76
  [[class.conv.fct]], allocation functions for *new-expression*s
77
  [[expr.new]], as well as non-default initialization [[dcl.init]]. A
@@ -86,31 +89,64 @@ A function is *named by* an expression or conversion as follows:
86
  - A deallocation function for a class is named by a *delete-expression*
87
  if it is the selected usual deallocation function as specified in 
88
  [[expr.delete]] and  [[class.free]].
89
 
90
  A variable is named by an expression if the expression is an
91
- *id-expression* that denotes it. A variable `x` that is named by a
92
- potentially-evaluated expression E is *odr-used* by E unless
 
93
 
94
- - `x` is a reference that is usable in constant expressions
95
- [[expr.const]], or
96
- - `x` is a variable of non-reference type that is usable in constant
97
- expressions and has no mutable subobjects, and E is an element of the
98
- set of potential results of an expression of non-volatile-qualified
99
- non-class type to which the lvalue-to-rvalue conversion [[conv.lval]]
100
- is applied, or
101
- - `x` is a variable of non-reference type, and E is an element of the
102
- set of potential results of a discarded-value expression
103
- [[expr.context]] to which the lvalue-to-rvalue conversion is not
104
- applied.
 
 
105
 
106
- A structured binding is odr-used if it appears as a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  potentially-evaluated expression.
108
 
109
  `*this` is odr-used if `this` appears as a potentially-evaluated
110
- expression (including as the result of the implicit transformation in
111
- the body of a non-static member function [[class.mfct.non.static]]).
112
 
113
  A virtual member function is odr-used if it is not pure. A function is
114
  odr-used if it is named by a potentially-evaluated expression or
115
  conversion. A non-placement allocation or deallocation function for a
116
  class is odr-used by the definition of a constructor of that class. A
@@ -118,36 +154,40 @@ non-placement deallocation function for a class is odr-used by the
118
  definition of the destructor of that class, or by being selected by the
119
  lookup at the point of definition of a virtual destructor
120
  [[class.dtor]].[^2]
121
 
122
  An assignment operator function in a class is odr-used by an
123
- implicitly-defined copy-assignment or move-assignment function for
124
  another class as specified in  [[class.copy.assign]]. A constructor for
125
  a class is odr-used as specified in  [[dcl.init]]. A destructor for a
126
  class is odr-used if it is potentially invoked [[class.dtor]].
127
 
128
  A local entity [[basic.pre]] is *odr-usable* in a scope
129
- [[basic.scope.scope]] if:
130
 
131
  - either the local entity is not `*this`, or an enclosing class or
132
  non-lambda function parameter scope exists and, if the innermost such
133
  scope is a function parameter scope, it corresponds to a non-static
134
  member function, and
135
  - for each intervening scope [[basic.scope.scope]] between the point at
136
  which the entity is introduced and the scope (where `*this` is
137
  considered to be introduced within the innermost enclosing class or
138
- non-lambda function definition scope), either:
139
- - the intervening scope is a block scope, or
 
 
140
  - the intervening scope is the function parameter scope of a
141
- *lambda-expression* that has a *simple-capture* naming the entity or
142
- has a *capture-default*, and the block scope of the
143
- *lambda-expression* is also an intervening scope.
 
 
144
 
145
  If a local entity is odr-used in a scope in which it is not odr-usable,
146
  the program is ill-formed.
147
 
148
- [*Example 2*:
149
 
150
  ``` cpp
151
  void f(int n) {
152
  [] { n = 1; }; // error: n is not odr-usable due to intervening lambda-expression
153
  struct A {
@@ -160,19 +200,41 @@ void f(int n) {
160
  }
161
  ```
162
 
163
  — *end example*]
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  Every program shall contain at least one definition of every function or
166
  variable that is odr-used in that program outside of a discarded
167
  statement [[stmt.if]]; no diagnostic required. The definition can appear
168
  explicitly in the program, it can be found in the standard or a
169
  user-defined library, or (when appropriate) it is implicitly defined
170
  (see  [[class.default.ctor]], [[class.copy.ctor]], [[class.dtor]], and
171
  [[class.copy.assign]]).
172
 
173
- [*Example 3*:
174
 
175
  ``` cpp
176
  auto f() {
177
  struct A {};
178
  return A{};
@@ -195,11 +257,11 @@ end of every definition domain in which it is odr-used outside of a
195
  discarded statement.
196
 
197
  A definition of a class shall be reachable in every context in which the
198
  class is used in a way that requires the class type to be complete.
199
 
200
- [*Example 4*:
201
 
202
  The following complete translation unit is well-formed, even though it
203
  never defines `X`:
204
 
205
  ``` cpp
@@ -211,11 +273,11 @@ X* x2; // use X in pointer formation
211
  — *end example*]
212
 
213
  [*Note 3*:
214
 
215
  The rules for declarations and expressions describe in which contexts
216
- complete class types are required. A class type `T` must be complete if:
217
 
218
  - an object of type `T` is defined [[basic.def]], or
219
  - a non-static class data member of type `T` is declared [[class.mem]],
220
  or
221
  - `T` is used as the allocated type or array element type in a
@@ -235,20 +297,27 @@ complete class types are required. A class type `T` must be complete if:
235
  - the `typeid` operator [[expr.typeid]] or the `sizeof` operator
236
  [[expr.sizeof]] is applied to an operand of type `T`, or
237
  - a function with a return type or argument type of type `T` is defined
238
  [[basic.def]] or called [[expr.call]], or
239
  - a class with a base class of type `T` is defined [[class.derived]], or
240
- - an lvalue of type `T` is assigned to [[expr.ass]], or
241
  - the type `T` is the subject of an `alignof` expression
242
  [[expr.alignof]], or
243
  - an *exception-declaration* has type `T`, reference to `T`, or pointer
244
  to `T` [[except.handle]].
245
 
246
  — *end note*]
247
 
248
- For any definable item `D` with definitions in multiple translation
249
- units,
 
 
 
 
 
 
 
250
 
251
  - if `D` is a non-inline non-templated function or variable, or
252
  - if the definitions in different translation units do not satisfy the
253
  following requirements,
254
 
@@ -263,24 +332,25 @@ point, the following requirements shall be satisfied.
263
  [[module.unit]].
264
  - Each such definition shall consist of the same sequence of tokens,
265
  where the definition of a closure type is considered to consist of the
266
  sequence of tokens of the corresponding *lambda-expression*.
267
  - In each such definition, corresponding names, looked up according to 
268
- [[basic.lookup]], shall refer to the same entity, after overload
269
  resolution [[over.match]] and after matching of partial template
270
- specialization [[temp.over]], except that a name can refer to
 
271
  - a non-volatile const object with internal or no linkage if the
272
  object
273
  - has the same literal type in all definitions of `D`,
274
  - is initialized with a constant expression [[expr.const]],
275
  - is not odr-used in any definition of `D`, and
276
  - has the same value in all definitions of `D`,
277
 
278
  or
279
  - a reference with internal or no linkage initialized with a constant
280
- expression such that the reference refers to the same entity in all
281
- definitions of `D`.
282
  - In each such definition, except within the default arguments and
283
  default template arguments of `D`, corresponding *lambda-expression*s
284
  shall have the same closure type (see below).
285
  - In each such definition, corresponding entities shall have the same
286
  language linkage.
@@ -294,20 +364,26 @@ point, the following requirements shall be satisfied.
294
  implicit calls to conversion functions, constructors, operator new
295
  functions and operator delete functions, shall refer to the same
296
  function.
297
  - In each such definition, a default argument used by an (implicit or
298
  explicit) function call or a default template argument used by an
299
- (implicit or explicit) *template-id* or *simple-template-id* is
300
- treated as if its token sequence were present in the definition of
301
- `D`; that is, the default argument or default template argument is
302
- subject to the requirements described in this paragraph (recursively).
 
 
 
 
 
 
303
  - If `D` is a class with an implicitly-declared constructor
304
  [[class.default.ctor]], [[class.copy.ctor]], it is as if the
305
  constructor was implicitly defined in every translation unit where it
306
  is odr-used, and the implicit definition in every translation unit
307
  shall call the same constructor for a subobject of `D`.
308
- \[*Example 5*:
309
  ``` cpp
310
  // translation unit 1:
311
  struct X {
312
  X(int, int);
313
  X(int, int, int);
@@ -335,31 +411,31 @@ point, the following requirements shall be satisfied.
335
  - If `D` is a class with a defaulted three-way comparison operator
336
  function [[class.spaceship]], it is as if the operator was implicitly
337
  defined in every translation unit where it is odr-used, and the
338
  implicit definition in every translation unit shall call the same
339
  comparison operators for each subobject of `D`.
 
 
 
 
340
 
341
- If `D` is a template and is defined in more than one translation unit,
342
- then the preceding requirements shall apply both to names from the
343
- template’s enclosing scope used in the template definition, and also to
344
- dependent names at the point of instantiation [[temp.dep]]. These
345
- requirements also apply to corresponding entities defined within each
346
- definition of `D` (including the closure types of *lambda-expression*s,
347
- but excluding entities defined within default arguments or default
348
- template arguments of either `D` or an entity not defined within `D`).
349
- For each such entity and for `D` itself, the behavior is as if there is
350
- a single entity with a single definition, including in the application
351
- of these requirements to other entities.
352
 
353
  [*Note 4*: The entity is still declared in multiple translation units,
354
  and [[basic.link]] still applies to these declarations. In particular,
355
  *lambda-expression*s [[expr.prim.lambda]] appearing in the type of `D`
356
  can result in the different declarations having distinct types, and
357
  *lambda-expression*s appearing in a default argument of `D` might still
358
  denote different types in different translation units. — *end note*]
359
 
360
- [*Example 6*:
361
 
362
  ``` cpp
363
  inline void f(bool cond, void (*p)()) {
364
  if (cond) f(false, []{});
365
  }
 
18
  unevaluated operand [[expr.context]], a subexpression thereof, or a
19
  conversion in an initialization or conversion sequence in such a
20
  context. The set of *potential results* of an expression E is defined as
21
  follows:
22
 
23
+ - If E is an *id-expression* [[expr.prim.id]] or a *splice-expression*
24
+ [[expr.prim.splice]], the set contains only E.
25
  - If E is a subscripting operation [[expr.sub]] with an array operand,
26
  the set contains the potential results of that operand.
27
  - If E is a class member access expression [[expr.ref]] of the form E₁
28
  `.` `template`ₒₚₜ E₂ naming a non-static data member, the set
29
  contains the potential results of E₁.
 
40
  potential results of the right operand.
41
  - Otherwise, the set is empty.
42
 
43
  [*Note 1*:
44
 
45
+ This set is a (possibly-empty) set of *id-expression*s and
46
+ *splice-expression*s, each of which is either E or a subexpression of E.
47
 
48
  [*Example 1*:
49
 
50
  In the following example, the set of potential results of the
51
  initializer of `n` contains the first `S::x` subexpression, but not the
52
+ second `S::x` subexpression. The set of potential results of the
53
+ initializer of `o` contains the subexpression `[:^^ S::x:]`.
54
 
55
  ``` cpp
56
  struct S { static const int x = 0; };
57
  const int &f(const int &r);
58
  int n = b ? (1, S::x) // S::x is not odr-used here
59
  : f(S::x); // S::x is odr-used here, so a definition is required
60
+ int o = [:^^S::x:];
61
  ```
62
 
63
  — *end example*]
64
 
65
  — *end note*]
 
68
 
69
  - A function is named by an expression or conversion if it is the
70
  selected member of an overload set
71
  [[basic.lookup]], [[over.match]], [[over.over]] in an overload
72
  resolution performed as part of forming that expression or conversion,
73
+ and either it is not a pure virtual function or the expression is an
74
+ *id-expression* naming the function with an explicitly qualified name
75
+ that does not form a pointer to member [[expr.unary.op]].
76
  \[*Note 2*: This covers taking the address of functions
77
  [[conv.func]], [[expr.unary.op]], calls to named functions
78
  [[expr.call]], operator overloading [[over]], user-defined conversions
79
  [[class.conv.fct]], allocation functions for *new-expression*s
80
  [[expr.new]], as well as non-default initialization [[dcl.init]]. A
 
89
  - A deallocation function for a class is named by a *delete-expression*
90
  if it is the selected usual deallocation function as specified in 
91
  [[expr.delete]] and  [[class.free]].
92
 
93
  A variable is named by an expression if the expression is an
94
+ *id-expression* or *splice-expression* [[expr.prim.splice]] that
95
+ designates it. A variable `x` that is named by a potentially-evaluated
96
+ expression N that appears at a point P is *odr-used* by N unless
97
 
98
+ - `x` is a reference that is usable in constant expressions at P
99
+ [[expr.const]] or
100
+ - N is an element of the set of potential results of an expression E,
101
+ where
102
+ - E is a discarded-value expression [[expr.context]] to which the
103
+ lvalue-to-rvalue conversion is not applied or
104
+ - `x` is a non-volatile object that is usable in constant expressions
105
+ at P and has no mutable subobjects and
106
+ - E is a class member access expression [[expr.ref]] naming a
107
+ non-static data member of reference type and whose object
108
+ expression has non-volatile-qualified type or
109
+ - the lvalue-to-rvalue conversion [[conv.lval]] is applied to E and
110
+ E has non-volatile-qualified non-class type
111
 
112
+ [*Example 2*:
113
+
114
+ ``` cpp
115
+ int f(int);
116
+ int g(int&);
117
+ struct A {
118
+ int x;
119
+ };
120
+ struct B {
121
+ int& r;
122
+ };
123
+ int h(bool cond) {
124
+ constexpr A a = {1};
125
+ constexpr const volatile A& r = a; // odr-uses a
126
+ int _ = f(cond ? a.x : r.x); // does not odr-use a or r
127
+ int x, y;
128
+ constexpr B b1 = {x}, b2 = {y}; // odr-uses x and y
129
+ int _ = g(cond ? b1.r : b2.r); // does not odr-use b1 or b2
130
+ int _ = ((cond ? x : y), 0); // does not odr-use x or y
131
+ return [] {
132
+ return b1.r; // error: b1 is odr-used here because the object
133
+ // referred to by b1.r is not constexpr-referenceable here
134
+ }();
135
+ }
136
+ ```
137
+
138
+ — *end example*]
139
+
140
+ A structured binding is named by an expression if that expression is
141
+ either an *id-expression* or a *splice-expression* that designates that
142
+ structured binding. A structured binding is odr-used if it is named by a
143
  potentially-evaluated expression.
144
 
145
  `*this` is odr-used if `this` appears as a potentially-evaluated
146
+ expression (including as the result of any implicit transformation to a
147
+ class member access expression [[expr.prim.id.general]]).
148
 
149
  A virtual member function is odr-used if it is not pure. A function is
150
  odr-used if it is named by a potentially-evaluated expression or
151
  conversion. A non-placement allocation or deallocation function for a
152
  class is odr-used by the definition of a constructor of that class. A
 
154
  definition of the destructor of that class, or by being selected by the
155
  lookup at the point of definition of a virtual destructor
156
  [[class.dtor]].[^2]
157
 
158
  An assignment operator function in a class is odr-used by an
159
+ implicitly-defined copy assignment or move assignment function for
160
  another class as specified in  [[class.copy.assign]]. A constructor for
161
  a class is odr-used as specified in  [[dcl.init]]. A destructor for a
162
  class is odr-used if it is potentially invoked [[class.dtor]].
163
 
164
  A local entity [[basic.pre]] is *odr-usable* in a scope
165
+ [[basic.scope.scope]] if
166
 
167
  - either the local entity is not `*this`, or an enclosing class or
168
  non-lambda function parameter scope exists and, if the innermost such
169
  scope is a function parameter scope, it corresponds to a non-static
170
  member function, and
171
  - for each intervening scope [[basic.scope.scope]] between the point at
172
  which the entity is introduced and the scope (where `*this` is
173
  considered to be introduced within the innermost enclosing class or
174
+ non-lambda function definition scope), either
175
+ - the intervening scope is a block scope,
176
+ - the intervening scope is a contract-assertion scope
177
+ [[basic.scope.contract]],
178
  - the intervening scope is the function parameter scope of a
179
+ *lambda-expression* or *requires-expression*, or
180
+ - the intervening scope is the lambda scope of a *lambda-expression*
181
+ that has a *simple-capture* naming the entity or has a
182
+ *capture-default*, and the block scope of the *lambda-expression* is
183
+ also an intervening scope.
184
 
185
  If a local entity is odr-used in a scope in which it is not odr-usable,
186
  the program is ill-formed.
187
 
188
+ [*Example 3*:
189
 
190
  ``` cpp
191
  void f(int n) {
192
  [] { n = 1; }; // error: n is not odr-usable due to intervening lambda-expression
193
  struct A {
 
200
  }
201
  ```
202
 
203
  — *end example*]
204
 
205
+ [*Example 4*:
206
+
207
+ ``` cpp
208
+ void g() {
209
+ constexpr int x = 1;
210
+ auto lambda = [] <typename T, int = ((T)x, 0)> {}; // OK
211
+ lambda.operator()<int, 1>(); // OK, does not consider x at all
212
+ lambda.operator()<int>(); // OK, does not odr-use x
213
+ lambda.operator()<const int&>(); // error: odr-uses x from a context where x is not odr-usable
214
+ }
215
+
216
+ void h() {
217
+ constexpr int x = 1;
218
+ auto lambda = [] <typename T> { (T)x; }; // OK
219
+ lambda.operator()<int>(); // OK, does not odr-use x
220
+ lambda.operator()<void>(); // OK, does not odr-use x
221
+ lambda.operator()<const int&>(); // error: odr-uses x from a context where x is not odr-usable
222
+ }
223
+ ```
224
+
225
+ — *end example*]
226
+
227
  Every program shall contain at least one definition of every function or
228
  variable that is odr-used in that program outside of a discarded
229
  statement [[stmt.if]]; no diagnostic required. The definition can appear
230
  explicitly in the program, it can be found in the standard or a
231
  user-defined library, or (when appropriate) it is implicitly defined
232
  (see  [[class.default.ctor]], [[class.copy.ctor]], [[class.dtor]], and
233
  [[class.copy.assign]]).
234
 
235
+ [*Example 5*:
236
 
237
  ``` cpp
238
  auto f() {
239
  struct A {};
240
  return A{};
 
257
  discarded statement.
258
 
259
  A definition of a class shall be reachable in every context in which the
260
  class is used in a way that requires the class type to be complete.
261
 
262
+ [*Example 6*:
263
 
264
  The following complete translation unit is well-formed, even though it
265
  never defines `X`:
266
 
267
  ``` cpp
 
273
  — *end example*]
274
 
275
  [*Note 3*:
276
 
277
  The rules for declarations and expressions describe in which contexts
278
+ complete class types are required. A class type `T` must be complete if
279
 
280
  - an object of type `T` is defined [[basic.def]], or
281
  - a non-static class data member of type `T` is declared [[class.mem]],
282
  or
283
  - `T` is used as the allocated type or array element type in a
 
297
  - the `typeid` operator [[expr.typeid]] or the `sizeof` operator
298
  [[expr.sizeof]] is applied to an operand of type `T`, or
299
  - a function with a return type or argument type of type `T` is defined
300
  [[basic.def]] or called [[expr.call]], or
301
  - a class with a base class of type `T` is defined [[class.derived]], or
302
+ - an lvalue of type `T` is assigned to [[expr.assign]], or
303
  - the type `T` is the subject of an `alignof` expression
304
  [[expr.alignof]], or
305
  - an *exception-declaration* has type `T`, reference to `T`, or pointer
306
  to `T` [[except.handle]].
307
 
308
  — *end note*]
309
 
310
+ If a definable item `D` is defined in a translation unit by an injected
311
+ declaration X [[expr.const]] and another translation unit contains a
312
+ definition of `D`, that definition shall be an injected declaration
313
+ having the same characteristic sequence as X; a diagnostic is required
314
+ only if `D` is attached to a named module and a prior definition is
315
+ reachable at the point where a later definition occurs.
316
+
317
+ For any other definable item `D` with definitions in multiple
318
+ translation units,
319
 
320
  - if `D` is a non-inline non-templated function or variable, or
321
  - if the definitions in different translation units do not satisfy the
322
  following requirements,
323
 
 
332
  [[module.unit]].
333
  - Each such definition shall consist of the same sequence of tokens,
334
  where the definition of a closure type is considered to consist of the
335
  sequence of tokens of the corresponding *lambda-expression*.
336
  - In each such definition, corresponding names, looked up according to 
337
+ [[basic.lookup]], shall denote the same entity, after overload
338
  resolution [[over.match]] and after matching of partial template
339
+ specializations [[temp.spec.partial.match]], except that a name can
340
+ refer to
341
  - a non-volatile const object with internal or no linkage if the
342
  object
343
  - has the same literal type in all definitions of `D`,
344
  - is initialized with a constant expression [[expr.const]],
345
  - is not odr-used in any definition of `D`, and
346
  - has the same value in all definitions of `D`,
347
 
348
  or
349
  - a reference with internal or no linkage initialized with a constant
350
+ expression such that the reference refers to the same object or
351
+ function in all definitions of `D`.
352
  - In each such definition, except within the default arguments and
353
  default template arguments of `D`, corresponding *lambda-expression*s
354
  shall have the same closure type (see below).
355
  - In each such definition, corresponding entities shall have the same
356
  language linkage.
 
364
  implicit calls to conversion functions, constructors, operator new
365
  functions and operator delete functions, shall refer to the same
366
  function.
367
  - In each such definition, a default argument used by an (implicit or
368
  explicit) function call or a default template argument used by an
369
+ (implicit or explicit) *template-id*, *simple-template-id*, or
370
+ *splice-specialization-specifier* is treated as if its token sequence
371
+ were present in the definition of `D`; that is, the default argument
372
+ or default template argument is subject to the requirements described
373
+ in this paragraph (recursively).
374
+ - In each such definition, corresponding *reflect-expression*s
375
+ [[expr.reflect]] compute equivalent values [[expr.eq]].
376
+
377
+ For the purposes of the preceding requirements:
378
+
379
  - If `D` is a class with an implicitly-declared constructor
380
  [[class.default.ctor]], [[class.copy.ctor]], it is as if the
381
  constructor was implicitly defined in every translation unit where it
382
  is odr-used, and the implicit definition in every translation unit
383
  shall call the same constructor for a subobject of `D`.
384
+ \[*Example 7*:
385
  ``` cpp
386
  // translation unit 1:
387
  struct X {
388
  X(int, int);
389
  X(int, int, int);
 
411
  - If `D` is a class with a defaulted three-way comparison operator
412
  function [[class.spaceship]], it is as if the operator was implicitly
413
  defined in every translation unit where it is odr-used, and the
414
  implicit definition in every translation unit shall call the same
415
  comparison operators for each subobject of `D`.
416
+ - If `D` is a template and is defined in more than one translation unit,
417
+ the requirements apply both to names from the template’s enclosing
418
+ scope used in the template definition, and also to dependent names at
419
+ the point of instantiation [[temp.dep]].
420
 
421
+ These requirements also apply to corresponding entities defined within
422
+ each definition of `D` (including the closure types of
423
+ *lambda-expression*s, but excluding entities defined within default
424
+ arguments or default template arguments of either `D` or an entity not
425
+ defined within `D`). For each such entity and for `D` itself, the
426
+ behavior is as if there is a single entity with a single definition,
427
+ including in the application of these requirements to other entities.
 
 
 
 
428
 
429
  [*Note 4*: The entity is still declared in multiple translation units,
430
  and [[basic.link]] still applies to these declarations. In particular,
431
  *lambda-expression*s [[expr.prim.lambda]] appearing in the type of `D`
432
  can result in the different declarations having distinct types, and
433
  *lambda-expression*s appearing in a default argument of `D` might still
434
  denote different types in different translation units. — *end note*]
435
 
436
+ [*Example 8*:
437
 
438
  ``` cpp
439
  inline void f(bool cond, void (*p)()) {
440
  if (cond) f(false, []{});
441
  }