On Wednesday, 18 January 2023 14:36:08 PST Hamish Moffatt via Interest wrote: > Is there any reason why QScopedPointer doesn't have a create static > method, like QSharedPointer does?
Because there's no benefit. QSharedPointer::create, like std::make_shared, makes a single allocation of both the data block and the control block. QScopedPointer has no control block, so there's only one allocation to begin with. Therefore, there's no benefit of having said function. That's probably also why C++11 forgot std::make_unique, though that was added in C++14. And unlike std::unique_ptr, QScopedPointer is not movable, so you can't write auto ptr = QScopedPointer<Foo>::create(args); > I didn't see any requests for it in jira. Should I just use unique_ptr > instead? Yes. QScopedPointer is not being developed any more and is there only for compatibility. std::unique_ptr is superior to it in every aspect. -- Thiago Macieira - thiago.macieira (AT) intel.com Cloud Software Architect - Intel DCAI Cloud Engineering
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest