
However, I've always thought the better interface was via a smart pointer. Upon construction, the smart pointer would access the Singleton instance and cache it in a data member. Subsequent access via operator ->() or operator *() would use the data member, thus avoiding the overhead of the instance accessor.
I think this is unnecessary. The very simple and obvious way is access via reference, don't it?
They do access global state, but there often is global state in an application. If Singletons provide the only > means to access state, they formalize that access. Singletons can also, using policies, control lifetime, post-destruction behavior, etc.
It it really true.
Consequently, Singletons are more than a crutch, though often overused, abused, or misused.
I disagree. -- View this message in context: http://old.nabble.com/-Boost.utility--tp27309940p27324463.html Sent from the Boost - Dev mailing list archive at Nabble.com.