Re: stretto...@tutanota.com

2016-06-10 Thread ArturG via Digitalmars-d-learn
you could also use a simple wrapped cast Ret castTo(Ret, T)(T t) if(is(T == class)) { return cast(Ret) t; } then do foo.stuff[0].castTo!Dong.x.writeln; and if you want to guard the access you could try foo.stuff[0].castTo!Dong.cc!((d){d.x = 5;}); cc is an alias for checkCall which is a t

Re: stretto...@tutanota.com

2016-06-09 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 9 June 2016 at 22:19:33 UTC, Stretto wrote: I have some class like class bar { } class foo : bar { bar[] stuff; } and have another class class dong : bar { int x; } Now sometimes stuff will contain dong's, but I cannot access its members it without a cast. fooo.stuff[0

Re: stretto...@tutanota.com

2016-06-09 Thread Stretto via Digitalmars-d-learn
Ultimately what I want to do is access a member foo.Dongs[i]; Where Dongs is essentially a "view" in to the Bars array and only accesses types of type Dong. It seems one can't do both an override on a name("Dongs") and an index on the overridden name(`[i]`)? It is not appropriate to use fo

stretto...@tutanota.com

2016-06-09 Thread Stretto via Digitalmars-d-learn
I have some class like class bar { } class foo : bar { bar[] stuff; } and have another class class dong : bar { int x; } Now sometimes stuff will contain dong's, but I cannot access its members it without a cast. fooo.stuff[0].x // invalid because bar doesn't contain x; Hence, ((c