Subject: Re: [boost] Is there interest in an alternative to the Singleton anti-pattern?
From: Ben Robinson (icaretaker_at_[hidden])
Date: 2011-06-28 03:29:27
On Mon, Jun 27, 2011 at 10:53 AM, Antony Polukhin <antoshkka_at_[hidden]>wrote:
> 2011/6/27 Jeffrey Lee Hellrung, Jr. <jeffrey.hellrung_at_[hidden]>:
> > 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?
> Yes, you are right. boost::scoped_ptr will suit better. Thank you.
> Antony and Jeffrey,
An improved version of Singularity is now available at
I have reimplemented Singularity using the scoped_ptr<T>. After further
research, I am convinced the volatile keyword was useless, given that all
accesses to the shared pointer were fenced by acquisition of a boost::mutex.
This greatly simplifies the implementation.
Also, should the user fail to call Singularity<T>::destroy(), the destructor
for the instance of T will be called when the program exits, as this is when
the static scoped_ptr<T> goes out of scope.
Ben Robinson, Ph.D.
> Antony Polukhin
> Unsubscribe & other changes: