Say I have the following:
std::unique_ptr<A> pA;
pA(new A);
In this convoluted example, what should the behavior of pA(new A); be?
As far as I can tell, in MSVC2010, void operator()(T*) const; from default_delete is called right after new returns and deletes the pointer right away. Whereas g++(4.7.0) gave me no match for call (std::unique_ptr<A>)(A*) error.
The code should not compile.
std::unique_ptrdoes not overloadoperator().The Visual C++ 2011 Developer Preview rightly rejects the code. Visual C++ 2010 only accepts the code due to a bug in its
std::unique_ptrimplementation.