Template type inference problem
Timon Gehr
timon.gehr at gmx.ch
Fri Oct 4 14:27:05 UTC 2024
On 10/4/24 12:12, Dennis wrote:
>
>
> This doesn't work with mutable parameters btw, because pointers to class
> types are only covariant when they are const. (Why is that? I don't know.)
```d
Throwable a;
Object* b = &a;
*b = new Object; // modifies `a`
assert(typeid(a) is typeid(Object));
throw a; // throwing something that is not a Throwable
```
Technically it would be enough that the pointer itself does not allow
writes, but `const` is transitive.
More information about the Digitalmars-d
mailing list