First Draft: Implicit Conversion of Template Instantiations

Timon Gehr timon.gehr at gmx.ch
Mon Mar 18 00:45:46 UTC 2024


On 3/16/24 16:50, Walter Bright wrote:
> https://github.com/WalterBright/documents/blob/9dba63a4c2887bdb2b988c354ebb0d6bb44c4968/templatecast.md
> 
> DConf: https://dconf.org/2024/online/index.html#walterb

Issue: It does not seem to work yet for class references:

```d
struct S(T){
     T a;
}

class A{}
class B:A{}

void main(){
     S!(const(int)[]) s1 = S!(int[])([1,2,3]); // ok
     S!A s2=S!B(new A); // error
}
```

The B is an A in essentially the same way an `int[]` is a 
`const(int)[]`. (Subtyping, no change in memory representation required 
for conversion.)


More information about the dip.development mailing list