Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
boost::scoped_ptr is a smart pointer that deletes the instance it points to when going out of scope.
boost::scoped_ptr is similar to std::auto_ptr, except that you cannot copy a boost::scoped_ptr (when you do this with std::auto_ptr, you might get behaviour you did not expected).
#include <boost/scoped_ptr.hpp> |
Smart pointers and null
Boost smart pointers check for null themselves, so there is no need to check these to be inititialized. In the example below a member variable of a class is requested from an unitialized smart pointer. The program will abort and the runtime error will be shown.
#include <boost/scoped_ptr.hpp> |
A boost::scoped_ptr can be null, but will check itself for it:
#include <boost/scoped_ptr.hpp> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.