memory.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2011-2013 Vicente J. Botet Escriba
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // See http://www.boost.org/libs/thread for documentation.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. #ifndef BOOST_THREAD_DETAIL_MEMORY_HPP
  12. #define BOOST_THREAD_DETAIL_MEMORY_HPP
  13. #include <boost/config.hpp>
  14. #include <boost/thread/csbl/memory/pointer_traits.hpp>
  15. #include <boost/thread/csbl/memory/allocator_arg.hpp>
  16. #include <boost/thread/csbl/memory/allocator_traits.hpp>
  17. #include <boost/thread/csbl/memory/scoped_allocator.hpp>
  18. namespace boost
  19. {
  20. namespace thread_detail
  21. {
  22. template <class _Alloc>
  23. class allocator_destructor
  24. {
  25. typedef csbl::allocator_traits<_Alloc> alloc_traits;
  26. public:
  27. typedef typename alloc_traits::pointer pointer;
  28. typedef typename alloc_traits::size_type size_type;
  29. private:
  30. _Alloc alloc_;
  31. size_type s_;
  32. public:
  33. allocator_destructor(_Alloc& a, size_type s)BOOST_NOEXCEPT
  34. : alloc_(a), s_(s)
  35. {}
  36. void operator()(pointer p)BOOST_NOEXCEPT
  37. {
  38. alloc_traits::destroy(alloc_, p);
  39. alloc_traits::deallocate(alloc_, p, s_);
  40. }
  41. };
  42. } //namespace thread_detail
  43. }
  44. #endif // BOOST_THREAD_DETAIL_MEMORY_HPP