Deduce template arguments from return value?
Yuxuan Shui via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 12 14:16:51 PDT 2015
On Sunday, 12 July 2015 at 10:45:52 UTC, rsw0x wrote:
> On Sunday, 12 July 2015 at 09:13:03 UTC, Yuxuan Shui wrote:
>> For example:
>> import std.conv;
>> T a(T)(int a) {
>> return to!T(a);
>> }
>> void main(){
>> string x = a(2);
>> }
>>
>> D is not able to deduce T. Can we make it possible to deduce
>> template arguments from where the return value is assigned to?
>
> auto a(T)(int a) {
> return to!T(a);
> }
>
> ?
This doesn't seem to work in the example I gave.
More information about the Digitalmars-d
mailing list