[Development] The future of smart pointers in Qt API

Alberto Mardegan mardy at users.sourceforge.net
Sat Feb 1 12:37:12 CET 2020


On 31/01/20 23:04, Ville Voutilainen wrote:
> On Fri, 31 Jan 2020 at 21:23, Alberto Mardegan
>>
>> I still have trouble understanding why std::unique_ptr is called like
>> this, whereas I could immediately understand what QScopedPointer does
>> even before reading its documentation.
> 
> What would you then name a Qt counterpart of std::unique_ptr, considering that
> QScopedPointer is not such a counterpart?

Do we need to have such a counterpart? In my work experience, when I'm
not allowed to use Qt and am restricted to the STL, all the times I had
to use std::unique_ptr was to get the same behaviour as a QScopedPointer.
It's true that QScopedPointer offers only a subset of std::unique_ptr's
functionalities, but, *for that subset*, its name is just perfect.
That's why I wouldn't like to see it go away, or moved to a compat library.

So, I don't really care about std::unique_ptr, but I like Vitaly's
suggestion of having a QUniquePointer with a nice data() method.

Ciao,
  Alberto

-- 
http://www.mardy.it - Geek in un lingua international


More information about the Development mailing list