Template argument deduction

In order to instantiate a function template, every template argument must be known, but not every template argument has to be specified. When possible, the compiler will deduce the missing template arguments from the function arguments. This occurs when a function call is attempted, when an address of a function template is taken, and in some other contexts:

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 70C++98whether array bounds would be deduced was not specifiedspecified as non-deduced
CWG 300C++98deduction took place for function parameters of formtype()(T)/T()()/T(*)(T), function pointersmatch these forms but function references do notchange these forms totype(T)/T()/T(T) so theycan also cover references
CWG 322C++98type parameters of reference types were notadjusted to use the referenced type for deductionadjustment added
CWG 976C++98in the deduction for conversion operator templates,const T& return type could never match T result typerules adjusted toallow such matches
CWG 1387C++11the expression of a decltype-specifier was not a non-deduced contextit is
CWG 1391C++98effect of implicit conversions of the argumentsthat aren’t involved in deduction were not specifiedspecified as described above
CWG 1591C++11cannot deduce array bound and element type from a braced-init-listdeduction allowed
CWG 2052C++98deducing an operator with non-classnon-enum arguments was a hard errorsoft error if thereare other overloads
CWG 2091C++98deducing a reference non-type parameter did notwork due to type mismatch against the argumenttype mismatch avoided
N3922C++11direct-list-initialization of auto deduces std::initializer_listill-formed for more than oneelements, deduce elementtype for single element
CWG 2355C++17value in a noexcept specifier of a function type was not deduciblemade deducible