Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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`.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: