
On Mon, Jun 27, 2011 at 12:59 AM, Antony Polukhin <antoshkka@gmail.com>wrote:
2011/6/27 Ben Robinson <icaretaker@gmail.com>:
The purpose of auto_ptr is to clean up the instance automatically. It was a design goal to make destruction of the Singularity explicit, especially in multi-threaded contexts. However, users can create custom ThreadingModel policies which use any kind of smart pointer they desires. I thought to provide the only a primitive pointer for the included policies.
It is a good thing, to have an explicit destructor, but we must call destructor in case, when user forgets to call destruction or when the program suddenly exits. Consider the following example:
DescriptorThatMustBeClosed & horizon = DescriptorThatMustBeClosed::create(&event); ... function_that_calls_exit(); ... DescriptorThatMustBeClosed::destroy();
Moreover, auto_ptr is primitive enough and will not make the performance worse.
[...] Forgive me as I don't know the entire context of this, but would boost::scoped_ptr be sufficient here? One would never transfer the ownership of the object referenced by std::auto_ptr, would they? - Jeff