Created on 2010-03-09.00:00:00 last changed 121 months ago
[Moved to DR at the April, 2013 meeting as part of paper N3638.]
Notes from the November, 2014 meeting:
CWG agreed that the change embodied in paper N3638 should be considered to have been a DR against C++11.
Proposed resolution, November, 2014:
This issue was actually resolved by paper N3638, adopted at the April, 2013 meeting. It is returned to "review" status to allow consideration of whether the resolution should be considered a change for C++14 or a retroactive change to C++11.
Additional note, February, 2014:
EWG noted that g++ and clang differ in their treatment of this example and referred it back to CWG for resolution.
auto and lambda return types use slightly different rules for determining the result type from an expression. auto uses the rules in 13.10.3.2 [temp.deduct.call], which explicitly drops top-level cv-qualification in all cases, while the lambda return type is based on the lvalue-to-rvalue conversion, which drops cv-qualification only for non-class types. As a result:
struct A { }; const A f(); auto a = f(); // decltype(a) is A auto b = []{ return f(); }; // decltype(b()) is const A
This seems like an unnecessary inconsistency.
John Spicer:
The difference is intentional; auto is intended only to give a const type if you explicitly ask for it, while the lambda return type should generally be the type of the expression.
Daniel Krügler:
Another inconsistency: with auto, use of a braced-init-list can deduce a specialization of std::initializer_list; it would be helpful if the same could be done for a lambda return type.
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-11-24 00:00:00 | admin | set | messages: + msg5264 |
2014-11-24 00:00:00 | admin | set | messages: + msg5263 |
2014-11-24 00:00:00 | admin | set | status: nad -> cd3 |
2014-07-07 00:00:00 | admin | set | messages: + msg5111 |
2014-07-07 00:00:00 | admin | set | status: open -> nad |
2014-03-03 00:00:00 | admin | set | messages: + msg4904 |
2014-03-03 00:00:00 | admin | set | status: extension -> open |
2010-08-23 00:00:00 | admin | set | status: open -> extension |
2010-03-09 00:00:00 | admin | create |