Re: Infer return type from assignment

2018-04-11 Thread ixid via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 14:33:06 UTC, Adam D. Ruppe wrote: On Wednesday, 11 April 2018 at 14:26:53 UTC, ixid wrote: 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? Not really. The function call needs

Re: Infer return type from assignment

2018-04-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 14:26:53 UTC, ixid wrote: 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? Not really. The function call needs to make sense by itself: fun(a) needs to be a complete thing for

Infer return type from assignment

2018-04-11 Thread ixid via Digitalmars-d-learn
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); }