Boost logo

Boost :

Subject: Re: [boost] Is there interest in an alternative to the Singleton anti-pattern?
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-06-27 12:10:08


On Mon, Jun 27, 2011 at 12:59 AM, Antony Polukhin <antoshkka_at_[hidden]>wrote:

> 2011/6/27 Ben Robinson <icaretaker_at_[hidden]>:
> > 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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk