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 { });
  }

(This is just an example. In reality, ptr would manage something non-trivial.)

It's useful to have the lambda take ownership of ptr, but currently that's not possible and we have to resort to shared_ptr. (Which is not the end of the world, but still.)

Is this a problem the Qt project is aware of and the design is intended, or is this something that can be considered a defect?

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to