Idea: Reverse Type Inference

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Wed May 24 07:58:42 PDT 2017


On 5/24/17 10:28 AM, Ola Fosheim Grøstad wrote:
> On Wednesday, 24 May 2017 at 13:03:37 UTC, Steven Schveighoffer wrote:
>> This is different. It's IFTI based on return type.
>
> Well, the way I see it it is a special case of top-down type inference.
> Yes, you also have to instantiate the template, but I assume that
> happens after type inference is complete?
>
> So my point was more: why not cover the general case, if you are going
> to add it as a feature?
>
>> auto p = Point(row.get("x"), row.get("y")); // with better IFTI
>
> Ok, well, I see templates in this context as a variation of overloading,
> just with the template parametric type being a set of types i.e. all
> types that the program provides, minus the ones prevented by
> contraints.  I guess it is a matter of vantage point.
>
> It would be odd to allow this for templates only and not provide it for
> functions...
>

I believe that IFTI would be much more straightforward than overloading, 
because there is no concern about implicit conversion.

-Steve


More information about the Digitalmars-d mailing list