C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] explicit class
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-11-13 04:01:26


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;


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

Standard Proposals Archives on Google Groups