Idea: Reverse Type Inference
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 5 07:13:34 PDT 2017
On 6/3/17 7:37 PM, Enamex wrote:
> On Wednesday, 24 May 2017 at 15:02:05 UTC, Steven Schveighoffer wrote:
>> In fact, you could simulate overloading of return values based on IFTI
>> instantiation:
>>
>> void fooImpl(ref int retval, int x) { ... }
>> void fooImpl(ref string retval, int x) { ... }
>>
>> T foo(T)(int x) { T t; fooImpl(t, x); return t; }
>> int x = foo(1);
>> string y = foo(2);
>
> https://dpaste.dzfl.pl/7d8351fe2f07
>
> What am I doing wrong?
You are not realizing that my example requires IFTI on return types,
something that I proposed but is not implemented ;)
-Steve
More information about the Digitalmars-d
mailing list