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