[Qt-interest] Implicitly Shared Classes

Tom Browder tom.browder at gmail.com
Sun Feb 15 20:01:54 CET 2009


On Sun, Feb 15, 2009 at 12:04 PM, Scott Aron Bloom
<Scott.Bloom at sabgroup.com> wrote:
...
> However, in general, when using implicitly shared, your case 1, passes
> back a "wrapper class" of a shared pointer with a reference of 1.  Then
> the copy constructor is called, and a new wrapper class is created, but
> the shared pointer is copied (not a deep copy) and the reference count
> is increased to 2, when the call to foo exits and m is destroyed, the
> reference count is decreased back to 1.  Since no write was requested to
> the shared pointed while its reference was > 1, no copying of the data
> was done.

Thanks, Scott.

And so I assume that, in case 1, M is then the only owner of the data,
thus the data will never have to be copied unless the value of M is
assigned to another container and one of the two then does something
to change the container contents, correct?

-Tom



More information about the Qt-interest-old mailing list