First Draft: Implicit Conversion of Template Instantiations
Timon Gehr
timon.gehr at gmx.ch
Mon Mar 18 01:28:18 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: Subtyping under indirections remains magic.
```d
struct Mutability(bool mutable,T){
static if(mutable){
T payload;
}else{
const(T) payload;
}
}
void main(){
int[] a1 = [1,2,3];
const(int)[] a2 = a1; // ok
auto m1=[Mutability!(true,int)(1),
Mutability!(true,int)(2),
Mutability!(true,int)(3)];
Mutability!(false,int)[] m2=m1; // error
}
```
(With variance annotations, this example would need some kind of support
for variance annotations for template value parameters.)
More information about the dip.development
mailing list