[Qt-interest] Implicitly Shared Classes
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Sun Feb 15 23:40:20 CET 2009
> ...
> > 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
[Scott Aron Bloom]
Correct... Again, read the QT docs, but knowing most of the answer,
allows for a much easier read of the implicitly sharing docs..
QT uses a copy on write methodology.
Scott
More information about the Qt-interest-old
mailing list