Description
[dcl.type.auto.deduct]/2 says:
"""
A type T
containing a placeholder type, and a corresponding initializer E, are determined as follows:
— for a variable declared with a type that contains a placeholder type, T
is the declared type of the variable and E is the initializer. ...
"""
[dcl.type.auto.deduct]/4 says:
"""
If the placeholder-type-specifier is of the form type-constraintopt auto
, the deduced type T
replacing T
is determined using the rules for template argument deduction.
Obtain P
from T
by replacing the occurrences of type-constraintopt auto
either with a new invented type template parameter U
, or ... [doesn't matter].
Deduce a value (!!!) for U
using the rules of template argument deduction from a function call, where P
is a function template parameter type and the corresponding argument is E.
...
[Example:
const auto &i = expr;
The type of i
is the deduced type of the parameter u
in the call f(expr)
of the following invented function template:
template <class U> void f(const U& u);
— end example]
"""
There are several issues here (both in normative wording and the Example): the major one is that for a variable declared as const auto &i = expr;
, the initializer is = expr
, not expr
. And one can't call a function with this initializer as an argument, like f(= expr)
. Probably, the paragraph should say that the initializer E is the default argument of an invented function template (and the type is deduces as if the function is called without argument)? Nah, the grammar for parameter-declaration doesn't allow initializer.
Also, is it ok that the Standard calls the deduced type "a value of a type parameter" and uses the instructing tone like Obtain P
from T
... Deduce a value ....