On Monday, 2 May 2022 at 19:17:19 UTC, Stanislav Blinov wrote:
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote:

Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Consider for example this code:

```d
    template MyAlias(T){
      alias MyAlias = int;
    }

    T simp(T)(MyAlias!T val){
      return T.init;
    }

    int main(){
      simp(3);//Impossible to deduce T

Why? That's the issue. It is very possible to deduce T here. Compiler just isn't trying. The function takes an int. Doesn't take a rocket scientist to figure that one out.

Maybe I am being silly, but it isn't possible to determine T here. Independent of what T is the input parameter would be an int (which the compiler can't see but we can) but the output depends on T which can't be deduced.

Reply via email to