New shared pointer
Frerich Raabe
raabe at kde.org
Fri Sep 9 23:56:28 BST 2005
On Friday 09 September 2005 20:45, Adriaan de Groot wrote:
> > Note that this new KSharedPtr is not like QSharedDataPointer because it
> > does not do copy-on-write (it doesn't automatically detach() when using
> > the non-const * and -> operators) - it features a copy() function though,
> > so you can have explicitely shared objects.
>
> Wouldn't clone() or detach() be better names? detach() in particular is
> used in the Qt explicitly shared classes.
clone() means 'return copy of object to me', it somehow lacks the 'copy which
is independant of other shared pointers' bit, but that's maybe just me.
I don't like detach() not so much, since it does not suggest that something
new is returned (i.e. 'p.detach()' would make me think that 'p' is detached,
but that's not the case - instead, a detached copy is returned). In fact, one
could probably add a 'detach()' function in addition to copy().
> I grabbed Alexandrescu's Modern C++ design, which has a whole chapter on
> smart pointers. Would that be an acceptable source of alternate code?
I bet Eva and Simon would like this, but IMHO it's totally over the edge,
doing much more than we need.
- Frerich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050909/b7826031/attachment.sig>
More information about the kde-core-devel
mailing list