On Sun, 25 Mar 2012 12:17:10 +0200 (CEST)
Marc Glisse <marc.glisse@inria.fr> wrote:
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 [...]
I am not a C++ or a GCC front-end expert, but I am not sure it is the right approach for
functions starting with
if (!p) return nullptr;
where p is a formal argument.
Or perhaps I am misunderstanding what Marc is saying.
I would rather suggest using all the return statements to infer the type of the function,
not only the first one.