Type Inference in Rust and C++
herecomesthemoon.net
herecomesthemoon.net
D has something similar too (aka IFTI), but otherwise that is more like the C++ inference system. So you can actually infer many things by a call to a function. Examples
array base type:
void v1(T)(T[] t);
int[] arg1;
v1(arg1); // during monomorphization `T` is `int`
template (unspecialized) + its generic args: void v2(T,U)(T!(U) tu);
struct S(T);
S!int arg2;
v2(arg2); // during monomorphization `T` is `S` and `U` is `int`.Take a look at reddit.com/r/cpp/comments/1i9e6ay/comment/m92le26/ .