Consider the following code:
std::auto_ptr<std::string> p;
if (p.get() == 0) {
...
}
Is the get()
member function a standard and reliable way for checking that p
has not been initialized? Will it always return 0, irrespective of the platform, compiler, compiler's optimization flags, etc.?
auto_ptr
is not "uninitialized". The default constructor initializes the pointer to a null pointer. – Autogenous