- tmp/tmpx84eneaq/{from.md → to.md} +225 -13
tmp/tmpx84eneaq/{from.md → to.md}
RENAMED
|
@@ -1,28 +1,26 @@
|
|
| 1 |
### Overload resolution <a id="temp.over">[[temp.over]]</a>
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
and/or explicit) are used to synthesize the declaration of a single
|
| 14 |
-
function template specialization which is added to the candidate
|
| 15 |
functions set to be used in overload resolution. If, for a given
|
| 16 |
function template, argument deduction fails or the synthesized function
|
| 17 |
template specialization would be ill-formed, no such function is added
|
| 18 |
to the set of candidate functions for that template. The complete set of
|
| 19 |
candidate functions includes all the synthesized declarations and all of
|
| 20 |
the non-template overloaded functions of the same name. The synthesized
|
| 21 |
declarations are treated like any other functions in the remainder of
|
| 22 |
overload resolution, except as explicitly noted in
|
| 23 |
-
[[over.match.best]].[^
|
| 24 |
|
| 25 |
[*Example 1*:
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
template<class T> T max(T a, T b) { return a>b?a:b; }
|
|
@@ -104,5 +102,219 @@ and not defined at the point of the call. The program will be ill-formed
|
|
| 104 |
unless a specialization for `f<const char*>`, either implicitly or
|
| 105 |
explicitly generated, is present in some translation unit.
|
| 106 |
|
| 107 |
— *end example*]
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
|
| 2 |
|
| 3 |
+
When a call to the name of a function or function template is written
|
| 4 |
+
(explicitly, or implicitly using the operator notation), template
|
| 5 |
+
argument deduction [[temp.deduct]] and checking of any explicit template
|
| 6 |
+
arguments [[temp.arg]] are performed for each function template to find
|
| 7 |
+
the template argument values (if any) that can be used with that
|
| 8 |
+
function template to instantiate a function template specialization that
|
| 9 |
+
can be invoked with the call arguments. For each function template, if
|
| 10 |
+
the argument deduction and checking succeeds, the *template-argument*s
|
| 11 |
+
(deduced and/or explicit) are used to synthesize the declaration of a
|
| 12 |
+
single function template specialization which is added to the candidate
|
|
|
|
|
|
|
| 13 |
functions set to be used in overload resolution. If, for a given
|
| 14 |
function template, argument deduction fails or the synthesized function
|
| 15 |
template specialization would be ill-formed, no such function is added
|
| 16 |
to the set of candidate functions for that template. The complete set of
|
| 17 |
candidate functions includes all the synthesized declarations and all of
|
| 18 |
the non-template overloaded functions of the same name. The synthesized
|
| 19 |
declarations are treated like any other functions in the remainder of
|
| 20 |
overload resolution, except as explicitly noted in
|
| 21 |
+
[[over.match.best]].[^14]
|
| 22 |
|
| 23 |
[*Example 1*:
|
| 24 |
|
| 25 |
``` cpp
|
| 26 |
template<class T> T max(T a, T b) { return a>b?a:b; }
|
|
|
|
| 102 |
unless a specialization for `f<const char*>`, either implicitly or
|
| 103 |
explicitly generated, is present in some translation unit.
|
| 104 |
|
| 105 |
— *end example*]
|
| 106 |
|
| 107 |
+
<!-- Link reference definitions -->
|
| 108 |
+
[basic.def]: basic.md#basic.def
|
| 109 |
+
[basic.def.odr]: basic.md#basic.def.odr
|
| 110 |
+
[basic.link]: basic.md#basic.link
|
| 111 |
+
[basic.lookup]: basic.md#basic.lookup
|
| 112 |
+
[basic.lookup.argdep]: basic.md#basic.lookup.argdep
|
| 113 |
+
[basic.lookup.classref]: basic.md#basic.lookup.classref
|
| 114 |
+
[basic.lookup.qual]: basic.md#basic.lookup.qual
|
| 115 |
+
[basic.lookup.unqual]: basic.md#basic.lookup.unqual
|
| 116 |
+
[basic.scope]: basic.md#basic.scope
|
| 117 |
+
[basic.scope.hiding]: basic.md#basic.scope.hiding
|
| 118 |
+
[basic.scope.namespace]: basic.md#basic.scope.namespace
|
| 119 |
+
[basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
|
| 120 |
+
[basic.types]: basic.md#basic.types
|
| 121 |
+
[class.access]: class.md#class.access
|
| 122 |
+
[class.base.init]: class.md#class.base.init
|
| 123 |
+
[class.conv.fct]: class.md#class.conv.fct
|
| 124 |
+
[class.ctor]: class.md#class.ctor
|
| 125 |
+
[class.default.ctor]: class.md#class.default.ctor
|
| 126 |
+
[class.derived]: class.md#class.derived
|
| 127 |
+
[class.dtor]: class.md#class.dtor
|
| 128 |
+
[class.friend]: class.md#class.friend
|
| 129 |
+
[class.local]: class.md#class.local
|
| 130 |
+
[class.mem]: class.md#class.mem
|
| 131 |
+
[class.member.lookup]: class.md#class.member.lookup
|
| 132 |
+
[class.pre]: class.md#class.pre
|
| 133 |
+
[class.qual]: basic.md#class.qual
|
| 134 |
+
[class.temporary]: basic.md#class.temporary
|
| 135 |
+
[conv]: expr.md#conv
|
| 136 |
+
[conv.array]: expr.md#conv.array
|
| 137 |
+
[conv.fctptr]: expr.md#conv.fctptr
|
| 138 |
+
[conv.func]: expr.md#conv.func
|
| 139 |
+
[conv.lval]: expr.md#conv.lval
|
| 140 |
+
[conv.qual]: expr.md#conv.qual
|
| 141 |
+
[dcl.align]: dcl.md#dcl.align
|
| 142 |
+
[dcl.attr.grammar]: dcl.md#dcl.attr.grammar
|
| 143 |
+
[dcl.decl]: dcl.md#dcl.decl
|
| 144 |
+
[dcl.enum]: dcl.md#dcl.enum
|
| 145 |
+
[dcl.fct]: dcl.md#dcl.fct
|
| 146 |
+
[dcl.fct.def.general]: dcl.md#dcl.fct.def.general
|
| 147 |
+
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 148 |
+
[dcl.init]: dcl.md#dcl.init
|
| 149 |
+
[dcl.init.list]: dcl.md#dcl.init.list
|
| 150 |
+
[dcl.meaning]: dcl.md#dcl.meaning
|
| 151 |
+
[dcl.pre]: dcl.md#dcl.pre
|
| 152 |
+
[dcl.spec.auto]: dcl.md#dcl.spec.auto
|
| 153 |
+
[dcl.stc]: dcl.md#dcl.stc
|
| 154 |
+
[dcl.struct.bind]: dcl.md#dcl.struct.bind
|
| 155 |
+
[dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
|
| 156 |
+
[dcl.type.elab]: dcl.md#dcl.type.elab
|
| 157 |
+
[dcl.type.simple]: dcl.md#dcl.type.simple
|
| 158 |
+
[except.spec]: except.md#except.spec
|
| 159 |
+
[expr.const]: expr.md#expr.const
|
| 160 |
+
[expr.context]: expr.md#expr.context
|
| 161 |
+
[expr.log.and]: expr.md#expr.log.and
|
| 162 |
+
[expr.log.or]: expr.md#expr.log.or
|
| 163 |
+
[expr.new]: expr.md#expr.new
|
| 164 |
+
[expr.prim.fold]: expr.md#expr.prim.fold
|
| 165 |
+
[expr.prim.id]: expr.md#expr.prim.id
|
| 166 |
+
[expr.prim.id.unqual]: expr.md#expr.prim.id.unqual
|
| 167 |
+
[expr.prim.lambda.capture]: expr.md#expr.prim.lambda.capture
|
| 168 |
+
[expr.prim.lambda.closure]: expr.md#expr.prim.lambda.closure
|
| 169 |
+
[expr.ref]: expr.md#expr.ref
|
| 170 |
+
[expr.sizeof]: expr.md#expr.sizeof
|
| 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 |
+
[namespace.def]: dcl.md#namespace.def
|
| 178 |
+
[namespace.memdef]: dcl.md#namespace.memdef
|
| 179 |
+
[namespace.udecl]: dcl.md#namespace.udecl
|
| 180 |
+
[over.ics.rank]: over.md#over.ics.rank
|
| 181 |
+
[over.match]: over.md#over.match
|
| 182 |
+
[over.match.best]: over.md#over.match.best
|
| 183 |
+
[over.match.class.deduct]: over.md#over.match.class.deduct
|
| 184 |
+
[over.match.conv]: over.md#over.match.conv
|
| 185 |
+
[over.match.oper]: over.md#over.match.oper
|
| 186 |
+
[over.match.ref]: over.md#over.match.ref
|
| 187 |
+
[over.match.viable]: over.md#over.match.viable
|
| 188 |
+
[over.over]: over.md#over.over
|
| 189 |
+
[special]: class.md#special
|
| 190 |
+
[stmt.if]: stmt.md#stmt.if
|
| 191 |
+
[support.types]: support.md#support.types
|
| 192 |
+
[temp]: #temp
|
| 193 |
+
[temp.alias]: #temp.alias
|
| 194 |
+
[temp.arg]: #temp.arg
|
| 195 |
+
[temp.arg.explicit]: #temp.arg.explicit
|
| 196 |
+
[temp.arg.nontype]: #temp.arg.nontype
|
| 197 |
+
[temp.arg.template]: #temp.arg.template
|
| 198 |
+
[temp.arg.type]: #temp.arg.type
|
| 199 |
+
[temp.class]: #temp.class
|
| 200 |
+
[temp.class.order]: #temp.class.order
|
| 201 |
+
[temp.class.spec]: #temp.class.spec
|
| 202 |
+
[temp.class.spec.match]: #temp.class.spec.match
|
| 203 |
+
[temp.class.spec.mfunc]: #temp.class.spec.mfunc
|
| 204 |
+
[temp.concept]: #temp.concept
|
| 205 |
+
[temp.constr]: #temp.constr
|
| 206 |
+
[temp.constr.atomic]: #temp.constr.atomic
|
| 207 |
+
[temp.constr.constr]: #temp.constr.constr
|
| 208 |
+
[temp.constr.decl]: #temp.constr.decl
|
| 209 |
+
[temp.constr.normal]: #temp.constr.normal
|
| 210 |
+
[temp.constr.op]: #temp.constr.op
|
| 211 |
+
[temp.constr.order]: #temp.constr.order
|
| 212 |
+
[temp.decls]: #temp.decls
|
| 213 |
+
[temp.deduct]: #temp.deduct
|
| 214 |
+
[temp.deduct.call]: #temp.deduct.call
|
| 215 |
+
[temp.deduct.conv]: #temp.deduct.conv
|
| 216 |
+
[temp.deduct.decl]: #temp.deduct.decl
|
| 217 |
+
[temp.deduct.funcaddr]: #temp.deduct.funcaddr
|
| 218 |
+
[temp.deduct.guide]: #temp.deduct.guide
|
| 219 |
+
[temp.deduct.partial]: #temp.deduct.partial
|
| 220 |
+
[temp.deduct.type]: #temp.deduct.type
|
| 221 |
+
[temp.dep]: #temp.dep
|
| 222 |
+
[temp.dep.candidate]: #temp.dep.candidate
|
| 223 |
+
[temp.dep.constexpr]: #temp.dep.constexpr
|
| 224 |
+
[temp.dep.expr]: #temp.dep.expr
|
| 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
|
| 231 |
+
[temp.fct.spec]: #temp.fct.spec
|
| 232 |
+
[temp.fold.empty]: #temp.fold.empty
|
| 233 |
+
[temp.friend]: #temp.friend
|
| 234 |
+
[temp.func.order]: #temp.func.order
|
| 235 |
+
[temp.inject]: #temp.inject
|
| 236 |
+
[temp.inst]: #temp.inst
|
| 237 |
+
[temp.local]: #temp.local
|
| 238 |
+
[temp.mem]: #temp.mem
|
| 239 |
+
[temp.mem.class]: #temp.mem.class
|
| 240 |
+
[temp.mem.enum]: #temp.mem.enum
|
| 241 |
+
[temp.mem.func]: #temp.mem.func
|
| 242 |
+
[temp.names]: #temp.names
|
| 243 |
+
[temp.nondep]: #temp.nondep
|
| 244 |
+
[temp.over]: #temp.over
|
| 245 |
+
[temp.over.link]: #temp.over.link
|
| 246 |
+
[temp.param]: #temp.param
|
| 247 |
+
[temp.point]: #temp.point
|
| 248 |
+
[temp.pre]: #temp.pre
|
| 249 |
+
[temp.res]: #temp.res
|
| 250 |
+
[temp.spec]: #temp.spec
|
| 251 |
+
[temp.static]: #temp.static
|
| 252 |
+
[temp.type]: #temp.type
|
| 253 |
+
[temp.variadic]: #temp.variadic
|
| 254 |
+
|
| 255 |
+
[^1]: Since template *template-parameter*s and template
|
| 256 |
+
*template-argument*s are treated as types for descriptive purposes,
|
| 257 |
+
the terms *non-type parameter* and *non-type argument* are used to
|
| 258 |
+
refer to non-type, non-template parameters and arguments.
|
| 259 |
+
|
| 260 |
+
[^2]: A `>` that encloses the *type-id* of a `dynamic_cast`,
|
| 261 |
+
`static_cast`, `reinterpret_cast` or `const_cast`, or which encloses
|
| 262 |
+
the *template-argument*s of a subsequent *template-id*, is
|
| 263 |
+
considered nested for the purpose of this description.
|
| 264 |
+
|
| 265 |
+
[^3]: There is no such ambiguity in a default *template-argument*
|
| 266 |
+
because the form of the *template-parameter* determines the
|
| 267 |
+
allowable forms of the *template-argument*.
|
| 268 |
+
|
| 269 |
+
[^4]: A constraint is in disjunctive normal form when it is a
|
| 270 |
+
disjunction of clauses where each clause is a conjunction of atomic
|
| 271 |
+
constraints.
|
| 272 |
+
|
| 273 |
+
\[*Example 5*: For atomic constraints A, B, and C, the disjunctive
|
| 274 |
+
normal form of the constraint A ∧ (B ∨ C) is (A ∧ B) ∨ (A ∧ C). Its
|
| 275 |
+
disjunctive clauses are (A ∧ B) and (A ∧ C). — *end example*]
|
| 276 |
+
|
| 277 |
+
[^5]: A constraint is in conjunctive normal form when it is a
|
| 278 |
+
conjunction of clauses where each clause is a disjunction of atomic
|
| 279 |
+
constraints.
|
| 280 |
+
|
| 281 |
+
\[*Example 6*: For atomic constraints A, B, and C, the constraint
|
| 282 |
+
A ∧ (B ∨ C) is in conjunctive normal form. Its conjunctive clauses
|
| 283 |
+
are A and (B ∨ C). — *end example*]
|
| 284 |
+
|
| 285 |
+
[^6]: The identity of enumerators is not preserved.
|
| 286 |
+
|
| 287 |
+
[^7]: An array as a *template-parameter* decays to a pointer.
|
| 288 |
+
|
| 289 |
+
[^8]: There is no way in which they could be used.
|
| 290 |
+
|
| 291 |
+
[^9]: That is, declarations of non-template functions do not merely
|
| 292 |
+
guide overload resolution of function template specializations with
|
| 293 |
+
the same name. If such a non-template function is odr-used
|
| 294 |
+
[[basic.def.odr]] in a program, it must be defined; it will not be
|
| 295 |
+
implicitly instantiated using the function template definition.
|
| 296 |
+
|
| 297 |
+
[^10]: This includes friend function declarations.
|
| 298 |
+
|
| 299 |
+
[^11]: Friend declarations do not introduce new names into any scope,
|
| 300 |
+
either when the template is declared or when it is instantiated.
|
| 301 |
+
|
| 302 |
+
[^12]: Default arguments are not considered to be arguments in this
|
| 303 |
+
context; they only become arguments after a function has been
|
| 304 |
+
selected.
|
| 305 |
+
|
| 306 |
+
[^13]: Although the *template-argument* corresponding to a
|
| 307 |
+
*template-parameter* of type `bool` may be deduced from an array
|
| 308 |
+
bound, the resulting value will always be `true` because the array
|
| 309 |
+
bound will be nonzero.
|
| 310 |
+
|
| 311 |
+
[^14]: The parameters of function template specializations contain no
|
| 312 |
+
template parameter types. The set of conversions allowed on deduced
|
| 313 |
+
arguments is limited, because the argument deduction process
|
| 314 |
+
produces function templates with parameters that either match the
|
| 315 |
+
call arguments exactly or differ only in ways that can be bridged by
|
| 316 |
+
the allowed limited conversions. Non-deduced arguments allow the
|
| 317 |
+
full range of conversions. Note also that [[over.match.best]]
|
| 318 |
+
specifies that a non-template function will be given preference over
|
| 319 |
+
a template specialization if the two functions are otherwise equally
|
| 320 |
+
good candidates for an overload match.
|