开发者

Where is alias this defined

开发者 https://www.devze.com 2023-03-14 15:31 出处:网络
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 inheri

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 officia开发者_高级运维lly?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消