[Development] The future of smart pointers in Qt API

Allan Sandfeld Jensen kde at carewolf.com
Sat Feb 1 13:31:31 CET 2020


On Samstag, 1. Februar 2020 10:15:02 CET you wrote:
> Il 01/02/20 09:27, Allan Sandfeld Jensen ha scritto:
> > To me the name is still perfect. It makes perfect sense. Just because it
> > is
> > movable doesn't mean you move the object itself, a move moves the content
> > of the object. So each move triggers a move of the payload of a scoped
> > pointer to another scoped pointer in another scope.
> > 
> > I never understood why anyone would think the name would make that
> > impossible.
> The counter argument is: it would imply that the _pointer_ escapes the
> _scope_.
> 
Not the smart pointer, it never leaves. Only the raw pointer does, and only 
because you have moved it out of the scoped pointer, and it into a new one.

> This conversation is 9 years too old -- the ship has sailed.
> std::unique_ptr is the vocabulary type that is on every C++ book
> teaches, every C++ talk explains, every C++ project uses (all over the
> place inside Qt itself). Unless some extraordinary argument appears,
> that's the name that Qt should also use.

It is still a terrible name. Unique pointer refers to something 
std::unique_ptr can abstractly achieve, but not what it actually is.

Note I am not saying we should duplicate std::unique_ptr. I would prefer we 
didn't. But if we did we should use a better name.

'Allan





More information about the Development mailing list