Boost logo

Boost :

Subject: Re: [boost] [Boost.utility]
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2010-01-26 08:17:51


Andrew Chinkoff wrote:
>> Perhaps some boost::global<T> utility would be better, but a singleton
>> itself is bad practice, in my opinion. boost::global<T> would merely
>> create
>> a global access point to T:
>>
>> typedef boost::global<int> global_Int;
>> global_int.get() = 5; // getting the global int
>
> Perhaps you're right. It is a matter of taste.
> But I like to write "Object::Instance().get()" rather than
> "global_object.get()".

I've always been mystified as to why a singleton instance is accessed
via pointer rather than by reference. Singleton models a
one-and-only-one relationship a pointer models a zero-or-one
relationship. That said, in my experience singletons are generally used
as a crutch to access global state.

Jeff


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