[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: auto_ptr ? (was Re: I'm back)

Peter Burns wrote:

>What about auto_ptr? I keep reading that if you use exceptions, then you
>probably should be using auto_ptr to prevent resource leaks. I remember
>auto_ptr commented out in the last <memory> header I saw for linux. The
>around it said this had been done because  it hadn't been properly
>Does anybody know if it has been standardised? It would be nice to be able
>to use it.

It's in the C++ standard, yes. I guess it will be in libstdc++ 3 which will
AFAIK come with gcc 3.

>Since some versions of the STL may not have it perhaps it would be good to
>an implementation of it in our distribution.

auto_ptr is relatively simple, at least compared to other STL classes. But
it's nevertheless a tricky thing I think...

>Has anybody had any experience using auto_ptr? Is it worth using? Is there

You don't have to care about freeing the memory anymore, i.e. you'll have
less memory leaks. OTOH you have to be a bit careful how you use it (e.g.
copying it, passing it to some function etc).
I'd say for most things a careful "normal" memory handling isn't that much


Drive A: not responding...Formatting C: instead