|
Boost Users : |
From: Peter Petrov (ppetrov_at_[hidden])
Date: 2006-01-08 06:00:44
Serge Skorokhodov wrote:
> Pooyan McSporran wrote:
>> void test (MemoryPtr m) {
>> m -> remember1 (FooPtr (this));
>
> Definetely a misuse. A poiner to a "newed" object or another
> shared_ptr must be passed to share_ptr ctor. Actually, you are
> baypassing reference counting here. "this" is neither:( Try this:
>
> void test ( MemoryPtr m, FooPtr f )
> {
> m->remember1( f );
> }
Or alternatively, you could use enable_shared_from_this (which is the
"standard" way to construct a shared_ptr from a "this" pointer).
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