
27 Feb
2009
27 Feb
'09
2:50 p.m.
Achilleas Margaritis wrote:
Hi Achilleas.
Could you explain why this should work?
The idea is this the following:
An object is deleted if all the ptrs that point to it expired.
This statement contradicts with
When a ptr releases an object, it checks if the object has any other ptrs with age older than the ptr. If not so, then it means the released ptr is the oldest one, and therefore the object should be deleted.
If the last one is correct, the idea seems equal to the following: int* new_ptr; { std::auto_ptr<int> oldest(new int(42)); new_ptr = oldest.get(); } *new_ptr = 43; // boom