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

Nikos Chantziaras realnc at gmail.com
Thu Aug 10 14:36:09 CEST 2017

On 10/08/17 01:05, Thiago Macieira 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?

As mentioned by the others, this seems to have already been brought up 
some months ago. Furthermore, you're the reviewer for the changes:


   Reviewed-by: Thiago Macieira <thiago.macieira at intel.com>


More information about the Interest mailing list