On 6/28/07, Daniel Oberhoff
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