[dcl.type.class.deduct]

# 9 Declarations [[dcl]](./#dcl)

## 9.2 Specifiers [[dcl.spec]](dcl.spec#dcl.type.class.deduct)

### 9.2.9 Type specifiers [[dcl.type]](dcl.type#class.deduct)

#### 9.2.9.8 Deduced class template specialization types [dcl.type.class.deduct]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L2254)

If a placeholder for a deduced class type
appears as a [*decl-specifier*](dcl.spec.general#nt:decl-specifier "9.2.1 General [dcl.spec.general]") in the [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]") of an initializing declaration ([[dcl.init]](dcl.init "9.5 Initializers")) of a variable,
the declared type of the variable shall be cv T,
where T is the placeholder[.](#1.sentence-1)

[*Example [1](#example-1)*: template <class ...T> struct A { A(T...) {}};
A x[29]{}; // error: no declarator operators allowedconst A& y{}; // error: no declarator operators allowed â *end example*]

The placeholder is replaced by the return type
of the function selected by overload resolution
for class template deduction ([[over.match.class.deduct]](over.match.class.deduct "12.2.2.9 Class template argument deduction"))[.](#1.sentence-2)

If the [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]") is followed by an [*init-declarator-list*](dcl.decl.general#nt:init-declarator-list "9.3.1 General [dcl.decl.general]") or [*member-declarator-list*](class.mem.general#nt:member-declarator-list "11.4.1 General [class.mem.general]") containing more than one [*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]"),
the type that replaces the placeholder shall be the same in each deduction[.](#1.sentence-3)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L2279)

A placeholder for a deduced class type
can also be used
in the [*type-specifier-seq*](dcl.type.general#nt:type-specifier-seq "9.2.9.1 General [dcl.type.general]") in the [*new-type-id*](expr.new#nt:new-type-id "7.6.2.8 New [expr.new]") or [*type-id*](dcl.name#nt:type-id "9.3.2 Type names [dcl.name]") of a [*new-expression*](expr.new#nt:new-expression "7.6.2.8 New [expr.new]") ([[expr.new]](expr.new "7.6.2.8 New")),
as the [*simple-type-specifier*](dcl.type.simple#nt:simple-type-specifier "9.2.9.3 Simple type specifiers [dcl.type.simple]") in an [explicit type conversion (functional notation)](expr.type.conv "7.6.1.4 Explicit type conversion (functional notation) [expr.type.conv]"),
or
as the [*type-specifier*](dcl.type.general#nt:type-specifier "9.2.9.1 General [dcl.type.general]") in the [*parameter-declaration*](dcl.fct#nt:parameter-declaration "9.3.4.6 Functions [dcl.fct]") of a [*template-parameter*](temp.param#nt:template-parameter "13.2 Template parameters [temp.param]") ([[temp.param]](temp.param "13.2 Template parameters"))[.](#2.sentence-1)

A placeholder for a deduced class type
shall not appear in any other context[.](#2.sentence-2)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L2293)

[*Example [2](#example-2)*: template<class T> struct container { container(T t) {}template<class Iter> container(Iter beg, Iter end);};template<class Iter> container(Iter b, Iter e) -> container<typename std::iterator_traits<Iter>::value_type>;
std::vector<double> v = { /* ... */ };

container c(7); // OK, deduces int for Tauto d = container(v.begin(), v.end()); // OK, deduces double for T container e{5, 6}; // error: int is not an iterator â *end example*]
