|
Boost : |
From: Thomas Witt (witt_at_[hidden])
Date: 2002-09-21 10:26:50
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Saturday 21 September 2002 16:52, David Abrahams wrote:
> I just remembered why it seemed so strange to implicitly limit the source
> pointer to 'this': I once needed the facility, but wouldn't have used it
> that way. The use case is simple. I was building a hierarchical GUI
> framework where parents owned their children (with shared pointers), and
> each child had raw parent back-pointers. It would've been nice to be able
> to return a shared_ptr to the parent in the external interface. Of course,
> we didn't have weak_ptr when I was doing that - I suppose weak_ptr would
> have been a superior interface.
I was dealing with a similar scheme recently. I discovered what I think is
another big advantage of weak_ptr<T>, T the backpointer does not have to be
an complete type when generating shared_ptr<T>. Unfortunately you cannot
initialize waek_ptr<T> back pointers during T construction. So choose your
poison.
- --Thomas
- --
Dipl.-Ing. Thomas Witt
Institut fuer Verkehrswesen, Eisenbahnbau und -betrieb, Universitaet Hannover
voice: +49(0) 511 762 - 4273, fax: +49(0) 511 762-3001
http://www.ive.uni-hannover.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9jI++0ds/gS3XsBoRAn1yAJ4iSay/HFEJGjaWrTd5K5sdGWFfkgCeJ92f
Ms7us0kVmiRXct/HDgwnsNc=
=XNy7
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk