[Interest] connect() is copying lambdas - can this be avoided?
Jean-Michaël Celerier
jeanmichael.celerier at gmail.com
Thu Aug 10 10:47:39 CEST 2017
By moving it instead ?
-------
Jean-Michaël Celerier
http://www.jcelerier.name
On Thu, Aug 10, 2017 at 12:05 AM, Thiago Macieira <thiago.macieira at intel.com
> wrote:
> On quarta-feira, 9 de agosto de 2017 08:04:16 PDT Nikos Chantziaras wrote:
> > It seems that connect() is copying its lambda parameter around. That
> > means that if a lambda capture contains a non-copyable object, like a
> > unique_ptr, connect() cannot be used:
> >
> > {
> > auto ptr = std::make_unique<int>(0);
> > connect(this, &MyQObject::mySignal,
> > [ptr = std::move(ptr)]() mutable { });
> > }
>
> How do you propose we keep the connection alive after the scope ends, if we
> don't copy the lambda?
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170810/56f0a422/attachment.html>
More information about the Interest
mailing list