Boost logo

Boost :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2005-05-06 10:11:38


Pavel Vozenilek wrote:

>
> "Neal Becker" write:
>
>> I'm a little confused about singleton usage. Can a singleton have a
>> constructor?
>>
>> I tried this:
>>
>> using boost::basic_singleton;
>>
>> struct Example :
>> public basic_singleton<Example> {
>> Example() {
>> std::cout << "Hello\n";
>> }
>> int Cnt() const { return 0; }
>> };
>>
>> int main() {
>> Example::pointer ptr;
>> std::cout << ptr->Cnt();
>> }
>>
>> ./Test1
>> 0
>>
>> It appears constructor wasn't run, because nothing was printed.
>>
>
> I tried it with Intel 7 (plugged in VC6 IDE) and it works for me.
> What is your compiler?
>

I ran it on gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.fc3) (x86_64),
latest singelton lib (per announcement), and boost-1.32.0


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