rsmith added a comment.
`decltype(auto) lambda = []{};` and `decltype(auto) list = {0,1};` seem like
very different situations to me; in the latter case, the initializer is not
even an expression.
The rule that bans `decltype([]{})` is that a *lambda-expression* shall not
appear in an unevaluated operand. But the initializer in `decltype(auto) lambda
= []{};` is not an unevaluated operand. The relevant rule is
[dcl.type.auto.deduct]p5, which says: "The type deduced for T is determined as
described in 10.1.7.2, as though e had been the operand of the decltype." --
so, while this is certainly not completely clear, this suggests that we only
consider the expression as the operand of decltype for the purpose of
determining the type, not for the purpose of determining whether the deduction
is valid. And certainly seems to be the interpretation that is more friendly to
users.
https://reviews.llvm.org/D37667
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits