Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-21 09:52:55


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. In fact, I'm guessing that's really the
argument for using 'this' in the name: it would be silly to have objects
contain weak_ptrs to themselves, but everybody else that wants to point at
the object without keeping it alive should be using weak_ptr.

If I got that right, maybe we should say something like that in the docs.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk