On Monday, 8 August 2022 at 12:02:02 UTC, Dom Disc wrote:
Hello.
I found in the documentation functions declared like this:

```D
pure @nogc @safe BigInt opAssign(T : BigInt)(T x);
```

This is a template function, even if T is constrained to always be BigInt (it may also include anything that is a subtype of BigInt... I've received different answers on what exactly `(T: SomeType)` means in this context). This means that it cannot be virtual, you can't take its address, and as bauss said, it won't show up in the object file if it's not used.

As far as I know, there's no advantage to doing this over `opAssign(BigInt x)`, UNLESS `(T: BigInt)` means "BigInt and any subtype of BigInt", in which case the advantage is similar to doing `<T extends BigInt> void opAssign(T val)` in Java (referring to polymorphism; this won't give you virtual dispatch like it does in Java).


Reply via email to