Re: [reSIProcate] compilation issues
- From: Alan Hawrylyshen <alan@xxxxxxxxxx>
- Date: Mon, 16 Aug 2004 10:42:45 -0600
On Aug 16, 2004, at 00:50, Jason Fischl wrote:
Use this instead:
std::auto_ptr<ClientAuthManager> clientAuth(new
ClientAuthManager(profile));
auto_ptr will delete whatever pointer it is wrapping when it goes out
of
scope.
Another 'gotcha' for auto_ptr objects:
Assignment transfers ownership.
Given the above clientAuth, and the following code:
std::auto_ptr<ClientAuthManager> other(clientAuth);
clientAuth no longer references the 'new ClientAuthManager', only
'other' does. This means that auto_ptr<> objects are incompatible with
STL containers (you cannot have a container of auto_ptrs since the
standard containers use the copy ctor and assignment operators to move
entries around within the container).
Alan
a l a n a t j a s o m i d o t c o m