[Top][All Lists]

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

Re: [lmi] Various C++ m12ns

From: Vadim Zeitlin
Subject: Re: [lmi] Various C++ m12ns
Date: Tue, 7 Mar 2017 18:24:22 +0100

On Tue, 7 Mar 2017 01:01:33 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2017-03-06 22:49, Vadim Zeitlin wrote:
GC> > On Mon, 6 Mar 2017 22:28:53 +0000 Greg Chicares <address@hidden> wrote:
GC> > 
GC> > [...discussion of replacing lmi::uncopyable<> with "= delete" snipped...]
GC> > 
GC> > GC> Let's see if we can write a guideline for this....
GC> > 
GC> >  I did try to do this already earlier today, let me repost the link I had
GC> > posted in the "Define special member functions inline?" thread:
GC> > 
GC> >   https://gist.github.com/vadz/3222ef957769f3a9415caa799113d640
GC> > 
GC> > The relevant guideline is at the bottom.
GC> Par ma foi, il y a plus de vingt ans que je dis des X macros,
GC> sans que j'en susse rien.

 How interesting then that you use .xpp extension for the files containing
them without knowing how they were called (unless I've misunderstood the
double negation?). FWIW I don't think the name X-Macros is that widespread
but I did hear it in a few different contexts/places, even though the first
mention of it I saw also significantly postdated my first use of this
technique. But it's nice to know how the things you do are called, isn't
it? I'm sure there must be some word for this too, but I don't know it

GC> > GC> Already I have a question about the guideline. Would you also
GC> > GC> always declare a destructor, with '= default' by default?
GC> > 
GC> >  This is really the edge case, isn't it. I ended up by including the dtor
GC> > in my guideline at the link above too, but I'm not sure about it. On one
GC> > hand, it's consistent with the other special member functions. OTOH, a
GC> > non-default dtor should be very rarely needed in modern C++ code, where 
GC> > resources should be handled by the wrapper classes, so it seems
GC> > unnecessarily verbose to write "~X() = default" everywhere. Maybe it would
GC> > be better to omit it...
GC> I tend to think it's better to omit it.

 OK, I'll update my Markdown file accordingly.

GC> Still, I'll state a possible argument in favor of writing it always: that it
GC> compels the author to make an explicit choice between virtual and 
GC> (I'm not moved by that argument. The absence of a virtual dtor says enough.)

 FWIW I agree.

GC> >  OTOH I'm definitely for extending the same treatment to the default ctor,
GC> > i.e. writing "X() = default", even if it's unnecessary, because it
GC> > immediately shows that the class is default constructible, which might not
GC> > be obvious otherwise
GC> Or, similarly, writing "X() = delete;"? (I don't think I'd advocate that,
GC> because it's obvious by its absence.)

 Yes, I agree again.

 Luckily, the email ends before I could agree thrice in a row again in the
span of 2 days,

reply via email to

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