Tag Archives: c++0x

std::unique_ptr semantics

Probably the best feature introduced by C++11 is std::unique_ptr. It will automagically make sure your dynamically allocated objects are deleted when you don’t use them anymore. In previous versions of C++, you needed to rely exclusively on documentation and conventions to ensure dynamically allocated memory was handled properly. With C++11, you can ask the compiler […]

How to get confused by VC++

Today, I came across a confusing compilation error with MS VC++ using a std::unique_ptr with a custom deleter. Here the code snippet:

The compiler complains : 12345678910111213c:\program files (x86)\microsoft visual studio 10.0\vc\include\memory(2218): error C2338: unique_ptr constructed with null deleter pointer 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\memory(2214) : while compiling class template member function […]