In article <e0**********@inews.gazeta.pl>,
Rafa©© Maj Raf256 <us*******************@raf256.com.invalid> wrote:
How can I manually (other then
http://www.boost.org/libs/smart_ptr/...from_this.html)
create a shared, and a weak pointer to "this"?
Of course I dont want the shared / weak pointer to cause object to be
deleted when shared/weak ptr will go out of scope.
That's the major problem with shaired pointers IMO. I have a class that
doesn't have this problem. I store the reference counts in a map<void*,
int>
That way, both pointer objects in the code below increment the same
reference count.
class MyClass {
public:
void doThis() {
Ptr<MyClass> p( this );
// ...
}
};
void func( Ptr<MyClass> foo ) {
foo->doThis();
}
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.