< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index  

Re: [reSIProcate] compilation issues



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