Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-02-14 09:00:08


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;


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