
6 May
2005
6 May
'05
3:11 p.m.
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