From Jason Turner

[dcl.type.class.deduct]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpr5u60xny/{from.md → to.md} +36 -0
tmp/tmpr5u60xny/{from.md → to.md} RENAMED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Deduced class template specialization types <a id="dcl.type.class.deduct">[[dcl.type.class.deduct]]</a>
2
+
3
+ If a placeholder for a deduced class type appears as a *decl-specifier*
4
+ in the *decl-specifier-seq* of an initializing declaration (
5
+ [[dcl.init]]) of a variable, the placeholder is replaced by the return
6
+ type of the function selected by overload resolution for class template
7
+ deduction ([[over.match.class.deduct]]). If the *decl-specifier-seq* is
8
+ followed by an *init-declarator-list* or *member-declarator-list*
9
+ containing more than one *declarator*, the type that replaces the
10
+ placeholder shall be the same in each deduction.
11
+
12
+ A placeholder for a deduced class type can also be used in the
13
+ *type-specifier-seq* in the *new-type-id* or *type-id* of a
14
+ *new-expression* ([[expr.new]]), or as the *simple-type-specifier* in
15
+ an explicit type conversion (functional notation) ([[expr.type.conv]]).
16
+ A placeholder for a deduced class type shall not appear in any other
17
+ context.
18
+
19
+ [*Example 1*:
20
+
21
+ ``` cpp
22
+ template<class T> struct container {
23
+ container(T t) {}
24
+ template<class Iter> container(Iter beg, Iter end);
25
+ };
26
+ template<class Iter>
27
+ container(Iter b, Iter e) -> container<typename std::iterator_traits<Iter>::value_type>;
28
+ std::vector<double> v = { ... };
29
+
30
+ container c(7); // OK, deduces int for T
31
+ auto d = container(v.begin(), v.end()); // OK, deduces double for T
32
+ container e{5, 6}; // error, int is not an iterator
33
+ ```
34
+
35
+ — *end example*]
36
+