[Understanding] Classes and delegate inheritance vs function pointers

sighoya sighoya at gmail.com
Sat Jan 9 21:57:43 UTC 2021


On Saturday, 9 January 2021 at 20:20:38 UTC, Q. Schroll wrote:
> That's not what I mean. You copy the reference. That's not what 
> referencing meant.
>
>   Derived d = new Derived();
>   Base* bp = &d; // fails
>   const(Base) cbp = &d; // compiles.

Generally, allowing covariant assignment for the Ptr<T>, i.e. T*, 
type only in case of const T* strikes me. IMHO, both should be 
synchronously (dis)allowed.
Because D doesn't support co(ntra)variance, it should be both 
disallowed?
Otherwise, because D already support the const case, why not the 
non const case?

Are there any alignment issues supporting the non const case?


More information about the Digitalmars-d-learn mailing list