benben schreef:
You can't blame memory leakage as programmer laziness. Memory leak is common
place in lots of systems and just by putting deletes over the places won't
completely solve the problem. Things like multiple owner ship, exceptions,
order of destruction all add to the complexity of eliminating memory leak.
No they don't. Multiple ownership: use a boost::shared_ptr (also in
TR1)
Exceptions: use any smart pointer (even std::auto_ptr). Order of
destruction:
not sure what exactly you mean, but boost::shared_ptr can solve the
order issues I'm aware of. Cyclic dependencies are still a reason for
attention then, but one can simply reset an owning shared_ptr and thus
break a cycle in a controlled fashion.
I see automatic garbage collection as a way to free programmers from memory
management tasks in general, as opposed to dealing just with memory leaks.
But it is not the only workable strategy.
Apparently, it's useful in some lambda constructs when passing
temporary
constructs around. Their types ideally are locally defined so one can't
have smart pointers to them. In all fairness, this is still esoteric
C++
HTH,
Michiel Salters