[Interest] QExplictlySharedDataPointer vs QSharedPointer

Elvis Stansvik elvstone at gmail.com
Thu Sep 8 21:09:13 CEST 2016


2016-09-08 20:33 GMT+02:00 Thiago Macieira <thiago.macieira at intel.com>:
> On quinta-feira, 8 de setembro de 2016 19:13:44 PDT Elvis Stansvik wrote:
>> Hm, okay. Perhaps a dumb question, but what are the consequences
>> internal vs external refcounting for me as a user of these classes?
>> Reading the docs for both of them, both seem to have a thread-safe
>> refcounting mechanism.
>
> The difference is, quite literally, where the reference counter lives.
>
> If it's inside the object whose lifetime it controls, then the reference
> counter cannot outlive the object itself. That means an internal reference
> counting cannot have QWeakPointer. If the reference count lives outside of the
> object, then QWeakPointer is possible.
>
> Also, for the reference counter to live inside the object, the class needs to
> have been designed with that in mind.

Ah, of course. Thanks.

Elvis

>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list