Annoyance with function template unwrapping

kdevel kdevel at vogtner.de
Sun Jan 17 20:03:46 UTC 2021


On Sunday, 17 January 2021 at 19:29:59 UTC, Paul Backus wrote:
[...]
> As long as the overloads are unambiguous, there's no problem. 
> As with functions, it's only when you have two overloads that 
> match the same arguments that you get an error.

And sometimes you don't get an error:

```temploverl.d
template S (U) { int x = 1; }
template S (U, V = void) { int x = 2; }

int main ()
{
    import std.stdio: writeln;
    writeln (S!(int).x);
    return 0;
}
```

$ dmd temploverl
$ ./temploverl
2



More information about the Digitalmars-d mailing list