On Sun, 25 Mar 2012, Jason Merrill wrote:

As I mentioned in my patch to add -std=c++1y, I've been working on a proposal for the next standard to support return type deduction for normal functions, not just lambdas. This patch implements that proposal.

Nice. I like the way you seem to be going for the basic, uncontroversial version (extensions can always be discussed later), instead of trying to figure out something universal.

If I understand correctly, you pick the first return statement for type deduction, and other returns (if any) are only checked afterwards for exact consistency, which simplifies the problem quite a bit while still allowing some recursion (although interestingly, constexpr functions require the use of a single return with ?: whereas your auto functions prefer an if and several returns). Naturally, auto functions have to be instantiated a bit more eagerly than regular functions, and there is no try to sfinae the auto deduction. That seems to fit many simple functions quite nicely with little room for unintended consequences.

I tried to send this message before with the proposal attached in HTML, but the mailing list rejects HTML attachments, so I've dropped it. I'm happy to send it separately to anyone interested.

I guess I'll have plenty of chances to look at it once it is submitted (it isn't like I'd have much to contribute...).

--
Marc Glisse

Reply via email to