From: "Brian"
--- In Boost-Users@y..., "Peter Dimov" wrote:
...
Yes, shared_ptr will call the destructor. It only requires a
complete type
at construction time.
Hmmm... we tried using shared_ptr today and our destructors were
still not called. This is with C++ Builder 5.5. I am now trying to
see if another department has a copy of 6.0 we could try.
What version of boost? Can you post a minimal example? It works here:
testbed.cpp:
#include
class X;
boost::shared_ptr<X> create();
int main()
{
boost::shared_ptr<X> px = create();
}
testbed2.cpp:
#include
#include <iostream>
class X
{
public:
X()
{
std::cout << "X::X()\n";
}
~X()
{
std::cout << "~X::X()\n";
}
private:
X(X const &);
X & operator= (X const &);
};
boost::shared_ptr<X> create()
{
boost::shared_ptr<X> px(new X);
return px;
}
Output:
C:\Documents and Settings\pdimov\My Documents\Projects\testbed>bcc32 -v
testbed.cpp testbed2.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
testbed.cpp:
testbed2.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
C:\Documents and Settings\pdimov\My Documents\Projects\testbed>testbed
X::X()
~X::X()