Boost logo

Boost :

From: Fisher; Damien Kaine (dfisher_at_[hidden])
Date: 2001-10-18 01:07:56


On Wed, 17 Oct 2001, Greg Colvin wrote:

> class foo {
> public:
> foo(): m_self(this) { std::cout << "foo constructor\n"; }
> ~foo() { std::cout << "foo destructor\n"; }
> void suicide() { m_self.reset(0); }
> private:
> boost::shared_ptr<foo> m_self;
> };

Is m_self(this) legal? You are passing in a pointer to an object which
has not yet been fully constructed. I am too sure whether that is
appropriate or not, even though boost::shared_ptr doesn't really "use" the
pointer.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk