lmi
[Top][All Lists]
Advanced

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

Re: [lmi] PATCH: Building lmi with gcc 10 and C++20


From: Vadim Zeitlin
Subject: Re: [lmi] PATCH: Building lmi with gcc 10 and C++20
Date: Thu, 14 May 2020 23:47:54 +0200

On Thu, 14 May 2020 21:39:27 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2020-05-10 22:12, Vadim Zeitlin wrote:
GC> [...]
GC> > - pdf_command_wx.cpp:2458:53: error: implicit capture of ‘this’ via ‘[=]’ 
is deprecated in C++20 [-Werror=deprecated]
GC> >  2458 |         auto const output_two_column_super_header = [=,&table_gen]
GC> >       |                                                     ^
GC> >   pdf_command_wx.cpp:2458:53: note: add explicit ‘this’ or ‘*this’ capture
GC> > 
GC> >   Here I've followed the compiler advice by capturing "this" (we don't 
want
GC> >   to make a copy of this object by capturing "*this") and also getting rid
GC> >   of the implicit capture mode and capturing everything we need 
explicitly.
GC> 
GC> Capturing everything we need explicitly does have a certain charm,
GC> albeit with a countervailing increase in verbosity:
GC> 
GC> -        auto const output_two_column_super_header = [=,&table_gen]
GC> +        auto const output_two_column_super_header = 
[this,pos_y,output_mode,z,&table_gen]

 Yes, this is why I had used implicit capture in the first place. I could
be over cautious, but I tend to avoid implicit capture as it's a bit too
magic (although definitely very convenient). I also wonder if it's not a
code smell when a lambda needs to capture too many things, but I don't have
enough experience with using lambdas yet to be really sure about it.

GC> so, when I began reading
GC>   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0806r2.html
GC> I wondered why you didn't choose the elegant "[=, this]" alternative
GC> (and why I hadn't encountered that syntax before). Then I read the last
GC> sentence of the paper:
GC> 
GC> | The replacement [=, this] for the deprecated [=] is ill-formed in C++17
GC> | and only available in C++20 as of P0409R2.
GC> 
GC> and was enlightened. It's probably not worth writing a preprocessor
GC> conditional here.

 Yes, exactly.

GC> Aside from that, I had no comments or questions concerning this
GC> patchset. Thanks for doing all this work.

 Thanks for merging it so quickly!
VZ

Attachment: pgpaNL1ehDYta.pgp
Description: PGP signature


reply via email to

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