local_free_on_destruction.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // local_free_on_exit.hpp ------------------------------------------------------------//
  2. // Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  3. // Copyright (c) 2010 Beman Dawes
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // See http://www.boost.org/LICENSE_1_0.txt
  6. // This is derived from boost/asio/detail/local_free_on_block_exit.hpp to avoid
  7. // a dependency on asio. Thanks to Chris Kohlhoff for pointing it out.
  8. #ifndef BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP
  9. #define BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP
  10. #include <boost/winapi/local_memory.hpp>
  11. namespace boost {
  12. namespace system {
  13. namespace detail {
  14. class local_free_on_destruction
  15. {
  16. public:
  17. explicit local_free_on_destruction(void* p)
  18. : p_(p) {}
  19. ~local_free_on_destruction()
  20. {
  21. boost::winapi::LocalFree(p_);
  22. }
  23. private:
  24. void* p_;
  25. local_free_on_destruction(const local_free_on_destruction&); // = deleted
  26. local_free_on_destruction& operator=(const local_free_on_destruction&); // = deleted
  27. };
  28. } // namespace detail
  29. } // namespace system
  30. } // namespace boost
  31. #endif // BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP