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
V Thu, 11 Sep 2014 11:40:05 +
andre via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
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;
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 has
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
alias.
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