null_deleter.qbk 863 B

12345678910111213141516171819202122232425262728293031323334
  1. [/
  2. / Copyright (c) 2014 Andrey Semashev
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section:null_deleter null_deleter]
  8. [simplesect Authors]
  9. * Andrey Semashev
  10. [endsimplesect]
  11. [section Header <boost/core/null_deleter.hpp>]
  12. The header `<boost/core/null_deleter.hpp>` defines the `boost::null_deleter` function object,
  13. which can be used as a deleter with smart pointers such as `unique_ptr` or `shared_ptr`. The
  14. deleter doesn't do anything with the pointer provided upon deallocation, which makes it useful
  15. when the pointed object is deallocated elsewhere.
  16. [section Example]
  17. ``
  18. std::shared_ptr< std::ostream > make_stream()
  19. {
  20. return std::shared_ptr< std::ostream >(&std::cout, boost::null_deleter());
  21. }
  22. ``
  23. [endsect]
  24. [endsect]
  25. [endsect]