Boost logo

Boost Users :

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


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

> How do you prevent people from instantiating Object (in your example)?
>
> Also, I was more or less looking for a member-specific way of doing the
> singleton access. For example:
>
> Object::instance()

You can do something like:

struct Object
{
  friend class singleton<Object>;
  Object& instance()
  {
    return singleton<Object>::instance();
  }

  private:
    Object(); ~Object();
};

I'm sure there is a nicer way to wrap that up.

-- 
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