[Interest] Qt::MakePointer for creating QPointer as std::make_shared for creating std::shared_ptr
Thiago Macieira
thiago.macieira at intel.com
Fri Oct 17 18:35:51 CEST 2014
On Thursday 16 October 2014 01:56:46 Mikhail Matrosov wrote:
> In modern C++ there is almost no need to use raw *new* and *delete*. As
> Bjarne Stroustrup is saying in his “A Tour of C++”: “Avoid ‘‘naked’’ new
> and delete operations; §4.2.2.”. We use standard containers and smart
> pointers for that, with std::make_shared and std::make_unique functions for
> smart pointers creation.
QPointer is the wrong class for this, since QPointer is a non-owning weak
reference.
If you want an equivalent of std::make_shared, you're looking at the
QSharedPointer class. And it already has an equivalent:
QSharedPointer<T>::create().
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list