Can we just have struct inheritence already?

Max Haughton maxhaton at gmail.com
Mon Jun 10 22:34:53 UTC 2019


On Monday, 10 June 2019 at 21:59:51 UTC, Ola Fosheim Grøstad 
wrote:
> On Monday, 10 June 2019 at 21:15:52 UTC, Walter Bright wrote:
>> On 6/10/2019 7:42 AM, Andrei Alexandrescu wrote:
>>> The same way it causes in C++. Crack open literally any C++ 
>>> introductory book to find the explanation.
>>
>> Some reasons:
>>
>> https://stackoverflow.com/questions/4353203/thou-shalt-not-inherit-from-stdvector
>
> The answers with high rating actually state that there is no 
> problem in inheriting from std::vector…
>
>> https://stackoverflow.com/questions/2034916/is-it-okay-to-inherit-implementation-from-stl-containers-rather-than-delegate
>
> The most highly rated answer says that there is no problem with 
> inheriting from std::vector if you don't rely on on having a 
> virtual destructor…
>
> So, not the best source for building an argument.

Just because the code is semantically correct or "safe" doesn't 
mean it's good code. Inheriting from a container that you either 
aren't directly extending or don't own is a huge code smell in my 
view


More information about the Digitalmars-d mailing list