Re: Alias this and inheritance

2017-11-05 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 5 November 2017 at 07:07:43 UTC, Aurelien Fredouelle wrote: struct S { } class A { S s; alias s this; } class B : A { } void main() { A asA = new B; B asB = cast(B)asA; } I would expect the last line to successfully cast the B instance I created back into type B, however

Alias this and inheritance

2017-11-05 Thread Aurelien Fredouelle via Digitalmars-d-learn
The following code does not compile: struct S { } class A { S s; alias s this; } class B : A { } void main() { A asA = new B; B asB = cast(B)asA; } I would expect the last line to successfully cast the B instance I created back into type B, however this seems to be preempted by the

Re: alias this for inheritance

2011-02-23 Thread Steven Schveighoffer
On Wed, 23 Feb 2011 10:34:04 -0500, spir denis.s...@gmail.com wrote: Hello, I have read several times that alias this is a way to implement inheritance for structs. I am simply unable to imagine how to use this feature that way. Has anyone an example? It allows *some* simulation of