The Status of Const

Michal Minich michal.minich at gmail.com
Tue Aug 17 04:34:13 PDT 2010


On Tue, 17 Aug 2010 12:05:55 +0200, Pelle wrote:

> class C { }
> class D : C { }
> class E : C { }
> 
> void append_to(ref const(C)[] cs, const(C) c) { cs ~= c; }
> 
> D[] ds;
> append_to(ds, new E);
> 
> 
> *ahem*
> D[] can not be converted to const(C). That it works today is pretty
> terrible. Rewrite the append_to to work with Objects, and well. :-)

what about appending instance of C? Doing this, you would end up with 
arrays of Ds, where one item will be instance of C!

D[] ds;
append_to(ds, new C);


More information about the Digitalmars-d mailing list