Re: alias this & cast

2014-09-11 Thread Ali Çehreli via Digitalmars-d-learn
On 09/11/2014 09:18 AM, andre wrote: > I am not sure. b is C but everything not in super class B is hidden. > Using cast I can cast b to a full C. > > The cast "cast(C)b" has the same information about b like the cast > "cast(A)b": The memory area of b knows compatitibility to C and also the > al

Re: alias this & cast

2014-09-11 Thread andre via Digitalmars-d-learn
I am not sure. b is C but everything not in super class B is hidden. Using cast I can cast b to a full C. The cast "cast(C)b" has the same information about b like the cast "cast(A)b": The memory area of b knows compatitibility to C and also the alias. For me, using alias this, the object b

Re: alias this & cast

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 11 Sep 2014 11:40:05 + andre via Digitalmars-d-learn napsáno: > Hi, > > I am 80% sure, the failing assertion is correct but please have a > look. No it is not assert(cast(A)cast(C)b); // this is OK b is B so it does not know about having alias to A; > Second assertion fails. > >

alias this & cast

2014-09-11 Thread andre via Digitalmars-d-learn
Hi, I am 80% sure, the failing assertion is correct but please have a look. Second assertion fails. Kind regards André class A{} class B{} class C : B { A a; alias a this; this() { a = new A(); } } void main() { B b =

alias this : cast turns into endless loop

2012-04-28 Thread Namespace
Trying with U opCast(U : Object)() { return new U(); } work fine. It isn't a solution, but i don't understand why this works and the following not: U opCast(U : Object)() { return cast(U) this._obj; } I hope really some of you ca