On 29.10.25 16:27, André Somers via Development wrote: >> · Add a QObject::addChild(std::unique_ptr child) > > Start simple, I would suggest. Do you really think that this will bring > a lot of value?
Every function that transfers ownership as a raw pointer is worth being replaced by one taking/returning by unique_ptr. Let the API enforce ownership transfer instead of letting the reader of the code guess. > Introduce the basic version, see how it actually impacts > your code base and collect feedback, and then see if an overload like > this really would bring value. One problem I see is that, AFAIK, a > std::unique_ptr is a distinct type from a > std::unique_ptr, so the signature above > won't work. Something _like_ this can of course be done, using a > template and casting, but it won't be as pretty. As you notied, std::unique_ptr implicitly converts into a std::unique_ptr<s> is T* implicitly converts to S*. -- Marc Mutz (he/his) Principal Software Engineer The Qt Company Erich-Thilo-Str. 10 12489 Berlin, Germany www.qt.io Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B </s> -- Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
