...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The header <boost/core/null_deleter.hpp>
defines the boost::null_deleter
function object, which can
be used as a deleter with smart pointers such as unique_ptr
or shared_ptr
. The deleter
doesn't do anything with the pointer provided upon deallocation, which makes
it useful when the pointed object is deallocated elsewhere.
std::shared_ptr< std::ostream > make_stream() { return std::shared_ptr< std::ostream >(&std::cout, boost::null_deleter()); }