Boost logo

Boost Users :

From: dick.bridges_at_[hidden]
Date: 2002-09-30 16:38:49


1) There are circumstances where the 'creator' should stick around as long
as one or more 'creations' still exist (e.g., a [network] session that's
created various asynchronous conversations).

2) I haven't had time to check, but I think this is the
as-yet-not-but-soon-to-be-released implementation of intrusive pointers.
Interesting: search google for "intrusive pointer" (quotes not required).
I got five hits - all of the URLs start with www.boost.org/.

BTW: Really slick. Trying to figure out where to keep "THE POINTER" was
driving me nuts. I'd completely forgotten about intrusive pointers.
Thanks. A *LOT*.

                                                                                                                                      
                      Mark Storer
                      <mstorer_at_cardiff To: "'Boost-Users_at_[hidden]'" <Boost-Users_at_[hidden]>
                      .com> cc:
                                               Subject: RE: [Boost-Users] Re: Use a shared_ptr as a 'backpointer'?
                      09/30/2002 09:36
                      AM
                      Please respond
                      to Boost-Users
                                                                                                                                      
                                                                                                                                      

I've got a comment and a question...

1) Couldn't the "backpointer" just be a constant reference? Backpointers,
in my mind, don't have anything to do with ownership, so a shared_ptr
woulnd't be appropriate.

2) shared_from_this?
             I can't find that one in any of the headers or docs I
downloaded
with 1.28. I did find shared_count in (oddly enough) shared_count.hpp,
which looks like it would prevent two seperate shared_ptr's from causing a
double-delete... pretty slick, but I couldn't find any docs on it.

--Mark Storer
  Software Engineer
  Cardiff Software

#include <disclaimer>
typedef std::disclaimer<Cardiff> Discard;

-----Original Message-----
From: David Abrahams [mailto:yg-boost-users_at_[hidden]]
Sent: Sunday, September 29, 2002 4:12 PM
To: boost-users_at_[hidden]
Subject: [Boost-Users] Re: Use a shared_ptr as a 'backpointer'?

<dick.bridges_at_[hidden]> wrote in message
news:OF699D7956.EED22A4F-ON88256C43.00722AD0_at_tais.net...
> I run into situations where it's useful for an object to have a
> 'backpointer' to the object instance that created it (example below). Is
> there a pattern/idiom for doing this using shared_ptr? Or maybe I need
to
> re-think the idea of the backpointer in the first place?
>

class Bar;

class Foo
{
 public:
    Foo(shared_ptr<Bar>);

 private:
    shared_ptr<Bar> p;
};

class Bar : boost::shared_count
{
    void doit()
    {
         new Foo(boost::shared_from_this(this)); // <<< new Foo(this)
obviously won't work.
    }
};

HTH,
Dave

--
-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com
Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net