|
Boost : |
From: Alan Griffiths (alan_at_[hidden])
Date: 2000-03-31 15:00:00
In message <38E2303A.DF5932B1_at_[hidden]>, Thomas Matelich
<tmatelich_at_[hidden]> writes
>This probably applies to all of the smart pointers, I just haven't used
>them. My problem is that I'm replacing some dumb pointers with
>shared_ptr and now, I can't use forward references in my headers.
[...]
>
>The error involves deletion of incomplete type. Oops just noticed that
>its a warning. In any case, I would like to avoid the warning. What
>have other people done with regards to this?
You are right to worry - unless the type has a trivial destructor you
have "undefined behaviour". There are ways to implement smart pointers
that work with incomplete types - for one approach see:
http://www.octopull.demon.co.uk/arglib/TheGrin.html
As a user of the boots pointers you must place any code that copies or
destroys the shared_ptr instances where the type is complete.
(Typically implementing copy construction, assignment and destructor in
the .cp file.)
-- Alan Griffiths (alan_at_[hidden]) http://www.octopull.demon.co.uk/ ACCU Chairman (chair_at_[hidden]) http://www.accu.org/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk