You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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-constraintoptauto, 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-constraintoptauto 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 ....
The text was updated successfully, but these errors were encountered:
So, how about this? decltype(auto) x2d(i); // decltype(x2d) is int?
If the placeholder-type-specifier is of the form type-constraint opt decltype(auto), T shall be the placeholder alone. The type deduced for T is determined as described in [dcl.type.decltype], as though E had been the operand of the decltype.
That means E would be (i) which is the initializer, hence, decltype((i)) should be deduced to int&. I think we should preprocess the form of initializer in this 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 typeT
replacingT
is determined using the rules for template argument deduction.Obtain
P
fromT
by replacing the occurrences of type-constraintoptauto
either with a new invented type template parameterU
, or ... [doesn't matter].Deduce a value (!!!) for
U
using the rules of template argument deduction from a function call, whereP
is a function template parameter type and the corresponding argument is E....
[Example:
The type of
i
is the deduced type of the parameteru
in the callf(expr)
of the following invented function template:— 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
, notexpr
. And one can't call a function with this initializer as an argument, likef(= 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
fromT
... Deduce a value ....The text was updated successfully, but these errors were encountered: