C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Conditional final class-virt-specifier
From: Paweł Benetkiewicz (pawel.benetkiewicz_at_[hidden])
Date: 2020-07-14 12:16:10


> If you want to limit what classes can use a class as a base, make everything
(esp. constructors) in the class private, make the "welcome" classes
friends and ensure that they behave. That's what some of us have indeed been
doing for many years in order to limit the set of classes that can inherit
from a particular base, and suggestions for some more direct facility
haven't come up, because that was unnecessary.

This way you disallow instantiation of a class, not the inheritance itself.
My proposal is about conditionally disallowing inheritance, not
instantiation of a class.

If you can do what this proposal proposes, share your knowledge with the
community, please.
And the quoted recipe is invalid as it does not do what this proposal
proposes (it does not disallow inheritance at all).

[Note you can inherit from a class with all six special member functions
explicitly deleted. — end note].

On Tue, Jul 14, 2020 at 11:01 AM Ville Voutilainen <
ville.voutilainen_at_[hidden]> wrote:

> On Tue, 14 Jul 2020 at 11:57, Paweł Benetkiewicz via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> > > So the basic question "why is this worth having?" is not answered by
> the proposal.
> > The Proposal is worth having, because it does "heavily increase
> compatibility correctness by inheritance constraints" by providing an
> ability to encapsulate interfaces. [Note: See Examples section of proposal.
> — end note]
>
> I can already do what this proposal proposes. There are existing ways
> in C++ to reach the same goal, so
> the proposal should explain why those ways are inadequate, and why an
> extension is necessary.
>



STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups