File indexing completed on 2025-01-18 09:29:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_RECYCLING_ALLOCATOR_HPP
0012 #define BOOST_ASIO_RECYCLING_ALLOCATOR_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/recycling_allocator.hpp>
0020
0021 #include <boost/asio/detail/push_options.hpp>
0022
0023 namespace boost {
0024 namespace asio {
0025
0026
0027
0028
0029
0030
0031
0032 template <typename T>
0033 class recycling_allocator
0034 {
0035 public:
0036
0037 typedef T value_type;
0038
0039
0040 template <typename U>
0041 struct rebind
0042 {
0043
0044 typedef recycling_allocator<U> other;
0045 };
0046
0047
0048 constexpr recycling_allocator() noexcept
0049 {
0050 }
0051
0052
0053 template <typename U>
0054 constexpr recycling_allocator(
0055 const recycling_allocator<U>&) noexcept
0056 {
0057 }
0058
0059
0060 constexpr bool operator==(
0061 const recycling_allocator&) const noexcept
0062 {
0063 return true;
0064 }
0065
0066
0067 constexpr bool operator!=(
0068 const recycling_allocator&) const noexcept
0069 {
0070 return false;
0071 }
0072
0073
0074 T* allocate(std::size_t n)
0075 {
0076 return detail::recycling_allocator<T>().allocate(n);
0077 }
0078
0079
0080 void deallocate(T* p, std::size_t n)
0081 {
0082 detail::recycling_allocator<T>().deallocate(p, n);
0083 }
0084 };
0085
0086
0087
0088
0089
0090
0091
0092
0093 template <>
0094 class recycling_allocator<void>
0095 {
0096 public:
0097
0098 typedef void value_type;
0099
0100
0101 template <typename U>
0102 struct rebind
0103 {
0104
0105 typedef recycling_allocator<U> other;
0106 };
0107
0108
0109 constexpr recycling_allocator() noexcept
0110 {
0111 }
0112
0113
0114 template <typename U>
0115 constexpr recycling_allocator(
0116 const recycling_allocator<U>&) noexcept
0117 {
0118 }
0119
0120
0121 constexpr bool operator==(
0122 const recycling_allocator&) const noexcept
0123 {
0124 return true;
0125 }
0126
0127
0128 constexpr bool operator!=(
0129 const recycling_allocator&) const noexcept
0130 {
0131 return false;
0132 }
0133 };
0134
0135 }
0136 }
0137
0138 #include <boost/asio/detail/pop_options.hpp>
0139
0140 #endif