C++ Logo

std-proposals

Advanced search

Re: Conditional final class-virt-specifier

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Sat, 11 Jul 2020 12:08:29 -0400
Besides the other (all correct) responses you've received,

> Conditioning inheritance was widely requested for many years,
{{citation needed}}

I have never *heard *of "conditional inheritance."

And the bogus example at the bottom of page 5:

> struct D final<class B>(!derived_from<B, E>) {};
> // struct D can be derived only from classes that derives from E

At this point, the name `E` is undeclared, so this can't possibly work.

> struct E {};
> struct F : E {};
> struct G {};
> struct F : D {}; // OK: F derives from E

Not okay; redefinition of struct `F`.

> struct G : D {}; // ill-formed: G does not derive from E

Not okay; redefinition of struct `G`.

I think the essential problem is that you don't understand how inheritance
works in C++. You can't "add base classes later" to an already-defined
class type. The class *itself *controls its list of base classes, just as
the class *itself *controls its list of data members, member functions, etc.

–Arthur


On Fri, Jul 10, 2020 at 10:11 PM Paweł Benetkiewicz via Std-Proposals <
std-proposals_at_[hidden]> wrote:

>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2020-07-11 11:11:56