[Interest] connect() is copying lambdas - can this be avoided?

Thiago Macieira thiago.macieira at intel.com
Thu Aug 10 00:05:09 CEST 2017

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

More information about the Interest mailing list