New paper: N3582, Return Type Deduction for Normal Functions (Revision 3) -- Jason Merrill

[Ed.: Also of broad interest and on track for near-term standardization.]

A new WG21 paper is available. A copy is linked below, and the paper will also appear in the next normal WG21 mailing. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N3582

Date: 2013-03-15

Return Type Deduction for Normal Functions (Revision 3)

by Jason Merrill

Excerpt:

Any C++ user introduced to the C++11 features of auto, lambdas, and trailing return types immediately wonders why they can't just write auto on their function declaration and have the return type deduced. This functionality was proposed previously in N2954, but dropped from C++11 due to time constraints, as the drafting didn't address various questions and concerns that the Core WG had. I have now implemented this functionality in GCC, and propose to add it to C++14. I discuss some of the less obvious aspects of the semantics below.

This proposal also resolves core DRs 975 (lambda return type deduction from multiple return statements) and 1048 (inconsistency between auto and lambda return type deduction).

 

Add a Comment

Comments are closed.

Comments (1)

0 0

Agentlien said on Mar 21, 2013 09:15 AM:

This looks really interesting.

I wouldn't say it's something I would use regularly outside of templates, since there are good reasons for explicitly declaring the return-type of a function. However, it does seem to plug a hole in the new rules about auto and trailing return types, and does not seem to conflict with anything (in an immediately obvious way).