16 Oct
2007
16 Oct
'07
8:57 p.m.
Peng Yu:
I don't think my question was completely answered. Do you means reseting shared_ptr with an array from the stack is not defined? Or it is defined and shared_ptr can figure out it is from the stack and do not delete it?
It's undefined. shared_ptr cannot figure it out automatically. If you really need to store the address of a stack object in a (short-lived) shared_ptr, you need to tell it to not call 'delete' by using a null deleter. http://boost.org/libs/smart_ptr/sp_techniques.html#static