Boost logo

Boost Users :

From: Sohail Somani (sohail_at_[hidden])
Date: 2007-12-05 16:26:22


On Wed, 05 Dec 2007 15:15:19 -0600, Robert Dailey wrote:

> Hi,
>
> I was wondering if the boost library had a class that I could derive my
> classes from to declare a singleton. For example:

Hi,

At the bottom of

http://uint32t.blogspot.com/2007/12/you-lazy-bastard-part-1.html

there is a simple class that I've used. The usage would look something
like:

struct Object {...};

// returns Object &, lazily-initialized and threadsafe
singleton<Object>::instance();

It requires Boost Threads to be threadsafe. I apologize in advance for
the language, but didn't think it could possibly be useful :-)

I also recently came to know that there is something in the Boost Vault
under the X-files folder.

Let me know if you have any questions.

-- 
Sohail Somani
http://uint32t.blogspot.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net