On Wed, 28 Mar 2012, Jason Merrill wrote:

On 03/28/2012 03:20 PM, Marc Glisse wrote:
I agree that it works like initialization, and like lambdas, so that
ship has sailed. I assume there were good reasons for that, even if they
are not obvious, I know things can be trickier than they appear.
However, I can't help thinking that there is something wrong with having
to write:

auto g(int i) -> decltype(f(i)) { return f(i); }

I agree that this is a serious problem; decltype has the semantics we want, and so new functionality that does something different may not actually be very useful.

It seems useful to have return type deduction while still being able to say: "return by value" or "return const" or "return an lvalue reference", which your change provides.

Unfortunately, making auto functions different from auto variables and lambdas isn't very appealing, either.

Especially lambdas, yes (in N1968, lambdas were supposed to use decltype for their return type, it was changed later in the process, I'll have to try and find that discussion).

Making them different from auto variables seems quite natural, the situations are really different.

Marc Glisse

Reply via email to