Can we make auto return type inference a little more lax?

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon May 16 21:31:27 PDT 2011


Yeah it's low priority, but nice to have.

Note that there's a similar issue with tuples. However since tuples
are a library type and not first-class citizens (when it comes to
return types that is), the compiler probably won't be able to figure
out a common type.

What I mean is this:

auto foo()
{
   if (1)
   {
       tuple(0, 0);
   }
   else
   {
       size_t one;
       size_t two;

       tuple(one, two);
   }
}

I don't think the compiler can figure that one out unless tuples
become a standard language feature, not a library one. But maybe I'm
wrong.


More information about the Digitalmars-d-learn mailing list