Boost logo

Boost :

From: Thomas Witt (witt_at_[hidden])
Date: 2002-09-21 10:26:50

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

- --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
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see


Boost list run by bdawes at, gregod at, cpdaniel at, john at