]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // |
2 | // detail/memory.hpp | |
3 | // ~~~~~~~~~~~~~~~~~ | |
4 | // | |
f67539c2 | 5 | // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
b32b8144 FG |
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 | ||
11 | #ifndef BOOST_ASIO_DETAIL_MEMORY_HPP | |
12 | #define BOOST_ASIO_DETAIL_MEMORY_HPP | |
13 | ||
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/asio/detail/config.hpp> | |
19 | #include <memory> | |
20 | ||
21 | #if !defined(BOOST_ASIO_HAS_STD_SHARED_PTR) | |
20effc67 | 22 | # include <boost/make_shared.hpp> |
b32b8144 FG |
23 | # include <boost/shared_ptr.hpp> |
24 | # include <boost/weak_ptr.hpp> | |
25 | #endif // !defined(BOOST_ASIO_HAS_STD_SHARED_PTR) | |
26 | ||
27 | #if !defined(BOOST_ASIO_HAS_STD_ADDRESSOF) | |
28 | # include <boost/utility/addressof.hpp> | |
29 | #endif // !defined(BOOST_ASIO_HAS_STD_ADDRESSOF) | |
30 | ||
31 | namespace boost { | |
32 | namespace asio { | |
33 | namespace detail { | |
34 | ||
35 | #if defined(BOOST_ASIO_HAS_STD_SHARED_PTR) | |
20effc67 | 36 | using std::make_shared; |
b32b8144 FG |
37 | using std::shared_ptr; |
38 | using std::weak_ptr; | |
39 | #else // defined(BOOST_ASIO_HAS_STD_SHARED_PTR) | |
20effc67 | 40 | using boost::make_shared; |
b32b8144 FG |
41 | using boost::shared_ptr; |
42 | using boost::weak_ptr; | |
43 | #endif // defined(BOOST_ASIO_HAS_STD_SHARED_PTR) | |
44 | ||
45 | #if defined(BOOST_ASIO_HAS_STD_ADDRESSOF) | |
46 | using std::addressof; | |
47 | #else // defined(BOOST_ASIO_HAS_STD_ADDRESSOF) | |
48 | using boost::addressof; | |
49 | #endif // defined(BOOST_ASIO_HAS_STD_ADDRESSOF) | |
50 | ||
51 | } // namespace detail | |
52 | ||
53 | #if defined(BOOST_ASIO_HAS_CXX11_ALLOCATORS) | |
54 | using std::allocator_arg_t; | |
55 | # define BOOST_ASIO_USES_ALLOCATOR(t) \ | |
56 | namespace std { \ | |
57 | template <typename Allocator> \ | |
58 | struct uses_allocator<t, Allocator> : true_type {}; \ | |
59 | } \ | |
60 | /**/ | |
61 | # define BOOST_ASIO_REBIND_ALLOC(alloc, t) \ | |
62 | typename std::allocator_traits<alloc>::template rebind_alloc<t> | |
63 | /**/ | |
64 | #else // defined(BOOST_ASIO_HAS_CXX11_ALLOCATORS) | |
65 | struct allocator_arg_t {}; | |
66 | # define BOOST_ASIO_USES_ALLOCATOR(t) | |
67 | # define BOOST_ASIO_REBIND_ALLOC(alloc, t) \ | |
68 | typename alloc::template rebind<t>::other | |
69 | /**/ | |
70 | #endif // defined(BOOST_ASIO_HAS_CXX11_ALLOCATORS) | |
71 | ||
72 | } // namespace asio | |
73 | } // namespace boost | |
74 | ||
75 | #endif // BOOST_ASIO_DETAIL_MEMORY_HPP |