This is just a VC6 bug. VC6 is very buggy. You can use std :: auto_ptr <> as a workaround.
#include <memory>
class X
{
friend std::auto_ptr<X>;
public:
static X& instance()
{
static std::auto_ptr<X> database(new X);
return *database;
}
.....
};
And please move the instance () implementation to the cpp file. Unfortunately, I do not remember the exact case, but there is another VC6 error with the implementation of singleton in the header files. A few years ago, we had several crashes when using VC6. The fix was to move instance () implmenetation to cpp.
source
share