| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- | 
 | 2 | //===-------------------------- memory ------------------------------------===// | 
 | 3 | // | 
| Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | //                     The LLVM Compiler Infrastructure | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // | 
| Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open | 
 | 7 | // Source Licenses. See LICENSE.TXT for details. | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // | 
 | 9 | //===----------------------------------------------------------------------===// | 
 | 10 |  | 
 | 11 | #ifndef _LIBCPP_MEMORY | 
 | 12 | #define _LIBCPP_MEMORY | 
 | 13 |  | 
 | 14 | /* | 
 | 15 |     memory synopsis | 
 | 16 |  | 
 | 17 | namespace std | 
 | 18 | { | 
 | 19 |  | 
 | 20 | struct allocator_arg_t { }; | 
 | 21 | constexpr allocator_arg_t allocator_arg = allocator_arg_t(); | 
 | 22 |  | 
 | 23 | template <class T, class Alloc> struct uses_allocator; | 
 | 24 |  | 
 | 25 | template <class Ptr> | 
 | 26 | struct pointer_traits | 
 | 27 | { | 
 | 28 |     typedef Ptr pointer; | 
 | 29 |     typedef <details> element_type; | 
 | 30 |     typedef <details> difference_type; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 31 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 32 |     template <class U> using rebind = <details>; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 33 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 34 |     static pointer pointer_to(<details>); | 
 | 35 | }; | 
 | 36 |  | 
 | 37 | template <class Alloc> | 
 | 38 | struct allocator_traits | 
 | 39 | { | 
 | 40 |     typedef Alloc                        allocator_type; | 
 | 41 |     typedef typename allocator_type::value_type | 
 | 42 |                                          value_type; | 
 | 43 |  | 
 | 44 |     typedef Alloc::pointer | value_type* pointer; | 
 | 45 |     typedef Alloc::const_pointer | 
 | 46 |           | pointer_traits<pointer>::rebind<const value_type> | 
 | 47 |                                          const_pointer; | 
 | 48 |     typedef Alloc::void_pointer | 
 | 49 |           | pointer_traits<pointer>::rebind<void> | 
 | 50 |                                          void_pointer; | 
 | 51 |     typedef Alloc::const_void_pointer | 
 | 52 |           | pointer_traits<pointer>::rebind<const void> | 
 | 53 |                                          const_void_pointer; | 
 | 54 |     typedef Alloc::difference_type | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame^] | 55 |           | pointer_traits<pointer>::difference_type | 
 | 56 |                                          difference_type; | 
 | 57 |     typedef Alloc::size_type | 
 | 58 |           | make_unsigned<difference_type>::type | 
 | 59 |                                          size_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 |     typedef Alloc::propagate_on_container_copy_assignment | 
 | 61 |           | false_type                   propagate_on_container_copy_assignment; | 
 | 62 |     typedef Alloc::propagate_on_container_move_assignment | 
 | 63 |           | false_type                   propagate_on_container_move_assignment; | 
 | 64 |     typedef Alloc::propagate_on_container_swap | 
 | 65 |           | false_type                   propagate_on_container_swap; | 
 | 66 |  | 
 | 67 |     template <class T> using rebind_alloc  = Alloc::rebind<U>::other | Alloc<T, Args...>; | 
 | 68 |     template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; | 
 | 69 |  | 
 | 70 |     static pointer allocate(allocator_type& a, size_type n); | 
 | 71 |     static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); | 
 | 72 |  | 
 | 73 |     static void deallocate(allocator_type& a, pointer p, size_type n); | 
 | 74 |  | 
 | 75 |     template <class T, class... Args> | 
 | 76 |         static void construct(allocator_type& a, T* p, Args&&... args); | 
 | 77 |  | 
 | 78 |     template <class T> | 
 | 79 |         static void destroy(allocator_type& a, T* p); | 
 | 80 |  | 
 | 81 |     static size_type max_size(const allocator_type& a); | 
 | 82 |  | 
 | 83 |     static allocator_type | 
 | 84 |         select_on_container_copy_construction(const allocator_type& a); | 
 | 85 | }; | 
 | 86 |  | 
 | 87 | template <> | 
 | 88 | class allocator<void> | 
 | 89 | { | 
 | 90 | public: | 
 | 91 |     typedef void*                                 pointer; | 
 | 92 |     typedef const void*                           const_pointer; | 
 | 93 |     typedef void                                  value_type; | 
 | 94 |  | 
 | 95 |     template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 
 | 96 | }; | 
 | 97 |  | 
 | 98 | template <class T> | 
 | 99 | class allocator | 
 | 100 | { | 
 | 101 | public: | 
 | 102 |     typedef size_t                                size_type; | 
 | 103 |     typedef ptrdiff_t                             difference_type; | 
 | 104 |     typedef T*                                    pointer; | 
 | 105 |     typedef const T*                              const_pointer; | 
 | 106 |     typedef typename add_lvalue_reference<T>::type       reference; | 
 | 107 |     typedef typename add_lvalue_reference<const T>::type const_reference; | 
 | 108 |     typedef T                                     value_type; | 
 | 109 |  | 
 | 110 |     template <class U> struct rebind {typedef allocator<U> other;}; | 
 | 111 |  | 
 | 112 |     allocator() throw(); | 
 | 113 |     allocator(const allocator&) throw(); | 
 | 114 |     template <class U> allocator(const allocator<U>&) throw(); | 
 | 115 |     ~allocator() throw(); | 
 | 116 |     pointer address(reference x) const; | 
 | 117 |     const_pointer address(const_reference x) const; | 
 | 118 |     pointer allocate(size_type, allocator<void>::const_pointer hint = 0); | 
 | 119 |     void deallocate(pointer p, size_type n); | 
 | 120 |     size_type max_size() const throw(); | 
 | 121 |     void construct(pointer p, const T& val); | 
 | 122 |     void destroy(pointer p); | 
 | 123 | }; | 
 | 124 |  | 
 | 125 | template <class T, class U> | 
 | 126 | bool operator==(const allocator<T>&, const allocator<U>&) throw(); | 
 | 127 |  | 
 | 128 | template <class T, class U> | 
 | 129 | bool operator!=(const allocator<T>&, const allocator<U>&) throw(); | 
 | 130 |  | 
 | 131 | template <class OutputIterator, class T> | 
 | 132 | class raw_storage_iterator | 
 | 133 |     : public iterator<output_iterator_tag, | 
 | 134 |                       T,                               // purposefully not C++03 | 
 | 135 |                       ptrdiff_t,                       // purposefully not C++03 | 
 | 136 |                       T*,                              // purposefully not C++03 | 
 | 137 |                       raw_storage_iterator&>           // purposefully not C++03 | 
 | 138 | { | 
 | 139 | public: | 
 | 140 |     explicit raw_storage_iterator(OutputIterator x); | 
 | 141 |     raw_storage_iterator& operator*(); | 
 | 142 |     raw_storage_iterator& operator=(const T& element); | 
 | 143 |     raw_storage_iterator& operator++(); | 
 | 144 |     raw_storage_iterator  operator++(int); | 
 | 145 | }; | 
 | 146 |  | 
 | 147 | template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n); | 
 | 148 | template <class T> void               return_temporary_buffer(T* p); | 
 | 149 |  | 
 | 150 | template <class InputIterator, class ForwardIterator> | 
 | 151 | ForwardIterator | 
 | 152 | uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); | 
 | 153 |  | 
 | 154 | template <class ForwardIterator, class T> | 
 | 155 | void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); | 
 | 156 |  | 
 | 157 | template <class ForwardIterator, class Size, class T> | 
 | 158 | void uninitialized_fill_n(ForwardIterator first, Size n, const T& x); | 
 | 159 |  | 
 | 160 | template <class Y> struct auto_ptr_ref {}; | 
 | 161 |  | 
 | 162 | template<class X> | 
 | 163 | class auto_ptr | 
 | 164 | { | 
 | 165 | public: | 
 | 166 |     typedef X element_type; | 
 | 167 |  | 
 | 168 |     explicit auto_ptr(X* p =0) throw(); | 
 | 169 |     auto_ptr(auto_ptr&) throw(); | 
 | 170 |     template<class Y> auto_ptr(auto_ptr<Y>&) throw(); | 
 | 171 |     auto_ptr& operator=(auto_ptr&) throw(); | 
 | 172 |     template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw(); | 
 | 173 |     auto_ptr& operator=(auto_ptr_ref<X> r) throw(); | 
 | 174 |     ~auto_ptr() throw(); | 
 | 175 |  | 
 | 176 |     typename add_lvalue_reference<X>::type operator*() const throw(); | 
 | 177 |     X* operator->() const throw(); | 
 | 178 |     X* get() const throw(); | 
 | 179 |     X* release() throw(); | 
 | 180 |     void reset(X* p =0) throw(); | 
 | 181 |  | 
 | 182 |     auto_ptr(auto_ptr_ref<X>) throw(); | 
 | 183 |     template<class Y> operator auto_ptr_ref<Y>() throw(); | 
 | 184 |     template<class Y> operator auto_ptr<Y>() throw(); | 
 | 185 | }; | 
 | 186 |  | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 187 | template <class T> | 
 | 188 | struct default_delete | 
 | 189 | { | 
 | 190 |     constexpr default_delete(); | 
 | 191 |     template <class U> default_delete(const default_delete<U>&); | 
 | 192 |  | 
 | 193 |     void operator()(T*) const; | 
 | 194 | }; | 
 | 195 |  | 
 | 196 | template <class T> | 
 | 197 | struct default_delete<T[]> | 
 | 198 | { | 
 | 199 |     constexpr default_delete(); | 
 | 200 |     void operator()(T*) const; | 
 | 201 |     template <class U> void operator()(U*) const = delete; | 
 | 202 | }; | 
 | 203 |  | 
 | 204 | template <class T, class D = default_delete<T>> class unique_ptr; | 
 | 205 |  | 
 | 206 | template <class T, class D = default_delete<T>> | 
 | 207 | class unique_ptr | 
 | 208 | { | 
 | 209 | public: | 
 | 210 |     typedef see below pointer; | 
 | 211 |     typedef T element_type; | 
 | 212 |     typedef D deleter_type; | 
 | 213 |  | 
 | 214 |     // constructors | 
 | 215 |     constexpr unique_ptr(); | 
 | 216 |     explicit unique_ptr(pointer p); | 
 | 217 |     unique_ptr(pointer p, implementation-defined d1); | 
 | 218 |     unique_ptr(pointer p, implementation-defined d2); | 
 | 219 |     unique_ptr(unique_ptr&& u); | 
 | 220 |     unique_ptr(nullptr_t) : unique_ptr() { } | 
 | 221 |     template <class U, class E> | 
 | 222 |         unique_ptr(unique_ptr<U, E>&& u); | 
 | 223 |     template <class U> | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 224 |         unique_ptr(auto_ptr<U>&& u); | 
 | 225 |  | 
 | 226 |     // destructor | 
 | 227 |     ~unique_ptr(); | 
 | 228 |  | 
 | 229 |     // assignment | 
 | 230 |     unique_ptr& operator=(unique_ptr&& u); | 
 | 231 |     template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u); | 
 | 232 |     unique_ptr& operator=(nullptr_t); | 
 | 233 |  | 
 | 234 |     // observers | 
 | 235 |     typename add_lvalue_reference<T>::type operator*() const; | 
 | 236 |     pointer operator->() const; | 
 | 237 |     pointer get() const; | 
 | 238 |     deleter_type& get_deleter(); | 
 | 239 |     const deleter_type& get_deleter() const; | 
 | 240 |     explicit operator bool() const; | 
 | 241 |  | 
 | 242 |     // modifiers | 
 | 243 |     pointer release(); | 
 | 244 |     void reset(pointer p = pointer()); | 
 | 245 |     void swap(unique_ptr& u); | 
 | 246 | }; | 
 | 247 |  | 
 | 248 | template <class T, class D> | 
 | 249 | class unique_ptr<T[], D> | 
 | 250 | { | 
 | 251 | public: | 
 | 252 |     typedef implementation-defined pointer; | 
 | 253 |     typedef T element_type; | 
 | 254 |     typedef D deleter_type; | 
 | 255 |  | 
 | 256 |     // constructors | 
 | 257 |     constexpr unique_ptr(); | 
 | 258 |     explicit unique_ptr(pointer p); | 
 | 259 |     unique_ptr(pointer p, implementation-defined d); | 
 | 260 |     unique_ptr(pointer p, implementation-defined d); | 
 | 261 |     unique_ptr(unique_ptr&& u); | 
 | 262 |     unique_ptr(nullptr_t) : unique_ptr() { } | 
 | 263 |  | 
 | 264 |     // destructor | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 265 |     ~unique_ptr(); | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 266 |  | 
 | 267 |     // assignment | 
 | 268 |     unique_ptr& operator=(unique_ptr&& u); | 
 | 269 |     unique_ptr& operator=(nullptr_t); | 
 | 270 |  | 
 | 271 |     // observers | 
 | 272 |     T& operator[](size_t i) const; | 
 | 273 |     pointer get() const; | 
 | 274 |     deleter_type& get_deleter(); | 
 | 275 |     const deleter_type& get_deleter() const; | 
 | 276 |     explicit operator bool() const; | 
 | 277 |  | 
 | 278 |     // modifiers | 
 | 279 |     pointer release(); | 
 | 280 |     void reset(pointer p = pointer()); | 
 | 281 |     void reset(nullptr_t); | 
 | 282 |     template <class U> void reset(U) = delete; | 
 | 283 |     void swap(unique_ptr& u); | 
 | 284 | }; | 
 | 285 |  | 
 | 286 | template <class T, class D> | 
 | 287 |     void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y); | 
 | 288 |  | 
 | 289 | template <class T1, class D1, class T2, class D2> | 
 | 290 |     bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 291 | template <class T1, class D1, class T2, class D2> | 
 | 292 |     bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 293 | template <class T1, class D1, class T2, class D2> | 
 | 294 |     bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 295 | template <class T1, class D1, class T2, class D2> | 
 | 296 |     bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 297 | template <class T1, class D1, class T2, class D2> | 
 | 298 |     bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 299 | template <class T1, class D1, class T2, class D2> | 
 | 300 |     bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 301 |  | 
 | 302 | class bad_weak_ptr | 
 | 303 |     : public std::exception | 
 | 304 | { | 
 | 305 |     bad_weak_ptr(); | 
 | 306 | }; | 
 | 307 |  | 
 | 308 | template<class T> | 
 | 309 | class shared_ptr | 
 | 310 | { | 
 | 311 | public: | 
 | 312 |     typedef T element_type; | 
 | 313 |  | 
 | 314 |     // constructors: | 
 | 315 |     constexpr shared_ptr(); | 
 | 316 |     template<class Y> explicit shared_ptr(Y* p); | 
 | 317 |     template<class Y, class D> shared_ptr(Y* p, D d); | 
 | 318 |     template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); | 
 | 319 |     template <class D> shared_ptr(nullptr_t p, D d); | 
 | 320 |     template <class D, class A> shared_ptr(nullptr_t p, D d, A a); | 
 | 321 |     template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p); | 
 | 322 |     shared_ptr(const shared_ptr& r); | 
 | 323 |     template<class Y> shared_ptr(const shared_ptr<Y>& r); | 
 | 324 |     shared_ptr(shared_ptr&& r); | 
 | 325 |     template<class Y> shared_ptr(shared_ptr<Y>&& r); | 
 | 326 |     template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); | 
 | 327 |     template<class Y> shared_ptr(auto_ptr<Y>&& r); | 
 | 328 |     template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r); | 
 | 329 |     shared_ptr(nullptr_t) : shared_ptr() { } | 
 | 330 |  | 
 | 331 |     // destructor: | 
 | 332 |     ~shared_ptr(); | 
 | 333 |  | 
 | 334 |     // assignment: | 
 | 335 |     shared_ptr& operator=(const shared_ptr& r); | 
 | 336 |     template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r); | 
 | 337 |     shared_ptr& operator=(shared_ptr&& r); | 
 | 338 |     template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r); | 
 | 339 |     template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); | 
 | 340 |     template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); | 
 | 341 |  | 
 | 342 |     // modifiers: | 
 | 343 |     void swap(shared_ptr& r); | 
 | 344 |     void reset(); | 
 | 345 |     template<class Y> void reset(Y* p); | 
 | 346 |     template<class Y, class D> void reset(Y* p, D d); | 
 | 347 |     template<class Y, class D, class A> void reset(Y* p, D d, A a); | 
 | 348 |  | 
 | 349 |     // observers: T* get() const; | 
 | 350 |     T& operator*() const; | 
 | 351 |     T* operator->() const; | 
 | 352 |     long use_count() const; | 
 | 353 |     bool unique() const; | 
 | 354 |     explicit operator bool() const; | 
 | 355 |     template<class U> bool owner_before(shared_ptr<U> const& b) const; | 
 | 356 |     template<class U> bool owner_before(weak_ptr<U> const& b) const; | 
 | 357 | }; | 
 | 358 |  | 
 | 359 | // shared_ptr comparisons: | 
 | 360 | template<class T, class U> | 
 | 361 |     bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b); | 
 | 362 | template<class T, class U> | 
 | 363 |     bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b); | 
 | 364 | template<class T, class U> | 
 | 365 |     bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b); | 
 | 366 | template<class T, class U> | 
 | 367 |     bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b); | 
 | 368 | template<class T, class U> | 
 | 369 |     bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b); | 
 | 370 | template<class T, class U> | 
 | 371 |     bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b); | 
 | 372 |  | 
 | 373 | // shared_ptr specialized algorithms: | 
 | 374 | template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b); | 
 | 375 |  | 
 | 376 | // shared_ptr casts: | 
 | 377 | template<class T, class U> | 
 | 378 |     shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r); | 
 | 379 | template<class T, class U> | 
 | 380 |     shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r); | 
 | 381 | template<class T, class U> | 
 | 382 |     shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r); | 
 | 383 |  | 
 | 384 | // shared_ptr I/O: | 
 | 385 | template<class E, class T, class Y> | 
 | 386 |     basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p); | 
 | 387 |  | 
 | 388 | // shared_ptr get_deleter: | 
 | 389 | template<class D, class T> D* get_deleter(shared_ptr<T> const& p); | 
 | 390 |  | 
 | 391 | template<class T, class... Args> | 
 | 392 |     shared_ptr<T> make_shared(Args&&... args); | 
 | 393 | template<class T, class A, class... Args> | 
 | 394 |     shared_ptr<T> allocate_shared(const A& a, Args&&... args); | 
 | 395 |  | 
 | 396 | template<class T> | 
 | 397 | class weak_ptr | 
 | 398 | { | 
 | 399 | public: | 
 | 400 |     typedef T element_type; | 
 | 401 |  | 
 | 402 |     // constructors | 
 | 403 |     constexpr weak_ptr(); | 
 | 404 |     template<class Y> weak_ptr(shared_ptr<Y> const& r); | 
 | 405 |     weak_ptr(weak_ptr const& r); | 
 | 406 |     template<class Y> weak_ptr(weak_ptr<Y> const& r); | 
 | 407 |  | 
 | 408 |     // destructor | 
 | 409 |     ~weak_ptr(); | 
 | 410 |  | 
 | 411 |     // assignment | 
 | 412 |     weak_ptr& operator=(weak_ptr const& r); | 
 | 413 |     template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r); | 
 | 414 |     template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r); | 
 | 415 |  | 
 | 416 |     // modifiers | 
 | 417 |     void swap(weak_ptr& r); | 
 | 418 |     void reset(); | 
 | 419 |  | 
 | 420 |     // observers | 
 | 421 |     long use_count() const; | 
 | 422 |     bool expired() const; | 
 | 423 |     shared_ptr<T> lock() const; | 
 | 424 |     template<class U> bool owner_before(shared_ptr<U> const& b); | 
 | 425 |     template<class U> bool owner_before(weak_ptr<U> const& b); | 
 | 426 | }; | 
 | 427 |  | 
 | 428 | // weak_ptr specialized algorithms: | 
 | 429 | template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b); | 
 | 430 |  | 
 | 431 | // class owner_less: | 
 | 432 | template<class T> struct owner_less; | 
 | 433 |  | 
 | 434 | template<class T> | 
 | 435 | struct owner_less<shared_ptr<T>> | 
 | 436 |     : binary_function<shared_ptr<T>, shared_ptr<T>, bool> | 
 | 437 | { | 
 | 438 |     typedef bool result_type; | 
 | 439 |     bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const; | 
 | 440 |     bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; | 
 | 441 |     bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; | 
 | 442 | }; | 
 | 443 |  | 
 | 444 | template<class T> | 
 | 445 | struct owner_less<weak_ptr<T>> | 
 | 446 |     : binary_function<weak_ptr<T>, weak_ptr<T>, bool> | 
 | 447 | { | 
 | 448 |     typedef bool result_type; | 
 | 449 |     bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; | 
 | 450 |     bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; | 
 | 451 |     bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; | 
 | 452 | }; | 
 | 453 |  | 
 | 454 | template<class T> | 
 | 455 | class enable_shared_from_this | 
 | 456 | { | 
 | 457 | protected: | 
 | 458 |     constexpr enable_shared_from_this(); | 
 | 459 |     enable_shared_from_this(enable_shared_from_this const&); | 
 | 460 |     enable_shared_from_this& operator=(enable_shared_from_this const&); | 
 | 461 |     ~enable_shared_from_this(); | 
 | 462 | public: | 
 | 463 |     shared_ptr<T> shared_from_this(); | 
 | 464 |     shared_ptr<T const> shared_from_this() const; | 
 | 465 | }; | 
 | 466 |  | 
 | 467 | template<class T> | 
 | 468 |     bool atomic_is_lock_free(const shared_ptr<T>* p); | 
 | 469 | template<class T> | 
 | 470 |     shared_ptr<T> atomic_load(const shared_ptr<T>* p); | 
 | 471 | template<class T> | 
 | 472 |     shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo); | 
 | 473 | template<class T> | 
 | 474 |     void atomic_store(shared_ptr<T>* p, shared_ptr<T> r); | 
 | 475 | template<class T> | 
 | 476 |     void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); | 
 | 477 | template<class T> | 
 | 478 |     shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r); | 
 | 479 | template<class T> | 
 | 480 |     shared_ptr<T> | 
 | 481 |     atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); | 
 | 482 | template<class T> | 
 | 483 |     bool | 
 | 484 |     atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); | 
 | 485 | template<class T> | 
 | 486 |     bool | 
 | 487 |     atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); | 
 | 488 | template<class T> | 
 | 489 |     bool | 
 | 490 |     atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, | 
 | 491 |                                           shared_ptr<T> w, memory_order success, | 
 | 492 |                                           memory_order failure); | 
 | 493 | template<class T> | 
 | 494 |     bool | 
 | 495 |     atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, | 
 | 496 |                                             shared_ptr<T> w, memory_order success, | 
 | 497 |                                             memory_order failure); | 
 | 498 | // Hash support | 
 | 499 | template <class T> struct hash; | 
 | 500 | template <class T, class D> struct hash<unique_ptr<T, D> >; | 
 | 501 | template <class T> struct hash<shared_ptr<T> >; | 
 | 502 |  | 
 | 503 | // Pointer safety | 
 | 504 | enum class pointer_safety { relaxed, preferred, strict }; | 
 | 505 | void declare_reachable(void *p); | 
 | 506 | template <class T> T *undeclare_reachable(T *p); | 
 | 507 | void declare_no_pointers(char *p, size_t n); | 
 | 508 | void undeclare_no_pointers(char *p, size_t n); | 
 | 509 | pointer_safety get_pointer_safety(); | 
 | 510 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 511 | void* align(size_t alignment, size_t size, void*& ptr, size_t& space); | 
 | 512 |  | 
 | 513 | }  // std | 
 | 514 |  | 
 | 515 | */ | 
 | 516 |  | 
 | 517 | #include <__config> | 
 | 518 | #include <type_traits> | 
 | 519 | #include <typeinfo> | 
 | 520 | #include <cstddef> | 
 | 521 | #include <cstdint> | 
 | 522 | #include <new> | 
 | 523 | #include <utility> | 
 | 524 | #include <limits> | 
 | 525 | #include <iterator> | 
 | 526 | #include <__functional_base> | 
 | 527 | #if defined(_LIBCPP_NO_EXCEPTIONS) | 
 | 528 |     #include <cassert> | 
 | 529 | #endif | 
 | 530 |  | 
 | 531 | #pragma GCC system_header | 
 | 532 |  | 
 | 533 | _LIBCPP_BEGIN_NAMESPACE_STD | 
 | 534 |  | 
 | 535 | // allocator_arg_t | 
 | 536 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 537 | struct _LIBCPP_VISIBLE allocator_arg_t { }; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 538 |  | 
 | 539 | extern const allocator_arg_t allocator_arg; | 
 | 540 |  | 
 | 541 | // addressof | 
 | 542 |  | 
 | 543 | template <class _Tp> | 
 | 544 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 545 | _Tp* | 
 | 546 | addressof(_Tp& __x) | 
 | 547 | { | 
 | 548 |     return (_Tp*)&(char&)__x; | 
 | 549 | } | 
 | 550 |  | 
 | 551 | template <class _Tp> class allocator; | 
 | 552 |  | 
 | 553 | template <> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 554 | class _LIBCPP_VISIBLE allocator<void> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 555 | { | 
 | 556 | public: | 
 | 557 |     typedef void*             pointer; | 
 | 558 |     typedef const void*       const_pointer; | 
 | 559 |     typedef void              value_type; | 
 | 560 |  | 
 | 561 |     template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 
 | 562 | }; | 
 | 563 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 564 | // pointer_traits | 
 | 565 |  | 
 | 566 | template <class _Tp> | 
 | 567 | struct __has_element_type | 
 | 568 | { | 
 | 569 | private: | 
 | 570 |     struct __two {char _; char __;}; | 
 | 571 |     template <class _Up> static __two __test(...); | 
 | 572 |     template <class _Up> static char __test(typename _Up::element_type* = 0); | 
 | 573 | public: | 
 | 574 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 575 | }; | 
 | 576 |  | 
 | 577 | template <class _Ptr, bool = __has_element_type<_Ptr>::value> | 
 | 578 | struct __pointer_traits_element_type; | 
 | 579 |  | 
 | 580 | template <class _Ptr> | 
 | 581 | struct __pointer_traits_element_type<_Ptr, true> | 
 | 582 | { | 
 | 583 |     typedef typename _Ptr::element_type type; | 
 | 584 | }; | 
 | 585 |  | 
 | 586 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 587 |  | 
 | 588 | template <template <class, class...> class _Sp, class _Tp, class ..._Args> | 
 | 589 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> | 
 | 590 | { | 
 | 591 |     typedef typename _Sp<_Tp, _Args...>::element_type type; | 
 | 592 | }; | 
 | 593 |  | 
 | 594 | template <template <class, class...> class _Sp, class _Tp, class ..._Args> | 
 | 595 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> | 
 | 596 | { | 
 | 597 |     typedef _Tp type; | 
 | 598 | }; | 
 | 599 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 600 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 601 |  | 
 | 602 | template <template <class> class _Sp, class _Tp> | 
 | 603 | struct __pointer_traits_element_type<_Sp<_Tp>, true> | 
 | 604 | { | 
 | 605 |     typedef typename _Sp<_Tp>::element_type type; | 
 | 606 | }; | 
 | 607 |  | 
 | 608 | template <template <class> class _Sp, class _Tp> | 
 | 609 | struct __pointer_traits_element_type<_Sp<_Tp>, false> | 
 | 610 | { | 
 | 611 |     typedef _Tp type; | 
 | 612 | }; | 
 | 613 |  | 
 | 614 | template <template <class, class> class _Sp, class _Tp, class _A0> | 
 | 615 | struct __pointer_traits_element_type<_Sp<_Tp, _A0>, true> | 
 | 616 | { | 
 | 617 |     typedef typename _Sp<_Tp, _A0>::element_type type; | 
 | 618 | }; | 
 | 619 |  | 
 | 620 | template <template <class, class> class _Sp, class _Tp, class _A0> | 
 | 621 | struct __pointer_traits_element_type<_Sp<_Tp, _A0>, false> | 
 | 622 | { | 
 | 623 |     typedef _Tp type; | 
 | 624 | }; | 
 | 625 |  | 
 | 626 | template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> | 
 | 627 | struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true> | 
 | 628 | { | 
 | 629 |     typedef typename _Sp<_Tp, _A0, _A1>::element_type type; | 
 | 630 | }; | 
 | 631 |  | 
 | 632 | template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> | 
 | 633 | struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false> | 
 | 634 | { | 
 | 635 |     typedef _Tp type; | 
 | 636 | }; | 
 | 637 |  | 
 | 638 | template <template <class, class, class, class> class _Sp, class _Tp, class _A0, | 
 | 639 |                                                            class _A1, class _A2> | 
 | 640 | struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true> | 
 | 641 | { | 
 | 642 |     typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type; | 
 | 643 | }; | 
 | 644 |  | 
 | 645 | template <template <class, class, class, class> class _Sp, class _Tp, class _A0, | 
 | 646 |                                                            class _A1, class _A2> | 
 | 647 | struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false> | 
 | 648 | { | 
 | 649 |     typedef _Tp type; | 
 | 650 | }; | 
 | 651 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 652 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 653 |  | 
 | 654 | template <class _Tp> | 
 | 655 | struct __has_difference_type | 
 | 656 | { | 
 | 657 | private: | 
 | 658 |     struct __two {char _; char __;}; | 
 | 659 |     template <class _Up> static __two __test(...); | 
 | 660 |     template <class _Up> static char __test(typename _Up::difference_type* = 0); | 
 | 661 | public: | 
 | 662 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 663 | }; | 
 | 664 |  | 
 | 665 | template <class _Ptr, bool = __has_difference_type<_Ptr>::value> | 
 | 666 | struct __pointer_traits_difference_type | 
 | 667 | { | 
 | 668 |     typedef ptrdiff_t type; | 
 | 669 | }; | 
 | 670 |  | 
 | 671 | template <class _Ptr> | 
 | 672 | struct __pointer_traits_difference_type<_Ptr, true> | 
 | 673 | { | 
 | 674 |     typedef typename _Ptr::difference_type type; | 
 | 675 | }; | 
 | 676 |  | 
 | 677 | template <class _Tp, class _Up> | 
 | 678 | struct __has_rebind | 
 | 679 | { | 
 | 680 | private: | 
 | 681 |     struct __two {char _; char __;}; | 
 | 682 |     template <class _Xp> static __two __test(...); | 
 | 683 |     template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); | 
 | 684 | public: | 
 | 685 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 686 | }; | 
 | 687 |  | 
 | 688 | template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> | 
 | 689 | struct __pointer_traits_rebind | 
 | 690 | { | 
 | 691 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 692 |     typedef typename _Tp::template rebind<_Up> type; | 
 | 693 | #else | 
 | 694 |     typedef typename _Tp::template rebind<_Up>::other type; | 
 | 695 | #endif | 
 | 696 | }; | 
 | 697 |  | 
 | 698 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 699 |  | 
 | 700 | template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> | 
 | 701 | struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> | 
 | 702 | { | 
 | 703 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 704 |     typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; | 
 | 705 | #else | 
 | 706 |     typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; | 
 | 707 | #endif | 
 | 708 | }; | 
 | 709 |  | 
 | 710 | template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> | 
 | 711 | struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> | 
 | 712 | { | 
 | 713 |     typedef _Sp<_Up, _Args...> type; | 
 | 714 | }; | 
 | 715 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 716 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 717 |  | 
 | 718 | template <template <class> class _Sp, class _Tp, class _Up> | 
 | 719 | struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> | 
 | 720 | { | 
 | 721 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 722 |     typedef typename _Sp<_Tp>::template rebind<_Up> type; | 
 | 723 | #else | 
 | 724 |     typedef typename _Sp<_Tp>::template rebind<_Up>::other type; | 
 | 725 | #endif | 
 | 726 | }; | 
 | 727 |  | 
 | 728 | template <template <class> class _Sp, class _Tp, class _Up> | 
 | 729 | struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false> | 
 | 730 | { | 
 | 731 |     typedef _Sp<_Up> type; | 
 | 732 | }; | 
 | 733 |  | 
 | 734 | template <template <class, class> class _Sp, class _Tp, class _A0, class _Up> | 
 | 735 | struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> | 
 | 736 | { | 
 | 737 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 738 |     typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; | 
 | 739 | #else | 
 | 740 |     typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; | 
 | 741 | #endif | 
 | 742 | }; | 
 | 743 |  | 
 | 744 | template <template <class, class> class _Sp, class _Tp, class _A0, class _Up> | 
 | 745 | struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false> | 
 | 746 | { | 
 | 747 |     typedef _Sp<_Up, _A0> type; | 
 | 748 | }; | 
 | 749 |  | 
 | 750 | template <template <class, class, class> class _Sp, class _Tp, class _A0, | 
 | 751 |                                          class _A1, class _Up> | 
 | 752 | struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> | 
 | 753 | { | 
 | 754 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 755 |     typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; | 
 | 756 | #else | 
 | 757 |     typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; | 
 | 758 | #endif | 
 | 759 | }; | 
 | 760 |  | 
 | 761 | template <template <class, class, class> class _Sp, class _Tp, class _A0, | 
 | 762 |                                          class _A1, class _Up> | 
 | 763 | struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false> | 
 | 764 | { | 
 | 765 |     typedef _Sp<_Up, _A0, _A1> type; | 
 | 766 | }; | 
 | 767 |  | 
 | 768 | template <template <class, class, class, class> class _Sp, class _Tp, class _A0, | 
 | 769 |                                                 class _A1, class _A2, class _Up> | 
 | 770 | struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> | 
 | 771 | { | 
 | 772 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 773 |     typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; | 
 | 774 | #else | 
 | 775 |     typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; | 
 | 776 | #endif | 
 | 777 | }; | 
 | 778 |  | 
 | 779 | template <template <class, class, class, class> class _Sp, class _Tp, class _A0, | 
 | 780 |                                                 class _A1, class _A2, class _Up> | 
 | 781 | struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> | 
 | 782 | { | 
 | 783 |     typedef _Sp<_Up, _A0, _A1, _A2> type; | 
 | 784 | }; | 
 | 785 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 786 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 787 |  | 
 | 788 | template <class _Ptr> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 789 | struct _LIBCPP_VISIBLE pointer_traits | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 790 | { | 
 | 791 |     typedef _Ptr                                                     pointer; | 
 | 792 |     typedef typename __pointer_traits_element_type<pointer>::type    element_type; | 
 | 793 |     typedef typename __pointer_traits_difference_type<pointer>::type difference_type; | 
 | 794 |  | 
 | 795 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 796 |     template <class _Up> using rebind = __pointer_traits_rebind<pointer, _Up>::type; | 
 | 797 | #else | 
 | 798 |     template <class _Up> struct rebind | 
 | 799 |         {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 800 | #endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 801 |  | 
 | 802 | private: | 
 | 803 |     struct __nat {}; | 
 | 804 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 805 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 806 |     static pointer pointer_to(typename conditional<is_void<element_type>::value, | 
 | 807 |                                            __nat, element_type>::type& __r) | 
 | 808 |         {return pointer::pointer_to(__r);} | 
 | 809 | }; | 
 | 810 |  | 
 | 811 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 812 | struct _LIBCPP_VISIBLE pointer_traits<_Tp*> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 813 | { | 
 | 814 |     typedef _Tp*      pointer; | 
 | 815 |     typedef _Tp       element_type; | 
 | 816 |     typedef ptrdiff_t difference_type; | 
 | 817 |  | 
 | 818 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 819 |     template <class _Up> using rebind = _Up*; | 
 | 820 | #else | 
 | 821 |     template <class _Up> struct rebind {typedef _Up* other;}; | 
 | 822 | #endif | 
 | 823 |  | 
 | 824 | private: | 
 | 825 |     struct __nat {}; | 
 | 826 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 827 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 828 |     static pointer pointer_to(typename conditional<is_void<element_type>::value, | 
 | 829 |                                            __nat, element_type>::type& __r) | 
 | 830 |         {return _STD::addressof(__r);} | 
 | 831 | }; | 
 | 832 |  | 
 | 833 | // allocator_traits | 
 | 834 |  | 
 | 835 | namespace __has_pointer_type_imp | 
 | 836 | { | 
 | 837 |     template <class _Up> static __two test(...); | 
 | 838 |     template <class _Up> static char test(typename _Up::pointer* = 0); | 
 | 839 | } | 
 | 840 |  | 
 | 841 | template <class _Tp> | 
 | 842 | struct __has_pointer_type | 
 | 843 |     : public integral_constant<bool, sizeof(__has_pointer_type_imp::test<_Tp>(0)) == 1> | 
 | 844 | { | 
 | 845 | }; | 
 | 846 |  | 
 | 847 | namespace __pointer_type_imp | 
 | 848 | { | 
 | 849 |  | 
 | 850 | template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value> | 
 | 851 | struct __pointer_type | 
 | 852 | { | 
 | 853 |     typedef typename _Dp::pointer type; | 
 | 854 | }; | 
 | 855 |  | 
 | 856 | template <class _Tp, class _Dp> | 
 | 857 | struct __pointer_type<_Tp, _Dp, false> | 
 | 858 | { | 
 | 859 |     typedef _Tp* type; | 
 | 860 | }; | 
 | 861 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame^] | 862 | }  // __pointer_type_imp | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 863 |  | 
 | 864 | template <class _Tp, class _Dp> | 
 | 865 | struct __pointer_type | 
 | 866 | { | 
 | 867 |     typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type; | 
 | 868 | }; | 
 | 869 |  | 
 | 870 | template <class _Tp> | 
 | 871 | struct __has_const_pointer | 
 | 872 | { | 
 | 873 | private: | 
 | 874 |     struct __two {char _; char __;}; | 
 | 875 |     template <class _Up> static __two __test(...); | 
 | 876 |     template <class _Up> static char __test(typename _Up::const_pointer* = 0); | 
 | 877 | public: | 
 | 878 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 879 | }; | 
 | 880 |  | 
 | 881 | template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value> | 
 | 882 | struct __const_pointer | 
 | 883 | { | 
 | 884 |     typedef typename _Alloc::const_pointer type; | 
 | 885 | }; | 
 | 886 |  | 
 | 887 | template <class _Tp, class _Ptr, class _Alloc> | 
 | 888 | struct __const_pointer<_Tp, _Ptr, _Alloc, false> | 
 | 889 | { | 
 | 890 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 891 |     typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; | 
 | 892 | #else | 
 | 893 |     typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; | 
 | 894 | #endif | 
 | 895 | }; | 
 | 896 |  | 
 | 897 | template <class _Tp> | 
 | 898 | struct __has_void_pointer | 
 | 899 | { | 
 | 900 | private: | 
 | 901 |     struct __two {char _; char __;}; | 
 | 902 |     template <class _Up> static __two __test(...); | 
 | 903 |     template <class _Up> static char __test(typename _Up::void_pointer* = 0); | 
 | 904 | public: | 
 | 905 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 906 | }; | 
 | 907 |  | 
 | 908 | template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value> | 
 | 909 | struct __void_pointer | 
 | 910 | { | 
 | 911 |     typedef typename _Alloc::void_pointer type; | 
 | 912 | }; | 
 | 913 |  | 
 | 914 | template <class _Ptr, class _Alloc> | 
 | 915 | struct __void_pointer<_Ptr, _Alloc, false> | 
 | 916 | { | 
 | 917 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 918 |     typedef typename pointer_traits<_Ptr>::template rebind<void> type; | 
 | 919 | #else | 
 | 920 |     typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; | 
 | 921 | #endif | 
 | 922 | }; | 
 | 923 |  | 
 | 924 | template <class _Tp> | 
 | 925 | struct __has_const_void_pointer | 
 | 926 | { | 
 | 927 | private: | 
 | 928 |     struct __two {char _; char __;}; | 
 | 929 |     template <class _Up> static __two __test(...); | 
 | 930 |     template <class _Up> static char __test(typename _Up::const_void_pointer* = 0); | 
 | 931 | public: | 
 | 932 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 933 | }; | 
 | 934 |  | 
 | 935 | template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value> | 
 | 936 | struct __const_void_pointer | 
 | 937 | { | 
 | 938 |     typedef typename _Alloc::const_void_pointer type; | 
 | 939 | }; | 
 | 940 |  | 
 | 941 | template <class _Ptr, class _Alloc> | 
 | 942 | struct __const_void_pointer<_Ptr, _Alloc, false> | 
 | 943 | { | 
 | 944 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 945 |     typedef typename pointer_traits<_Ptr>::template rebind<const void> type; | 
 | 946 | #else | 
 | 947 |     typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; | 
 | 948 | #endif | 
 | 949 | }; | 
 | 950 |  | 
 | 951 | template <class _T> | 
 | 952 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 953 | _T* | 
 | 954 | __to_raw_pointer(_T* __p) | 
 | 955 | { | 
 | 956 |     return __p; | 
 | 957 | } | 
 | 958 |  | 
 | 959 | template <class _Pointer> | 
 | 960 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 961 | typename pointer_traits<_Pointer>::element_type* | 
 | 962 | __to_raw_pointer(_Pointer __p) | 
 | 963 | { | 
 | 964 |     return _STD::__to_raw_pointer(__p.operator->()); | 
 | 965 | } | 
 | 966 |  | 
 | 967 | template <class _Tp> | 
 | 968 | struct __has_size_type | 
 | 969 | { | 
 | 970 | private: | 
 | 971 |     struct __two {char _; char __;}; | 
 | 972 |     template <class _Up> static __two __test(...); | 
 | 973 |     template <class _Up> static char __test(typename _Up::size_type* = 0); | 
 | 974 | public: | 
 | 975 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 976 | }; | 
 | 977 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame^] | 978 | template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 979 | struct __size_type | 
 | 980 | { | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame^] | 981 |     typedef typename make_unsigned<_DiffType>::type type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 982 | }; | 
 | 983 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame^] | 984 | template <class _Alloc, class _DiffType> | 
 | 985 | struct __size_type<_Alloc, _DiffType, true> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 986 | { | 
 | 987 |     typedef typename _Alloc::size_type type; | 
 | 988 | }; | 
 | 989 |  | 
 | 990 | template <class _Tp> | 
 | 991 | struct __has_propagate_on_container_copy_assignment | 
 | 992 | { | 
 | 993 | private: | 
 | 994 |     struct __two {char _; char __;}; | 
 | 995 |     template <class _Up> static __two __test(...); | 
 | 996 |     template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0); | 
 | 997 | public: | 
 | 998 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 999 | }; | 
 | 1000 |  | 
 | 1001 | template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value> | 
 | 1002 | struct __propagate_on_container_copy_assignment | 
 | 1003 | { | 
 | 1004 |     typedef false_type type; | 
 | 1005 | }; | 
 | 1006 |  | 
 | 1007 | template <class _Alloc> | 
 | 1008 | struct __propagate_on_container_copy_assignment<_Alloc, true> | 
 | 1009 | { | 
 | 1010 |     typedef typename _Alloc::propagate_on_container_copy_assignment type; | 
 | 1011 | }; | 
 | 1012 |  | 
 | 1013 | template <class _Tp> | 
 | 1014 | struct __has_propagate_on_container_move_assignment | 
 | 1015 | { | 
 | 1016 | private: | 
 | 1017 |     struct __two {char _; char __;}; | 
 | 1018 |     template <class _Up> static __two __test(...); | 
 | 1019 |     template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0); | 
 | 1020 | public: | 
 | 1021 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1022 | }; | 
 | 1023 |  | 
 | 1024 | template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value> | 
 | 1025 | struct __propagate_on_container_move_assignment | 
 | 1026 | { | 
 | 1027 |     typedef false_type type; | 
 | 1028 | }; | 
 | 1029 |  | 
 | 1030 | template <class _Alloc> | 
 | 1031 | struct __propagate_on_container_move_assignment<_Alloc, true> | 
 | 1032 | { | 
 | 1033 |     typedef typename _Alloc::propagate_on_container_move_assignment type; | 
 | 1034 | }; | 
 | 1035 |  | 
 | 1036 | template <class _Tp> | 
 | 1037 | struct __has_propagate_on_container_swap | 
 | 1038 | { | 
 | 1039 | private: | 
 | 1040 |     struct __two {char _; char __;}; | 
 | 1041 |     template <class _Up> static __two __test(...); | 
 | 1042 |     template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0); | 
 | 1043 | public: | 
 | 1044 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1045 | }; | 
 | 1046 |  | 
 | 1047 | template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> | 
 | 1048 | struct __propagate_on_container_swap | 
 | 1049 | { | 
 | 1050 |     typedef false_type type; | 
 | 1051 | }; | 
 | 1052 |  | 
 | 1053 | template <class _Alloc> | 
 | 1054 | struct __propagate_on_container_swap<_Alloc, true> | 
 | 1055 | { | 
 | 1056 |     typedef typename _Alloc::propagate_on_container_swap type; | 
 | 1057 | }; | 
 | 1058 |  | 
 | 1059 | template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> | 
 | 1060 | struct __has_rebind_other | 
 | 1061 | { | 
 | 1062 | private: | 
 | 1063 |     struct __two {char _; char __;}; | 
 | 1064 |     template <class _Xp> static __two __test(...); | 
 | 1065 |     template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); | 
 | 1066 | public: | 
 | 1067 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1068 | }; | 
 | 1069 |  | 
 | 1070 | template <class _Tp, class _Up> | 
 | 1071 | struct __has_rebind_other<_Tp, _Up, false> | 
 | 1072 | { | 
 | 1073 |     static const bool value = false; | 
 | 1074 | }; | 
 | 1075 |  | 
 | 1076 | template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> | 
 | 1077 | struct __allocator_traits_rebind | 
 | 1078 | { | 
 | 1079 |     typedef typename _Tp::template rebind<_Up>::other type; | 
 | 1080 | }; | 
 | 1081 |  | 
 | 1082 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1083 |  | 
 | 1084 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> | 
 | 1085 | struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> | 
 | 1086 | { | 
 | 1087 |     typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; | 
 | 1088 | }; | 
 | 1089 |  | 
 | 1090 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> | 
 | 1091 | struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> | 
 | 1092 | { | 
 | 1093 |     typedef _Alloc<_Up, _Args...> type; | 
 | 1094 | }; | 
 | 1095 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1096 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1097 |  | 
 | 1098 | template <template <class> class _Alloc, class _Tp, class _Up> | 
 | 1099 | struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true> | 
 | 1100 | { | 
 | 1101 |     typedef typename _Alloc<_Tp>::template rebind<_Up>::other type; | 
 | 1102 | }; | 
 | 1103 |  | 
 | 1104 | template <template <class> class _Alloc, class _Tp, class _Up> | 
 | 1105 | struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false> | 
 | 1106 | { | 
 | 1107 |     typedef _Alloc<_Up> type; | 
 | 1108 | }; | 
 | 1109 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1110 | template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> | 
 | 1111 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true> | 
 | 1112 | { | 
 | 1113 |     typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type; | 
 | 1114 | }; | 
 | 1115 |  | 
 | 1116 | template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> | 
 | 1117 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false> | 
 | 1118 | { | 
 | 1119 |     typedef _Alloc<_Up, _A0> type; | 
 | 1120 | }; | 
 | 1121 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1122 | template <template <class, class, class> class _Alloc, class _Tp, class _A0, | 
 | 1123 |                                          class _A1, class _Up> | 
 | 1124 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true> | 
 | 1125 | { | 
 | 1126 |     typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type; | 
 | 1127 | }; | 
 | 1128 |  | 
 | 1129 | template <template <class, class, class> class _Alloc, class _Tp, class _A0, | 
 | 1130 |                                          class _A1, class _Up> | 
 | 1131 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false> | 
 | 1132 | { | 
 | 1133 |     typedef _Alloc<_Up, _A0, _A1> type; | 
 | 1134 | }; | 
 | 1135 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1136 | template <template <class, class, class, class> class _Alloc, class _Tp, class _A0, | 
 | 1137 |                                                 class _A1, class _A2, class _Up> | 
 | 1138 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true> | 
 | 1139 | { | 
 | 1140 |     typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; | 
 | 1141 | }; | 
 | 1142 |  | 
 | 1143 | template <template <class, class, class, class> class _Alloc, class _Tp, class _A0, | 
 | 1144 |                                                 class _A1, class _A2, class _Up> | 
 | 1145 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> | 
 | 1146 | { | 
 | 1147 |     typedef _Alloc<_Up, _A0, _A1, _A2> type; | 
 | 1148 | }; | 
 | 1149 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1150 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1151 |  | 
 | 1152 | #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
 | 1153 |  | 
 | 1154 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 
 | 1155 | auto | 
 | 1156 | __has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) | 
 | 1157 |     -> decltype(__a.allocate(__sz, __p), true_type()); | 
 | 1158 |  | 
 | 1159 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 
 | 1160 | auto | 
 | 1161 | __has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) | 
 | 1162 |     -> false_type; | 
 | 1163 |  | 
 | 1164 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 
 | 1165 | struct __has_allocate_hint | 
 | 1166 |     : integral_constant<bool, | 
 | 1167 |         is_same< | 
 | 1168 |             decltype(__has_allocate_hint_test(declval<_Alloc>(), | 
 | 1169 |                                           declval<_SizeType>(), | 
 | 1170 |                                           declval<_ConstVoidPtr>())), | 
 | 1171 |             true_type>::value> | 
 | 1172 | { | 
 | 1173 | }; | 
 | 1174 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1175 | #else  // _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1176 |  | 
 | 1177 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 
 | 1178 | struct __has_allocate_hint | 
 | 1179 |     : true_type | 
 | 1180 | { | 
 | 1181 | }; | 
 | 1182 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1183 | #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1184 |  | 
 | 1185 | #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
 | 1186 |  | 
 | 1187 | template <class _Alloc, class _Tp, class ..._Args> | 
 | 1188 | decltype(_STD::declval<_Alloc>().construct(_STD::declval<_Tp*>(), | 
 | 1189 |                                            _STD::declval<_Args>()...), | 
 | 1190 |                                            true_type()) | 
 | 1191 | __has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args); | 
 | 1192 |  | 
 | 1193 | template <class _Alloc, class _Pointer, class ..._Args> | 
 | 1194 | false_type | 
 | 1195 | __has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args); | 
 | 1196 |  | 
 | 1197 | template <class _Alloc, class _Pointer, class ..._Args> | 
 | 1198 | struct __has_construct | 
 | 1199 |     : integral_constant<bool, | 
 | 1200 |         is_same< | 
 | 1201 |             decltype(__has_construct_test(declval<_Alloc>(), | 
 | 1202 |                                           declval<_Pointer>(), | 
 | 1203 |                                           declval<_Args>()...)), | 
 | 1204 |             true_type>::value> | 
 | 1205 | { | 
 | 1206 | }; | 
 | 1207 |  | 
 | 1208 | template <class _Alloc, class _Pointer> | 
 | 1209 | auto | 
 | 1210 | __has_destroy_test(_Alloc&& __a, _Pointer&& __p) | 
 | 1211 |     -> decltype(__a.destroy(__p), true_type()); | 
 | 1212 |  | 
 | 1213 | template <class _Alloc, class _Pointer> | 
 | 1214 | auto | 
 | 1215 | __has_destroy_test(const _Alloc& __a, _Pointer&& __p) | 
 | 1216 |     -> false_type; | 
 | 1217 |  | 
 | 1218 | template <class _Alloc, class _Pointer> | 
 | 1219 | struct __has_destroy | 
 | 1220 |     : integral_constant<bool, | 
 | 1221 |         is_same< | 
 | 1222 |             decltype(__has_destroy_test(declval<_Alloc>(), | 
 | 1223 |                                         declval<_Pointer>())), | 
 | 1224 |             true_type>::value> | 
 | 1225 | { | 
 | 1226 | }; | 
 | 1227 |  | 
 | 1228 | template <class _Alloc> | 
 | 1229 | auto | 
 | 1230 | __has_max_size_test(_Alloc&& __a) | 
 | 1231 |     -> decltype(__a.max_size(), true_type()); | 
 | 1232 |  | 
 | 1233 | template <class _Alloc> | 
 | 1234 | auto | 
 | 1235 | __has_max_size_test(const volatile _Alloc& __a) | 
 | 1236 |     -> false_type; | 
 | 1237 |  | 
 | 1238 | template <class _Alloc> | 
 | 1239 | struct __has_max_size | 
 | 1240 |     : integral_constant<bool, | 
 | 1241 |         is_same< | 
 | 1242 |             decltype(__has_max_size_test(declval<_Alloc&>())), | 
 | 1243 |             true_type>::value> | 
 | 1244 | { | 
 | 1245 | }; | 
 | 1246 |  | 
 | 1247 | template <class _Alloc> | 
 | 1248 | auto | 
 | 1249 | __has_select_on_container_copy_construction_test(_Alloc&& __a) | 
 | 1250 |     -> decltype(__a.select_on_container_copy_construction(), true_type()); | 
 | 1251 |  | 
 | 1252 | template <class _Alloc> | 
 | 1253 | auto | 
 | 1254 | __has_select_on_container_copy_construction_test(const volatile _Alloc& __a) | 
 | 1255 |     -> false_type; | 
 | 1256 |  | 
 | 1257 | template <class _Alloc> | 
 | 1258 | struct __has_select_on_container_copy_construction | 
 | 1259 |     : integral_constant<bool, | 
 | 1260 |         is_same< | 
 | 1261 |             decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())), | 
 | 1262 |             true_type>::value> | 
 | 1263 | { | 
 | 1264 | }; | 
 | 1265 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1266 | #else  // _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1267 |  | 
 | 1268 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1269 |  | 
 | 1270 | template <class _Alloc, class _Pointer, class ..._Args> | 
 | 1271 | struct __has_construct | 
 | 1272 |     : false_type | 
 | 1273 | { | 
 | 1274 | }; | 
 | 1275 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1276 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1277 |  | 
 | 1278 | template <class _Alloc, class _Pointer> | 
 | 1279 | struct __has_destroy | 
 | 1280 |     : false_type | 
 | 1281 | { | 
 | 1282 | }; | 
 | 1283 |  | 
 | 1284 | template <class _Alloc> | 
 | 1285 | struct __has_max_size | 
 | 1286 |     : true_type | 
 | 1287 | { | 
 | 1288 | }; | 
 | 1289 |  | 
 | 1290 | template <class _Alloc> | 
 | 1291 | struct __has_select_on_container_copy_construction | 
 | 1292 |     : false_type | 
 | 1293 | { | 
 | 1294 | }; | 
 | 1295 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1296 | #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1297 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame^] | 1298 | template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> | 
 | 1299 | struct __alloc_traits_difference_type | 
 | 1300 | { | 
 | 1301 |     typedef typename pointer_traits<_Ptr>::difference_type type; | 
 | 1302 | }; | 
 | 1303 |  | 
 | 1304 | template <class _Alloc, class _Ptr> | 
 | 1305 | struct __alloc_traits_difference_type<_Alloc, _Ptr, true> | 
 | 1306 | { | 
 | 1307 |     typedef typename _Alloc::difference_type type; | 
 | 1308 | }; | 
 | 1309 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1310 | template <class _Alloc> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1311 | struct _LIBCPP_VISIBLE allocator_traits | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1312 | { | 
 | 1313 |     typedef _Alloc                              allocator_type; | 
 | 1314 |     typedef typename allocator_type::value_type value_type; | 
 | 1315 |  | 
 | 1316 |     typedef typename __pointer_type<value_type, allocator_type>::type pointer; | 
 | 1317 |     typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer; | 
 | 1318 |     typedef typename __void_pointer<pointer, allocator_type>::type void_pointer; | 
 | 1319 |     typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer; | 
 | 1320 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame^] | 1321 |     typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type; | 
 | 1322 |     typedef typename __size_type<allocator_type, difference_type>::type size_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1323 |  | 
 | 1324 |     typedef typename __propagate_on_container_copy_assignment<allocator_type>::type | 
 | 1325 |                      propagate_on_container_copy_assignment; | 
 | 1326 |     typedef typename __propagate_on_container_move_assignment<allocator_type>::type | 
 | 1327 |                      propagate_on_container_move_assignment; | 
 | 1328 |     typedef typename __propagate_on_container_swap<allocator_type>::type | 
 | 1329 |                      propagate_on_container_swap; | 
 | 1330 |  | 
 | 1331 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 1332 |     template <class _Tp> using rebind_alloc = | 
 | 1333 |                            __allocator_traits_rebind<allocator_type, _Tp>::type; | 
 | 1334 |     template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1335 | #else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1336 |     template <class _Tp> struct rebind_alloc | 
 | 1337 |         {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;}; | 
 | 1338 |     template <class _Tp> struct rebind_traits | 
 | 1339 |         {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;}; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1340 | #endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1341 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1342 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1343 |     static pointer allocate(allocator_type& __a, size_type __n) | 
 | 1344 |         {return __a.allocate(__n);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1345 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1346 |     static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) | 
 | 1347 |         {return allocate(__a, __n, __hint, | 
 | 1348 |             __has_allocate_hint<allocator_type, size_type, const_void_pointer>());} | 
 | 1349 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1350 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1351 |     static void deallocate(allocator_type& __a, pointer __p, size_type __n) | 
 | 1352 |         {__a.deallocate(__p, __n);} | 
 | 1353 |  | 
 | 1354 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1355 |     template <class _Tp, class... _Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1356 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1357 |         static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) | 
 | 1358 |             {__construct(__has_construct<allocator_type, pointer, _Args...>(), | 
 | 1359 |                          __a, __p, _STD::forward<_Args>(__args)...);} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1360 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1361 |     template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1362 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1363 |         static void construct(allocator_type& __a, _Tp* __p) | 
 | 1364 |             { | 
 | 1365 |                 ::new ((void*)__p) _Tp(); | 
 | 1366 |             } | 
 | 1367 |     template <class _Tp, class _A0> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1368 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1369 |         static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0) | 
 | 1370 |             { | 
 | 1371 |                 ::new ((void*)__p) _Tp(__a0); | 
 | 1372 |             } | 
 | 1373 |     template <class _Tp, class _A0, class _A1> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1374 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1375 |         static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, | 
 | 1376 |                               const _A1& __a1) | 
 | 1377 |             { | 
 | 1378 |                 ::new ((void*)__p) _Tp(__a0, __a1); | 
 | 1379 |             } | 
 | 1380 |     template <class _Tp, class _A0, class _A1, class _A2> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1381 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1382 |         static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, | 
 | 1383 |                               const _A1& __a1, const _A2& __a2) | 
 | 1384 |             { | 
 | 1385 |                 ::new ((void*)__p) _Tp(__a0, __a1, __a2); | 
 | 1386 |             } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1387 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1388 |  | 
 | 1389 |     template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1390 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1391 |         static void destroy(allocator_type& __a, _Tp* __p) | 
 | 1392 |             {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} | 
 | 1393 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1394 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1395 |     static size_type max_size(const allocator_type& __a) | 
 | 1396 |         {return __max_size(__has_max_size<const allocator_type>(), __a);} | 
 | 1397 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1398 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1399 |     static allocator_type | 
 | 1400 |         select_on_container_copy_construction(const allocator_type& __a) | 
 | 1401 |             {return select_on_container_copy_construction( | 
 | 1402 |                 __has_select_on_container_copy_construction<const allocator_type>(), | 
 | 1403 |                 __a);} | 
 | 1404 |  | 
 | 1405 | private: | 
 | 1406 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1407 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1408 |     static pointer allocate(allocator_type& __a, size_type __n, | 
 | 1409 |         const_void_pointer __hint, true_type) | 
 | 1410 |         {return __a.allocate(__n, __hint);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1411 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1412 |     static pointer allocate(allocator_type& __a, size_type __n, | 
 | 1413 |         const_void_pointer __hint, false_type) | 
 | 1414 |         {return __a.allocate(__n);} | 
 | 1415 |  | 
 | 1416 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1417 |     template <class _Tp, class... _Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1418 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1419 |         static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) | 
 | 1420 |             {__a.construct(__p, _STD::forward<_Args>(__args)...);} | 
 | 1421 |     template <class _Tp, class... _Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1422 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1423 |         static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) | 
 | 1424 |             { | 
 | 1425 |                 ::new ((void*)__p) _Tp(_STD::forward<_Args>(__args)...); | 
 | 1426 |             } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1427 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1428 |  | 
 | 1429 |     template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1430 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1431 |         static void __destroy(true_type, allocator_type& __a, _Tp* __p) | 
 | 1432 |             {__a.destroy(__p);} | 
 | 1433 |     template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1434 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1435 |         static void __destroy(false_type, allocator_type&, _Tp* __p) | 
 | 1436 |             { | 
 | 1437 |                 __p->~_Tp(); | 
 | 1438 |             } | 
 | 1439 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1440 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1441 |     static size_type __max_size(true_type, const allocator_type& __a) | 
 | 1442 |             {return __a.max_size();} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1443 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1444 |     static size_type __max_size(false_type, const allocator_type&) | 
 | 1445 |             {return numeric_limits<size_type>::max();} | 
 | 1446 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1447 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1448 |     static allocator_type | 
 | 1449 |         select_on_container_copy_construction(true_type, const allocator_type& __a) | 
 | 1450 |             {return __a.select_on_container_copy_construction();} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1451 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1452 |     static allocator_type | 
 | 1453 |         select_on_container_copy_construction(false_type, const allocator_type& __a) | 
 | 1454 |             {return __a;} | 
 | 1455 | }; | 
 | 1456 |  | 
 | 1457 | // uses_allocator | 
 | 1458 |  | 
 | 1459 | template <class _Tp> | 
 | 1460 | struct __has_allocator_type | 
 | 1461 | { | 
 | 1462 | private: | 
 | 1463 |     struct __two {char _; char __;}; | 
 | 1464 |     template <class _Up> static __two __test(...); | 
 | 1465 |     template <class _Up> static char __test(typename _Up::allocator_type* = 0); | 
 | 1466 | public: | 
 | 1467 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1468 | }; | 
 | 1469 |  | 
 | 1470 | template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value> | 
 | 1471 | struct __uses_allocator | 
 | 1472 |     : public integral_constant<bool, | 
 | 1473 |         is_convertible<_Alloc, typename _Tp::allocator_type>::value> | 
 | 1474 | { | 
 | 1475 | }; | 
 | 1476 |  | 
 | 1477 | template <class _Tp, class _Alloc> | 
 | 1478 | struct __uses_allocator<_Tp, _Alloc, false> | 
 | 1479 |     : public false_type | 
 | 1480 | { | 
 | 1481 | }; | 
 | 1482 |  | 
 | 1483 | template <class _Tp, class _Alloc> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1484 | struct _LIBCPP_VISIBLE uses_allocator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1485 |     : public __uses_allocator<_Tp, _Alloc> | 
 | 1486 | { | 
 | 1487 | }; | 
 | 1488 |  | 
| Howard Hinnant | 726a76f | 2010-11-16 21:10:23 +0000 | [diff] [blame] | 1489 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1490 |  | 
 | 1491 | // uses-allocator construction | 
 | 1492 |  | 
 | 1493 | template <class _Tp, class _Alloc, class ..._Args> | 
 | 1494 | struct __uses_alloc_ctor_imp | 
 | 1495 | { | 
 | 1496 |     static const bool __ua = uses_allocator<_Tp, _Alloc>::value; | 
 | 1497 |     static const bool __ic = | 
 | 1498 |         is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; | 
 | 1499 |     static const int value = __ua ? 2 - __ic : 0; | 
 | 1500 | }; | 
 | 1501 |  | 
 | 1502 | template <class _Tp, class _Alloc, class ..._Args> | 
 | 1503 | struct __uses_alloc_ctor | 
 | 1504 |     : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value> | 
 | 1505 |     {}; | 
 | 1506 |  | 
| Howard Hinnant | 726a76f | 2010-11-16 21:10:23 +0000 | [diff] [blame] | 1507 | #endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1508 |  | 
 | 1509 | // allocator | 
 | 1510 |  | 
 | 1511 | template <class _Tp> | 
| Howard Hinnant | 36cdf02 | 2010-09-10 16:42:26 +0000 | [diff] [blame] | 1512 | class _LIBCPP_VISIBLE allocator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1513 | { | 
 | 1514 | public: | 
 | 1515 |     typedef size_t            size_type; | 
 | 1516 |     typedef ptrdiff_t         difference_type; | 
 | 1517 |     typedef _Tp*              pointer; | 
 | 1518 |     typedef const _Tp*        const_pointer; | 
 | 1519 |     typedef _Tp&              reference; | 
 | 1520 |     typedef const _Tp&        const_reference; | 
 | 1521 |     typedef _Tp               value_type; | 
 | 1522 |  | 
 | 1523 |     template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 
 | 1524 |  | 
 | 1525 |     _LIBCPP_INLINE_VISIBILITY allocator() throw() {} | 
 | 1526 |     template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) throw() {} | 
 | 1527 |     _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const             {return addressof(__x);} | 
 | 1528 |     _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const {return addressof(__x);} | 
 | 1529 |     _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) | 
 | 1530 |         {return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));} | 
 | 1531 |     _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) {::operator delete((void*)__p);} | 
 | 1532 |     _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);} | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1533 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1534 |     template <class _Up, class... _Args> | 
 | 1535 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1536 |         void | 
 | 1537 |         construct(_Up* __p, _Args&&... __args) | 
 | 1538 |         { | 
 | 1539 |             ::new((void*)__p) _Up(_STD::forward<_Args>(__args)...); | 
 | 1540 |         } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1541 | #else  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1542 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1543 |         void | 
 | 1544 |         construct(pointer __p) | 
 | 1545 |         { | 
 | 1546 |             ::new((void*)__p) _Tp(); | 
 | 1547 |         } | 
 | 1548 |     template <class _A0> | 
 | 1549 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1550 |         typename enable_if | 
 | 1551 |         < | 
 | 1552 |             !is_convertible<_A0, __rv<_A0> >::value, | 
 | 1553 |             void | 
 | 1554 |         >::type | 
 | 1555 |         construct(pointer __p, _A0& __a0) | 
 | 1556 |         { | 
 | 1557 |             ::new((void*)__p) _Tp(__a0); | 
 | 1558 |         } | 
 | 1559 |     template <class _A0> | 
 | 1560 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1561 |         typename enable_if | 
 | 1562 |         < | 
 | 1563 |             !is_convertible<_A0, __rv<_A0> >::value, | 
 | 1564 |             void | 
 | 1565 |         >::type | 
 | 1566 |         construct(pointer __p, const _A0& __a0) | 
 | 1567 |         { | 
 | 1568 |             ::new((void*)__p) _Tp(__a0); | 
 | 1569 |         } | 
 | 1570 |     template <class _A0> | 
 | 1571 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1572 |         typename enable_if | 
 | 1573 |         < | 
 | 1574 |             is_convertible<_A0, __rv<_A0> >::value, | 
 | 1575 |             void | 
 | 1576 |         >::type | 
 | 1577 |         construct(pointer __p, _A0 __a0) | 
 | 1578 |         { | 
 | 1579 |             ::new((void*)__p) _Tp(_STD::move(__a0)); | 
 | 1580 |         } | 
 | 1581 |     template <class _A0, class _A1> | 
 | 1582 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1583 |         void | 
 | 1584 |         construct(pointer __p, _A0& __a0, _A1& __a1) | 
 | 1585 |         { | 
 | 1586 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1587 |         } | 
 | 1588 |     template <class _A0, class _A1> | 
 | 1589 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1590 |         void | 
 | 1591 |         construct(pointer __p, const _A0& __a0, _A1& __a1) | 
 | 1592 |         { | 
 | 1593 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1594 |         } | 
 | 1595 |     template <class _A0, class _A1> | 
 | 1596 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1597 |         void | 
 | 1598 |         construct(pointer __p, _A0& __a0, const _A1& __a1) | 
 | 1599 |         { | 
 | 1600 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1601 |         } | 
 | 1602 |     template <class _A0, class _A1> | 
 | 1603 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1604 |         void | 
 | 1605 |         construct(pointer __p, const _A0& __a0, const _A1& __a1) | 
 | 1606 |         { | 
 | 1607 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1608 |         } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1609 | #endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1610 |     _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} | 
 | 1611 | }; | 
 | 1612 |  | 
 | 1613 | template <class _Tp, class _Up> | 
 | 1614 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 1615 | bool operator==(const allocator<_Tp>&, const allocator<_Up>&) throw() {return true;} | 
 | 1616 |  | 
 | 1617 | template <class _Tp, class _Up> | 
 | 1618 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 1619 | bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) throw() {return false;} | 
 | 1620 |  | 
 | 1621 | template <class _OutputIterator, class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1622 | class _LIBCPP_VISIBLE raw_storage_iterator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1623 |     : public iterator<output_iterator_tag, | 
 | 1624 |                       _Tp,                                         // purposefully not C++03 | 
 | 1625 |                       ptrdiff_t,                                   // purposefully not C++03 | 
 | 1626 |                       _Tp*,                                        // purposefully not C++03 | 
 | 1627 |                       raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03 | 
 | 1628 | { | 
 | 1629 | private: | 
 | 1630 |     _OutputIterator __x_; | 
 | 1631 | public: | 
 | 1632 |     _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} | 
 | 1633 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} | 
 | 1634 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) | 
 | 1635 |         {::new(&*__x_) _Tp(__element); return *this;} | 
 | 1636 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} | 
 | 1637 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator  operator++(int) | 
 | 1638 |         {raw_storage_iterator __t(*this); ++__x_; return __t;} | 
 | 1639 | }; | 
 | 1640 |  | 
 | 1641 | template <class _Tp> | 
 | 1642 | pair<_Tp*, ptrdiff_t> | 
 | 1643 | get_temporary_buffer(ptrdiff_t __n) | 
 | 1644 | { | 
 | 1645 |     pair<_Tp*, ptrdiff_t> __r(0, 0); | 
 | 1646 |     const ptrdiff_t __m = (~ptrdiff_t(0) ^ | 
 | 1647 |                            ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) | 
 | 1648 |                            / sizeof(_Tp); | 
 | 1649 |     if (__n > __m) | 
 | 1650 |         __n = __m; | 
 | 1651 |     while (__n > 0) | 
 | 1652 |     { | 
 | 1653 |         __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); | 
 | 1654 |         if (__r.first) | 
 | 1655 |         { | 
 | 1656 |             __r.second = __n; | 
 | 1657 |             break; | 
 | 1658 |         } | 
 | 1659 |         __n /= 2; | 
 | 1660 |     } | 
 | 1661 |     return __r; | 
 | 1662 | } | 
 | 1663 |  | 
 | 1664 | template <class _Tp> | 
 | 1665 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 1666 | void return_temporary_buffer(_Tp* __p) {::operator delete(__p);} | 
 | 1667 |  | 
 | 1668 | template <class _Tp> | 
 | 1669 | struct auto_ptr_ref | 
 | 1670 | { | 
 | 1671 |     _Tp* __ptr_; | 
 | 1672 | }; | 
 | 1673 |  | 
 | 1674 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1675 | class _LIBCPP_VISIBLE auto_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1676 | { | 
 | 1677 | private: | 
 | 1678 |     _Tp* __ptr_; | 
 | 1679 | public: | 
 | 1680 |     typedef _Tp element_type; | 
 | 1681 |  | 
 | 1682 |     _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} | 
 | 1683 |     _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} | 
 | 1684 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() | 
 | 1685 |         : __ptr_(__p.release()) {} | 
 | 1686 |     _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() | 
 | 1687 |         {reset(__p.release()); return *this;} | 
 | 1688 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() | 
 | 1689 |         {reset(__p.release()); return *this;} | 
 | 1690 |     _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() | 
 | 1691 |         {reset(__p.__ptr_); return *this;} | 
 | 1692 |     _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} | 
 | 1693 |  | 
 | 1694 |     _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() | 
 | 1695 |         {return *__ptr_;} | 
 | 1696 |     _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} | 
 | 1697 |     _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} | 
 | 1698 |     _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() | 
 | 1699 |     { | 
 | 1700 |         _Tp* __t = __ptr_; | 
 | 1701 |         __ptr_ = 0; | 
 | 1702 |         return __t; | 
 | 1703 |     } | 
 | 1704 |     _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() | 
 | 1705 |     { | 
 | 1706 |         if (__ptr_ != __p) | 
 | 1707 |             delete __ptr_; | 
 | 1708 |         __ptr_ = __p; | 
 | 1709 |     } | 
 | 1710 |  | 
 | 1711 |     _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} | 
 | 1712 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() | 
 | 1713 |         {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} | 
 | 1714 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() | 
 | 1715 |         {return auto_ptr<_Up>(release());} | 
 | 1716 | }; | 
 | 1717 |  | 
 | 1718 | template <> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1719 | class _LIBCPP_VISIBLE auto_ptr<void> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1720 | { | 
 | 1721 | public: | 
 | 1722 |     typedef void element_type; | 
 | 1723 | }; | 
 | 1724 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1725 | template <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, | 
 | 1726 |                                                      typename remove_cv<_T2>::type>::value, | 
 | 1727 |                                 bool = is_empty<_T1>::value, | 
 | 1728 |                                 bool = is_empty<_T2>::value> | 
 | 1729 | struct __libcpp_compressed_pair_switch; | 
 | 1730 |  | 
 | 1731 | template <class _T1, class _T2, bool IsSame> | 
 | 1732 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};}; | 
 | 1733 |  | 
 | 1734 | template <class _T1, class _T2, bool IsSame> | 
 | 1735 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false>  {enum {value = 1};}; | 
 | 1736 |  | 
 | 1737 | template <class _T1, class _T2, bool IsSame> | 
 | 1738 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true>  {enum {value = 2};}; | 
 | 1739 |  | 
 | 1740 | template <class _T1, class _T2> | 
 | 1741 | struct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true>    {enum {value = 3};}; | 
 | 1742 |  | 
 | 1743 | template <class _T1, class _T2> | 
 | 1744 | struct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true>     {enum {value = 1};}; | 
 | 1745 |  | 
 | 1746 | template <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value> | 
 | 1747 | class __libcpp_compressed_pair_imp; | 
 | 1748 |  | 
 | 1749 | template <class _T1, class _T2> | 
 | 1750 | class __libcpp_compressed_pair_imp<_T1, _T2, 0> | 
 | 1751 | { | 
 | 1752 | private: | 
 | 1753 |     _T1 __first_; | 
 | 1754 |     _T2 __second_; | 
 | 1755 | public: | 
 | 1756 |     typedef _T1 _T1_param; | 
 | 1757 |     typedef _T2 _T2_param; | 
 | 1758 |  | 
 | 1759 |     typedef typename remove_reference<_T1>::type& _T1_reference; | 
 | 1760 |     typedef typename remove_reference<_T2>::type& _T2_reference; | 
 | 1761 |  | 
 | 1762 |     typedef const typename remove_reference<_T1>::type& _T1_const_reference; | 
 | 1763 |     typedef const typename remove_reference<_T2>::type& _T2_const_reference; | 
 | 1764 |  | 
 | 1765 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 1766 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1, int = 0) | 
 | 1767 |         : __first_(_STD::forward<_T1_param>(__t1)) {} | 
 | 1768 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2, int* = 0) | 
 | 1769 |         : __second_(_STD::forward<_T2_param>(__t2)) {} | 
 | 1770 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) | 
 | 1771 |         : __first_(_STD::forward<_T1_param>(__t1)), __second_(_STD::forward<_T2_param>(__t2)) {} | 
 | 1772 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1773 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1774 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
 | 1775 |         : __first_(_STD::forward<_T1>(__p.first())), __second_(_STD::forward<_T2>(__p.second())) {} | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1776 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1777 |  | 
 | 1778 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first()       {return __first_;} | 
 | 1779 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const {return __first_;} | 
 | 1780 |  | 
 | 1781 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second()       {return __second_;} | 
 | 1782 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const {return __second_;} | 
 | 1783 |  | 
 | 1784 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
 | 1785 |     { | 
 | 1786 |         using _STD::swap; | 
 | 1787 |         swap(__first_, __x.__first_); | 
 | 1788 |         swap(__second_, __x.__second_); | 
 | 1789 |     } | 
 | 1790 | }; | 
 | 1791 |  | 
 | 1792 | template <class _T1, class _T2> | 
 | 1793 | class __libcpp_compressed_pair_imp<_T1, _T2, 1> | 
 | 1794 |     : private _T1 | 
 | 1795 | { | 
 | 1796 | private: | 
 | 1797 |     _T2 __second_; | 
 | 1798 | public: | 
 | 1799 |     typedef _T1 _T1_param; | 
 | 1800 |     typedef _T2 _T2_param; | 
 | 1801 |  | 
 | 1802 |     typedef _T1&                                        _T1_reference; | 
 | 1803 |     typedef typename remove_reference<_T2>::type& _T2_reference; | 
 | 1804 |  | 
 | 1805 |     typedef const _T1&                                        _T1_const_reference; | 
 | 1806 |     typedef const typename remove_reference<_T2>::type& _T2_const_reference; | 
 | 1807 |  | 
 | 1808 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 1809 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1, int = 0) | 
 | 1810 |         : _T1(_STD::forward<_T1_param>(__t1)) {} | 
 | 1811 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2, int* = 0) | 
 | 1812 |         : __second_(_STD::forward<_T2_param>(__t2)) {} | 
 | 1813 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) | 
 | 1814 |         : _T1(_STD::forward<_T1_param>(__t1)), __second_(_STD::forward<_T2_param>(__t2)) {} | 
 | 1815 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1816 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1817 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
 | 1818 |         : _T1(_STD::move(__p.first())), __second_(_STD::forward<_T2>(__p.second())) {} | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1819 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1820 |  | 
 | 1821 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first()       {return *this;} | 
 | 1822 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const {return *this;} | 
 | 1823 |  | 
 | 1824 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second()       {return __second_;} | 
 | 1825 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const {return __second_;} | 
 | 1826 |  | 
 | 1827 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
 | 1828 |     { | 
 | 1829 |         using _STD::swap; | 
 | 1830 |         swap(__second_, __x.__second_); | 
 | 1831 |     } | 
 | 1832 | }; | 
 | 1833 |  | 
 | 1834 | template <class _T1, class _T2> | 
 | 1835 | class __libcpp_compressed_pair_imp<_T1, _T2, 2> | 
 | 1836 |     : private _T2 | 
 | 1837 | { | 
 | 1838 | private: | 
 | 1839 |     _T1 __first_; | 
 | 1840 | public: | 
 | 1841 |     typedef _T1 _T1_param; | 
 | 1842 |     typedef _T2 _T2_param; | 
 | 1843 |  | 
 | 1844 |     typedef typename remove_reference<_T1>::type& _T1_reference; | 
 | 1845 |     typedef _T2&                                        _T2_reference; | 
 | 1846 |  | 
 | 1847 |     typedef const typename remove_reference<_T1>::type& _T1_const_reference; | 
 | 1848 |     typedef const _T2&                                        _T2_const_reference; | 
 | 1849 |  | 
 | 1850 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 1851 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) | 
 | 1852 |         : __first_(_STD::forward<_T1_param>(__t1)) {} | 
 | 1853 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) | 
 | 1854 |         : _T2(_STD::forward<_T2_param>(__t2)) {} | 
 | 1855 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) | 
 | 1856 |         : _T2(_STD::forward<_T2_param>(__t2)), __first_(_STD::forward<_T1_param>(__t1)) {} | 
 | 1857 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1858 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1859 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
 | 1860 |         : _T2(_STD::forward<_T2>(__p.second())), __first_(_STD::move(__p.first())) {} | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1861 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1862 |  | 
 | 1863 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first()       {return __first_;} | 
 | 1864 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const {return __first_;} | 
 | 1865 |  | 
 | 1866 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second()       {return *this;} | 
 | 1867 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const {return *this;} | 
 | 1868 |  | 
 | 1869 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
 | 1870 |     { | 
 | 1871 |         using _STD::swap; | 
 | 1872 |         swap(__first_, __x.__first_); | 
 | 1873 |     } | 
 | 1874 | }; | 
 | 1875 |  | 
 | 1876 | template <class _T1, class _T2> | 
 | 1877 | class __libcpp_compressed_pair_imp<_T1, _T2, 3> | 
 | 1878 |     : private _T1, | 
 | 1879 |       private _T2 | 
 | 1880 | { | 
 | 1881 | public: | 
 | 1882 |     typedef _T1 _T1_param; | 
 | 1883 |     typedef _T2 _T2_param; | 
 | 1884 |  | 
 | 1885 |     typedef _T1& _T1_reference; | 
 | 1886 |     typedef _T2& _T2_reference; | 
 | 1887 |  | 
 | 1888 |     typedef const _T1& _T1_const_reference; | 
 | 1889 |     typedef const _T2& _T2_const_reference; | 
 | 1890 |  | 
 | 1891 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 1892 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) | 
 | 1893 |         : _T1(_STD::forward<_T1_param>(__t1)) {} | 
 | 1894 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) | 
 | 1895 |         : _T2(_STD::forward<_T2_param>(__t2)) {} | 
 | 1896 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) | 
 | 1897 |         : _T1(_STD::forward<_T1_param>(__t1)), _T2(_STD::forward<_T2_param>(__t2)) {} | 
 | 1898 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1899 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1900 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
 | 1901 |         : _T1(_STD::move(__p.first())), _T2(_STD::move(__p.second())) {} | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1902 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1903 |  | 
 | 1904 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first()       {return *this;} | 
 | 1905 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const {return *this;} | 
 | 1906 |  | 
 | 1907 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second()       {return *this;} | 
 | 1908 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const {return *this;} | 
 | 1909 |  | 
 | 1910 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
 | 1911 |     { | 
 | 1912 |     } | 
 | 1913 | }; | 
 | 1914 |  | 
 | 1915 | template <class _T1, class _T2> | 
 | 1916 | class __compressed_pair | 
 | 1917 |     : private __libcpp_compressed_pair_imp<_T1, _T2> | 
 | 1918 | { | 
 | 1919 |     typedef __libcpp_compressed_pair_imp<_T1, _T2> base; | 
 | 1920 | public: | 
 | 1921 |     typedef typename base::_T1_param _T1_param; | 
 | 1922 |     typedef typename base::_T2_param _T2_param; | 
 | 1923 |  | 
 | 1924 |     typedef typename base::_T1_reference _T1_reference; | 
 | 1925 |     typedef typename base::_T2_reference _T2_reference; | 
 | 1926 |  | 
 | 1927 |     typedef typename base::_T1_const_reference _T1_const_reference; | 
 | 1928 |     typedef typename base::_T2_const_reference _T2_const_reference; | 
 | 1929 |  | 
 | 1930 |     _LIBCPP_INLINE_VISIBILITY __compressed_pair() {} | 
 | 1931 |     _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1, int = 0) | 
 | 1932 |         : base(_STD::forward<_T1_param>(__t1)) {} | 
 | 1933 |     _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2, int* = 0) | 
 | 1934 |         : base(_STD::forward<_T2_param>(__t2)) {} | 
 | 1935 |     _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) | 
 | 1936 |         : base(_STD::forward<_T1_param>(__t1), _STD::forward<_T2_param>(__t2)) {} | 
 | 1937 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1938 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1939 |     __compressed_pair(__compressed_pair&& __p) | 
 | 1940 |         : base(_STD::move(__p)) {} | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1941 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1942 |  | 
 | 1943 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first()       {return base::first();} | 
 | 1944 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const {return base::first();} | 
 | 1945 |  | 
 | 1946 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second()       {return base::second();} | 
 | 1947 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const {return base::second();} | 
 | 1948 |  | 
 | 1949 |     _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) {base::swap(__x);} | 
 | 1950 | }; | 
 | 1951 |  | 
 | 1952 | template <class _T1, class _T2> | 
 | 1953 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 1954 | void | 
 | 1955 | swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) | 
 | 1956 |     {__x.swap(__y);} | 
 | 1957 |  | 
 | 1958 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1959 | struct _LIBCPP_VISIBLE default_delete | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1960 | { | 
 | 1961 |     _LIBCPP_INLINE_VISIBILITY default_delete() {} | 
 | 1962 |     template <class _Up> | 
 | 1963 |         _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, | 
 | 1964 |                       typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) {} | 
 | 1965 |     _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const | 
 | 1966 |         { | 
 | 1967 |             static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); | 
 | 1968 |             delete __ptr; | 
 | 1969 |         } | 
 | 1970 | }; | 
 | 1971 |  | 
 | 1972 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1973 | struct _LIBCPP_VISIBLE default_delete<_Tp[]> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1974 | { | 
 | 1975 |     _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const | 
 | 1976 |         { | 
 | 1977 |             static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); | 
 | 1978 |             delete [] __ptr; | 
 | 1979 |         } | 
 | 1980 | private: | 
 | 1981 |     template <class _Up> void operator() (_Up*) const; | 
 | 1982 | }; | 
 | 1983 |  | 
 | 1984 | template <class _Tp, class _Dp = default_delete<_Tp> > | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1985 | class _LIBCPP_VISIBLE unique_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1986 | { | 
 | 1987 | public: | 
 | 1988 |     typedef _Tp element_type; | 
 | 1989 |     typedef _Dp deleter_type; | 
 | 1990 |     typedef typename __pointer_type<_Tp, deleter_type>::type pointer; | 
 | 1991 | private: | 
 | 1992 |     __compressed_pair<pointer, deleter_type> __ptr_; | 
 | 1993 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1994 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1995 |     unique_ptr(const unique_ptr&); | 
 | 1996 |     unique_ptr& operator=(const unique_ptr&); | 
 | 1997 |     template <class _Up, class _Ep> | 
 | 1998 |         unique_ptr(const unique_ptr<_Up, _Ep>&); | 
 | 1999 |     template <class _Up, class _Ep> | 
 | 2000 |         unique_ptr& operator=(const unique_ptr<_Up, _Ep>&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2001 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2002 |     unique_ptr(unique_ptr&); | 
 | 2003 |     template <class _Up, class _Ep> | 
 | 2004 |         unique_ptr(unique_ptr<_Up, _Ep>&); | 
 | 2005 |     unique_ptr& operator=(unique_ptr&); | 
 | 2006 |     template <class _Up, class _Ep> | 
 | 2007 |         unique_ptr& operator=(unique_ptr<_Up, _Ep>&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2008 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2009 |  | 
 | 2010 |     struct __nat {int __for_bool_;}; | 
 | 2011 |  | 
 | 2012 |     typedef       typename remove_reference<deleter_type>::type& _Dp_reference; | 
 | 2013 |     typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; | 
 | 2014 | public: | 
 | 2015 |     _LIBCPP_INLINE_VISIBILITY unique_ptr() | 
 | 2016 |         : __ptr_(pointer()) | 
 | 2017 |         { | 
 | 2018 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2019 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2020 |         } | 
 | 2021 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) | 
 | 2022 |         : __ptr_(pointer()) | 
 | 2023 |         { | 
 | 2024 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2025 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2026 |         } | 
 | 2027 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) | 
 | 2028 |         : __ptr_(_STD::move(__p)) | 
 | 2029 |         { | 
 | 2030 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2031 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2032 |         } | 
 | 2033 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2034 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2035 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional< | 
 | 2036 |                                         is_reference<deleter_type>::value, | 
 | 2037 |                                         deleter_type, | 
 | 2038 |                                         typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
 | 2039 |         : __ptr_(__p, __d) {} | 
 | 2040 |  | 
 | 2041 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d) | 
 | 2042 |         : __ptr_(__p, _STD::move(__d)) | 
 | 2043 |         { | 
 | 2044 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2045 |         } | 
 | 2046 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) | 
 | 2047 |         : __ptr_(__u.release(), _STD::forward<deleter_type>(__u.get_deleter())) {} | 
 | 2048 |     template <class _Up, class _Ep> | 
 | 2049 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2050 |         unique_ptr(unique_ptr<_Up, _Ep>&& __u, | 
 | 2051 |                    typename enable_if | 
 | 2052 |                       < | 
 | 2053 |                         !is_array<_Up>::value && | 
 | 2054 |                          is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && | 
 | 2055 |                          is_convertible<_Ep, deleter_type>::value && | 
 | 2056 |                          ( | 
 | 2057 |                             !is_reference<deleter_type>::value || | 
 | 2058 |                             is_same<deleter_type, _Ep>::value | 
 | 2059 |                          ), | 
 | 2060 |                          __nat | 
 | 2061 |                       >::type = __nat()) | 
 | 2062 |             : __ptr_(__u.release(), _STD::forward<_Ep>(__u.get_deleter())) {} | 
 | 2063 |  | 
 | 2064 |     template <class _Up> | 
 | 2065 |         _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, | 
 | 2066 |                 typename enable_if< | 
 | 2067 |                                       is_convertible<_Up*, _Tp*>::value && | 
 | 2068 |                                       is_same<_Dp, default_delete<_Tp> >::value, | 
 | 2069 |                                       __nat | 
 | 2070 |                                   >::type = __nat()) | 
 | 2071 |             : __ptr_(__p.release()) | 
 | 2072 |             { | 
 | 2073 |             } | 
 | 2074 |  | 
 | 2075 |         _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) | 
 | 2076 |             { | 
 | 2077 |                 reset(__u.release()); | 
 | 2078 |                 __ptr_.second() = _STD::forward<deleter_type>(__u.get_deleter()); | 
 | 2079 |                 return *this; | 
 | 2080 |             } | 
 | 2081 |  | 
 | 2082 |         template <class _Up, class _Ep> | 
 | 2083 |             _LIBCPP_INLINE_VISIBILITY | 
 | 2084 |             typename enable_if | 
 | 2085 |             < | 
 | 2086 |                 !is_array<_Up>::value, | 
 | 2087 |                 unique_ptr& | 
 | 2088 |             >::type | 
 | 2089 |             operator=(unique_ptr<_Up, _Ep>&& __u) | 
 | 2090 |             { | 
 | 2091 |                 reset(__u.release()); | 
 | 2092 |                 __ptr_.second() = _STD::forward<_Ep>(__u.get_deleter()); | 
 | 2093 |                 return *this; | 
 | 2094 |             } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2095 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2096 |  | 
 | 2097 |     _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() | 
 | 2098 |     { | 
 | 2099 |         return __rv<unique_ptr>(*this); | 
 | 2100 |     } | 
 | 2101 |  | 
 | 2102 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) | 
 | 2103 |         : __ptr_(__u->release(), _STD::forward<deleter_type>(__u->get_deleter())) {} | 
 | 2104 |  | 
 | 2105 |     template <class _Up, class _Ep> | 
 | 2106 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) | 
 | 2107 |     { | 
 | 2108 |         reset(__u.release()); | 
 | 2109 |         __ptr_.second() = _STD::forward<deleter_type>(__u.get_deleter()); | 
 | 2110 |         return *this; | 
 | 2111 |     } | 
 | 2112 |  | 
 | 2113 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) | 
 | 2114 |         : __ptr_(_STD::move(__p), _STD::move(__d)) {} | 
 | 2115 |  | 
 | 2116 |     template <class _Up> | 
 | 2117 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2118 |                 typename enable_if< | 
 | 2119 |                                       is_convertible<_Up*, _Tp*>::value && | 
 | 2120 |                                       is_same<_Dp, default_delete<_Tp> >::value, | 
 | 2121 |                                       unique_ptr& | 
 | 2122 |                                   >::type | 
 | 2123 |         operator=(auto_ptr<_Up> __p) | 
 | 2124 |             {reset(__p.release()); return *this;} | 
 | 2125 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2126 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2127 |     _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} | 
 | 2128 |  | 
 | 2129 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) | 
 | 2130 |     { | 
 | 2131 |         reset(); | 
 | 2132 |         return *this; | 
 | 2133 |     } | 
 | 2134 |  | 
 | 2135 |     _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const | 
 | 2136 |         {return *__ptr_.first();} | 
 | 2137 |     _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return __ptr_.first();} | 
 | 2138 |     _LIBCPP_INLINE_VISIBILITY pointer get() const {return __ptr_.first();} | 
 | 2139 |     _LIBCPP_INLINE_VISIBILITY       _Dp_reference get_deleter()       {return __ptr_.second();} | 
 | 2140 |     _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const {return __ptr_.second();} | 
 | 2141 |     _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const {return __ptr_.first() ? &__nat::__for_bool_ : 0;} | 
 | 2142 |  | 
 | 2143 |     _LIBCPP_INLINE_VISIBILITY pointer release() | 
 | 2144 |     { | 
 | 2145 |         pointer __t = __ptr_.first(); | 
 | 2146 |         __ptr_.first() = pointer(); | 
 | 2147 |         return __t; | 
 | 2148 |     } | 
 | 2149 |  | 
 | 2150 |     _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) | 
 | 2151 |     { | 
 | 2152 |         pointer __tmp = __ptr_.first(); | 
 | 2153 |         __ptr_.first() = __p; | 
 | 2154 |         if (__tmp) | 
 | 2155 |             __ptr_.second()(__tmp); | 
 | 2156 |     } | 
 | 2157 |  | 
 | 2158 |     _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} | 
 | 2159 | }; | 
 | 2160 |  | 
 | 2161 | template <class _Tp, class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2162 | class _LIBCPP_VISIBLE unique_ptr<_Tp[], _Dp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2163 | { | 
 | 2164 | public: | 
 | 2165 |     typedef _Tp element_type; | 
 | 2166 |     typedef _Dp deleter_type; | 
 | 2167 |     typedef typename __pointer_type<_Tp, deleter_type>::type pointer; | 
 | 2168 | private: | 
 | 2169 |     __compressed_pair<pointer, deleter_type> __ptr_; | 
 | 2170 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2171 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2172 |     unique_ptr(const unique_ptr&); | 
 | 2173 |     unique_ptr& operator=(const unique_ptr&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2174 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2175 |     unique_ptr(unique_ptr&); | 
 | 2176 |     template <class _Up> | 
 | 2177 |         unique_ptr(unique_ptr<_Up>&); | 
 | 2178 |     unique_ptr& operator=(unique_ptr&); | 
 | 2179 |     template <class _Up> | 
 | 2180 |         unique_ptr& operator=(unique_ptr<_Up>&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2181 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2182 |  | 
 | 2183 |     struct __nat {int __for_bool_;}; | 
 | 2184 |  | 
 | 2185 |     typedef       typename remove_reference<deleter_type>::type& _Dp_reference; | 
 | 2186 |     typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; | 
 | 2187 | public: | 
 | 2188 |     _LIBCPP_INLINE_VISIBILITY unique_ptr() | 
 | 2189 |         : __ptr_(pointer()) | 
 | 2190 |         { | 
 | 2191 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2192 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2193 |         } | 
 | 2194 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) | 
 | 2195 |         : __ptr_(pointer()) | 
 | 2196 |         { | 
 | 2197 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2198 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2199 |         } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2200 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2201 |     template <class _P, | 
 | 2202 |               class = typename enable_if<is_same<_P, pointer>::value>::type | 
 | 2203 |              > | 
 | 2204 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_P __p) | 
 | 2205 |         : __ptr_(__p) | 
 | 2206 |         { | 
 | 2207 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2208 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2209 |         } | 
 | 2210 |  | 
 | 2211 |     template <class _P, | 
 | 2212 |               class = typename enable_if<is_same<_P, pointer>::value>::type | 
 | 2213 |              > | 
 | 2214 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(_P __p, typename conditional< | 
 | 2215 |                                        is_reference<deleter_type>::value, | 
 | 2216 |                                        deleter_type, | 
 | 2217 |                                        typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
 | 2218 |         : __ptr_(__p, __d) {} | 
 | 2219 |  | 
 | 2220 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional< | 
 | 2221 |                                        is_reference<deleter_type>::value, | 
 | 2222 |                                        deleter_type, | 
 | 2223 |                                        typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
 | 2224 |         : __ptr_(pointer(), __d) {} | 
 | 2225 |  | 
 | 2226 |     template <class _P, | 
 | 2227 |               class = typename enable_if<is_same<_P, pointer>::value || | 
 | 2228 |                                          is_same<_P, nullptr_t>::value>::type | 
 | 2229 |              > | 
 | 2230 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(_P __p, typename remove_reference<deleter_type>::type&& __d) | 
 | 2231 |         : __ptr_(__p, _STD::move(__d)) | 
 | 2232 |         { | 
 | 2233 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2234 |         } | 
 | 2235 |  | 
 | 2236 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d) | 
 | 2237 |         : __ptr_(pointer(), _STD::move(__d)) | 
 | 2238 |         { | 
 | 2239 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2240 |         } | 
 | 2241 |  | 
 | 2242 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) | 
 | 2243 |         : __ptr_(__u.release(), _STD::forward<deleter_type>(__u.get_deleter())) {} | 
 | 2244 |  | 
 | 2245 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) | 
 | 2246 |         { | 
 | 2247 |             reset(__u.release()); | 
 | 2248 |             __ptr_.second() = _STD::forward<deleter_type>(__u.get_deleter()); | 
 | 2249 |             return *this; | 
 | 2250 |         } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2251 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2252 |  | 
 | 2253 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) | 
 | 2254 |         : __ptr_(__p) | 
 | 2255 |         { | 
 | 2256 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2257 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2258 |         } | 
 | 2259 |  | 
 | 2260 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) | 
 | 2261 |         : __ptr_(__p, _STD::forward<deleter_type>(__d)) {} | 
 | 2262 |  | 
 | 2263 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d) | 
 | 2264 |         : __ptr_(pointer(), _STD::forward<deleter_type>(__d)) {} | 
 | 2265 |  | 
 | 2266 |     _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() | 
 | 2267 |     { | 
 | 2268 |         return __rv<unique_ptr>(*this); | 
 | 2269 |     } | 
 | 2270 |  | 
 | 2271 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) | 
 | 2272 |         : __ptr_(__u->release(), _STD::forward<deleter_type>(__u->get_deleter())) {} | 
 | 2273 |  | 
 | 2274 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u) | 
 | 2275 |     { | 
 | 2276 |         reset(__u->release()); | 
 | 2277 |         __ptr_.second() = _STD::forward<deleter_type>(__u->get_deleter()); | 
 | 2278 |         return *this; | 
 | 2279 |     } | 
 | 2280 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2281 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2282 |     _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} | 
 | 2283 |  | 
 | 2284 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) | 
 | 2285 |     { | 
 | 2286 |         reset(); | 
 | 2287 |         return *this; | 
 | 2288 |     } | 
 | 2289 |  | 
 | 2290 |     _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const | 
 | 2291 |         {return __ptr_.first()[__i];} | 
 | 2292 |     _LIBCPP_INLINE_VISIBILITY pointer get() const {return __ptr_.first();} | 
 | 2293 |     _LIBCPP_INLINE_VISIBILITY       _Dp_reference get_deleter()       {return __ptr_.second();} | 
 | 2294 |     _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const {return __ptr_.second();} | 
 | 2295 |     _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const {return __ptr_.first() ? &__nat::__for_bool_ : 0;} | 
 | 2296 |  | 
 | 2297 |     _LIBCPP_INLINE_VISIBILITY pointer release() | 
 | 2298 |     { | 
 | 2299 |         pointer __t = __ptr_.first(); | 
 | 2300 |         __ptr_.first() = pointer(); | 
 | 2301 |         return __t; | 
 | 2302 |     } | 
 | 2303 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2304 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2305 |     template <class _P, | 
 | 2306 |               class = typename enable_if<is_same<_P, pointer>::value>::type | 
 | 2307 |              > | 
 | 2308 |     _LIBCPP_INLINE_VISIBILITY void reset(_P __p) | 
 | 2309 |     { | 
 | 2310 |         pointer __tmp = __ptr_.first(); | 
 | 2311 |         __ptr_.first() = __p; | 
 | 2312 |         if (__tmp) | 
 | 2313 |             __ptr_.second()(__tmp); | 
 | 2314 |     } | 
 | 2315 |     _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) | 
 | 2316 |     { | 
 | 2317 |         pointer __tmp = __ptr_.first(); | 
 | 2318 |         __ptr_.first() = nullptr; | 
 | 2319 |         if (__tmp) | 
 | 2320 |             __ptr_.second()(__tmp); | 
 | 2321 |     } | 
 | 2322 |     _LIBCPP_INLINE_VISIBILITY void reset() | 
 | 2323 |     { | 
 | 2324 |         pointer __tmp = __ptr_.first(); | 
 | 2325 |         __ptr_.first() = nullptr; | 
 | 2326 |         if (__tmp) | 
 | 2327 |             __ptr_.second()(__tmp); | 
 | 2328 |     } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2329 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2330 |     _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) | 
 | 2331 |     { | 
 | 2332 |         pointer __tmp = __ptr_.first(); | 
 | 2333 |         __ptr_.first() = __p; | 
 | 2334 |         if (__tmp) | 
 | 2335 |             __ptr_.second()(__tmp); | 
 | 2336 |     } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2337 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2338 |  | 
 | 2339 |     _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} | 
 | 2340 | private: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2341 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2342 | #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2343 |     template <class _Up> | 
 | 2344 |         explicit unique_ptr(_Up); | 
 | 2345 |     template <class _Up> | 
 | 2346 |         unique_ptr(_Up __u, | 
 | 2347 |                    typename conditional< | 
 | 2348 |                                        is_reference<deleter_type>::value, | 
 | 2349 |                                        deleter_type, | 
 | 2350 |                                        typename add_lvalue_reference<const deleter_type>::type>::type, | 
 | 2351 |                    typename enable_if | 
 | 2352 |                       < | 
 | 2353 |                          is_convertible<_Up, pointer>::value, | 
 | 2354 |                          __nat | 
 | 2355 |                       >::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2356 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2357 | }; | 
 | 2358 |  | 
 | 2359 | template <class _Tp, class _Dp> | 
 | 2360 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2361 | void | 
 | 2362 | swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) {__x.swap(__y);} | 
 | 2363 |  | 
 | 2364 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2365 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2366 | bool | 
 | 2367 | operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();} | 
 | 2368 |  | 
 | 2369 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2370 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2371 | bool | 
 | 2372 | operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);} | 
 | 2373 |  | 
 | 2374 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2375 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2376 | bool | 
 | 2377 | operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() < __y.get();} | 
 | 2378 |  | 
 | 2379 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2380 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2381 | bool | 
 | 2382 | operator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;} | 
 | 2383 |  | 
 | 2384 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2385 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2386 | bool | 
 | 2387 | operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);} | 
 | 2388 |  | 
 | 2389 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2390 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2391 | bool | 
 | 2392 | operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} | 
 | 2393 |  | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 2394 | template <class> struct hash; | 
 | 2395 |  | 
 | 2396 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2397 | struct _LIBCPP_VISIBLE hash<_Tp*> | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 2398 |     : public unary_function<_Tp*, size_t> | 
 | 2399 | { | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2400 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 2401 |     size_t operator()(_Tp* __v) const | 
 | 2402 |     { | 
 | 2403 |         const size_t* const __p = reinterpret_cast<const size_t*>(&__v); | 
 | 2404 |         return *__p; | 
 | 2405 |     } | 
 | 2406 | }; | 
 | 2407 |  | 
 | 2408 | template <class _Tp, class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2409 | struct _LIBCPP_VISIBLE hash<unique_ptr<_Tp, _Dp> > | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 2410 | { | 
 | 2411 |     typedef unique_ptr<_Tp, _Dp> argument_type; | 
 | 2412 |     typedef size_t               result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2413 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 2414 |     result_type operator()(const argument_type& __ptr) const | 
 | 2415 |     { | 
 | 2416 |         typedef typename argument_type::pointer pointer; | 
 | 2417 |         return hash<pointer>()(__ptr.get()); | 
 | 2418 |     } | 
 | 2419 | }; | 
 | 2420 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2421 | struct __destruct_n | 
 | 2422 | { | 
 | 2423 | private: | 
 | 2424 |     size_t size; | 
 | 2425 |  | 
 | 2426 |     template <class _Tp> | 
 | 2427 |     _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) | 
 | 2428 |         {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} | 
 | 2429 |  | 
 | 2430 |     template <class _Tp> | 
 | 2431 |     _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) | 
 | 2432 |         {} | 
 | 2433 |  | 
 | 2434 |     _LIBCPP_INLINE_VISIBILITY void __incr(false_type) | 
 | 2435 |         {++size;} | 
 | 2436 |     _LIBCPP_INLINE_VISIBILITY void __incr(true_type) | 
 | 2437 |         {} | 
 | 2438 |  | 
 | 2439 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) | 
 | 2440 |         {size = __s;} | 
 | 2441 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) | 
 | 2442 |         {} | 
 | 2443 | public: | 
 | 2444 |     _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) : size(__s) {} | 
 | 2445 |  | 
 | 2446 |     template <class _Tp> | 
 | 2447 |     _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) | 
 | 2448 |         {__incr(integral_constant<bool, has_trivial_destructor<_Tp>::value>());} | 
 | 2449 |  | 
 | 2450 |     template <class _Tp> | 
 | 2451 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) | 
 | 2452 |         {__set(__s, integral_constant<bool, has_trivial_destructor<_Tp>::value>());} | 
 | 2453 |  | 
 | 2454 |     template <class _Tp> | 
 | 2455 |     _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) | 
 | 2456 |         {__process(__p, integral_constant<bool, has_trivial_destructor<_Tp>::value>());} | 
 | 2457 | }; | 
 | 2458 |  | 
 | 2459 | template <class _Alloc> | 
 | 2460 | class __allocator_destructor | 
 | 2461 | { | 
 | 2462 |     typedef allocator_traits<_Alloc> __alloc_traits; | 
 | 2463 | public: | 
 | 2464 |     typedef typename __alloc_traits::pointer pointer; | 
 | 2465 |     typedef typename __alloc_traits::size_type size_type; | 
 | 2466 | private: | 
 | 2467 |     _Alloc& __alloc_; | 
 | 2468 |     size_type __s_; | 
 | 2469 | public: | 
 | 2470 |     _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) | 
 | 2471 |         : __alloc_(__a), __s_(__s) {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2472 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2473 |     void operator()(pointer __p) {__alloc_traits::deallocate(__alloc_, __p, __s_);} | 
 | 2474 | }; | 
 | 2475 |  | 
 | 2476 | template <class _InputIterator, class _ForwardIterator> | 
 | 2477 | _ForwardIterator | 
 | 2478 | uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) | 
 | 2479 | { | 
 | 2480 |     __destruct_n __d(0); | 
 | 2481 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
 | 2482 |     unique_ptr<value_type, __destruct_n&> __h(&*__r, __d); | 
 | 2483 |     for (; __f != __l; ++__f, ++__r, __d.__incr((value_type*)0)) | 
 | 2484 |         ::new(&*__r) value_type(*__f); | 
 | 2485 |     __h.release(); | 
 | 2486 |     return __r; | 
 | 2487 | } | 
 | 2488 |  | 
 | 2489 | template <class _InputIterator, class _Size, class _ForwardIterator> | 
 | 2490 | _ForwardIterator | 
 | 2491 | uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) | 
 | 2492 | { | 
 | 2493 |     __destruct_n __d(0); | 
 | 2494 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
 | 2495 |     unique_ptr<value_type, __destruct_n&> __h(&*__r, __d); | 
 | 2496 |     for (; __n > 0; ++__f, ++__r, __d.__incr((value_type*)0), --__n) | 
 | 2497 |         ::new(&*__r) value_type(*__f); | 
 | 2498 |     __h.release(); | 
 | 2499 |     return __r; | 
 | 2500 | } | 
 | 2501 |  | 
 | 2502 | template <class _ForwardIterator, class _Tp> | 
 | 2503 | void | 
 | 2504 | uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) | 
 | 2505 | { | 
 | 2506 |     __destruct_n __d(0); | 
 | 2507 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
 | 2508 |     unique_ptr<value_type, __destruct_n&> __h(&*__f, __d); | 
 | 2509 |     for (; __f != __l; ++__f, __d.__incr((value_type*)0)) | 
 | 2510 |         ::new(&*__f) value_type(__x); | 
 | 2511 |     __h.release(); | 
 | 2512 | } | 
 | 2513 |  | 
 | 2514 | template <class _ForwardIterator, class _Size, class _Tp> | 
 | 2515 | void | 
 | 2516 | uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) | 
 | 2517 | { | 
 | 2518 |     __destruct_n __d(0); | 
 | 2519 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
 | 2520 |     unique_ptr<value_type, __destruct_n&> __h(&*__f, __d); | 
 | 2521 |     for (; __n > 0; ++__f, --__n, __d.__incr((value_type*)0)) | 
 | 2522 |         ::new(&*__f) value_type(__x); | 
 | 2523 |     __h.release(); | 
 | 2524 | } | 
 | 2525 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2526 | class _LIBCPP_EXCEPTION_ABI bad_weak_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2527 |     : public std::exception | 
 | 2528 | { | 
 | 2529 | public: | 
 | 2530 |     virtual ~bad_weak_ptr() throw(); | 
 | 2531 |     virtual const char* what() const throw(); | 
 | 2532 | }; | 
 | 2533 |  | 
 | 2534 | template<class _Tp> class weak_ptr; | 
 | 2535 |  | 
 | 2536 | class __shared_count | 
 | 2537 | { | 
 | 2538 |     __shared_count(const __shared_count&); | 
 | 2539 |     __shared_count& operator=(const __shared_count&); | 
 | 2540 |  | 
 | 2541 | protected: | 
 | 2542 |     long __shared_owners_; | 
 | 2543 |     virtual ~__shared_count(); | 
 | 2544 | private: | 
 | 2545 |     virtual void __on_zero_shared() = 0; | 
 | 2546 |  | 
 | 2547 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2548 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2549 |     explicit __shared_count(long __refs = 0) | 
 | 2550 |         : __shared_owners_(__refs) {} | 
 | 2551 |  | 
 | 2552 |     void __add_shared(); | 
| Howard Hinnant | 28dbbe0 | 2010-11-16 21:33:17 +0000 | [diff] [blame] | 2553 |     bool __release_shared(); | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2554 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2555 |     long use_count() const {return __shared_owners_ + 1;} | 
 | 2556 | }; | 
 | 2557 |  | 
 | 2558 | class __shared_weak_count | 
 | 2559 |     : private __shared_count | 
 | 2560 | { | 
 | 2561 |     long __shared_weak_owners_; | 
 | 2562 |  | 
 | 2563 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2564 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2565 |     explicit __shared_weak_count(long __refs = 0) | 
 | 2566 |         : __shared_count(__refs), | 
 | 2567 |           __shared_weak_owners_(__refs) {} | 
 | 2568 | protected: | 
 | 2569 |     virtual ~__shared_weak_count(); | 
 | 2570 |  | 
 | 2571 | public: | 
 | 2572 |     void __add_shared(); | 
 | 2573 |     void __add_weak(); | 
 | 2574 |     void __release_shared(); | 
 | 2575 |     void __release_weak(); | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2576 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2577 |     long use_count() const {return __shared_count::use_count();} | 
 | 2578 |     __shared_weak_count* lock(); | 
 | 2579 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2580 | #ifndef _LIBCPP_NO_RTTI | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2581 |     virtual const void* __get_deleter(const type_info&) const; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2582 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2583 | private: | 
 | 2584 |     virtual void __on_zero_shared_weak() = 0; | 
 | 2585 | }; | 
 | 2586 |  | 
 | 2587 | template <class _Tp, class _Dp, class _Alloc> | 
 | 2588 | class __shared_ptr_pointer | 
 | 2589 |     : public __shared_weak_count | 
 | 2590 | { | 
 | 2591 |     __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; | 
 | 2592 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2593 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2594 |     __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) | 
 | 2595 |         :  __data_(__compressed_pair<_Tp, _Dp>(__p, _STD::move(__d)), _STD::move(__a)) {} | 
 | 2596 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2597 | #ifndef _LIBCPP_NO_RTTI | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2598 |     virtual const void* __get_deleter(const type_info&) const; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2599 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2600 |  | 
 | 2601 | private: | 
 | 2602 |     virtual void __on_zero_shared(); | 
 | 2603 |     virtual void __on_zero_shared_weak(); | 
 | 2604 | }; | 
 | 2605 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2606 | #ifndef _LIBCPP_NO_RTTI | 
 | 2607 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2608 | template <class _Tp, class _Dp, class _Alloc> | 
 | 2609 | const void* | 
 | 2610 | __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const | 
 | 2611 | { | 
 | 2612 |     return __t == typeid(_Dp) ? &__data_.first().second() : 0; | 
 | 2613 | } | 
 | 2614 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2615 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2616 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2617 | template <class _Tp, class _Dp, class _Alloc> | 
 | 2618 | void | 
 | 2619 | __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() | 
 | 2620 | { | 
 | 2621 |     __data_.first().second()(__data_.first().first()); | 
 | 2622 |     __data_.first().second().~_Dp(); | 
 | 2623 | } | 
 | 2624 |  | 
 | 2625 | template <class _Tp, class _Dp, class _Alloc> | 
 | 2626 | void | 
 | 2627 | __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() | 
 | 2628 | { | 
 | 2629 |     typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second()); | 
 | 2630 |     __data_.second().~_Alloc(); | 
 | 2631 |     __a.deallocate(this, 1); | 
 | 2632 | } | 
 | 2633 |  | 
 | 2634 | template <class _Tp, class _Alloc> | 
 | 2635 | class __shared_ptr_emplace | 
 | 2636 |     : public __shared_weak_count | 
 | 2637 | { | 
 | 2638 |     __compressed_pair<_Alloc, _Tp> __data_; | 
 | 2639 | public: | 
 | 2640 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2641 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2642 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2643 |     __shared_ptr_emplace(_Alloc __a) | 
 | 2644 |         :  __data_(_STD::move(__a)) {} | 
 | 2645 |  | 
 | 2646 |     template <class ..._Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2647 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2648 |         __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) | 
 | 2649 |             :  __data_(_STD::move(__a), _Tp(_STD::forward<_Args>(__args)...)) {} | 
 | 2650 |  | 
 | 2651 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2652 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2653 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2654 |     __shared_ptr_emplace(_Alloc __a) | 
 | 2655 |         :  __data_(__a) {} | 
 | 2656 |  | 
 | 2657 |     template <class _A0> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2658 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2659 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0) | 
 | 2660 |             :  __data_(__a, _Tp(__a0)) {} | 
 | 2661 |  | 
 | 2662 |     template <class _A0, class _A1> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2663 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2664 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1) | 
 | 2665 |             :  __data_(__a, _Tp(__a0, __a1)) {} | 
 | 2666 |  | 
 | 2667 |     template <class _A0, class _A1, class _A2> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2668 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2669 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 2670 |             :  __data_(__a, _Tp(__a0, __a1, __a2)) {} | 
 | 2671 |  | 
 | 2672 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2673 |  | 
 | 2674 | private: | 
 | 2675 |     virtual void __on_zero_shared(); | 
 | 2676 |     virtual void __on_zero_shared_weak(); | 
 | 2677 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2678 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2679 |     _Tp* get() {return &__data_.second();} | 
 | 2680 | }; | 
 | 2681 |  | 
 | 2682 | template <class _Tp, class _Alloc> | 
 | 2683 | void | 
 | 2684 | __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() | 
 | 2685 | { | 
 | 2686 |     __data_.second().~_Tp(); | 
 | 2687 | } | 
 | 2688 |  | 
 | 2689 | template <class _Tp, class _Alloc> | 
 | 2690 | void | 
 | 2691 | __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() | 
 | 2692 | { | 
 | 2693 |     typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first()); | 
 | 2694 |     __data_.first().~_Alloc(); | 
 | 2695 |     __a.deallocate(this, 1); | 
 | 2696 | } | 
 | 2697 |  | 
 | 2698 | template<class _Tp> class enable_shared_from_this; | 
 | 2699 |  | 
 | 2700 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2701 | class _LIBCPP_VISIBLE shared_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2702 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2703 | public: | 
 | 2704 |     typedef _Tp element_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2705 | private: | 
 | 2706 |     element_type*      __ptr_; | 
 | 2707 |     __shared_weak_count* __cntrl_; | 
 | 2708 |  | 
 | 2709 |     struct __nat {int __for_bool_;}; | 
 | 2710 | public: | 
 | 2711 |     shared_ptr(); | 
 | 2712 |     shared_ptr(nullptr_t); | 
 | 2713 |     template<class _Yp> explicit shared_ptr(_Yp* __p); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2714 |     template<class _Yp, class _Dp> shared_ptr(_Yp* __p, _Dp __d); | 
 | 2715 |     template<class _Yp, class _Dp, class _Alloc> shared_ptr(_Yp* __p, _Dp __d, _Alloc __a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2716 |     template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); | 
 | 2717 |     template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2718 |     template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2719 |     shared_ptr(const shared_ptr& __r); | 
 | 2720 |     template<class _Yp> | 
 | 2721 |         shared_ptr(const shared_ptr<_Yp>& __r, | 
 | 2722 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2723 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2724 |     shared_ptr(shared_ptr&& __r); | 
 | 2725 |     template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r, | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2726 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2727 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2728 |     template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2729 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2730 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2731 |     template<class _Yp> shared_ptr(auto_ptr<_Yp>&& __r); | 
 | 2732 | #else | 
 | 2733 |     template<class _Yp> shared_ptr(auto_ptr<_Yp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2734 | #endif | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2735 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2736 | private: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2737 |     template <class _Yp, class _Dp> shared_ptr(const unique_ptr<_Yp, _Dp>& __r);// = delete; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2738 | public: | 
 | 2739 |     template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>&&, | 
 | 2740 |        typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
 | 2741 |     template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>&&, | 
 | 2742 |        typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2743 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2744 |     template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>, | 
 | 2745 |        typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
 | 2746 |     template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>, | 
 | 2747 |        typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2748 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2749 |  | 
 | 2750 |     ~shared_ptr(); | 
 | 2751 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2752 |     shared_ptr& operator=(const shared_ptr& __r); | 
 | 2753 |     template<class _Yp> shared_ptr& operator=(const shared_ptr<_Yp>& __r); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2754 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2755 |     shared_ptr& operator=(shared_ptr&& __r); | 
 | 2756 |     template<class _Yp> shared_ptr& operator=(shared_ptr<_Yp>&& __r); | 
 | 2757 |     template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp>&& __r); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2758 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2759 |     template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2760 | #endif | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2761 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2762 | private: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2763 |     template <class _Yp, class _Dp> shared_ptr& operator=(const unique_ptr<_Yp, _Dp>& __r);// = delete; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2764 | public: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2765 |     template <class _Yp, class _Dp> shared_ptr& operator=(unique_ptr<_Yp, _Dp>&& __r); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2766 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2767 |     template <class _Yp, class _Dp> shared_ptr& operator=(unique_ptr<_Yp, _Dp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2768 | #endif | 
 | 2769 |  | 
 | 2770 |     void swap(shared_ptr& __r); | 
 | 2771 |     void reset(); | 
 | 2772 |     template<class _Yp> void reset(_Yp* __p); | 
 | 2773 |     template<class _Yp, class _Dp> void reset(_Yp* __p, _Dp __d); | 
 | 2774 |     template<class _Yp, class _Dp, class _Alloc> void reset(_Yp* __p, _Dp __d, _Alloc __a); | 
 | 2775 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2776 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2777 |     element_type* get() const {return __ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2778 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2779 |     typename add_lvalue_reference<element_type>::type operator*() const {return *__ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2780 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2781 |     element_type* operator->() const {return __ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2782 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2783 |     long use_count() const {return __cntrl_ ? __cntrl_->use_count() : 0;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2784 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2785 |     bool unique() const {return use_count() == 1;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2786 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2787 |     bool empty() const {return __cntrl_ == 0;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2788 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2789 |     /*explicit*/ operator bool() const {return get() != 0;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2790 |     template <class _U> | 
 | 2791 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2792 |         bool owner_before(shared_ptr<_U> const& __p) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2793 |         {return __cntrl_ < __p.__cntrl_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2794 |     template <class _U> | 
 | 2795 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2796 |         bool owner_before(weak_ptr<_U> const& __p) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2797 |         {return __cntrl_ < __p.__cntrl_;} | 
 | 2798 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 2799 | #ifndef _LIBCPP_NO_RTTI | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2800 |     template <class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2801 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2802 |         _Dp* __get_deleter() const | 
 | 2803 |             {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2804 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2805 |  | 
 | 2806 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2807 |  | 
 | 2808 |     template<class ..._Args> | 
 | 2809 |         static | 
 | 2810 |         shared_ptr<_Tp> | 
 | 2811 |         make_shared(_Args&& ...__args); | 
 | 2812 |  | 
 | 2813 |     template<class _Alloc, class ..._Args> | 
 | 2814 |         static | 
 | 2815 |         shared_ptr<_Tp> | 
 | 2816 |         allocate_shared(const _Alloc& __a, _Args&& ...__args); | 
 | 2817 |  | 
 | 2818 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2819 |  | 
 | 2820 |     static shared_ptr<_Tp> make_shared(); | 
 | 2821 |  | 
 | 2822 |     template<class _A0> | 
 | 2823 |         static shared_ptr<_Tp> make_shared(_A0&); | 
 | 2824 |  | 
 | 2825 |     template<class _A0, class _A1> | 
 | 2826 |         static shared_ptr<_Tp> make_shared(_A0&, _A1&); | 
 | 2827 |  | 
 | 2828 |     template<class _A0, class _A1, class _A2> | 
 | 2829 |         static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&); | 
 | 2830 |  | 
 | 2831 |     template<class _Alloc> | 
 | 2832 |         static shared_ptr<_Tp> | 
 | 2833 |         allocate_shared(const _Alloc& __a); | 
 | 2834 |  | 
 | 2835 |     template<class _Alloc, class _A0> | 
 | 2836 |         static shared_ptr<_Tp> | 
 | 2837 |         allocate_shared(const _Alloc& __a, _A0& __a0); | 
 | 2838 |  | 
 | 2839 |     template<class _Alloc, class _A0, class _A1> | 
 | 2840 |         static shared_ptr<_Tp> | 
 | 2841 |         allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1); | 
 | 2842 |  | 
 | 2843 |     template<class _Alloc, class _A0, class _A1, class _A2> | 
 | 2844 |         static shared_ptr<_Tp> | 
 | 2845 |         allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2); | 
 | 2846 |  | 
 | 2847 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2848 |  | 
 | 2849 | private: | 
 | 2850 |  | 
 | 2851 |     template <class _Yp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2852 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2853 |         void | 
 | 2854 |         __enable_weak_this(const enable_shared_from_this<_Yp>* __e) | 
 | 2855 |         { | 
 | 2856 |             if (__e) | 
 | 2857 |                 __e->__weak_this_ = *this; | 
 | 2858 |         } | 
 | 2859 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2860 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2861 |     void __enable_weak_this(const void*) {} | 
 | 2862 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2863 |     template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; | 
 | 2864 |     template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2865 | }; | 
 | 2866 |  | 
 | 2867 | template<class _Tp> | 
 | 2868 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2869 | shared_ptr<_Tp>::shared_ptr() | 
 | 2870 |     : __ptr_(0), | 
 | 2871 |       __cntrl_(0) | 
 | 2872 | { | 
 | 2873 | } | 
 | 2874 |  | 
 | 2875 | template<class _Tp> | 
 | 2876 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2877 | shared_ptr<_Tp>::shared_ptr(nullptr_t) | 
 | 2878 |     : __ptr_(0), | 
 | 2879 |       __cntrl_(0) | 
 | 2880 | { | 
 | 2881 | } | 
 | 2882 |  | 
 | 2883 | template<class _Tp> | 
 | 2884 | template<class _Yp> | 
 | 2885 | shared_ptr<_Tp>::shared_ptr(_Yp* __p) | 
 | 2886 |     : __ptr_(__p) | 
 | 2887 | { | 
 | 2888 |     unique_ptr<_Yp> __hold(__p); | 
 | 2889 |     typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | 
 | 2890 |     __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); | 
 | 2891 |     __hold.release(); | 
 | 2892 |     __enable_weak_this(__p); | 
 | 2893 | } | 
 | 2894 |  | 
 | 2895 | template<class _Tp> | 
 | 2896 | template<class _Yp, class _Dp> | 
 | 2897 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d) | 
 | 2898 |     : __ptr_(__p) | 
 | 2899 | { | 
 | 2900 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2901 |     try | 
 | 2902 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2903 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2904 |         typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; | 
 | 2905 |         __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); | 
 | 2906 |         __enable_weak_this(__p); | 
 | 2907 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2908 |     } | 
 | 2909 |     catch (...) | 
 | 2910 |     { | 
 | 2911 |         __d(__p); | 
 | 2912 |         throw; | 
 | 2913 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2914 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2915 | } | 
 | 2916 |  | 
 | 2917 | template<class _Tp> | 
 | 2918 | template<class _Dp> | 
 | 2919 | shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) | 
 | 2920 |     : __ptr_(0) | 
 | 2921 | { | 
 | 2922 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2923 |     try | 
 | 2924 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2925 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2926 |         typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; | 
 | 2927 |         __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); | 
 | 2928 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2929 |     } | 
 | 2930 |     catch (...) | 
 | 2931 |     { | 
 | 2932 |         __d(__p); | 
 | 2933 |         throw; | 
 | 2934 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2935 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2936 | } | 
 | 2937 |  | 
 | 2938 | template<class _Tp> | 
 | 2939 | template<class _Yp, class _Dp, class _Alloc> | 
 | 2940 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) | 
 | 2941 |     : __ptr_(__p) | 
 | 2942 | { | 
 | 2943 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2944 |     try | 
 | 2945 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2946 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2947 |         typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; | 
 | 2948 |         typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 2949 |         typedef __allocator_destructor<_A2> _D2; | 
 | 2950 |         _A2 __a2(__a); | 
 | 2951 |         unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
 | 2952 |         ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); | 
 | 2953 |         __cntrl_ = __hold2.release(); | 
 | 2954 |         __enable_weak_this(__p); | 
 | 2955 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2956 |     } | 
 | 2957 |     catch (...) | 
 | 2958 |     { | 
 | 2959 |         __d(__p); | 
 | 2960 |         throw; | 
 | 2961 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2962 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2963 | } | 
 | 2964 |  | 
 | 2965 | template<class _Tp> | 
 | 2966 | template<class _Dp, class _Alloc> | 
 | 2967 | shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) | 
 | 2968 |     : __ptr_(0) | 
 | 2969 | { | 
 | 2970 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2971 |     try | 
 | 2972 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2973 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2974 |         typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; | 
 | 2975 |         typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 2976 |         typedef __allocator_destructor<_A2> _D2; | 
 | 2977 |         _A2 __a2(__a); | 
 | 2978 |         unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
 | 2979 |         ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); | 
 | 2980 |         __cntrl_ = __hold2.release(); | 
 | 2981 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 2982 |     } | 
 | 2983 |     catch (...) | 
 | 2984 |     { | 
 | 2985 |         __d(__p); | 
 | 2986 |         throw; | 
 | 2987 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2988 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2989 | } | 
 | 2990 |  | 
 | 2991 | template<class _Tp> | 
 | 2992 | template<class _Yp> | 
 | 2993 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2994 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) | 
 | 2995 |     : __ptr_(__p), | 
 | 2996 |       __cntrl_(__r.__cntrl_) | 
 | 2997 | { | 
 | 2998 |     if (__cntrl_) | 
 | 2999 |         __cntrl_->__add_shared(); | 
 | 3000 | } | 
 | 3001 |  | 
 | 3002 | template<class _Tp> | 
 | 3003 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3004 | shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) | 
 | 3005 |     : __ptr_(__r.__ptr_), | 
 | 3006 |       __cntrl_(__r.__cntrl_) | 
 | 3007 | { | 
 | 3008 |     if (__cntrl_) | 
 | 3009 |         __cntrl_->__add_shared(); | 
 | 3010 | } | 
 | 3011 |  | 
 | 3012 | template<class _Tp> | 
 | 3013 | template<class _Yp> | 
 | 3014 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3015 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, | 
 | 3016 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
 | 3017 |     : __ptr_(__r.__ptr_), | 
 | 3018 |       __cntrl_(__r.__cntrl_) | 
 | 3019 | { | 
 | 3020 |     if (__cntrl_) | 
 | 3021 |         __cntrl_->__add_shared(); | 
 | 3022 | } | 
 | 3023 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3024 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3025 |  | 
 | 3026 | template<class _Tp> | 
 | 3027 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3028 | shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) | 
 | 3029 |     : __ptr_(__r.__ptr_), | 
 | 3030 |       __cntrl_(__r.__cntrl_) | 
 | 3031 | { | 
 | 3032 |     __r.__ptr_ = 0; | 
 | 3033 |     __r.__cntrl_ = 0; | 
 | 3034 | } | 
 | 3035 |  | 
 | 3036 | template<class _Tp> | 
 | 3037 | template<class _Yp> | 
 | 3038 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3039 | shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, | 
 | 3040 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
 | 3041 |     : __ptr_(__r.__ptr_), | 
 | 3042 |       __cntrl_(__r.__cntrl_) | 
 | 3043 | { | 
 | 3044 |     __r.__ptr_ = 0; | 
 | 3045 |     __r.__cntrl_ = 0; | 
 | 3046 | } | 
 | 3047 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3048 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3049 |  | 
 | 3050 | template<class _Tp> | 
 | 3051 | template<class _Yp> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3052 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3053 | shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r) | 
 | 3054 | #else | 
| Howard Hinnant | 92172b8 | 2010-08-21 21:14:53 +0000 | [diff] [blame] | 3055 | shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3056 | #endif | 
 | 3057 |     : __ptr_(__r.get()) | 
 | 3058 | { | 
 | 3059 |     typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | 
 | 3060 |     __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); | 
 | 3061 |     __enable_weak_this(__r.get()); | 
 | 3062 |     __r.release(); | 
 | 3063 | } | 
 | 3064 |  | 
 | 3065 | template<class _Tp> | 
 | 3066 | template <class _Yp, class _Dp> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3067 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3068 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 
 | 3069 | #else | 
 | 3070 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | 
 | 3071 | #endif | 
 | 3072 |            typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type) | 
 | 3073 |     : __ptr_(__r.get()) | 
 | 3074 | { | 
 | 3075 |     typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; | 
 | 3076 |     __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); | 
 | 3077 |     __enable_weak_this(__r.get()); | 
 | 3078 |     __r.release(); | 
 | 3079 | } | 
 | 3080 |  | 
 | 3081 | template<class _Tp> | 
 | 3082 | template <class _Yp, class _Dp> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3083 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3084 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 
 | 3085 | #else | 
 | 3086 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | 
 | 3087 | #endif | 
 | 3088 |            typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type) | 
 | 3089 |     : __ptr_(__r.get()) | 
 | 3090 | { | 
 | 3091 |     typedef __shared_ptr_pointer<_Yp*, | 
 | 3092 |                                  reference_wrapper<typename remove_reference<_Dp>::type>, | 
 | 3093 |                                  allocator<_Yp> > _CntrlBlk; | 
 | 3094 |     __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); | 
 | 3095 |     __enable_weak_this(__r.get()); | 
 | 3096 |     __r.release(); | 
 | 3097 | } | 
 | 3098 |  | 
 | 3099 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 3100 |  | 
 | 3101 | template<class _Tp> | 
 | 3102 | template<class ..._Args> | 
 | 3103 | shared_ptr<_Tp> | 
 | 3104 | shared_ptr<_Tp>::make_shared(_Args&& ...__args) | 
 | 3105 | { | 
 | 3106 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3107 |     typedef allocator<_CntrlBlk> _A2; | 
 | 3108 |     typedef __allocator_destructor<_A2> _D2; | 
 | 3109 |     _A2 __a2; | 
 | 3110 |     unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
 | 3111 |     ::new(__hold2.get()) _CntrlBlk(__a2, _STD::forward<_Args>(__args)...); | 
 | 3112 |     shared_ptr<_Tp> __r; | 
 | 3113 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3114 |     __r.__cntrl_ = __hold2.release(); | 
 | 3115 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3116 |     return __r; | 
 | 3117 | } | 
 | 3118 |  | 
 | 3119 | template<class _Tp> | 
 | 3120 | template<class _Alloc, class ..._Args> | 
 | 3121 | shared_ptr<_Tp> | 
 | 3122 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) | 
 | 3123 | { | 
 | 3124 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3125 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 3126 |     typedef __allocator_destructor<_A2> _D2; | 
 | 3127 |     _A2 __a2(__a); | 
 | 3128 |     unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
 | 3129 |     ::new(__hold2.get()) _CntrlBlk(__a, _STD::forward<_Args>(__args)...); | 
 | 3130 |     shared_ptr<_Tp> __r; | 
 | 3131 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3132 |     __r.__cntrl_ = __hold2.release(); | 
 | 3133 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3134 |     return __r; | 
 | 3135 | } | 
 | 3136 |  | 
 | 3137 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3138 |  | 
 | 3139 | template<class _Tp> | 
 | 3140 | shared_ptr<_Tp> | 
 | 3141 | shared_ptr<_Tp>::make_shared() | 
 | 3142 | { | 
 | 3143 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3144 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 3145 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3146 |     _Alloc2 __alloc2; | 
 | 3147 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3148 |     ::new(__hold2.get()) _CntrlBlk(__alloc2); | 
 | 3149 |     shared_ptr<_Tp> __r; | 
 | 3150 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3151 |     __r.__cntrl_ = __hold2.release(); | 
 | 3152 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3153 |     return __r; | 
 | 3154 | } | 
 | 3155 |  | 
 | 3156 | template<class _Tp> | 
 | 3157 | template<class _A0> | 
 | 3158 | shared_ptr<_Tp> | 
 | 3159 | shared_ptr<_Tp>::make_shared(_A0& __a0) | 
 | 3160 | { | 
 | 3161 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3162 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 3163 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3164 |     _Alloc2 __alloc2; | 
 | 3165 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3166 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); | 
 | 3167 |     shared_ptr<_Tp> __r; | 
 | 3168 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3169 |     __r.__cntrl_ = __hold2.release(); | 
 | 3170 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3171 |     return __r; | 
 | 3172 | } | 
 | 3173 |  | 
 | 3174 | template<class _Tp> | 
 | 3175 | template<class _A0, class _A1> | 
 | 3176 | shared_ptr<_Tp> | 
 | 3177 | shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) | 
 | 3178 | { | 
 | 3179 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3180 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 3181 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3182 |     _Alloc2 __alloc2; | 
 | 3183 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3184 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); | 
 | 3185 |     shared_ptr<_Tp> __r; | 
 | 3186 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3187 |     __r.__cntrl_ = __hold2.release(); | 
 | 3188 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3189 |     return __r; | 
 | 3190 | } | 
 | 3191 |  | 
 | 3192 | template<class _Tp> | 
 | 3193 | template<class _A0, class _A1, class _A2> | 
 | 3194 | shared_ptr<_Tp> | 
 | 3195 | shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) | 
 | 3196 | { | 
 | 3197 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3198 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 3199 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3200 |     _Alloc2 __alloc2; | 
 | 3201 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3202 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); | 
 | 3203 |     shared_ptr<_Tp> __r; | 
 | 3204 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3205 |     __r.__cntrl_ = __hold2.release(); | 
 | 3206 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3207 |     return __r; | 
 | 3208 | } | 
 | 3209 |  | 
 | 3210 | template<class _Tp> | 
 | 3211 | template<class _Alloc> | 
 | 3212 | shared_ptr<_Tp> | 
 | 3213 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a) | 
 | 3214 | { | 
 | 3215 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3216 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 3217 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3218 |     _Alloc2 __alloc2(__a); | 
 | 3219 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3220 |     ::new(__hold2.get()) _CntrlBlk(__a); | 
 | 3221 |     shared_ptr<_Tp> __r; | 
 | 3222 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3223 |     __r.__cntrl_ = __hold2.release(); | 
 | 3224 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3225 |     return __r; | 
 | 3226 | } | 
 | 3227 |  | 
 | 3228 | template<class _Tp> | 
 | 3229 | template<class _Alloc, class _A0> | 
 | 3230 | shared_ptr<_Tp> | 
 | 3231 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) | 
 | 3232 | { | 
 | 3233 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3234 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 3235 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3236 |     _Alloc2 __alloc2(__a); | 
 | 3237 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3238 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0); | 
 | 3239 |     shared_ptr<_Tp> __r; | 
 | 3240 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3241 |     __r.__cntrl_ = __hold2.release(); | 
 | 3242 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3243 |     return __r; | 
 | 3244 | } | 
 | 3245 |  | 
 | 3246 | template<class _Tp> | 
 | 3247 | template<class _Alloc, class _A0, class _A1> | 
 | 3248 | shared_ptr<_Tp> | 
 | 3249 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) | 
 | 3250 | { | 
 | 3251 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3252 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 3253 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3254 |     _Alloc2 __alloc2(__a); | 
 | 3255 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3256 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1); | 
 | 3257 |     shared_ptr<_Tp> __r; | 
 | 3258 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3259 |     __r.__cntrl_ = __hold2.release(); | 
 | 3260 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3261 |     return __r; | 
 | 3262 | } | 
 | 3263 |  | 
 | 3264 | template<class _Tp> | 
 | 3265 | template<class _Alloc, class _A0, class _A1, class _A2> | 
 | 3266 | shared_ptr<_Tp> | 
 | 3267 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 3268 | { | 
 | 3269 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3270 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 3271 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3272 |     _Alloc2 __alloc2(__a); | 
 | 3273 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3274 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2); | 
 | 3275 |     shared_ptr<_Tp> __r; | 
 | 3276 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3277 |     __r.__cntrl_ = __hold2.release(); | 
 | 3278 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3279 |     return __r; | 
 | 3280 | } | 
 | 3281 |  | 
 | 3282 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3283 |  | 
 | 3284 | template<class _Tp> | 
 | 3285 | shared_ptr<_Tp>::~shared_ptr() | 
 | 3286 | { | 
 | 3287 |     if (__cntrl_) | 
 | 3288 |         __cntrl_->__release_shared(); | 
 | 3289 | } | 
 | 3290 |  | 
 | 3291 | template<class _Tp> | 
 | 3292 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3293 | shared_ptr<_Tp>& | 
 | 3294 | shared_ptr<_Tp>::operator=(const shared_ptr& __r) | 
 | 3295 | { | 
 | 3296 |     shared_ptr(__r).swap(*this); | 
 | 3297 |     return *this; | 
 | 3298 | } | 
 | 3299 |  | 
 | 3300 | template<class _Tp> | 
 | 3301 | template<class _Yp> | 
 | 3302 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3303 | shared_ptr<_Tp>& | 
 | 3304 | shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) | 
 | 3305 | { | 
 | 3306 |     shared_ptr(__r).swap(*this); | 
 | 3307 |     return *this; | 
 | 3308 | } | 
 | 3309 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3310 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3311 |  | 
 | 3312 | template<class _Tp> | 
 | 3313 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3314 | shared_ptr<_Tp>& | 
 | 3315 | shared_ptr<_Tp>::operator=(shared_ptr&& __r) | 
 | 3316 | { | 
 | 3317 |     shared_ptr(_STD::move(__r)).swap(*this); | 
 | 3318 |     return *this; | 
 | 3319 | } | 
 | 3320 |  | 
 | 3321 | template<class _Tp> | 
 | 3322 | template<class _Yp> | 
 | 3323 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3324 | shared_ptr<_Tp>& | 
 | 3325 | shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) | 
 | 3326 | { | 
 | 3327 |     shared_ptr(_STD::move(__r)).swap(*this); | 
 | 3328 |     return *this; | 
 | 3329 | } | 
 | 3330 |  | 
 | 3331 | template<class _Tp> | 
 | 3332 | template<class _Yp> | 
 | 3333 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3334 | shared_ptr<_Tp>& | 
 | 3335 | shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) | 
 | 3336 | { | 
 | 3337 |     shared_ptr(__r).swap(*this); | 
 | 3338 |     return *this; | 
 | 3339 | } | 
 | 3340 |  | 
 | 3341 | template<class _Tp> | 
 | 3342 | template <class _Yp, class _Dp> | 
 | 3343 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3344 | shared_ptr<_Tp>& | 
 | 3345 | shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) | 
 | 3346 | { | 
 | 3347 |     shared_ptr(_STD::move(__r)).swap(*this); | 
 | 3348 |     return *this; | 
 | 3349 | } | 
 | 3350 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3351 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3352 |  | 
 | 3353 | template<class _Tp> | 
 | 3354 | template<class _Yp> | 
 | 3355 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3356 | shared_ptr<_Tp>& | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3357 | shared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3358 | { | 
 | 3359 |     shared_ptr(__r).swap(*this); | 
 | 3360 |     return *this; | 
 | 3361 | } | 
 | 3362 |  | 
 | 3363 | template<class _Tp> | 
 | 3364 | template <class _Yp, class _Dp> | 
 | 3365 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3366 | shared_ptr<_Tp>& | 
 | 3367 | shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) | 
 | 3368 | { | 
 | 3369 |     shared_ptr(_STD::move(__r)).swap(*this); | 
 | 3370 |     return *this; | 
 | 3371 | } | 
 | 3372 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3373 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3374 |  | 
 | 3375 | template<class _Tp> | 
 | 3376 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3377 | void | 
 | 3378 | shared_ptr<_Tp>::swap(shared_ptr& __r) | 
 | 3379 | { | 
 | 3380 |     _STD::swap(__ptr_, __r.__ptr_); | 
 | 3381 |     _STD::swap(__cntrl_, __r.__cntrl_); | 
 | 3382 | } | 
 | 3383 |  | 
 | 3384 | template<class _Tp> | 
 | 3385 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3386 | void | 
 | 3387 | shared_ptr<_Tp>::reset() | 
 | 3388 | { | 
 | 3389 |     shared_ptr().swap(*this); | 
 | 3390 | } | 
 | 3391 |  | 
 | 3392 | template<class _Tp> | 
 | 3393 | template<class _Yp> | 
 | 3394 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3395 | void | 
 | 3396 | shared_ptr<_Tp>::reset(_Yp* __p) | 
 | 3397 | { | 
 | 3398 |     shared_ptr(__p).swap(*this); | 
 | 3399 | } | 
 | 3400 |  | 
 | 3401 | template<class _Tp> | 
 | 3402 | template<class _Yp, class _Dp> | 
 | 3403 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3404 | void | 
 | 3405 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) | 
 | 3406 | { | 
 | 3407 |     shared_ptr(__p, __d).swap(*this); | 
 | 3408 | } | 
 | 3409 |  | 
 | 3410 | template<class _Tp> | 
 | 3411 | template<class _Yp, class _Dp, class _Alloc> | 
 | 3412 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3413 | void | 
 | 3414 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) | 
 | 3415 | { | 
 | 3416 |     shared_ptr(__p, __d, __a).swap(*this); | 
 | 3417 | } | 
 | 3418 |  | 
 | 3419 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 3420 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3421 | template<class _Tp, class ..._Args> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3422 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3423 | shared_ptr<_Tp> | 
 | 3424 | make_shared(_Args&& ...__args) | 
 | 3425 | { | 
 | 3426 |     return shared_ptr<_Tp>::make_shared(_STD::forward<_Args>(__args)...); | 
 | 3427 | } | 
 | 3428 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3429 | template<class _Tp, class _Alloc, class ..._Args> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3430 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3431 | shared_ptr<_Tp> | 
 | 3432 | allocate_shared(const _Alloc& __a, _Args&& ...__args) | 
 | 3433 | { | 
 | 3434 |     return shared_ptr<_Tp>::allocate_shared(__a, _STD::forward<_Args>(__args)...); | 
 | 3435 | } | 
 | 3436 |  | 
 | 3437 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3438 |  | 
 | 3439 | template<class _Tp> | 
 | 3440 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3441 | shared_ptr<_Tp> | 
 | 3442 | make_shared() | 
 | 3443 | { | 
 | 3444 |     return shared_ptr<_Tp>::make_shared(); | 
 | 3445 | } | 
 | 3446 |  | 
 | 3447 | template<class _Tp, class _A0> | 
 | 3448 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3449 | shared_ptr<_Tp> | 
 | 3450 | make_shared(_A0& __a0) | 
 | 3451 | { | 
 | 3452 |     return shared_ptr<_Tp>::make_shared(__a0); | 
 | 3453 | } | 
 | 3454 |  | 
 | 3455 | template<class _Tp, class _A0, class _A1> | 
 | 3456 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3457 | shared_ptr<_Tp> | 
 | 3458 | make_shared(_A0& __a0, _A1& __a1) | 
 | 3459 | { | 
 | 3460 |     return shared_ptr<_Tp>::make_shared(__a0, __a1); | 
 | 3461 | } | 
 | 3462 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3463 | template<class _Tp, class _A0, class _A1, class _A2> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3464 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3465 | shared_ptr<_Tp> | 
 | 3466 | make_shared(_A0& __a0, _A1& __a1, _A2& __a2) | 
 | 3467 | { | 
 | 3468 |     return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2); | 
 | 3469 | } | 
 | 3470 |  | 
 | 3471 | template<class _Tp, class _Alloc> | 
 | 3472 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3473 | shared_ptr<_Tp> | 
 | 3474 | allocate_shared(const _Alloc& __a) | 
 | 3475 | { | 
 | 3476 |     return shared_ptr<_Tp>::allocate_shared(__a); | 
 | 3477 | } | 
 | 3478 |  | 
 | 3479 | template<class _Tp, class _Alloc, class _A0> | 
 | 3480 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3481 | shared_ptr<_Tp> | 
 | 3482 | allocate_shared(const _Alloc& __a, _A0& __a0) | 
 | 3483 | { | 
 | 3484 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0); | 
 | 3485 | } | 
 | 3486 |  | 
 | 3487 | template<class _Tp, class _Alloc, class _A0, class _A1> | 
 | 3488 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3489 | shared_ptr<_Tp> | 
 | 3490 | allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) | 
 | 3491 | { | 
 | 3492 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1); | 
 | 3493 | } | 
 | 3494 |  | 
 | 3495 | template<class _Tp, class _Alloc, class _A0, class _A1, class _A2> | 
 | 3496 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3497 | shared_ptr<_Tp> | 
 | 3498 | allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 3499 | { | 
 | 3500 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2); | 
 | 3501 | } | 
 | 3502 |  | 
 | 3503 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3504 |  | 
 | 3505 | template<class _Tp, class _Up> | 
 | 3506 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3507 | bool | 
 | 3508 | operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) | 
 | 3509 | { | 
 | 3510 |     return __x.get() == __y.get(); | 
 | 3511 | } | 
 | 3512 |  | 
 | 3513 | template<class _Tp, class _Up> | 
 | 3514 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3515 | bool | 
 | 3516 | operator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) | 
 | 3517 | { | 
 | 3518 |     return !(__x == __y); | 
 | 3519 | } | 
 | 3520 |  | 
 | 3521 | template<class _Tp, class _Up> | 
 | 3522 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3523 | bool | 
 | 3524 | operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) | 
 | 3525 | { | 
 | 3526 |     return __x.get() < __y.get(); | 
 | 3527 | } | 
 | 3528 |  | 
 | 3529 | template<class _Tp> | 
 | 3530 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3531 | void | 
 | 3532 | swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) | 
 | 3533 | { | 
 | 3534 |     __x.swap(__y); | 
 | 3535 | } | 
 | 3536 |  | 
 | 3537 | template<class _Tp, class _Up> | 
 | 3538 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3539 | shared_ptr<_Tp> | 
 | 3540 | static_pointer_cast(const shared_ptr<_Up>& __r) | 
 | 3541 | { | 
 | 3542 |     return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); | 
 | 3543 | } | 
 | 3544 |  | 
 | 3545 | template<class _Tp, class _Up> | 
 | 3546 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3547 | shared_ptr<_Tp> | 
 | 3548 | dynamic_pointer_cast(const shared_ptr<_Up>& __r) | 
 | 3549 | { | 
 | 3550 |     _Tp* __p = dynamic_cast<_Tp*>(__r.get()); | 
 | 3551 |     return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); | 
 | 3552 | } | 
 | 3553 |  | 
 | 3554 | template<class _Tp, class _Up> | 
 | 3555 | shared_ptr<_Tp> | 
 | 3556 | const_pointer_cast(const shared_ptr<_Up>& __r) | 
 | 3557 | { | 
 | 3558 |     return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get())); | 
 | 3559 | } | 
 | 3560 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3561 | #ifndef _LIBCPP_NO_RTTI | 
 | 3562 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3563 | template<class _Dp, class _Tp> | 
 | 3564 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3565 | _Dp* | 
 | 3566 | get_deleter(const shared_ptr<_Tp>& __p) | 
 | 3567 | { | 
 | 3568 |     return __p.template __get_deleter<_Dp>(); | 
 | 3569 | } | 
 | 3570 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3571 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3572 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3573 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3574 | class _LIBCPP_VISIBLE weak_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3575 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3576 | public: | 
 | 3577 |     typedef _Tp element_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3578 | private: | 
 | 3579 |     element_type*        __ptr_; | 
 | 3580 |     __shared_weak_count* __cntrl_; | 
 | 3581 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3582 | public: | 
 | 3583 |     weak_ptr(); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3584 |     template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r, | 
 | 3585 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3586 |     weak_ptr(weak_ptr const& __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3587 |     template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r, | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3588 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()); | 
 | 3589 |  | 
 | 3590 |     ~weak_ptr(); | 
 | 3591 |  | 
 | 3592 |     weak_ptr& operator=(weak_ptr const& __r); | 
 | 3593 |     template<class _Yp> weak_ptr& operator=(weak_ptr<_Yp> const& __r); | 
 | 3594 |     template<class _Yp> weak_ptr& operator=(shared_ptr<_Yp> const& __r); | 
 | 3595 |  | 
 | 3596 |     void swap(weak_ptr& __r); | 
 | 3597 |     void reset(); | 
 | 3598 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3599 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3600 |     long use_count() const {return __cntrl_ ? __cntrl_->use_count() : 0;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3601 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3602 |     bool expired() const {return __cntrl_ == 0 || __cntrl_->use_count() == 0;} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3603 |     shared_ptr<_Tp> lock() const; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3604 |     template<class _Up> | 
 | 3605 |         _LIBCPP_INLINE_VISIBILITY | 
 | 3606 |         bool owner_before(const shared_ptr<_Up>& __r) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3607 |         {return __cntrl_ < __r.__cntrl_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3608 |     template<class _Up> | 
 | 3609 |         _LIBCPP_INLINE_VISIBILITY | 
 | 3610 |         bool owner_before(const weak_ptr<_Up>& __r) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3611 |         {return __cntrl_ < __r.__cntrl_;} | 
 | 3612 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3613 |     template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; | 
 | 3614 |     template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3615 | }; | 
 | 3616 |  | 
 | 3617 | template<class _Tp> | 
 | 3618 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3619 | weak_ptr<_Tp>::weak_ptr() | 
 | 3620 |     : __ptr_(0), | 
 | 3621 |       __cntrl_(0) | 
 | 3622 | { | 
 | 3623 | } | 
 | 3624 |  | 
 | 3625 | template<class _Tp> | 
 | 3626 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3627 | weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) | 
 | 3628 |     : __ptr_(__r.__ptr_), | 
 | 3629 |       __cntrl_(__r.__cntrl_) | 
 | 3630 | { | 
 | 3631 |     if (__cntrl_) | 
 | 3632 |         __cntrl_->__add_weak(); | 
 | 3633 | } | 
 | 3634 |  | 
 | 3635 | template<class _Tp> | 
 | 3636 | template<class _Yp> | 
 | 3637 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3638 | weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, | 
 | 3639 |                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
 | 3640 |     : __ptr_(__r.__ptr_), | 
 | 3641 |       __cntrl_(__r.__cntrl_) | 
 | 3642 | { | 
 | 3643 |     if (__cntrl_) | 
 | 3644 |         __cntrl_->__add_weak(); | 
 | 3645 | } | 
 | 3646 |  | 
 | 3647 | template<class _Tp> | 
 | 3648 | template<class _Yp> | 
 | 3649 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3650 | weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, | 
 | 3651 |                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
 | 3652 |     : __ptr_(__r.__ptr_), | 
 | 3653 |       __cntrl_(__r.__cntrl_) | 
 | 3654 | { | 
 | 3655 |     if (__cntrl_) | 
 | 3656 |         __cntrl_->__add_weak(); | 
 | 3657 | } | 
 | 3658 |  | 
 | 3659 | template<class _Tp> | 
 | 3660 | weak_ptr<_Tp>::~weak_ptr() | 
 | 3661 | { | 
 | 3662 |     if (__cntrl_) | 
 | 3663 |         __cntrl_->__release_weak(); | 
 | 3664 | } | 
 | 3665 |  | 
 | 3666 | template<class _Tp> | 
 | 3667 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3668 | weak_ptr<_Tp>& | 
 | 3669 | weak_ptr<_Tp>::operator=(weak_ptr const& __r) | 
 | 3670 | { | 
 | 3671 |     weak_ptr(__r).swap(*this); | 
 | 3672 |     return *this; | 
 | 3673 | } | 
 | 3674 |  | 
 | 3675 | template<class _Tp> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3676 | template<class _Yp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3677 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3678 | weak_ptr<_Tp>& | 
 | 3679 | weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) | 
 | 3680 | { | 
 | 3681 |     weak_ptr(__r).swap(*this); | 
 | 3682 |     return *this; | 
 | 3683 | } | 
 | 3684 |  | 
 | 3685 | template<class _Tp> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3686 | template<class _Yp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3687 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3688 | weak_ptr<_Tp>& | 
 | 3689 | weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) | 
 | 3690 | { | 
 | 3691 |     weak_ptr(__r).swap(*this); | 
 | 3692 |     return *this; | 
 | 3693 | } | 
 | 3694 |  | 
 | 3695 | template<class _Tp> | 
 | 3696 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3697 | void | 
 | 3698 | weak_ptr<_Tp>::swap(weak_ptr& __r) | 
 | 3699 | { | 
 | 3700 |     _STD::swap(__ptr_, __r.__ptr_); | 
 | 3701 |     _STD::swap(__cntrl_, __r.__cntrl_); | 
 | 3702 | } | 
 | 3703 |  | 
 | 3704 | template<class _Tp> | 
 | 3705 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3706 | void | 
 | 3707 | swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) | 
 | 3708 | { | 
 | 3709 |     __x.swap(__y); | 
 | 3710 | } | 
 | 3711 |  | 
 | 3712 | template<class _Tp> | 
 | 3713 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3714 | void | 
 | 3715 | weak_ptr<_Tp>::reset() | 
 | 3716 | { | 
 | 3717 |     weak_ptr().swap(*this); | 
 | 3718 | } | 
 | 3719 |  | 
 | 3720 | template<class _Tp> | 
 | 3721 | template<class _Yp> | 
 | 3722 | shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, | 
 | 3723 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
 | 3724 |     : __ptr_(__r.__ptr_), | 
 | 3725 |       __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) | 
 | 3726 | { | 
 | 3727 |     if (__cntrl_ == 0) | 
 | 3728 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3729 |         throw bad_weak_ptr(); | 
 | 3730 | #else | 
 | 3731 |         assert(!"bad_weak_ptr"); | 
 | 3732 | #endif | 
 | 3733 | } | 
 | 3734 |  | 
 | 3735 | template<class _Tp> | 
 | 3736 | shared_ptr<_Tp> | 
 | 3737 | weak_ptr<_Tp>::lock() const | 
 | 3738 | { | 
 | 3739 |     shared_ptr<_Tp> __r; | 
 | 3740 |     __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_; | 
 | 3741 |     if (__r.__cntrl_) | 
 | 3742 |         __r.__ptr_ = __ptr_; | 
 | 3743 |     return __r; | 
 | 3744 | } | 
 | 3745 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3746 | template <class _Tp> struct owner_less; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3747 |  | 
 | 3748 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3749 | struct _LIBCPP_VISIBLE owner_less<shared_ptr<_Tp> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3750 |     : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3751 | { | 
 | 3752 |     typedef bool result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3753 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3754 |     bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 3755 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3756 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3757 |     bool operator()(shared_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 3758 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3759 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3760 |     bool operator()(  weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 3761 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3762 | }; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3763 |  | 
 | 3764 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3765 | struct _LIBCPP_VISIBLE owner_less<weak_ptr<_Tp> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3766 |     : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> | 
 | 3767 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3768 |     typedef bool result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3769 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3770 |     bool operator()(  weak_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 3771 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3772 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3773 |     bool operator()(shared_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 3774 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3775 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3776 |     bool operator()(  weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 3777 |         {return __x.owner_before(__y);} | 
 | 3778 | }; | 
 | 3779 |  | 
 | 3780 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3781 | class _LIBCPP_VISIBLE enable_shared_from_this | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3782 | { | 
 | 3783 |     mutable weak_ptr<_Tp> __weak_this_; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3784 | protected: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3785 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3786 |     enable_shared_from_this() {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3787 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3788 |     enable_shared_from_this(enable_shared_from_this const&) {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3789 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3790 |     enable_shared_from_this& operator=(enable_shared_from_this const&) {return *this;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3791 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3792 |     ~enable_shared_from_this() {} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3793 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3794 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3795 |     shared_ptr<_Tp> shared_from_this() {return shared_ptr<_Tp>(__weak_this_);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3796 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3797 |     shared_ptr<_Tp const> shared_from_this() const {return shared_ptr<const _Tp>(__weak_this_);} | 
 | 3798 |  | 
 | 3799 |     template <class _Up> friend class shared_ptr; | 
 | 3800 | }; | 
 | 3801 |  | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3802 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3803 | struct _LIBCPP_VISIBLE hash<shared_ptr<_Tp> > | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3804 | { | 
 | 3805 |     typedef shared_ptr<_Tp>      argument_type; | 
 | 3806 |     typedef size_t               result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3807 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3808 |     result_type operator()(const argument_type& __ptr) const | 
 | 3809 |     { | 
 | 3810 |         return hash<_Tp*>()(__ptr.get()); | 
 | 3811 |     } | 
 | 3812 | }; | 
 | 3813 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3814 | //enum class | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3815 | struct _LIBCPP_VISIBLE pointer_safety | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3816 | { | 
 | 3817 |     enum _ | 
 | 3818 |     { | 
 | 3819 |         relaxed, | 
 | 3820 |         preferred, | 
 | 3821 |         strict | 
 | 3822 |     }; | 
 | 3823 |  | 
 | 3824 |     _ __v_; | 
 | 3825 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3826 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3827 |     pointer_safety(_ __v) : __v_(__v) {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3828 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3829 |     operator int() const {return __v_;} | 
 | 3830 | }; | 
 | 3831 |  | 
 | 3832 | void declare_reachable(void* __p); | 
 | 3833 | void declare_no_pointers(char* __p, size_t __n); | 
 | 3834 | void undeclare_no_pointers(char* __p, size_t __n); | 
 | 3835 | pointer_safety get_pointer_safety(); | 
 | 3836 | void* __undeclare_reachable(void*); | 
 | 3837 |  | 
 | 3838 | template <class _Tp> | 
 | 3839 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3840 | _Tp* | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3841 | undeclare_reachable(_Tp* __p) | 
 | 3842 | { | 
 | 3843 |     return static_cast<_Tp*>(__undeclare_reachable(__p)); | 
 | 3844 | } | 
 | 3845 |  | 
 | 3846 | void* align(size_t, size_t, void*&, size_t&); | 
 | 3847 |  | 
 | 3848 | _LIBCPP_END_NAMESPACE_STD | 
 | 3849 |  | 
 | 3850 | #endif  // _LIBCPP_MEMORY |