lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] depr.impldec


From: Vadim Zeitlin
Subject: Re: [lmi] depr.impldec
Date: Thu, 28 Jul 2022 02:29:07 +0200

On Wed, 27 Jul 2022 19:55:32 +0000 Greg Chicares <gchicares@sbcglobal.net> 
wrote:

GC> On 7/13/22 20:51, Greg Chicares wrote:
GC> [...]
GC> > I weakly favor the Rule of Zero, while you more strongly favor
GC> > the Rule of Five, so let's start with a universal Rule of Five
GC> 
GC> I've changed my opinion.
GC> 
GC> After following that path for a while, e.g.:
GC> 
GC>  6a59da54d When in doubt, prefer the Rule of Five to the Rule of Zero
GC>  4d052024d Follow the Rule of Five
GC>  702c4cddd Follow the Rule of Zero (initializing all data members in class)
GC>  7d05361b5 Follow the Rule of Zero, even expunging a virtual dtor
GC>  601db1782 Follow the Rule of Zero
GC> 
GC> I asked myself whether it seemed good to follow it all the way to the end,
GC> adding approximately five defaulted special members to every other class
GC> in lmi. Looking back over those changes, I found that I really dislike them:
GC> I see only clutter and no benefit.

 One benefit that I hadn't mentioned yet, I think, is that if you ever
define a special member in your class, e.g. decide to do something in the
default ctor, it would silently inhibit moving. This should, arguably,
happen only rarely, but I guarantee that if it does happen, it will remain
unnoticed for a long time.

GC> I've striven for "value semantics" out of aversion to the tedious
GC> labor of writing copy special member functions, in pre-C++11 days;
GC> as an unexpected reward, the move members are now free.

 Of course not defining any special members is nice, but I just don't trust
myself (and usually, although not in lmi case, the others working on the
same code) to not accidentally do something wrong if I don't explicitly
write them out.

 Also, there are many important exceptions, e.g. you still have to write
all 5 special members for any polymorphic base classes, so it's somewhat
inconsistent too.

 And brevity is the only benefit of the rule of zero that I see. And
typically we don't tend to value brevity that much, do we?

 But I'll stop here and won't return to this any more if this is your final
decision because I do believe having given all my arguments now.

 Regards,
VZ

Attachment: pgpURH3DEQHiQ.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]