> Full disclosure: This whole section was missing a subsection about Class Template Argument Deduction (CTAD), which I apparently completely forgot existed. So I am adding it now.
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`.
Rust is not the most principled programming language in the world when it comes to type systems. It has several type system holes, and the Rust Project is busy making a new type system with as much backwards compatibility as possible.
Take a look at reddit.com/r/cpp/comments/1i9e6ay/comment/m92le26/ .
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:
template (unspecialized) + its generic args: