Boost logo

Boost :

From: Gennadiy E. Rozental (rogeeff_at_[hidden])
Date: 2001-11-15 20:20:56


--- In boost_at_y..., Thomas Matelich <toms-mailing-lists_at_h...> wrote:
> Peter Dimov wrote:
>
> > > In
> > > that respect, this code clearly communicates that "A isa
singleton":
> > >
> > > class A : public singleton<A> {
> > > /* ... */
> > > };
> >
> > Is this a library interface? If it is, why do you need the class
name at
> > all? You know that there is a single instance of A.
> >
> > Instead of
> >
> > class A: public /* public? */ singleton<A>
> > {
> > void f();
> > };
> >
> > A::instance().f();
> >
> > why not simply
> >
> > namespace A
> > {
> > void f();
> > }
> >
> > f();
>
> Funny you should mention this. We (my coworkers and I) have been
pretty bad about
> using too many singletons, and I recently rewrote one of them like
that. I just might
> be hooked. I'm getting really tired of A::Instance() especially
since A is usually
> something like ProcedureManager.

Maybe you just need Monostate pattern mentioned in one of previos
postings instead of Singleton?

Gennadiy.

>
> --
> Thomas O Matelich
> Senior Software Designer
> Zetec, Inc.
> matelich_at_h...
> tmatelich_at_z...


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