Deduce template arguments from return value?

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 12 03:45:51 PDT 2015


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);
}

?




More information about the Digitalmars-d mailing list