Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-03-02 13:13:28


The follow little example illustrates an issue I have with scoped_ptr. I
would like to use this to automatically manage destruction of a pointer to
and undefined class. It seems that scope_ptr is instantiating its
destructor "too early" and complaining about incomplete type for b;

In my view, this should not occur as ~a() isn't defined yet.

The following example fails on vc 7.1 and gcc 3.2

Note that shared_ptr works as one would hope in this context. Is there
anyway to adjust scoped_ptr to work here?

Robert Ramey

// in my opinion this should not fail to compile under any circumstances.

// however it seems that that the inline destructor of scoped_ptr
// requires a complete type even though the destructor is not defined.

// note: changing scoped_ptr to shared_ptr works as one would hope
// note:: changing to auto_ptr still fails in with the same problem

#include <boost/scoped_ptr.hpp>

struct b;

struct a
{
        boost::scoped_ptr<b> pimpl;
        ~a();
};

int main()
{
        a a_instance;
}


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