Re: Singleton pattern and destruction

From: Ulrich Eckhardt (
Date: 02/05/04

Date: Thu, 05 Feb 2004 22:03:02 +0100

Erik J�evik wrote:
> However, the auto_ptr needs access to the singleton's destructor in
> order to call delete on it. But, since it's a singleton, I want the
> destructor to be protected so that no other class can call it.
> Any suggestions on how to to get around this?

Make auto_ptr<your_class> a friend?

There's other ways, too, using e.g. boost::shared_ptr<> with a custom
deleter or things like that.


Questions ?
see  C++-FAQ Lite:  first !