memory.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // detail/memory.hpp
  3. // ~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_DETAIL_MEMORY_HPP
  11. #define BOOST_ASIO_DETAIL_MEMORY_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <memory>
  17. #if !defined(BOOST_ASIO_HAS_STD_SHARED_PTR)
  18. # include <boost/shared_ptr.hpp>
  19. # include <boost/weak_ptr.hpp>
  20. #endif // !defined(BOOST_ASIO_HAS_STD_SHARED_PTR)
  21. #if !defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
  22. # include <boost/utility/addressof.hpp>
  23. #endif // !defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
  24. namespace boost {
  25. namespace asio {
  26. namespace detail {
  27. #if defined(BOOST_ASIO_HAS_STD_SHARED_PTR)
  28. using std::shared_ptr;
  29. using std::weak_ptr;
  30. #else // defined(BOOST_ASIO_HAS_STD_SHARED_PTR)
  31. using boost::shared_ptr;
  32. using boost::weak_ptr;
  33. #endif // defined(BOOST_ASIO_HAS_STD_SHARED_PTR)
  34. #if defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
  35. using std::addressof;
  36. #else // defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
  37. using boost::addressof;
  38. #endif // defined(BOOST_ASIO_HAS_STD_ADDRESSOF)
  39. } // namespace detail
  40. #if defined(BOOST_ASIO_HAS_CXX11_ALLOCATORS)
  41. using std::allocator_arg_t;
  42. # define BOOST_ASIO_USES_ALLOCATOR(t) \
  43. namespace std { \
  44. template <typename Allocator> \
  45. struct uses_allocator<t, Allocator> : true_type {}; \
  46. } \
  47. /**/
  48. # define BOOST_ASIO_REBIND_ALLOC(alloc, t) \
  49. typename std::allocator_traits<alloc>::template rebind_alloc<t>
  50. /**/
  51. #else // defined(BOOST_ASIO_HAS_CXX11_ALLOCATORS)
  52. struct allocator_arg_t {};
  53. # define BOOST_ASIO_USES_ALLOCATOR(t)
  54. # define BOOST_ASIO_REBIND_ALLOC(alloc, t) \
  55. typename alloc::template rebind<t>::other
  56. /**/
  57. #endif // defined(BOOST_ASIO_HAS_CXX11_ALLOCATORS)
  58. } // namespace asio
  59. } // namespace boost
  60. #endif // BOOST_ASIO_DETAIL_MEMORY_HPP