Infer return type from assignment

ixid nuaccount at gmail.com
Wed Apr 11 14:26:53 UTC 2018


Is it possible to infer a template's return type from what it's 
assigned to? If not is this a difficult or worthless feature to 
add?

OUT fun(IN, OUT)(IN value) {
     return value.to!OUT;
}

void main() {
     float a = 5.0;
     int b = fun(a);
}


More information about the Digitalmars-d-learn mailing list