C++ Logo

std-proposals

Advanced search

Re: explicit class

From: Tony V E <tvaneerd_at_[hidden]>
Date: Wed, 13 Nov 2019 14:06:04 -0500
While you are bikeshedding, you could have

class C {
    default = delete;
};

ie by default, everything is deleted.

Of course, someone might think

class C {
    default = delete;
    ~C() = default; // well default = delete, so default means delete,
so...deleted?
};




On Wed, Nov 13, 2019 at 11:08 AM Magnus Fromreide via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Wed, Nov 13, 2019 at 01:01:26PM +0300, Andrey Semashev via
> Std-Proposals wrote:
> > On 2019-11-13 11:39, Magnus Fromreide via Std-Proposals wrote:
> > > On Mon, Nov 11, 2019 at 11:47:18AM -0700, Steve Weinrich via
> Std-Proposals wrote:
> > > > This is an idea that has been roaming around my head for some 20
> years!
> > > >
> > > >
> > > > As we know, there is a list of some 15 (or so) operations
> (construction,
> > > > assignment, copy, move, conversion, etc.) that the simple statement:
> "class
> > > > T {};" defines.
> > > >
> > > >
> > > > If one wishes some control over this behavior, one has to be
> knowledgeable
> > > > in all that the compiler provides. In non-C++ terms, one has to say
> (modern
> > > > use: =delete), "I don't want that, I don't want this, etc." The
> compiler
> > > > provides no aid for this!
> > > >
> > > >
> > > > My notion is to reverse this via "explicit class T {};". While I am
> sure
> > > > there are some details that would need to be debated, this would
> eliminate
> > > > (most) everything that the compiler defines for you. Thus, if you
> wanted
> > > > something, you would have to define it or use " = default" (yes, I
> am aware
> > > > that would require extending "= default" to more items - seems OK to
> me).
> > > > The obvious advantage is that the compiler now provides some help,
> in that
> > > > using something that is not defined will yield a compiler error.
> > >
> > > I do not say anything about wether this is useful or not but I dislike
> the
> > > gracious co-opting of explicit so lets open up the bikeshed painting
> session.
> > >
> > > I would propose that you reuse "= delete" like this:
> > >
> > > class T = delete : private B { };
> > >
> > > The point of is that it it more logical to use "= delete" than
> "explicit" to
> > > state that all defaulted members are deleted.
> >
> > This would make a forward declaration look misleading, wouldn't it?
> >
> > class T = delete;
>
> I would expect a forward declaration to read
>
> class T;
>
> regardless of explicitness - is there any reason to distinguish explicit
> classes in forward declarations?
>
> /MF
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>


-- 
Be seeing you,
Tony

Received on 2019-11-13 13:08:37