From Jason Turner

[temp.over]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpqvl8gwm3/{from.md → to.md} +60 -47
tmp/tmpqvl8gwm3/{from.md → to.md} RENAMED
@@ -5,23 +5,26 @@ or implicitly using the operator notation), template argument deduction
5
  [[temp.deduct]] and checking of any explicit template arguments
6
  [[temp.arg]] are performed for each function template to find the
7
  template argument values (if any) that can be used with that function
8
  template to instantiate a function template specialization that can be
9
  invoked with the call arguments or, for conversion function templates,
10
- that can convert to the required type. For each function template, if
11
- the argument deduction and checking succeeds, the *template-argument*s
12
- (deduced and/or explicit) are used to synthesize the declaration of a
13
- single function template specialization which is added to the candidate
14
- functions set to be used in overload resolution. If, for a given
15
- function template, argument deduction fails or the synthesized function
16
- template specialization would be ill-formed, no such function is added
17
- to the set of candidate functions for that template. The complete set of
18
- candidate functions includes all the synthesized declarations and all of
19
- the non-template functions found by name lookup. The synthesized
20
- declarations are treated like any other functions in the remainder of
21
- overload resolution, except as explicitly noted in 
22
- [[over.match.best]].[^15]
 
 
 
23
 
24
  [*Example 1*:
25
 
26
  ``` cpp
27
  template<class T> T max(T a, T b) { return a>b?a:b; }
@@ -46,11 +49,11 @@ conversion of `char` to `int` for `c`.
46
  — *end example*]
47
 
48
  [*Example 2*:
49
 
50
  Here is an example involving conversions on a function argument involved
51
- in *template-argument* deduction:
52
 
53
  ``` cpp
54
  template<class T> struct B { ... };
55
  template<class T> struct D : public B<T> { ... };
56
  template<class T> void f(B<T>&);
@@ -64,11 +67,11 @@ void g(B<int>& bi, D<int>& di) {
64
  — *end example*]
65
 
66
  [*Example 3*:
67
 
68
  Here is an example involving conversions on a function argument not
69
- involved in *template-parameter* deduction:
70
 
71
  ``` cpp
72
  template<class T> void f(T*,int); // #1
73
  template<class T> void f(T,char); // #2
74
 
@@ -112,10 +115,11 @@ in some translation unit [[temp.pre]].
112
  [basic.lookup]: basic.md#basic.lookup
113
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
114
  [basic.lookup.qual]: basic.md#basic.lookup.qual
115
  [basic.scope.namespace]: basic.md#basic.scope.namespace
116
  [basic.scope.scope]: basic.md#basic.scope.scope
 
117
  [basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
118
  [basic.types]: basic.md#basic.types
119
  [class.access]: class.md#class.access
120
  [class.base.init]: class.md#class.base.init
121
  [class.conv.fct]: class.md#class.conv.fct
@@ -123,10 +127,11 @@ in some translation unit [[temp.pre]].
123
  [class.default.ctor]: class.md#class.default.ctor
124
  [class.derived]: class.md#class.derived
125
  [class.dtor]: class.md#class.dtor
126
  [class.local]: class.md#class.local
127
  [class.mem]: class.md#class.mem
 
128
  [class.member.lookup]: basic.md#class.member.lookup
129
  [class.pre]: class.md#class.pre
130
  [class.qual]: basic.md#class.qual
131
  [class.temporary]: basic.md#class.temporary
132
  [conv]: expr.md#conv
@@ -135,28 +140,33 @@ in some translation unit [[temp.pre]].
135
  [conv.func]: expr.md#conv.func
136
  [conv.lval]: expr.md#conv.lval
137
  [conv.qual]: expr.md#conv.qual
138
  [dcl.align]: dcl.md#dcl.align
139
  [dcl.attr.grammar]: dcl.md#dcl.attr.grammar
 
 
 
140
  [dcl.decl]: dcl.md#dcl.decl
141
  [dcl.fct]: dcl.md#dcl.fct
142
  [dcl.fct.def.general]: dcl.md#dcl.fct.def.general
143
  [dcl.fct.default]: dcl.md#dcl.fct.default
144
  [dcl.init]: dcl.md#dcl.init
145
  [dcl.init.list]: dcl.md#dcl.init.list
146
  [dcl.meaning]: dcl.md#dcl.meaning
147
  [dcl.pre]: dcl.md#dcl.pre
148
  [dcl.spec.auto]: dcl.md#dcl.spec.auto
 
149
  [dcl.stc]: dcl.md#dcl.stc
150
  [dcl.struct.bind]: dcl.md#dcl.struct.bind
151
  [dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
152
  [dcl.type.elab]: dcl.md#dcl.type.elab
153
  [dcl.type.simple]: dcl.md#dcl.type.simple
154
  [depr.template.template]: future.md#depr.template.template
155
  [except.spec]: except.md#except.spec
156
  [expr.const]: expr.md#expr.const
157
  [expr.context]: expr.md#expr.context
 
158
  [expr.log.and]: expr.md#expr.log.and
159
  [expr.log.or]: expr.md#expr.log.or
160
  [expr.new]: expr.md#expr.new
161
  [expr.prim.fold]: expr.md#expr.prim.fold
162
  [expr.prim.id]: expr.md#expr.prim.id
@@ -167,13 +177,15 @@ in some translation unit [[temp.pre]].
167
  [expr.prim.this]: expr.md#expr.prim.this
168
  [expr.ref]: expr.md#expr.ref
169
  [expr.sizeof]: expr.md#expr.sizeof
170
  [expr.type.conv]: expr.md#expr.type.conv
171
  [expr.typeid]: expr.md#expr.typeid
 
172
  [expr.unary.op]: expr.md#expr.unary.op
173
  [implimits]: limits.md#implimits
174
  [intro.defs]: intro.md#intro.defs
 
175
  [intro.object]: basic.md#intro.object
176
  [lex.string]: lex.md#lex.string
177
  [module.unit]: module.md#module.unit
178
  [namespace.udecl]: dcl.md#namespace.udecl
179
  [over.match]: over.md#over.match
@@ -182,10 +194,11 @@ in some translation unit [[temp.pre]].
182
  [over.match.funcs]: over.md#over.match.funcs
183
  [over.match.oper]: over.md#over.match.oper
184
  [over.match.viable]: over.md#over.match.viable
185
  [over.over]: over.md#over.over
186
  [special]: class.md#special
 
187
  [stmt.if]: stmt.md#stmt.if
188
  [support.types]: support.md#support.types
189
  [temp]: #temp
190
  [temp.alias]: #temp.alias
191
  [temp.arg]: #temp.arg
@@ -197,13 +210,15 @@ in some translation unit [[temp.pre]].
197
  [temp.class]: #temp.class
198
  [temp.class.general]: #temp.class.general
199
  [temp.concept]: #temp.concept
200
  [temp.constr]: #temp.constr
201
  [temp.constr.atomic]: #temp.constr.atomic
 
202
  [temp.constr.constr]: #temp.constr.constr
203
  [temp.constr.constr.general]: #temp.constr.constr.general
204
  [temp.constr.decl]: #temp.constr.decl
 
205
  [temp.constr.general]: #temp.constr.general
206
  [temp.constr.normal]: #temp.constr.normal
207
  [temp.constr.op]: #temp.constr.op
208
  [temp.constr.order]: #temp.constr.order
209
  [temp.decls]: #temp.decls
@@ -220,11 +235,13 @@ in some translation unit [[temp.pre]].
220
  [temp.dep]: #temp.dep
221
  [temp.dep.candidate]: #temp.dep.candidate
222
  [temp.dep.constexpr]: #temp.dep.constexpr
223
  [temp.dep.expr]: #temp.dep.expr
224
  [temp.dep.general]: #temp.dep.general
 
225
  [temp.dep.res]: #temp.dep.res
 
226
  [temp.dep.temp]: #temp.dep.temp
227
  [temp.dep.type]: #temp.dep.type
228
  [temp.expl.spec]: #temp.expl.spec
229
  [temp.explicit]: #temp.explicit
230
  [temp.fct]: #temp.fct
@@ -259,66 +276,62 @@ in some translation unit [[temp.pre]].
259
  [temp.type]: #temp.type
260
  [temp.variadic]: #temp.variadic
261
  [term.incomplete.type]: basic.md#term.incomplete.type
262
  [term.odr.use]: basic.md#term.odr.use
263
 
264
- [^1]: Since template *template-parameter*s and template
265
- *template-argument*s are treated as types for descriptive purposes,
266
- the terms *non-type parameter* and *non-type argument* are used to
267
- refer to non-type, non-template parameters and arguments.
268
-
269
- [^2]: A `>` that encloses the *type-id* of a `dynamic_cast`,
270
  `static_cast`, `reinterpret_cast` or `const_cast`, or which encloses
271
- the *template-argument*s of a subsequent *template-id*, is
272
- considered nested for the purpose of this description.
 
273
 
274
- [^3]: There is no such ambiguity in a default *template-argument*
275
  because the form of the *template-parameter* determines the
276
  allowable forms of the *template-argument*.
277
 
278
- [^4]: A constraint is in disjunctive normal form when it is a
279
- disjunction of clauses where each clause is a conjunction of atomic
280
- constraints. For atomic constraints A, B, and C, the disjunctive
281
- normal form of the constraint A ∧ (B ∨ C) is (A ∧ B) ∨ (A ∧ C). Its
282
- disjunctive clauses are (A ∧ B) and (A ∧ C).
283
 
284
- [^5]: A constraint is in conjunctive normal form when it is a
285
- conjunction of clauses where each clause is a disjunction of atomic
286
- constraints. For atomic constraints A, B, and C, the constraint
287
- A ∧ (B ∨ C) is in conjunctive normal form. Its conjunctive clauses
288
- are A and (B ∨ C).
289
 
290
- [^6]: The identity of enumerators is not preserved.
291
 
292
- [^7]: An array as a *template-parameter* decays to a pointer.
293
 
294
- [^8]: There is no context in which they would be used.
295
 
296
- [^9]: That is, declarations of non-template functions do not merely
297
  guide overload resolution of function template specializations with
298
  the same name. If such a non-template function is odr-used
299
  [[term.odr.use]] in a program, it must be defined; it will not be
300
  implicitly instantiated using the function template definition.
301
 
302
- [^10]: This includes friend function declarations.
303
 
304
- [^11]: Every instantiation of a class template declares a different set
305
  of assignment operators.
306
 
307
- [^12]: This includes an injected-class-name [[class.pre]] of a class
308
  template used without a *template-argument-list*.
309
 
310
- [^13]: Default arguments are not considered to be arguments in this
311
  context; they only become arguments after a function has been
312
  selected.
313
 
314
- [^14]: Although the *template-argument* corresponding to a
315
- *template-parameter* of type `bool` can be deduced from an array
316
- bound, the resulting value will always be `true` because the array
317
- bound will be nonzero.
318
 
319
- [^15]: The parameters of function template specializations contain no
320
  template parameter types. The set of conversions allowed on deduced
321
  arguments is limited, because the argument deduction process
322
  produces function templates with parameters that either match the
323
  call arguments exactly or differ only in ways that can be bridged by
324
  the allowed limited conversions. Non-deduced arguments allow the
 
5
  [[temp.deduct]] and checking of any explicit template arguments
6
  [[temp.arg]] are performed for each function template to find the
7
  template argument values (if any) that can be used with that function
8
  template to instantiate a function template specialization that can be
9
  invoked with the call arguments or, for conversion function templates,
10
+ that can convert to the required type. For each function template:
11
+
12
+ - If the argument deduction and checking succeeds, the
13
+ *template-argument*s (deduced and/or explicit) are used to synthesize
14
+ the declaration of a single function template specialization which is
15
+ added to the candidate functions set to be used in overload
16
+ resolution.
17
+ - If the argument deduction fails or the synthesized function template
18
+ specialization would be ill-formed, no such function is added to the
19
+ set of candidate functions for that template.
20
+
21
+ The complete set of candidate functions includes all the synthesized
22
+ declarations and all of the non-template functions found by name lookup.
23
+ The synthesized declarations are treated like any other functions in the
24
+ remainder of overload resolution, except as explicitly noted in 
25
+ [[over.match.best]].[^14]
26
 
27
  [*Example 1*:
28
 
29
  ``` cpp
30
  template<class T> T max(T a, T b) { return a>b?a:b; }
 
49
  — *end example*]
50
 
51
  [*Example 2*:
52
 
53
  Here is an example involving conversions on a function argument involved
54
+ in template argument deduction:
55
 
56
  ``` cpp
57
  template<class T> struct B { ... };
58
  template<class T> struct D : public B<T> { ... };
59
  template<class T> void f(B<T>&);
 
67
  — *end example*]
68
 
69
  [*Example 3*:
70
 
71
  Here is an example involving conversions on a function argument not
72
+ involved in template argument deduction:
73
 
74
  ``` cpp
75
  template<class T> void f(T*,int); // #1
76
  template<class T> void f(T,char); // #2
77
 
 
115
  [basic.lookup]: basic.md#basic.lookup
116
  [basic.lookup.argdep]: basic.md#basic.lookup.argdep
117
  [basic.lookup.qual]: basic.md#basic.lookup.qual
118
  [basic.scope.namespace]: basic.md#basic.scope.namespace
119
  [basic.scope.scope]: basic.md#basic.scope.scope
120
+ [basic.splice]: basic.md#basic.splice
121
  [basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
122
  [basic.types]: basic.md#basic.types
123
  [class.access]: class.md#class.access
124
  [class.base.init]: class.md#class.base.init
125
  [class.conv.fct]: class.md#class.conv.fct
 
127
  [class.default.ctor]: class.md#class.default.ctor
128
  [class.derived]: class.md#class.derived
129
  [class.dtor]: class.md#class.dtor
130
  [class.local]: class.md#class.local
131
  [class.mem]: class.md#class.mem
132
+ [class.mem.general]: class.md#class.mem.general
133
  [class.member.lookup]: basic.md#class.member.lookup
134
  [class.pre]: class.md#class.pre
135
  [class.qual]: basic.md#class.qual
136
  [class.temporary]: basic.md#class.temporary
137
  [conv]: expr.md#conv
 
140
  [conv.func]: expr.md#conv.func
141
  [conv.lval]: expr.md#conv.lval
142
  [conv.qual]: expr.md#conv.qual
143
  [dcl.align]: dcl.md#dcl.align
144
  [dcl.attr.grammar]: dcl.md#dcl.attr.grammar
145
+ [dcl.constexpr]: dcl.md#dcl.constexpr
146
+ [dcl.contract.func]: dcl.md#dcl.contract.func
147
+ [dcl.contract.res]: dcl.md#dcl.contract.res
148
  [dcl.decl]: dcl.md#dcl.decl
149
  [dcl.fct]: dcl.md#dcl.fct
150
  [dcl.fct.def.general]: dcl.md#dcl.fct.def.general
151
  [dcl.fct.default]: dcl.md#dcl.fct.default
152
  [dcl.init]: dcl.md#dcl.init
153
  [dcl.init.list]: dcl.md#dcl.init.list
154
  [dcl.meaning]: dcl.md#dcl.meaning
155
  [dcl.pre]: dcl.md#dcl.pre
156
  [dcl.spec.auto]: dcl.md#dcl.spec.auto
157
+ [dcl.spec.auto.general]: dcl.md#dcl.spec.auto.general
158
  [dcl.stc]: dcl.md#dcl.stc
159
  [dcl.struct.bind]: dcl.md#dcl.struct.bind
160
  [dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
161
  [dcl.type.elab]: dcl.md#dcl.type.elab
162
  [dcl.type.simple]: dcl.md#dcl.type.simple
163
  [depr.template.template]: future.md#depr.template.template
164
  [except.spec]: except.md#except.spec
165
  [expr.const]: expr.md#expr.const
166
  [expr.context]: expr.md#expr.context
167
+ [expr.eq]: expr.md#expr.eq
168
  [expr.log.and]: expr.md#expr.log.and
169
  [expr.log.or]: expr.md#expr.log.or
170
  [expr.new]: expr.md#expr.new
171
  [expr.prim.fold]: expr.md#expr.prim.fold
172
  [expr.prim.id]: expr.md#expr.prim.id
 
177
  [expr.prim.this]: expr.md#expr.prim.this
178
  [expr.ref]: expr.md#expr.ref
179
  [expr.sizeof]: expr.md#expr.sizeof
180
  [expr.type.conv]: expr.md#expr.type.conv
181
  [expr.typeid]: expr.md#expr.typeid
182
+ [expr.unary.noexcept]: expr.md#expr.unary.noexcept
183
  [expr.unary.op]: expr.md#expr.unary.op
184
  [implimits]: limits.md#implimits
185
  [intro.defs]: intro.md#intro.defs
186
+ [intro.execution]: basic.md#intro.execution
187
  [intro.object]: basic.md#intro.object
188
  [lex.string]: lex.md#lex.string
189
  [module.unit]: module.md#module.unit
190
  [namespace.udecl]: dcl.md#namespace.udecl
191
  [over.match]: over.md#over.match
 
194
  [over.match.funcs]: over.md#over.match.funcs
195
  [over.match.oper]: over.md#over.match.oper
196
  [over.match.viable]: over.md#over.match.viable
197
  [over.over]: over.md#over.over
198
  [special]: class.md#special
199
+ [stmt.expand]: stmt.md#stmt.expand
200
  [stmt.if]: stmt.md#stmt.if
201
  [support.types]: support.md#support.types
202
  [temp]: #temp
203
  [temp.alias]: #temp.alias
204
  [temp.arg]: #temp.arg
 
210
  [temp.class]: #temp.class
211
  [temp.class.general]: #temp.class.general
212
  [temp.concept]: #temp.concept
213
  [temp.constr]: #temp.constr
214
  [temp.constr.atomic]: #temp.constr.atomic
215
+ [temp.constr.concept]: #temp.constr.concept
216
  [temp.constr.constr]: #temp.constr.constr
217
  [temp.constr.constr.general]: #temp.constr.constr.general
218
  [temp.constr.decl]: #temp.constr.decl
219
+ [temp.constr.fold]: #temp.constr.fold
220
  [temp.constr.general]: #temp.constr.general
221
  [temp.constr.normal]: #temp.constr.normal
222
  [temp.constr.op]: #temp.constr.op
223
  [temp.constr.order]: #temp.constr.order
224
  [temp.decls]: #temp.decls
 
235
  [temp.dep]: #temp.dep
236
  [temp.dep.candidate]: #temp.dep.candidate
237
  [temp.dep.constexpr]: #temp.dep.constexpr
238
  [temp.dep.expr]: #temp.dep.expr
239
  [temp.dep.general]: #temp.dep.general
240
+ [temp.dep.namespace]: #temp.dep.namespace
241
  [temp.dep.res]: #temp.dep.res
242
+ [temp.dep.splice]: #temp.dep.splice
243
  [temp.dep.temp]: #temp.dep.temp
244
  [temp.dep.type]: #temp.dep.type
245
  [temp.expl.spec]: #temp.expl.spec
246
  [temp.explicit]: #temp.explicit
247
  [temp.fct]: #temp.fct
 
276
  [temp.type]: #temp.type
277
  [temp.variadic]: #temp.variadic
278
  [term.incomplete.type]: basic.md#term.incomplete.type
279
  [term.odr.use]: basic.md#term.odr.use
280
 
281
+ [^1]: A `>` that encloses the *type-id* of a `dynamic_cast`,
 
 
 
 
 
282
  `static_cast`, `reinterpret_cast` or `const_cast`, or which encloses
283
+ the *template-argument*s of a subsequent *template-id* or
284
+ *splice-specialization-specifier*, is considered nested for the
285
+ purpose of this description.
286
 
287
+ [^2]: There is no such ambiguity in a default *template-argument*
288
  because the form of the *template-parameter* determines the
289
  allowable forms of the *template-argument*.
290
 
291
+ [^3]: A constraint is in disjunctive normal form when it is a
292
+ disjunction of clauses where each clause is a conjunction of fold
293
+ expanded or atomic constraints. For atomic constraints A, B, and C,
294
+ the disjunctive normal form of the constraint A ∧ (B ∨ C) is
295
+ (A ∧ B) ∨ (A ∧ C). Its disjunctive clauses are (A ∧ B) and (A ∧ C).
296
 
297
+ [^4]: A constraint is in conjunctive normal form when it is a
298
+ conjunction of clauses where each clause is a disjunction of fold
299
+ expanded or atomic constraints. For atomic constraints A, B, and C,
300
+ the constraint A ∧ (B ∨ C) is in conjunctive normal form. Its
301
+ conjunctive clauses are A and (B ∨ C).
302
 
303
+ [^5]: The identity of enumerators is not preserved.
304
 
305
+ [^6]: An array as a *template-parameter* decays to a pointer.
306
 
307
+ [^7]: There is no context in which they would be used.
308
 
309
+ [^8]: That is, declarations of non-template functions do not merely
310
  guide overload resolution of function template specializations with
311
  the same name. If such a non-template function is odr-used
312
  [[term.odr.use]] in a program, it must be defined; it will not be
313
  implicitly instantiated using the function template definition.
314
 
315
+ [^9]: This includes friend function declarations.
316
 
317
+ [^10]: Every instantiation of a class template declares a different set
318
  of assignment operators.
319
 
320
+ [^11]: This includes an injected-class-name [[class.pre]] of a class
321
  template used without a *template-argument-list*.
322
 
323
+ [^12]: Default arguments are not considered to be arguments in this
324
  context; they only become arguments after a function has been
325
  selected.
326
 
327
+ [^13]: Although the *template-argument* corresponding to a template
328
+ parameter of type `bool` can be deduced from an array bound, the
329
+ resulting value will always be `true` because the array bound will
330
+ be nonzero.
331
 
332
+ [^14]: The parameters of function template specializations contain no
333
  template parameter types. The set of conversions allowed on deduced
334
  arguments is limited, because the argument deduction process
335
  produces function templates with parameters that either match the
336
  call arguments exactly or differ only in ways that can be bridged by
337
  the allowed limited conversions. Non-deduced arguments allow the