Boost logo

Boost Users :

From: Joe Angell (joe.d.angell_at_[hidden])
Date: 2007-06-28 15:32:28


On 6/28/07, Daniel Oberhoff <daniel_at_[hidden]> wrote:
> Hi all,
>
> I am using shared_ptr to ease implementation of a matlab file
> wrapper. Esepcially the fact that it is in tr1 and thus available on
> many platforms already pushed that decision. Now I was wondering about
> one thing:
>
> Is there a devent way, using shared_ptr, to hand out multiple
> references? What I mean is something like this:
>
> class Variable {
> shared_ptr<Variable> ref();
> };
>
> The problem with shared_ptr is, that, or so it seems, you can only
> create one directly from the object like this:
>
> shared_ptr<Variable> p(new Variable(...));
>

Take a look at shared_from_this(), I believe that is what you want.
 http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html

-- 
---------------
Joe Angell
Boulder Labs, Inc.
7105 LaVista Pl
Suite 200
Niwot, CO  80503
(303) 817-8252

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