[Development] unique_ptr vs. QSharedPointer

Shawn Rutledge Shawn.Rutledge at qt.io
Tue May 3 16:19:00 CEST 2016


> On 3 May 2016, at 13:31, Marc Mutz <marc.mutz at kdab.com> wrote:
> 
> On Tuesday 03 May 2016 13:14:05 Shawn Rutledge wrote:
>> In what ways are they different?
> 
> One implements unique ownership, isn't copyable, only movable, has almost zero 
> overhead (with a stateless deleter), and is standardised from C++11 on, the 
> other implements shared ownership, is copyable and movable, has the overhead 
> of a separate control block, and is Qt-specific.

OK.

But a function could return a unique_ptr, right? the caller of that function would then be restricted from doing anything that results in a copy?

>> Is it OK to use unique_ptr in public API starting in 5.7?
> 
> No.

Because of the convention that we return only Qt data structures, never STL ones? or because we’re not sure if all compilers support unique_ptr?  Or something else?



More information about the Development mailing list