From Jason Turner

[temp.deduct.guide]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpo7o0lm5v/{from.md → to.md} +211 -0
tmp/tmpo7o0lm5v/{from.md → to.md} RENAMED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Deduction guides <a id="temp.deduct.guide">[[temp.deduct.guide]]</a>
2
+
3
+ Deduction guides are used when a *template-name* appears as a type
4
+ specifier for a deduced class type ([[dcl.type.class.deduct]]).
5
+ Deduction guides are not found by name lookup. Instead, when performing
6
+ class template argument deduction ([[over.match.class.deduct]]), any
7
+ deduction guides declared for the class template are considered.
8
+
9
+ ``` bnf
10
+ deduction-guide:
11
+ 'explicit'ₒₚₜ template-name '(' parameter-declaration-clause ') ->' simple-template-id ';'
12
+ ```
13
+
14
+ [*Example 1*:
15
+
16
+ ``` cpp
17
+ template<class T, class D = int>
18
+ struct S {
19
+ T data;
20
+ };
21
+ template<class U>
22
+ S(U) -> S<typename U::type>;
23
+
24
+ struct A {
25
+ using type = short;
26
+ operator type();
27
+ };
28
+ S x{A()}; // x is of type S<short, int>
29
+ ```
30
+
31
+ — *end example*]
32
+
33
+ The same restrictions apply to the *parameter-declaration-clause* of a
34
+ deduction guide as in a function declaration ([[dcl.fct]]). The
35
+ *simple-template-id* shall name a class template specialization. The
36
+ *template-name* shall be the same *identifier* as the *template-name* of
37
+ the *simple-template-id*. A *deduction-guide* shall be declared in the
38
+ same scope as the corresponding class template and, for a member class
39
+ template, with the same access. Two deduction guide declarations in the
40
+ same translation unit for the same class template shall not have
41
+ equivalent *parameter-declaration-clause*s.
42
+
43
+ <!-- Link reference definitions -->
44
+ [basic.def]: basic.md#basic.def
45
+ [basic.def.odr]: basic.md#basic.def.odr
46
+ [basic.link]: basic.md#basic.link
47
+ [basic.lookup]: basic.md#basic.lookup
48
+ [basic.lookup.argdep]: basic.md#basic.lookup.argdep
49
+ [basic.lookup.classref]: basic.md#basic.lookup.classref
50
+ [basic.lookup.qual]: basic.md#basic.lookup.qual
51
+ [basic.lookup.unqual]: basic.md#basic.lookup.unqual
52
+ [basic.scope]: basic.md#basic.scope
53
+ [basic.scope.hiding]: basic.md#basic.scope.hiding
54
+ [basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
55
+ [basic.types]: basic.md#basic.types
56
+ [class]: class.md#class
57
+ [class.abstract]: class.md#class.abstract
58
+ [class.access]: class.md#class.access
59
+ [class.base.init]: special.md#class.base.init
60
+ [class.derived]: class.md#class.derived
61
+ [class.dtor]: special.md#class.dtor
62
+ [class.friend]: class.md#class.friend
63
+ [class.local]: class.md#class.local
64
+ [class.mem]: class.md#class.mem
65
+ [class.member.lookup]: class.md#class.member.lookup
66
+ [class.qual]: basic.md#class.qual
67
+ [class.temporary]: special.md#class.temporary
68
+ [conv]: conv.md#conv
69
+ [conv.array]: conv.md#conv.array
70
+ [conv.fctptr]: conv.md#conv.fctptr
71
+ [conv.func]: conv.md#conv.func
72
+ [conv.qual]: conv.md#conv.qual
73
+ [dcl.align]: dcl.md#dcl.align
74
+ [dcl.attr.grammar]: dcl.md#dcl.attr.grammar
75
+ [dcl.dcl]: dcl.md#dcl.dcl
76
+ [dcl.enum]: dcl.md#dcl.enum
77
+ [dcl.fct]: dcl.md#dcl.fct
78
+ [dcl.fct.def.general]: dcl.md#dcl.fct.def.general
79
+ [dcl.fct.default]: dcl.md#dcl.fct.default
80
+ [dcl.init]: dcl.md#dcl.init
81
+ [dcl.init.list]: dcl.md#dcl.init.list
82
+ [dcl.meaning]: dcl.md#dcl.meaning
83
+ [dcl.spec.auto]: dcl.md#dcl.spec.auto
84
+ [dcl.struct.bind]: dcl.md#dcl.struct.bind
85
+ [dcl.type.auto.deduct]: dcl.md#dcl.type.auto.deduct
86
+ [dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
87
+ [dcl.type.elab]: dcl.md#dcl.type.elab
88
+ [except.spec]: except.md#except.spec
89
+ [expr.const]: expr.md#expr.const
90
+ [expr.new]: expr.md#expr.new
91
+ [expr.prim.fold]: expr.md#expr.prim.fold
92
+ [expr.prim.lambda]: expr.md#expr.prim.lambda
93
+ [expr.prim.lambda.closure]: expr.md#expr.prim.lambda.closure
94
+ [expr.ref]: expr.md#expr.ref
95
+ [expr.sizeof]: expr.md#expr.sizeof
96
+ [expr.typeid]: expr.md#expr.typeid
97
+ [implimits]: limits.md#implimits
98
+ [intro.defs]: intro.md#intro.defs
99
+ [intro.object]: intro.md#intro.object
100
+ [lex.string]: lex.md#lex.string
101
+ [namespace.def]: dcl.md#namespace.def
102
+ [namespace.memdef]: dcl.md#namespace.memdef
103
+ [namespace.udecl]: dcl.md#namespace.udecl
104
+ [over.ics.rank]: over.md#over.ics.rank
105
+ [over.match]: over.md#over.match
106
+ [over.match.best]: over.md#over.match.best
107
+ [over.match.class.deduct]: over.md#over.match.class.deduct
108
+ [over.match.conv]: over.md#over.match.conv
109
+ [over.match.ref]: over.md#over.match.ref
110
+ [over.over]: over.md#over.over
111
+ [special]: special.md#special
112
+ [stmt.if]: stmt.md#stmt.if
113
+ [support.types]: language.md#support.types
114
+ [tab:fold.empty]: #tab:fold.empty
115
+ [temp]: #temp
116
+ [temp.alias]: #temp.alias
117
+ [temp.arg]: #temp.arg
118
+ [temp.arg.explicit]: #temp.arg.explicit
119
+ [temp.arg.nontype]: #temp.arg.nontype
120
+ [temp.arg.template]: #temp.arg.template
121
+ [temp.arg.type]: #temp.arg.type
122
+ [temp.class]: #temp.class
123
+ [temp.class.order]: #temp.class.order
124
+ [temp.class.spec]: #temp.class.spec
125
+ [temp.class.spec.match]: #temp.class.spec.match
126
+ [temp.class.spec.mfunc]: #temp.class.spec.mfunc
127
+ [temp.decls]: #temp.decls
128
+ [temp.deduct]: #temp.deduct
129
+ [temp.deduct.call]: #temp.deduct.call
130
+ [temp.deduct.conv]: #temp.deduct.conv
131
+ [temp.deduct.decl]: #temp.deduct.decl
132
+ [temp.deduct.funcaddr]: #temp.deduct.funcaddr
133
+ [temp.deduct.guide]: #temp.deduct.guide
134
+ [temp.deduct.partial]: #temp.deduct.partial
135
+ [temp.deduct.type]: #temp.deduct.type
136
+ [temp.dep]: #temp.dep
137
+ [temp.dep.candidate]: #temp.dep.candidate
138
+ [temp.dep.constexpr]: #temp.dep.constexpr
139
+ [temp.dep.expr]: #temp.dep.expr
140
+ [temp.dep.res]: #temp.dep.res
141
+ [temp.dep.temp]: #temp.dep.temp
142
+ [temp.dep.type]: #temp.dep.type
143
+ [temp.expl.spec]: #temp.expl.spec
144
+ [temp.explicit]: #temp.explicit
145
+ [temp.fct]: #temp.fct
146
+ [temp.fct.spec]: #temp.fct.spec
147
+ [temp.friend]: #temp.friend
148
+ [temp.func.order]: #temp.func.order
149
+ [temp.inject]: #temp.inject
150
+ [temp.inst]: #temp.inst
151
+ [temp.local]: #temp.local
152
+ [temp.mem]: #temp.mem
153
+ [temp.mem.class]: #temp.mem.class
154
+ [temp.mem.enum]: #temp.mem.enum
155
+ [temp.mem.func]: #temp.mem.func
156
+ [temp.names]: #temp.names
157
+ [temp.nondep]: #temp.nondep
158
+ [temp.over]: #temp.over
159
+ [temp.over.link]: #temp.over.link
160
+ [temp.param]: #temp.param
161
+ [temp.point]: #temp.point
162
+ [temp.res]: #temp.res
163
+ [temp.spec]: #temp.spec
164
+ [temp.static]: #temp.static
165
+ [temp.type]: #temp.type
166
+ [temp.variadic]: #temp.variadic
167
+
168
+ [^1]: Since template *template-parameter*s and template
169
+ *template-argument*s are treated as types for descriptive purposes,
170
+ the terms *non-type parameter* and *non-type argument* are used to
171
+ refer to non-type, non-template parameters and arguments.
172
+
173
+ [^2]: A `>` that encloses the *type-id* of a `dynamic_cast`,
174
+ `static_cast`, `reinterpret_cast` or `const_cast`, or which encloses
175
+ the *template-argument*s of a subsequent *template-id*, is
176
+ considered nested for the purpose of this description.
177
+
178
+ [^3]: There is no such ambiguity in a default *template-argument*
179
+ because the form of the *template-parameter* determines the
180
+ allowable forms of the *template-argument*.
181
+
182
+ [^4]: There is no way in which they could be used.
183
+
184
+ [^5]: That is, declarations of non-template functions do not merely
185
+ guide overload resolution of function template specializations with
186
+ the same name. If such a non-template function is odr-used (
187
+ [[basic.def.odr]]) in a program, it must be defined; it will not be
188
+ implicitly instantiated using the function template definition.
189
+
190
+ [^6]: Friend declarations do not introduce new names into any scope,
191
+ either when the template is declared or when it is instantiated.
192
+
193
+ [^7]: Default arguments are not considered to be arguments in this
194
+ context; they only become arguments after a function has been
195
+ selected.
196
+
197
+ [^8]: Although the *template-argument* corresponding to a
198
+ *template-parameter* of type `bool` may be deduced from an array
199
+ bound, the resulting value will always be `true` because the array
200
+ bound will be nonzero.
201
+
202
+ [^9]: The parameters of function template specializations contain no
203
+ template parameter types. The set of conversions allowed on deduced
204
+ arguments is limited, because the argument deduction process
205
+ produces function templates with parameters that either match the
206
+ call arguments exactly or differ only in ways that can be bridged by
207
+ the allowed limited conversions. Non-deduced arguments allow the
208
+ full range of conversions. Note also that  [[over.match.best]]
209
+ specifies that a non-template function will be given preference over
210
+ a template specialization if the two functions are otherwise equally
211
+ good candidates for an overload match.