| 1 | // Distributed under the Boost Software License, Version 1.0. (See |
| 2 | // accompanying file LICENSE_1_0.txt or copy at |
| 3 | // http://www.boost.org/LICENSE_1_0.txt) |
| 4 | // (C) Copyright 2008 Anthony Williams |
| 5 | #ifndef THREAD_HEAP_ALLOC_PTHREAD_HPP |
| 6 | #define THREAD_HEAP_ALLOC_PTHREAD_HPP |
| 7 | |
| 8 | #include <boost/config/abi_prefix.hpp> |
| 9 | |
| 10 | namespace boost |
| 11 | { |
| 12 | namespace detail |
| 13 | { |
| 14 | template<typename T> |
| 15 | inline T* heap_new() |
| 16 | { |
| 17 | return new T(); |
| 18 | } |
| 19 | |
| 20 | #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES |
| 21 | template<typename T,typename A1> |
| 22 | inline T* heap_new(A1&& a1) |
| 23 | { |
| 24 | return new T(static_cast<A1&&>(a1)); |
| 25 | } |
| 26 | template<typename T,typename A1,typename A2> |
| 27 | inline T* heap_new(A1&& a1,A2&& a2) |
| 28 | { |
| 29 | return new T(static_cast<A1&&>(a1),static_cast<A2&&>(a2)); |
| 30 | } |
| 31 | template<typename T,typename A1,typename A2,typename A3> |
| 32 | inline T* heap_new(A1&& a1,A2&& a2,A3&& a3) |
| 33 | { |
| 34 | return new T(static_cast<A1&&>(a1),static_cast<A2&&>(a2), |
| 35 | static_cast<A3&&>(a3)); |
| 36 | } |
| 37 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 38 | inline T* heap_new(A1&& a1,A2&& a2,A3&& a3,A4&& a4) |
| 39 | { |
| 40 | return new T(static_cast<A1&&>(a1),static_cast<A2&&>(a2), |
| 41 | static_cast<A3&&>(a3),static_cast<A4&&>(a4)); |
| 42 | } |
| 43 | #else |
| 44 | template<typename T,typename A1> |
| 45 | inline T* heap_new_impl(A1 a1) |
| 46 | { |
| 47 | return new T(a1); |
| 48 | } |
| 49 | template<typename T,typename A1,typename A2> |
| 50 | inline T* heap_new_impl(A1 a1,A2 a2) |
| 51 | { |
| 52 | return new T(a1,a2); |
| 53 | } |
| 54 | template<typename T,typename A1,typename A2,typename A3> |
| 55 | inline T* heap_new_impl(A1 a1,A2 a2,A3 a3) |
| 56 | { |
| 57 | return new T(a1,a2,a3); |
| 58 | } |
| 59 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 60 | inline T* heap_new_impl(A1 a1,A2 a2,A3 a3,A4 a4) |
| 61 | { |
| 62 | return new T(a1,a2,a3,a4); |
| 63 | } |
| 64 | |
| 65 | template<typename T,typename A1> |
| 66 | inline T* heap_new(A1 const& a1) |
| 67 | { |
| 68 | return heap_new_impl<T,A1 const&>(a1); |
| 69 | } |
| 70 | template<typename T,typename A1> |
| 71 | inline T* heap_new(A1& a1) |
| 72 | { |
| 73 | return heap_new_impl<T,A1&>(a1); |
| 74 | } |
| 75 | |
| 76 | template<typename T,typename A1,typename A2> |
| 77 | inline T* heap_new(A1 const& a1,A2 const& a2) |
| 78 | { |
| 79 | return heap_new_impl<T,A1 const&,A2 const&>(a1,a2); |
| 80 | } |
| 81 | template<typename T,typename A1,typename A2> |
| 82 | inline T* heap_new(A1& a1,A2 const& a2) |
| 83 | { |
| 84 | return heap_new_impl<T,A1&,A2 const&>(a1,a2); |
| 85 | } |
| 86 | template<typename T,typename A1,typename A2> |
| 87 | inline T* heap_new(A1 const& a1,A2& a2) |
| 88 | { |
| 89 | return heap_new_impl<T,A1 const&,A2&>(a1,a2); |
| 90 | } |
| 91 | template<typename T,typename A1,typename A2> |
| 92 | inline T* heap_new(A1& a1,A2& a2) |
| 93 | { |
| 94 | return heap_new_impl<T,A1&,A2&>(a1,a2); |
| 95 | } |
| 96 | |
| 97 | template<typename T,typename A1,typename A2,typename A3> |
| 98 | inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3) |
| 99 | { |
| 100 | return heap_new_impl<T,A1 const&,A2 const&,A3 const&>(a1,a2,a3); |
| 101 | } |
| 102 | template<typename T,typename A1,typename A2,typename A3> |
| 103 | inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3) |
| 104 | { |
| 105 | return heap_new_impl<T,A1&,A2 const&,A3 const&>(a1,a2,a3); |
| 106 | } |
| 107 | template<typename T,typename A1,typename A2,typename A3> |
| 108 | inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3) |
| 109 | { |
| 110 | return heap_new_impl<T,A1 const&,A2&,A3 const&>(a1,a2,a3); |
| 111 | } |
| 112 | template<typename T,typename A1,typename A2,typename A3> |
| 113 | inline T* heap_new(A1& a1,A2& a2,A3 const& a3) |
| 114 | { |
| 115 | return heap_new_impl<T,A1&,A2&,A3 const&>(a1,a2,a3); |
| 116 | } |
| 117 | |
| 118 | template<typename T,typename A1,typename A2,typename A3> |
| 119 | inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3) |
| 120 | { |
| 121 | return heap_new_impl<T,A1 const&,A2 const&,A3&>(a1,a2,a3); |
| 122 | } |
| 123 | template<typename T,typename A1,typename A2,typename A3> |
| 124 | inline T* heap_new(A1& a1,A2 const& a2,A3& a3) |
| 125 | { |
| 126 | return heap_new_impl<T,A1&,A2 const&,A3&>(a1,a2,a3); |
| 127 | } |
| 128 | template<typename T,typename A1,typename A2,typename A3> |
| 129 | inline T* heap_new(A1 const& a1,A2& a2,A3& a3) |
| 130 | { |
| 131 | return heap_new_impl<T,A1 const&,A2&,A3&>(a1,a2,a3); |
| 132 | } |
| 133 | template<typename T,typename A1,typename A2,typename A3> |
| 134 | inline T* heap_new(A1& a1,A2& a2,A3& a3) |
| 135 | { |
| 136 | return heap_new_impl<T,A1&,A2&,A3&>(a1,a2,a3); |
| 137 | } |
| 138 | |
| 139 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 140 | inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3,A4 const& a4) |
| 141 | { |
| 142 | return heap_new_impl<T,A1 const&,A2 const&,A3 const&,A4 const&>(a1,a2,a3,a4); |
| 143 | } |
| 144 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 145 | inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3,A4 const& a4) |
| 146 | { |
| 147 | return heap_new_impl<T,A1&,A2 const&,A3 const&,A4 const&>(a1,a2,a3,a4); |
| 148 | } |
| 149 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 150 | inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3,A4 const& a4) |
| 151 | { |
| 152 | return heap_new_impl<T,A1 const&,A2&,A3 const&,A4 const&>(a1,a2,a3,a4); |
| 153 | } |
| 154 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 155 | inline T* heap_new(A1& a1,A2& a2,A3 const& a3,A4 const& a4) |
| 156 | { |
| 157 | return heap_new_impl<T,A1&,A2&,A3 const&,A4 const&>(a1,a2,a3,a4); |
| 158 | } |
| 159 | |
| 160 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 161 | inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3,A4 const& a4) |
| 162 | { |
| 163 | return heap_new_impl<T,A1 const&,A2 const&,A3&,A4 const&>(a1,a2,a3,a4); |
| 164 | } |
| 165 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 166 | inline T* heap_new(A1& a1,A2 const& a2,A3& a3,A4 const& a4) |
| 167 | { |
| 168 | return heap_new_impl<T,A1&,A2 const&,A3&,A4 const&>(a1,a2,a3,a4); |
| 169 | } |
| 170 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 171 | inline T* heap_new(A1 const& a1,A2& a2,A3& a3,A4 const& a4) |
| 172 | { |
| 173 | return heap_new_impl<T,A1 const&,A2&,A3&,A4 const&>(a1,a2,a3,a4); |
| 174 | } |
| 175 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 176 | inline T* heap_new(A1& a1,A2& a2,A3& a3,A4 const& a4) |
| 177 | { |
| 178 | return heap_new_impl<T,A1&,A2&,A3&,A4 const&>(a1,a2,a3,a4); |
| 179 | } |
| 180 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 181 | inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3,A4& a4) |
| 182 | { |
| 183 | return heap_new_impl<T,A1 const&,A2 const&,A3 const&,A4&>(a1,a2,a3,a4); |
| 184 | } |
| 185 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 186 | inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3,A4& a4) |
| 187 | { |
| 188 | return heap_new_impl<T,A1&,A2 const&,A3 const&,A4&>(a1,a2,a3,a4); |
| 189 | } |
| 190 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 191 | inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3,A4& a4) |
| 192 | { |
| 193 | return heap_new_impl<T,A1 const&,A2&,A3 const&,A4&>(a1,a2,a3,a4); |
| 194 | } |
| 195 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 196 | inline T* heap_new(A1& a1,A2& a2,A3 const& a3,A4& a4) |
| 197 | { |
| 198 | return heap_new_impl<T,A1&,A2&,A3 const&,A4&>(a1,a2,a3,a4); |
| 199 | } |
| 200 | |
| 201 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 202 | inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3,A4& a4) |
| 203 | { |
| 204 | return heap_new_impl<T,A1 const&,A2 const&,A3&,A4&>(a1,a2,a3,a4); |
| 205 | } |
| 206 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 207 | inline T* heap_new(A1& a1,A2 const& a2,A3& a3,A4& a4) |
| 208 | { |
| 209 | return heap_new_impl<T,A1&,A2 const&,A3&,A4&>(a1,a2,a3,a4); |
| 210 | } |
| 211 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 212 | inline T* heap_new(A1 const& a1,A2& a2,A3& a3,A4& a4) |
| 213 | { |
| 214 | return heap_new_impl<T,A1 const&,A2&,A3&,A4&>(a1,a2,a3,a4); |
| 215 | } |
| 216 | template<typename T,typename A1,typename A2,typename A3,typename A4> |
| 217 | inline T* heap_new(A1& a1,A2& a2,A3& a3,A4& a4) |
| 218 | { |
| 219 | return heap_new_impl<T,A1&,A2&,A3&,A4&>(a1,a2,a3,a4); |
| 220 | } |
| 221 | |
| 222 | #endif |
| 223 | template<typename T> |
| 224 | inline void heap_delete(T* data) |
| 225 | { |
| 226 | delete data; |
| 227 | } |
| 228 | |
| 229 | template<typename T> |
| 230 | struct do_heap_delete |
| 231 | { |
| 232 | void operator()(T* data) const |
| 233 | { |
| 234 | detail::heap_delete(data); |
| 235 | } |
| 236 | }; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | #include <boost/config/abi_suffix.hpp> |
| 241 | |
| 242 | #endif |
| 243 | |