From Jason Turner

[dcl.type.class.deduct]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp311iogms/{from.md → to.md} +29 -13
tmp/tmp311iogms/{from.md → to.md} RENAMED
@@ -1,24 +1,40 @@
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);
@@ -27,10 +43,10 @@ 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
 
 
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 [[dcl.init]]
5
+ of a variable, the declared type of the variable shall be cv `T`, where
6
+ `T` is the placeholder.
7
+
8
+ [*Example 1*:
9
+
10
+ ``` cpp
11
+ template <class ...T> struct A {
12
+ A(T...) {}
13
+ };
14
+ A x[29]{}; // error: no declarator operators allowed
15
+ const A& y{}; // error: no declarator operators allowed
16
+ ```
17
+
18
+ — *end example*]
19
+
20
+ The placeholder is replaced by the return type of the function selected
21
+ by overload resolution for class template deduction
22
+ [[over.match.class.deduct]]. If the *decl-specifier-seq* is followed by
23
+ an *init-declarator-list* or *member-declarator-list* containing more
24
+ than one *declarator*, the type that replaces the placeholder shall be
25
+ the same in each deduction.
26
 
27
  A placeholder for a deduced class type can also be used in the
28
  *type-specifier-seq* in the *new-type-id* or *type-id* of a
29
+ *new-expression* [[expr.new]], as the *simple-type-specifier* in an
30
+ explicit type conversion (functional notation) [[expr.type.conv]], or as
31
+ the *type-specifier* in the *parameter-declaration* of a
32
+ *template-parameter* [[temp.param]]. A placeholder for a deduced class
33
+ type shall not appear in any other context.
34
 
35
+ [*Example 2*:
36
 
37
  ``` cpp
38
  template<class T> struct container {
39
  container(T t) {}
40
  template<class Iter> container(Iter beg, Iter end);
 
43
  container(Iter b, Iter e) -> container<typename std::iterator_traits<Iter>::value_type>;
44
  std::vector<double> v = { ... };
45
 
46
  container c(7); // OK, deduces int for T
47
  auto d = container(v.begin(), v.end()); // OK, deduces double for T
48
+ container e{5, 6}; // error: int is not an iterator
49
  ```
50
 
51
  — *end example*]
52