Boost logo

Boost :

From: Sérgio Vale e Pace (svpace.forum_at_[hidden])
Date: 2005-02-14 09:25:01


On Mon, 14 Feb 2005 16:00:08 +0200, Peter Dimov <pdimov_at_[hidden]> wrote:
> Sérgio Vale e Pace wrote:
> > On Sun, 13 Feb 2005 19:20:07 -0500, Jason Hise <chaos_at_[hidden]>
> > wrote:
> >> I recently discovered that my singleton could potentially be used in
> >> a way other than as a base class. For example, to create and use a
> >> singleton instance of a class which could have other ordinary
> >> instances as well, one could just do:
> >>
> >> class Example
> >> {
> >> public:
> >> void foo ( )
> >> {
> >> }
> >> };
> >>
> >> // elsewhere...
> >>
> >> singleton < Example >::pointer ptr;
> >> ptr->foo ( );
> >>
> > I believe (as in "I didn´t tested it" :) that using it in this way
> > would allow multiple instances of Example? For example?
> >
> > singleton<Example>::pointer ptr;
> > Example other;
>
> This is not a problem. The designer of Example does permit such use:
>
> Example a;
> Example b;
>

Sorry for the ignorance, but then what´s the point of using the
singleton if Example is not suposed to be a singleton?


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