cleanup_scope_guard.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file cleanup_scope_guard.hpp
  9. * \author Andrey Semashev
  10. * \date 11.03.2008
  11. *
  12. * \brief This header is the Boost.Log library implementation, see the library documentation
  13. * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
  14. */
  15. #ifndef BOOST_LOG_DETAIL_CLEANUP_SCOPE_GUARD_HPP_INCLUDED_
  16. #define BOOST_LOG_DETAIL_CLEANUP_SCOPE_GUARD_HPP_INCLUDED_
  17. #include <boost/log/detail/config.hpp>
  18. #include <boost/log/detail/header.hpp>
  19. #ifdef BOOST_HAS_PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22. namespace boost {
  23. BOOST_LOG_OPEN_NAMESPACE
  24. namespace aux {
  25. //! Cleanup scope guard
  26. template< typename T >
  27. struct cleanup_guard
  28. {
  29. explicit cleanup_guard(T& obj) : m_Obj(obj) {}
  30. ~cleanup_guard() { m_Obj.clear(); }
  31. // Copying prohibited
  32. BOOST_DELETED_FUNCTION(cleanup_guard(cleanup_guard const&))
  33. BOOST_DELETED_FUNCTION(cleanup_guard& operator= (cleanup_guard const&))
  34. private:
  35. T& m_Obj;
  36. };
  37. } // namespace aux
  38. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  39. } // namespace boost
  40. #include <boost/log/detail/footer.hpp>
  41. #endif // BOOST_LOG_DETAIL_CLEANUP_SCOPE_GUARD_HPP_INCLUDED_