Search code examples
standardsmultiple-inheritanced

Where is alias this defined


When programming a C++ application I needed a class that supported interfaces. After implmenting it with MI is had a big ugh moment when I realized if I wasn't careful I would introduce diamond inheritance and that I should probably virtually inherit my interfaces. Further, the only elegant way to implement the code required dynamic_cast.

About this point I thought there must be a better way. When I remember reading about subtypeing/alias this in TDPL. I copied the basic idea into my class. I think the solution is much more elegant, but not coventional.

To preemptively justify my code, I was hoping that I could link to a page that describes the alias this feature of D. However I could find one on the website.

Where is subtypeing / alias this described officially?


Solution

  • http://www.digitalmars.com/d/2.0/class.html#AliasThis

    But I think this might be a little bit out of date. IIRC TDPL describes the possibility of several alias this per class.