Fix template parameter

Dom Disc dominikus at scherkl.de
Tue Aug 9 22:32:23 UTC 2022


On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote:
> Yes, this syntax allows anything that implicitly converts to 
> `BigInt`; for example:
>
> ```d
> import std.bigint;
>
> void fun(T : BigInt)(T t)
> {
>     pragma(msg, "Instantiated with T = `" ~ T.stringof ~ "`");
> }
>
> struct S
> {
>     BigInt n;
>     alias n this;
> }
>
> void main()
> {
>     S s;
>     fun(s); // Instantiated with T = `S`
> }

Aha. But isn't that also true for the other declaration?

```d
void fun(BigInt t) { }
```

will also accept anything that implicitly converts to BigInt, no?
So I still don't see the big difference.
Except that is is a template - for what ever that may be useful 
if it doesn't take more than one type.
Relying on something as subtle as this difference does have a 
code-smell for me.


More information about the Digitalmars-d-learn mailing list