memory revision 227825
1227825Stheraven// -*- C++ -*- 2227825Stheraven//===-------------------------- memory ------------------------------------===// 3227825Stheraven// 4227825Stheraven// The LLVM Compiler Infrastructure 5227825Stheraven// 6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open 7227825Stheraven// Source Licenses. See LICENSE.TXT for details. 8227825Stheraven// 9227825Stheraven//===----------------------------------------------------------------------===// 10227825Stheraven 11227825Stheraven#ifndef _LIBCPP_MEMORY 12227825Stheraven#define _LIBCPP_MEMORY 13227825Stheraven 14227825Stheraven/* 15227825Stheraven memory synopsis 16227825Stheraven 17227825Stheravennamespace std 18227825Stheraven{ 19227825Stheraven 20227825Stheravenstruct allocator_arg_t { }; 21227825Stheravenconstexpr allocator_arg_t allocator_arg = allocator_arg_t(); 22227825Stheraven 23227825Stheraventemplate <class T, class Alloc> struct uses_allocator; 24227825Stheraven 25227825Stheraventemplate <class Ptr> 26227825Stheravenstruct pointer_traits 27227825Stheraven{ 28227825Stheraven typedef Ptr pointer; 29227825Stheraven typedef <details> element_type; 30227825Stheraven typedef <details> difference_type; 31227825Stheraven 32227825Stheraven template <class U> using rebind = <details>; 33227825Stheraven 34227825Stheraven static pointer pointer_to(<details>); 35227825Stheraven}; 36227825Stheraven 37227825Stheraventemplate <class T> 38227825Stheravenstruct pointer_traits<T*> 39227825Stheraven{ 40227825Stheraven typedef T* pointer; 41227825Stheraven typedef T element_type; 42227825Stheraven typedef ptrdiff_t difference_type; 43227825Stheraven 44227825Stheraven template <class U> using rebind = U*; 45227825Stheraven 46227825Stheraven static pointer pointer_to(<details>) noexcept; 47227825Stheraven}; 48227825Stheraven 49227825Stheraventemplate <class Alloc> 50227825Stheravenstruct allocator_traits 51227825Stheraven{ 52227825Stheraven typedef Alloc allocator_type; 53227825Stheraven typedef typename allocator_type::value_type 54227825Stheraven value_type; 55227825Stheraven 56227825Stheraven typedef Alloc::pointer | value_type* pointer; 57227825Stheraven typedef Alloc::const_pointer 58227825Stheraven | pointer_traits<pointer>::rebind<const value_type> 59227825Stheraven const_pointer; 60227825Stheraven typedef Alloc::void_pointer 61227825Stheraven | pointer_traits<pointer>::rebind<void> 62227825Stheraven void_pointer; 63227825Stheraven typedef Alloc::const_void_pointer 64227825Stheraven | pointer_traits<pointer>::rebind<const void> 65227825Stheraven const_void_pointer; 66227825Stheraven typedef Alloc::difference_type 67227825Stheraven | pointer_traits<pointer>::difference_type 68227825Stheraven difference_type; 69227825Stheraven typedef Alloc::size_type 70227825Stheraven | make_unsigned<difference_type>::type 71227825Stheraven size_type; 72227825Stheraven typedef Alloc::propagate_on_container_copy_assignment 73227825Stheraven | false_type propagate_on_container_copy_assignment; 74227825Stheraven typedef Alloc::propagate_on_container_move_assignment 75227825Stheraven | false_type propagate_on_container_move_assignment; 76227825Stheraven typedef Alloc::propagate_on_container_swap 77227825Stheraven | false_type propagate_on_container_swap; 78227825Stheraven 79227825Stheraven template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>; 80227825Stheraven template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; 81227825Stheraven 82227825Stheraven static pointer allocate(allocator_type& a, size_type n); 83227825Stheraven static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); 84227825Stheraven 85227825Stheraven static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; 86227825Stheraven 87227825Stheraven template <class T, class... Args> 88227825Stheraven static void construct(allocator_type& a, T* p, Args&&... args); 89227825Stheraven 90227825Stheraven template <class T> 91227825Stheraven static void destroy(allocator_type& a, T* p); 92227825Stheraven 93227825Stheraven static size_type max_size(const allocator_type& a); 94227825Stheraven 95227825Stheraven static allocator_type 96227825Stheraven select_on_container_copy_construction(const allocator_type& a); 97227825Stheraven}; 98227825Stheraven 99227825Stheraventemplate <> 100227825Stheravenclass allocator<void> 101227825Stheraven{ 102227825Stheravenpublic: 103227825Stheraven typedef void* pointer; 104227825Stheraven typedef const void* const_pointer; 105227825Stheraven typedef void value_type; 106227825Stheraven 107227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 108227825Stheraven}; 109227825Stheraven 110227825Stheraventemplate <class T> 111227825Stheravenclass allocator 112227825Stheraven{ 113227825Stheravenpublic: 114227825Stheraven typedef size_t size_type; 115227825Stheraven typedef ptrdiff_t difference_type; 116227825Stheraven typedef T* pointer; 117227825Stheraven typedef const T* const_pointer; 118227825Stheraven typedef typename add_lvalue_reference<T>::type reference; 119227825Stheraven typedef typename add_lvalue_reference<const T>::type const_reference; 120227825Stheraven typedef T value_type; 121227825Stheraven 122227825Stheraven template <class U> struct rebind {typedef allocator<U> other;}; 123227825Stheraven 124227825Stheraven allocator() noexcept; 125227825Stheraven allocator(const allocator&) noexcept; 126227825Stheraven template <class U> allocator(const allocator<U>&) noexcept; 127227825Stheraven ~allocator(); 128227825Stheraven pointer address(reference x) const noexcept; 129227825Stheraven const_pointer address(const_reference x) const noexcept; 130227825Stheraven pointer allocate(size_type, allocator<void>::const_pointer hint = 0); 131227825Stheraven void deallocate(pointer p, size_type n) noexcept; 132227825Stheraven size_type max_size() const noexcept; 133227825Stheraven template<class U, class... Args> 134227825Stheraven void construct(U* p, Args&&... args); 135227825Stheraven template <class U> 136227825Stheraven void destroy(U* p); 137227825Stheraven}; 138227825Stheraven 139227825Stheraventemplate <class T, class U> 140227825Stheravenbool operator==(const allocator<T>&, const allocator<U>&) noexcept; 141227825Stheraven 142227825Stheraventemplate <class T, class U> 143227825Stheravenbool operator!=(const allocator<T>&, const allocator<U>&) noexcept; 144227825Stheraven 145227825Stheraventemplate <class OutputIterator, class T> 146227825Stheravenclass raw_storage_iterator 147227825Stheraven : public iterator<output_iterator_tag, 148227825Stheraven T, // purposefully not C++03 149227825Stheraven ptrdiff_t, // purposefully not C++03 150227825Stheraven T*, // purposefully not C++03 151227825Stheraven raw_storage_iterator&> // purposefully not C++03 152227825Stheraven{ 153227825Stheravenpublic: 154227825Stheraven explicit raw_storage_iterator(OutputIterator x); 155227825Stheraven raw_storage_iterator& operator*(); 156227825Stheraven raw_storage_iterator& operator=(const T& element); 157227825Stheraven raw_storage_iterator& operator++(); 158227825Stheraven raw_storage_iterator operator++(int); 159227825Stheraven}; 160227825Stheraven 161227825Stheraventemplate <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; 162227825Stheraventemplate <class T> void return_temporary_buffer(T* p) noexcept; 163227825Stheraven 164227825Stheraventemplate <class T> T* addressof(T& r) noexcept; 165227825Stheraven 166227825Stheraventemplate <class InputIterator, class ForwardIterator> 167227825StheravenForwardIterator 168227825Stheravenuninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); 169227825Stheraven 170227825Stheraventemplate <class InputIterator, class Size, class ForwardIterator> 171227825StheravenForwardIterator 172227825Stheravenuninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); 173227825Stheraven 174227825Stheraventemplate <class ForwardIterator, class T> 175227825Stheravenvoid uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); 176227825Stheraven 177227825Stheraventemplate <class ForwardIterator, class Size, class T> 178227825StheravenForwardIterator 179227825Stheravenuninitialized_fill_n(ForwardIterator first, Size n, const T& x); 180227825Stheraven 181227825Stheraventemplate <class Y> struct auto_ptr_ref {}; 182227825Stheraven 183227825Stheraventemplate<class X> 184227825Stheravenclass auto_ptr 185227825Stheraven{ 186227825Stheravenpublic: 187227825Stheraven typedef X element_type; 188227825Stheraven 189227825Stheraven explicit auto_ptr(X* p =0) throw(); 190227825Stheraven auto_ptr(auto_ptr&) throw(); 191227825Stheraven template<class Y> auto_ptr(auto_ptr<Y>&) throw(); 192227825Stheraven auto_ptr& operator=(auto_ptr&) throw(); 193227825Stheraven template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw(); 194227825Stheraven auto_ptr& operator=(auto_ptr_ref<X> r) throw(); 195227825Stheraven ~auto_ptr() throw(); 196227825Stheraven 197227825Stheraven typename add_lvalue_reference<X>::type operator*() const throw(); 198227825Stheraven X* operator->() const throw(); 199227825Stheraven X* get() const throw(); 200227825Stheraven X* release() throw(); 201227825Stheraven void reset(X* p =0) throw(); 202227825Stheraven 203227825Stheraven auto_ptr(auto_ptr_ref<X>) throw(); 204227825Stheraven template<class Y> operator auto_ptr_ref<Y>() throw(); 205227825Stheraven template<class Y> operator auto_ptr<Y>() throw(); 206227825Stheraven}; 207227825Stheraven 208227825Stheraventemplate <class T> 209227825Stheravenstruct default_delete 210227825Stheraven{ 211227825Stheraven constexpr default_delete() noexcept = default; 212227825Stheraven template <class U> default_delete(const default_delete<U>&) noexcept; 213227825Stheraven 214227825Stheraven void operator()(T*) const noexcept; 215227825Stheraven}; 216227825Stheraven 217227825Stheraventemplate <class T> 218227825Stheravenstruct default_delete<T[]> 219227825Stheraven{ 220227825Stheraven constexpr default_delete() noexcept = default; 221227825Stheraven void operator()(T*) const noexcept; 222227825Stheraven template <class U> void operator()(U*) const = delete; 223227825Stheraven}; 224227825Stheraven 225227825Stheraventemplate <class T, class D = default_delete<T>> 226227825Stheravenclass unique_ptr 227227825Stheraven{ 228227825Stheravenpublic: 229227825Stheraven typedef see below pointer; 230227825Stheraven typedef T element_type; 231227825Stheraven typedef D deleter_type; 232227825Stheraven 233227825Stheraven // constructors 234227825Stheraven constexpr unique_ptr() noexcept; 235227825Stheraven explicit unique_ptr(pointer p) noexcept; 236227825Stheraven unique_ptr(pointer p, see below d1) noexcept; 237227825Stheraven unique_ptr(pointer p, see below d2) noexcept; 238227825Stheraven unique_ptr(unique_ptr&& u) noexcept; 239227825Stheraven unique_ptr(nullptr_t) noexcept : unique_ptr() { } 240227825Stheraven template <class U, class E> 241227825Stheraven unique_ptr(unique_ptr<U, E>&& u) noexcept; 242227825Stheraven template <class U> 243227825Stheraven unique_ptr(auto_ptr<U>&& u) noexcept; 244227825Stheraven 245227825Stheraven // destructor 246227825Stheraven ~unique_ptr(); 247227825Stheraven 248227825Stheraven // assignment 249227825Stheraven unique_ptr& operator=(unique_ptr&& u) noexcept; 250227825Stheraven template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept; 251227825Stheraven unique_ptr& operator=(nullptr_t) noexcept; 252227825Stheraven 253227825Stheraven // observers 254227825Stheraven typename add_lvalue_reference<T>::type operator*() const; 255227825Stheraven pointer operator->() const noexcept; 256227825Stheraven pointer get() const noexcept; 257227825Stheraven deleter_type& get_deleter() noexcept; 258227825Stheraven const deleter_type& get_deleter() const noexcept; 259227825Stheraven explicit operator bool() const noexcept; 260227825Stheraven 261227825Stheraven // modifiers 262227825Stheraven pointer release() noexcept; 263227825Stheraven void reset(pointer p = pointer()) noexcept; 264227825Stheraven void swap(unique_ptr& u) noexcept; 265227825Stheraven}; 266227825Stheraven 267227825Stheraventemplate <class T, class D> 268227825Stheravenclass unique_ptr<T[], D> 269227825Stheraven{ 270227825Stheravenpublic: 271227825Stheraven typedef implementation-defined pointer; 272227825Stheraven typedef T element_type; 273227825Stheraven typedef D deleter_type; 274227825Stheraven 275227825Stheraven // constructors 276227825Stheraven constexpr unique_ptr() noexcept; 277227825Stheraven explicit unique_ptr(pointer p) noexcept; 278227825Stheraven unique_ptr(pointer p, see below d) noexcept; 279227825Stheraven unique_ptr(pointer p, see below d) noexcept; 280227825Stheraven unique_ptr(unique_ptr&& u) noexcept; 281227825Stheraven unique_ptr(nullptr_t) noexcept : unique_ptr() { } 282227825Stheraven 283227825Stheraven // destructor 284227825Stheraven ~unique_ptr(); 285227825Stheraven 286227825Stheraven // assignment 287227825Stheraven unique_ptr& operator=(unique_ptr&& u) noexcept; 288227825Stheraven unique_ptr& operator=(nullptr_t) noexcept; 289227825Stheraven 290227825Stheraven // observers 291227825Stheraven T& operator[](size_t i) const; 292227825Stheraven pointer get() const noexcept; 293227825Stheraven deleter_type& get_deleter() noexcept; 294227825Stheraven const deleter_type& get_deleter() const noexcept; 295227825Stheraven explicit operator bool() const noexcept; 296227825Stheraven 297227825Stheraven // modifiers 298227825Stheraven pointer release() noexcept; 299227825Stheraven void reset(pointer p = pointer()) noexcept; 300227825Stheraven void reset(nullptr_t) noexcept; 301227825Stheraven template <class U> void reset(U) = delete; 302227825Stheraven void swap(unique_ptr& u) noexcept; 303227825Stheraven}; 304227825Stheraven 305227825Stheraventemplate <class T, class D> 306227825Stheraven void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept; 307227825Stheraven 308227825Stheraventemplate <class T1, class D1, class T2, class D2> 309227825Stheraven bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 310227825Stheraventemplate <class T1, class D1, class T2, class D2> 311227825Stheraven bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 312227825Stheraventemplate <class T1, class D1, class T2, class D2> 313227825Stheraven bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 314227825Stheraventemplate <class T1, class D1, class T2, class D2> 315227825Stheraven bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 316227825Stheraventemplate <class T1, class D1, class T2, class D2> 317227825Stheraven bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 318227825Stheraventemplate <class T1, class D1, class T2, class D2> 319227825Stheraven bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 320227825Stheraven 321227825Stheraventemplate <class T, class D> 322227825Stheraven bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; 323227825Stheraventemplate <class T, class D> 324227825Stheraven bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; 325227825Stheraventemplate <class T, class D> 326227825Stheraven bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; 327227825Stheraventemplate <class T, class D> 328227825Stheraven bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; 329227825Stheraven 330227825Stheraventemplate <class T, class D> 331227825Stheraven bool operator<(const unique_ptr<T, D>& x, nullptr_t); 332227825Stheraventemplate <class T, class D> 333227825Stheraven bool operator<(nullptr_t, const unique_ptr<T, D>& y); 334227825Stheraventemplate <class T, class D> 335227825Stheraven bool operator<=(const unique_ptr<T, D>& x, nullptr_t); 336227825Stheraventemplate <class T, class D> 337227825Stheraven bool operator<=(nullptr_t, const unique_ptr<T, D>& y); 338227825Stheraventemplate <class T, class D> 339227825Stheraven bool operator>(const unique_ptr<T, D>& x, nullptr_t); 340227825Stheraventemplate <class T, class D> 341227825Stheraven bool operator>(nullptr_t, const unique_ptr<T, D>& y); 342227825Stheraventemplate <class T, class D> 343227825Stheraven bool operator>=(const unique_ptr<T, D>& x, nullptr_t); 344227825Stheraventemplate <class T, class D> 345227825Stheraven bool operator>=(nullptr_t, const unique_ptr<T, D>& y); 346227825Stheraven 347227825Stheravenclass bad_weak_ptr 348227825Stheraven : public std::exception 349227825Stheraven{ 350227825Stheraven bad_weak_ptr() noexcept; 351227825Stheraven}; 352227825Stheraven 353227825Stheraventemplate<class T> 354227825Stheravenclass shared_ptr 355227825Stheraven{ 356227825Stheravenpublic: 357227825Stheraven typedef T element_type; 358227825Stheraven 359227825Stheraven // constructors: 360227825Stheraven constexpr shared_ptr() noexcept; 361227825Stheraven template<class Y> explicit shared_ptr(Y* p); 362227825Stheraven template<class Y, class D> shared_ptr(Y* p, D d); 363227825Stheraven template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); 364227825Stheraven template <class D> shared_ptr(nullptr_t p, D d); 365227825Stheraven template <class D, class A> shared_ptr(nullptr_t p, D d, A a); 366227825Stheraven template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept; 367227825Stheraven shared_ptr(const shared_ptr& r) noexcept; 368227825Stheraven template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept; 369227825Stheraven shared_ptr(shared_ptr&& r) noexcept; 370227825Stheraven template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept; 371227825Stheraven template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); 372227825Stheraven template<class Y> shared_ptr(auto_ptr<Y>&& r); 373227825Stheraven template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r); 374227825Stheraven shared_ptr(nullptr_t) : shared_ptr() { } 375227825Stheraven 376227825Stheraven // destructor: 377227825Stheraven ~shared_ptr(); 378227825Stheraven 379227825Stheraven // assignment: 380227825Stheraven shared_ptr& operator=(const shared_ptr& r) noexcept; 381227825Stheraven template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept; 382227825Stheraven shared_ptr& operator=(shared_ptr&& r) noexcept; 383227825Stheraven template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r); 384227825Stheraven template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); 385227825Stheraven template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); 386227825Stheraven 387227825Stheraven // modifiers: 388227825Stheraven void swap(shared_ptr& r) noexcept; 389227825Stheraven void reset() noexcept; 390227825Stheraven template<class Y> void reset(Y* p); 391227825Stheraven template<class Y, class D> void reset(Y* p, D d); 392227825Stheraven template<class Y, class D, class A> void reset(Y* p, D d, A a); 393227825Stheraven 394227825Stheraven // observers: 395227825Stheraven T* get() const noexcept; 396227825Stheraven T& operator*() const noexcept; 397227825Stheraven T* operator->() const noexcept; 398227825Stheraven long use_count() const noexcept; 399227825Stheraven bool unique() const noexcept; 400227825Stheraven explicit operator bool() const noexcept; 401227825Stheraven template<class U> bool owner_before(shared_ptr<U> const& b) const; 402227825Stheraven template<class U> bool owner_before(weak_ptr<U> const& b) const; 403227825Stheraven}; 404227825Stheraven 405227825Stheraven// shared_ptr comparisons: 406227825Stheraventemplate<class T, class U> 407227825Stheraven bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 408227825Stheraventemplate<class T, class U> 409227825Stheraven bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 410227825Stheraventemplate<class T, class U> 411227825Stheraven bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 412227825Stheraventemplate<class T, class U> 413227825Stheraven bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 414227825Stheraventemplate<class T, class U> 415227825Stheraven bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 416227825Stheraventemplate<class T, class U> 417227825Stheraven bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 418227825Stheraven 419227825Stheraventemplate <class T> 420227825Stheraven bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept; 421227825Stheraventemplate <class T> 422227825Stheraven bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept; 423227825Stheraventemplate <class T> 424227825Stheraven bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept; 425227825Stheraventemplate <class T> 426227825Stheraven bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept; 427227825Stheraventemplate <class T> 428227825Stheraven bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept; 429227825Stheraventemplate <class T> 430227825Stheravenbool operator<(nullptr_t, const shared_ptr<T>& y) noexcept; 431227825Stheraventemplate <class T> 432227825Stheraven bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept; 433227825Stheraventemplate <class T> 434227825Stheraven bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept; 435227825Stheraventemplate <class T> 436227825Stheraven bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept; 437227825Stheraventemplate <class T> 438227825Stheraven bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept; 439227825Stheraventemplate <class T> 440227825Stheraven bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept; 441227825Stheraventemplate <class T> 442227825Stheraven bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept; 443227825Stheraven 444227825Stheraven// shared_ptr specialized algorithms: 445227825Stheraventemplate<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept; 446227825Stheraven 447227825Stheraven// shared_ptr casts: 448227825Stheraventemplate<class T, class U> 449227825Stheraven shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept; 450227825Stheraventemplate<class T, class U> 451227825Stheraven shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept; 452227825Stheraventemplate<class T, class U> 453227825Stheraven shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept; 454227825Stheraven 455227825Stheraven// shared_ptr I/O: 456227825Stheraventemplate<class E, class T, class Y> 457227825Stheraven basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p); 458227825Stheraven 459227825Stheraven// shared_ptr get_deleter: 460227825Stheraventemplate<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept; 461227825Stheraven 462227825Stheraventemplate<class T, class... Args> 463227825Stheraven shared_ptr<T> make_shared(Args&&... args); 464227825Stheraventemplate<class T, class A, class... Args> 465227825Stheraven shared_ptr<T> allocate_shared(const A& a, Args&&... args); 466227825Stheraven 467227825Stheraventemplate<class T> 468227825Stheravenclass weak_ptr 469227825Stheraven{ 470227825Stheravenpublic: 471227825Stheraven typedef T element_type; 472227825Stheraven 473227825Stheraven // constructors 474227825Stheraven constexpr weak_ptr() noexcept; 475227825Stheraven template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept; 476227825Stheraven weak_ptr(weak_ptr const& r) noexcept; 477227825Stheraven template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept; 478227825Stheraven 479227825Stheraven // destructor 480227825Stheraven ~weak_ptr(); 481227825Stheraven 482227825Stheraven // assignment 483227825Stheraven weak_ptr& operator=(weak_ptr const& r) noexcept; 484227825Stheraven template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept; 485227825Stheraven template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept; 486227825Stheraven 487227825Stheraven // modifiers 488227825Stheraven void swap(weak_ptr& r) noexcept; 489227825Stheraven void reset() noexcept; 490227825Stheraven 491227825Stheraven // observers 492227825Stheraven long use_count() const noexcept; 493227825Stheraven bool expired() const noexcept; 494227825Stheraven shared_ptr<T> lock() const noexcept; 495227825Stheraven template<class U> bool owner_before(shared_ptr<U> const& b); 496227825Stheraven template<class U> bool owner_before(weak_ptr<U> const& b); 497227825Stheraven}; 498227825Stheraven 499227825Stheraven// weak_ptr specialized algorithms: 500227825Stheraventemplate<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept; 501227825Stheraven 502227825Stheraven// class owner_less: 503227825Stheraventemplate<class T> struct owner_less; 504227825Stheraven 505227825Stheraventemplate<class T> 506227825Stheravenstruct owner_less<shared_ptr<T>> 507227825Stheraven : binary_function<shared_ptr<T>, shared_ptr<T>, bool> 508227825Stheraven{ 509227825Stheraven typedef bool result_type; 510227825Stheraven bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const; 511227825Stheraven bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; 512227825Stheraven bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; 513227825Stheraven}; 514227825Stheraven 515227825Stheraventemplate<class T> 516227825Stheravenstruct owner_less<weak_ptr<T>> 517227825Stheraven : binary_function<weak_ptr<T>, weak_ptr<T>, bool> 518227825Stheraven{ 519227825Stheraven typedef bool result_type; 520227825Stheraven bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; 521227825Stheraven bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; 522227825Stheraven bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; 523227825Stheraven}; 524227825Stheraven 525227825Stheraventemplate<class T> 526227825Stheravenclass enable_shared_from_this 527227825Stheraven{ 528227825Stheravenprotected: 529227825Stheraven constexpr enable_shared_from_this() noexcept; 530227825Stheraven enable_shared_from_this(enable_shared_from_this const&) noexcept; 531227825Stheraven enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; 532227825Stheraven ~enable_shared_from_this(); 533227825Stheravenpublic: 534227825Stheraven shared_ptr<T> shared_from_this(); 535227825Stheraven shared_ptr<T const> shared_from_this() const; 536227825Stheraven}; 537227825Stheraven 538227825Stheraventemplate<class T> 539227825Stheraven bool atomic_is_lock_free(const shared_ptr<T>* p); 540227825Stheraventemplate<class T> 541227825Stheraven shared_ptr<T> atomic_load(const shared_ptr<T>* p); 542227825Stheraventemplate<class T> 543227825Stheraven shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo); 544227825Stheraventemplate<class T> 545227825Stheraven void atomic_store(shared_ptr<T>* p, shared_ptr<T> r); 546227825Stheraventemplate<class T> 547227825Stheraven void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); 548227825Stheraventemplate<class T> 549227825Stheraven shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r); 550227825Stheraventemplate<class T> 551227825Stheraven shared_ptr<T> 552227825Stheraven atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); 553227825Stheraventemplate<class T> 554227825Stheraven bool 555227825Stheraven atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); 556227825Stheraventemplate<class T> 557227825Stheraven bool 558227825Stheraven atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); 559227825Stheraventemplate<class T> 560227825Stheraven bool 561227825Stheraven atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, 562227825Stheraven shared_ptr<T> w, memory_order success, 563227825Stheraven memory_order failure); 564227825Stheraventemplate<class T> 565227825Stheraven bool 566227825Stheraven atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, 567227825Stheraven shared_ptr<T> w, memory_order success, 568227825Stheraven memory_order failure); 569227825Stheraven// Hash support 570227825Stheraventemplate <class T> struct hash; 571227825Stheraventemplate <class T, class D> struct hash<unique_ptr<T, D> >; 572227825Stheraventemplate <class T> struct hash<shared_ptr<T> >; 573227825Stheraven 574227825Stheraven// Pointer safety 575227825Stheravenenum class pointer_safety { relaxed, preferred, strict }; 576227825Stheravenvoid declare_reachable(void *p); 577227825Stheraventemplate <class T> T *undeclare_reachable(T *p); 578227825Stheravenvoid declare_no_pointers(char *p, size_t n); 579227825Stheravenvoid undeclare_no_pointers(char *p, size_t n); 580227825Stheravenpointer_safety get_pointer_safety() noexcept; 581227825Stheraven 582227825Stheravenvoid* align(size_t alignment, size_t size, void*& ptr, size_t& space); 583227825Stheraven 584227825Stheraven} // std 585227825Stheraven 586227825Stheraven*/ 587227825Stheraven 588227825Stheraven#include <__config> 589227825Stheraven#include <type_traits> 590227825Stheraven#include <typeinfo> 591227825Stheraven#include <cstddef> 592227825Stheraven#include <cstdint> 593227825Stheraven#include <new> 594227825Stheraven#include <utility> 595227825Stheraven#include <limits> 596227825Stheraven#include <iterator> 597227825Stheraven#include <__functional_base> 598227825Stheraven#include <iosfwd> 599227825Stheraven#if defined(_LIBCPP_NO_EXCEPTIONS) 600227825Stheraven #include <cassert> 601227825Stheraven#endif 602227825Stheraven 603227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 604227825Stheraven#pragma GCC system_header 605227825Stheraven#endif 606227825Stheraven 607227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 608227825Stheraven 609227825Stheraven// allocator_arg_t 610227825Stheraven 611227825Stheravenstruct _LIBCPP_VISIBLE allocator_arg_t { }; 612227825Stheraven 613227825Stheravenextern const allocator_arg_t allocator_arg; 614227825Stheraven 615227825Stheraven// addressof 616227825Stheraven 617227825Stheraventemplate <class _Tp> 618227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 619227825Stheraven_Tp* 620227825Stheravenaddressof(_Tp& __x) _NOEXCEPT 621227825Stheraven{ 622227825Stheraven return (_Tp*)&(char&)__x; 623227825Stheraven} 624227825Stheraven 625227825Stheraven#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) 626227825Stheraven// Objective-C++ Automatic Reference Counting uses qualified pointers 627227825Stheraven// that require special addressof() signatures. When 628227825Stheraven// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler 629227825Stheraven// itself is providing these definitions. Otherwise, we provide them. 630227825Stheraventemplate <class _Tp> 631227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 632227825Stheraven__strong _Tp* 633227825Stheravenaddressof(__strong _Tp& __x) _NOEXCEPT 634227825Stheraven{ 635227825Stheraven return &__x; 636227825Stheraven} 637227825Stheraven 638227825Stheraven#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK 639227825Stheraventemplate <class _Tp> 640227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 641227825Stheraven__weak _Tp* 642227825Stheravenaddressof(__weak _Tp& __x) _NOEXCEPT 643227825Stheraven{ 644227825Stheraven return &__x; 645227825Stheraven} 646227825Stheraven#endif 647227825Stheraven 648227825Stheraventemplate <class _Tp> 649227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 650227825Stheraven__autoreleasing _Tp* 651227825Stheravenaddressof(__autoreleasing _Tp& __x) _NOEXCEPT 652227825Stheraven{ 653227825Stheraven return &__x; 654227825Stheraven} 655227825Stheraven 656227825Stheraventemplate <class _Tp> 657227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 658227825Stheraven__unsafe_unretained _Tp* 659227825Stheravenaddressof(__unsafe_unretained _Tp& __x) _NOEXCEPT 660227825Stheraven{ 661227825Stheraven return &__x; 662227825Stheraven} 663227825Stheraven#endif 664227825Stheraven 665227825Stheraventemplate <class _Tp> class allocator; 666227825Stheraven 667227825Stheraventemplate <> 668227825Stheravenclass _LIBCPP_VISIBLE allocator<void> 669227825Stheraven{ 670227825Stheravenpublic: 671227825Stheraven typedef void* pointer; 672227825Stheraven typedef const void* const_pointer; 673227825Stheraven typedef void value_type; 674227825Stheraven 675227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 676227825Stheraven}; 677227825Stheraven 678227825Stheraven// pointer_traits 679227825Stheraven 680227825Stheraventemplate <class _Tp> 681227825Stheravenstruct __has_element_type 682227825Stheraven{ 683227825Stheravenprivate: 684227825Stheraven struct __two {char _; char __;}; 685227825Stheraven template <class _Up> static __two __test(...); 686227825Stheraven template <class _Up> static char __test(typename _Up::element_type* = 0); 687227825Stheravenpublic: 688227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 689227825Stheraven}; 690227825Stheraven 691227825Stheraventemplate <class _Ptr, bool = __has_element_type<_Ptr>::value> 692227825Stheravenstruct __pointer_traits_element_type; 693227825Stheraven 694227825Stheraventemplate <class _Ptr> 695227825Stheravenstruct __pointer_traits_element_type<_Ptr, true> 696227825Stheraven{ 697227825Stheraven typedef typename _Ptr::element_type type; 698227825Stheraven}; 699227825Stheraven 700227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 701227825Stheraven 702227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 703227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> 704227825Stheraven{ 705227825Stheraven typedef typename _Sp<_Tp, _Args...>::element_type type; 706227825Stheraven}; 707227825Stheraven 708227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 709227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> 710227825Stheraven{ 711227825Stheraven typedef _Tp type; 712227825Stheraven}; 713227825Stheraven 714227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 715227825Stheraven 716227825Stheraventemplate <template <class> class _Sp, class _Tp> 717227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp>, true> 718227825Stheraven{ 719227825Stheraven typedef typename _Sp<_Tp>::element_type type; 720227825Stheraven}; 721227825Stheraven 722227825Stheraventemplate <template <class> class _Sp, class _Tp> 723227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp>, false> 724227825Stheraven{ 725227825Stheraven typedef _Tp type; 726227825Stheraven}; 727227825Stheraven 728227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0> 729227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, true> 730227825Stheraven{ 731227825Stheraven typedef typename _Sp<_Tp, _A0>::element_type type; 732227825Stheraven}; 733227825Stheraven 734227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0> 735227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, false> 736227825Stheraven{ 737227825Stheraven typedef _Tp type; 738227825Stheraven}; 739227825Stheraven 740227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 741227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true> 742227825Stheraven{ 743227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::element_type type; 744227825Stheraven}; 745227825Stheraven 746227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 747227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false> 748227825Stheraven{ 749227825Stheraven typedef _Tp type; 750227825Stheraven}; 751227825Stheraven 752227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 753227825Stheraven class _A1, class _A2> 754227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true> 755227825Stheraven{ 756227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type; 757227825Stheraven}; 758227825Stheraven 759227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 760227825Stheraven class _A1, class _A2> 761227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false> 762227825Stheraven{ 763227825Stheraven typedef _Tp type; 764227825Stheraven}; 765227825Stheraven 766227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 767227825Stheraven 768227825Stheraventemplate <class _Tp> 769227825Stheravenstruct __has_difference_type 770227825Stheraven{ 771227825Stheravenprivate: 772227825Stheraven struct __two {char _; char __;}; 773227825Stheraven template <class _Up> static __two __test(...); 774227825Stheraven template <class _Up> static char __test(typename _Up::difference_type* = 0); 775227825Stheravenpublic: 776227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 777227825Stheraven}; 778227825Stheraven 779227825Stheraventemplate <class _Ptr, bool = __has_difference_type<_Ptr>::value> 780227825Stheravenstruct __pointer_traits_difference_type 781227825Stheraven{ 782227825Stheraven typedef ptrdiff_t type; 783227825Stheraven}; 784227825Stheraven 785227825Stheraventemplate <class _Ptr> 786227825Stheravenstruct __pointer_traits_difference_type<_Ptr, true> 787227825Stheraven{ 788227825Stheraven typedef typename _Ptr::difference_type type; 789227825Stheraven}; 790227825Stheraven 791227825Stheraventemplate <class _Tp, class _Up> 792227825Stheravenstruct __has_rebind 793227825Stheraven{ 794227825Stheravenprivate: 795227825Stheraven struct __two {char _; char __;}; 796227825Stheraven template <class _Xp> static __two __test(...); 797227825Stheraven template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); 798227825Stheravenpublic: 799227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 800227825Stheraven}; 801227825Stheraven 802227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 803227825Stheravenstruct __pointer_traits_rebind 804227825Stheraven{ 805227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 806227825Stheraven typedef typename _Tp::template rebind<_Up> type; 807227825Stheraven#else 808227825Stheraven typedef typename _Tp::template rebind<_Up>::other type; 809227825Stheraven#endif 810227825Stheraven}; 811227825Stheraven 812227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 813227825Stheraven 814227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 815227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> 816227825Stheraven{ 817227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 818227825Stheraven typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; 819227825Stheraven#else 820227825Stheraven typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; 821227825Stheraven#endif 822227825Stheraven}; 823227825Stheraven 824227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 825227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> 826227825Stheraven{ 827227825Stheraven typedef _Sp<_Up, _Args...> type; 828227825Stheraven}; 829227825Stheraven 830227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 831227825Stheraven 832227825Stheraventemplate <template <class> class _Sp, class _Tp, class _Up> 833227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> 834227825Stheraven{ 835227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 836227825Stheraven typedef typename _Sp<_Tp>::template rebind<_Up> type; 837227825Stheraven#else 838227825Stheraven typedef typename _Sp<_Tp>::template rebind<_Up>::other type; 839227825Stheraven#endif 840227825Stheraven}; 841227825Stheraven 842227825Stheraventemplate <template <class> class _Sp, class _Tp, class _Up> 843227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, false> 844227825Stheraven{ 845227825Stheraven typedef _Sp<_Up> type; 846227825Stheraven}; 847227825Stheraven 848227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 849227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> 850227825Stheraven{ 851227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 852227825Stheraven typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; 853227825Stheraven#else 854227825Stheraven typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; 855227825Stheraven#endif 856227825Stheraven}; 857227825Stheraven 858227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 859227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false> 860227825Stheraven{ 861227825Stheraven typedef _Sp<_Up, _A0> type; 862227825Stheraven}; 863227825Stheraven 864227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 865227825Stheraven class _A1, class _Up> 866227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> 867227825Stheraven{ 868227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 869227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; 870227825Stheraven#else 871227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; 872227825Stheraven#endif 873227825Stheraven}; 874227825Stheraven 875227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 876227825Stheraven class _A1, class _Up> 877227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false> 878227825Stheraven{ 879227825Stheraven typedef _Sp<_Up, _A0, _A1> type; 880227825Stheraven}; 881227825Stheraven 882227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 883227825Stheraven class _A1, class _A2, class _Up> 884227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> 885227825Stheraven{ 886227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 887227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; 888227825Stheraven#else 889227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 890227825Stheraven#endif 891227825Stheraven}; 892227825Stheraven 893227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 894227825Stheraven class _A1, class _A2, class _Up> 895227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> 896227825Stheraven{ 897227825Stheraven typedef _Sp<_Up, _A0, _A1, _A2> type; 898227825Stheraven}; 899227825Stheraven 900227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 901227825Stheraven 902227825Stheraventemplate <class _Ptr> 903227825Stheravenstruct _LIBCPP_VISIBLE pointer_traits 904227825Stheraven{ 905227825Stheraven typedef _Ptr pointer; 906227825Stheraven typedef typename __pointer_traits_element_type<pointer>::type element_type; 907227825Stheraven typedef typename __pointer_traits_difference_type<pointer>::type difference_type; 908227825Stheraven 909227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 910227825Stheraven template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; 911227825Stheraven#else 912227825Stheraven template <class _Up> struct rebind 913227825Stheraven {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; 914227825Stheraven#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 915227825Stheraven 916227825Stheravenprivate: 917227825Stheraven struct __nat {}; 918227825Stheravenpublic: 919227825Stheraven _LIBCPP_INLINE_VISIBILITY 920227825Stheraven static pointer pointer_to(typename conditional<is_void<element_type>::value, 921227825Stheraven __nat, element_type>::type& __r) 922227825Stheraven {return pointer::pointer_to(__r);} 923227825Stheraven}; 924227825Stheraven 925227825Stheraventemplate <class _Tp> 926227825Stheravenstruct _LIBCPP_VISIBLE pointer_traits<_Tp*> 927227825Stheraven{ 928227825Stheraven typedef _Tp* pointer; 929227825Stheraven typedef _Tp element_type; 930227825Stheraven typedef ptrdiff_t difference_type; 931227825Stheraven 932227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 933227825Stheraven template <class _Up> using rebind = _Up*; 934227825Stheraven#else 935227825Stheraven template <class _Up> struct rebind {typedef _Up* other;}; 936227825Stheraven#endif 937227825Stheraven 938227825Stheravenprivate: 939227825Stheraven struct __nat {}; 940227825Stheravenpublic: 941227825Stheraven _LIBCPP_INLINE_VISIBILITY 942227825Stheraven static pointer pointer_to(typename conditional<is_void<element_type>::value, 943227825Stheraven __nat, element_type>::type& __r) _NOEXCEPT 944227825Stheraven {return _VSTD::addressof(__r);} 945227825Stheraven}; 946227825Stheraven 947227825Stheraven// allocator_traits 948227825Stheraven 949227825Stheravennamespace __has_pointer_type_imp 950227825Stheraven{ 951227825Stheraven template <class _Up> static __two test(...); 952227825Stheraven template <class _Up> static char test(typename _Up::pointer* = 0); 953227825Stheraven} 954227825Stheraven 955227825Stheraventemplate <class _Tp> 956227825Stheravenstruct __has_pointer_type 957227825Stheraven : public integral_constant<bool, sizeof(__has_pointer_type_imp::test<_Tp>(0)) == 1> 958227825Stheraven{ 959227825Stheraven}; 960227825Stheraven 961227825Stheravennamespace __pointer_type_imp 962227825Stheraven{ 963227825Stheraven 964227825Stheraventemplate <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value> 965227825Stheravenstruct __pointer_type 966227825Stheraven{ 967227825Stheraven typedef typename _Dp::pointer type; 968227825Stheraven}; 969227825Stheraven 970227825Stheraventemplate <class _Tp, class _Dp> 971227825Stheravenstruct __pointer_type<_Tp, _Dp, false> 972227825Stheraven{ 973227825Stheraven typedef _Tp* type; 974227825Stheraven}; 975227825Stheraven 976227825Stheraven} // __pointer_type_imp 977227825Stheraven 978227825Stheraventemplate <class _Tp, class _Dp> 979227825Stheravenstruct __pointer_type 980227825Stheraven{ 981227825Stheraven typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type; 982227825Stheraven}; 983227825Stheraven 984227825Stheraventemplate <class _Tp> 985227825Stheravenstruct __has_const_pointer 986227825Stheraven{ 987227825Stheravenprivate: 988227825Stheraven struct __two {char _; char __;}; 989227825Stheraven template <class _Up> static __two __test(...); 990227825Stheraven template <class _Up> static char __test(typename _Up::const_pointer* = 0); 991227825Stheravenpublic: 992227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 993227825Stheraven}; 994227825Stheraven 995227825Stheraventemplate <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value> 996227825Stheravenstruct __const_pointer 997227825Stheraven{ 998227825Stheraven typedef typename _Alloc::const_pointer type; 999227825Stheraven}; 1000227825Stheraven 1001227825Stheraventemplate <class _Tp, class _Ptr, class _Alloc> 1002227825Stheravenstruct __const_pointer<_Tp, _Ptr, _Alloc, false> 1003227825Stheraven{ 1004227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1005227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; 1006227825Stheraven#else 1007227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; 1008227825Stheraven#endif 1009227825Stheraven}; 1010227825Stheraven 1011227825Stheraventemplate <class _Tp> 1012227825Stheravenstruct __has_void_pointer 1013227825Stheraven{ 1014227825Stheravenprivate: 1015227825Stheraven struct __two {char _; char __;}; 1016227825Stheraven template <class _Up> static __two __test(...); 1017227825Stheraven template <class _Up> static char __test(typename _Up::void_pointer* = 0); 1018227825Stheravenpublic: 1019227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1020227825Stheraven}; 1021227825Stheraven 1022227825Stheraventemplate <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value> 1023227825Stheravenstruct __void_pointer 1024227825Stheraven{ 1025227825Stheraven typedef typename _Alloc::void_pointer type; 1026227825Stheraven}; 1027227825Stheraven 1028227825Stheraventemplate <class _Ptr, class _Alloc> 1029227825Stheravenstruct __void_pointer<_Ptr, _Alloc, false> 1030227825Stheraven{ 1031227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1032227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<void> type; 1033227825Stheraven#else 1034227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; 1035227825Stheraven#endif 1036227825Stheraven}; 1037227825Stheraven 1038227825Stheraventemplate <class _Tp> 1039227825Stheravenstruct __has_const_void_pointer 1040227825Stheraven{ 1041227825Stheravenprivate: 1042227825Stheraven struct __two {char _; char __;}; 1043227825Stheraven template <class _Up> static __two __test(...); 1044227825Stheraven template <class _Up> static char __test(typename _Up::const_void_pointer* = 0); 1045227825Stheravenpublic: 1046227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1047227825Stheraven}; 1048227825Stheraven 1049227825Stheraventemplate <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value> 1050227825Stheravenstruct __const_void_pointer 1051227825Stheraven{ 1052227825Stheraven typedef typename _Alloc::const_void_pointer type; 1053227825Stheraven}; 1054227825Stheraven 1055227825Stheraventemplate <class _Ptr, class _Alloc> 1056227825Stheravenstruct __const_void_pointer<_Ptr, _Alloc, false> 1057227825Stheraven{ 1058227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1059227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const void> type; 1060227825Stheraven#else 1061227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; 1062227825Stheraven#endif 1063227825Stheraven}; 1064227825Stheraven 1065227825Stheraventemplate <class _T> 1066227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1067227825Stheraven_T* 1068227825Stheraven__to_raw_pointer(_T* __p) _NOEXCEPT 1069227825Stheraven{ 1070227825Stheraven return __p; 1071227825Stheraven} 1072227825Stheraven 1073227825Stheraventemplate <class _Pointer> 1074227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1075227825Stheraventypename pointer_traits<_Pointer>::element_type* 1076227825Stheraven__to_raw_pointer(_Pointer __p) _NOEXCEPT 1077227825Stheraven{ 1078227825Stheraven return _VSTD::__to_raw_pointer(__p.operator->()); 1079227825Stheraven} 1080227825Stheraven 1081227825Stheraventemplate <class _Tp> 1082227825Stheravenstruct __has_size_type 1083227825Stheraven{ 1084227825Stheravenprivate: 1085227825Stheraven struct __two {char _; char __;}; 1086227825Stheraven template <class _Up> static __two __test(...); 1087227825Stheraven template <class _Up> static char __test(typename _Up::size_type* = 0); 1088227825Stheravenpublic: 1089227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1090227825Stheraven}; 1091227825Stheraven 1092227825Stheraventemplate <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> 1093227825Stheravenstruct __size_type 1094227825Stheraven{ 1095227825Stheraven typedef typename make_unsigned<_DiffType>::type type; 1096227825Stheraven}; 1097227825Stheraven 1098227825Stheraventemplate <class _Alloc, class _DiffType> 1099227825Stheravenstruct __size_type<_Alloc, _DiffType, true> 1100227825Stheraven{ 1101227825Stheraven typedef typename _Alloc::size_type type; 1102227825Stheraven}; 1103227825Stheraven 1104227825Stheraventemplate <class _Tp> 1105227825Stheravenstruct __has_propagate_on_container_copy_assignment 1106227825Stheraven{ 1107227825Stheravenprivate: 1108227825Stheraven struct __two {char _; char __;}; 1109227825Stheraven template <class _Up> static __two __test(...); 1110227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0); 1111227825Stheravenpublic: 1112227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1113227825Stheraven}; 1114227825Stheraven 1115227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value> 1116227825Stheravenstruct __propagate_on_container_copy_assignment 1117227825Stheraven{ 1118227825Stheraven typedef false_type type; 1119227825Stheraven}; 1120227825Stheraven 1121227825Stheraventemplate <class _Alloc> 1122227825Stheravenstruct __propagate_on_container_copy_assignment<_Alloc, true> 1123227825Stheraven{ 1124227825Stheraven typedef typename _Alloc::propagate_on_container_copy_assignment type; 1125227825Stheraven}; 1126227825Stheraven 1127227825Stheraventemplate <class _Tp> 1128227825Stheravenstruct __has_propagate_on_container_move_assignment 1129227825Stheraven{ 1130227825Stheravenprivate: 1131227825Stheraven struct __two {char _; char __;}; 1132227825Stheraven template <class _Up> static __two __test(...); 1133227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0); 1134227825Stheravenpublic: 1135227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1136227825Stheraven}; 1137227825Stheraven 1138227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value> 1139227825Stheravenstruct __propagate_on_container_move_assignment 1140227825Stheraven{ 1141227825Stheraven typedef false_type type; 1142227825Stheraven}; 1143227825Stheraven 1144227825Stheraventemplate <class _Alloc> 1145227825Stheravenstruct __propagate_on_container_move_assignment<_Alloc, true> 1146227825Stheraven{ 1147227825Stheraven typedef typename _Alloc::propagate_on_container_move_assignment type; 1148227825Stheraven}; 1149227825Stheraven 1150227825Stheraventemplate <class _Tp> 1151227825Stheravenstruct __has_propagate_on_container_swap 1152227825Stheraven{ 1153227825Stheravenprivate: 1154227825Stheraven struct __two {char _; char __;}; 1155227825Stheraven template <class _Up> static __two __test(...); 1156227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0); 1157227825Stheravenpublic: 1158227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1159227825Stheraven}; 1160227825Stheraven 1161227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> 1162227825Stheravenstruct __propagate_on_container_swap 1163227825Stheraven{ 1164227825Stheraven typedef false_type type; 1165227825Stheraven}; 1166227825Stheraven 1167227825Stheraventemplate <class _Alloc> 1168227825Stheravenstruct __propagate_on_container_swap<_Alloc, true> 1169227825Stheraven{ 1170227825Stheraven typedef typename _Alloc::propagate_on_container_swap type; 1171227825Stheraven}; 1172227825Stheraven 1173227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 1174227825Stheravenstruct __has_rebind_other 1175227825Stheraven{ 1176227825Stheravenprivate: 1177227825Stheraven struct __two {char _; char __;}; 1178227825Stheraven template <class _Xp> static __two __test(...); 1179227825Stheraven template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); 1180227825Stheravenpublic: 1181227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1182227825Stheraven}; 1183227825Stheraven 1184227825Stheraventemplate <class _Tp, class _Up> 1185227825Stheravenstruct __has_rebind_other<_Tp, _Up, false> 1186227825Stheraven{ 1187227825Stheraven static const bool value = false; 1188227825Stheraven}; 1189227825Stheraven 1190227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> 1191227825Stheravenstruct __allocator_traits_rebind 1192227825Stheraven{ 1193227825Stheraven typedef typename _Tp::template rebind<_Up>::other type; 1194227825Stheraven}; 1195227825Stheraven 1196227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1197227825Stheraven 1198227825Stheraventemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 1199227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> 1200227825Stheraven{ 1201227825Stheraven typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; 1202227825Stheraven}; 1203227825Stheraven 1204227825Stheraventemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 1205227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> 1206227825Stheraven{ 1207227825Stheraven typedef _Alloc<_Up, _Args...> type; 1208227825Stheraven}; 1209227825Stheraven 1210227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1211227825Stheraven 1212227825Stheraventemplate <template <class> class _Alloc, class _Tp, class _Up> 1213227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true> 1214227825Stheraven{ 1215227825Stheraven typedef typename _Alloc<_Tp>::template rebind<_Up>::other type; 1216227825Stheraven}; 1217227825Stheraven 1218227825Stheraventemplate <template <class> class _Alloc, class _Tp, class _Up> 1219227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false> 1220227825Stheraven{ 1221227825Stheraven typedef _Alloc<_Up> type; 1222227825Stheraven}; 1223227825Stheraven 1224227825Stheraventemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 1225227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true> 1226227825Stheraven{ 1227227825Stheraven typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type; 1228227825Stheraven}; 1229227825Stheraven 1230227825Stheraventemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 1231227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false> 1232227825Stheraven{ 1233227825Stheraven typedef _Alloc<_Up, _A0> type; 1234227825Stheraven}; 1235227825Stheraven 1236227825Stheraventemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 1237227825Stheraven class _A1, class _Up> 1238227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true> 1239227825Stheraven{ 1240227825Stheraven typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type; 1241227825Stheraven}; 1242227825Stheraven 1243227825Stheraventemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 1244227825Stheraven class _A1, class _Up> 1245227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false> 1246227825Stheraven{ 1247227825Stheraven typedef _Alloc<_Up, _A0, _A1> type; 1248227825Stheraven}; 1249227825Stheraven 1250227825Stheraventemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 1251227825Stheraven class _A1, class _A2, class _Up> 1252227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true> 1253227825Stheraven{ 1254227825Stheraven typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 1255227825Stheraven}; 1256227825Stheraven 1257227825Stheraventemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 1258227825Stheraven class _A1, class _A2, class _Up> 1259227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> 1260227825Stheraven{ 1261227825Stheraven typedef _Alloc<_Up, _A0, _A1, _A2> type; 1262227825Stheraven}; 1263227825Stheraven 1264227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1265227825Stheraven 1266227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 1267227825Stheraven 1268227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1269227825Stheravenauto 1270227825Stheraven__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 1271227825Stheraven -> decltype(__a.allocate(__sz, __p), true_type()); 1272227825Stheraven 1273227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1274227825Stheravenauto 1275227825Stheraven__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 1276227825Stheraven -> false_type; 1277227825Stheraven 1278227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1279227825Stheravenstruct __has_allocate_hint 1280227825Stheraven : integral_constant<bool, 1281227825Stheraven is_same< 1282227825Stheraven decltype(__has_allocate_hint_test(declval<_Alloc>(), 1283227825Stheraven declval<_SizeType>(), 1284227825Stheraven declval<_ConstVoidPtr>())), 1285227825Stheraven true_type>::value> 1286227825Stheraven{ 1287227825Stheraven}; 1288227825Stheraven 1289227825Stheraven#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1290227825Stheraven 1291227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1292227825Stheravenstruct __has_allocate_hint 1293227825Stheraven : true_type 1294227825Stheraven{ 1295227825Stheraven}; 1296227825Stheraven 1297227825Stheraven#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1298227825Stheraven 1299227825Stheraven#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1300227825Stheraven 1301227825Stheraventemplate <class _Alloc, class _Tp, class ..._Args> 1302227825Stheravendecltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), 1303227825Stheraven _VSTD::declval<_Args>()...), 1304227825Stheraven true_type()) 1305227825Stheraven__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args); 1306227825Stheraven 1307227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1308227825Stheravenfalse_type 1309227825Stheraven__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args); 1310227825Stheraven 1311227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1312227825Stheravenstruct __has_construct 1313227825Stheraven : integral_constant<bool, 1314227825Stheraven is_same< 1315227825Stheraven decltype(__has_construct_test(declval<_Alloc>(), 1316227825Stheraven declval<_Pointer>(), 1317227825Stheraven declval<_Args>()...)), 1318227825Stheraven true_type>::value> 1319227825Stheraven{ 1320227825Stheraven}; 1321227825Stheraven 1322227825Stheraventemplate <class _Alloc, class _Pointer> 1323227825Stheravenauto 1324227825Stheraven__has_destroy_test(_Alloc&& __a, _Pointer&& __p) 1325227825Stheraven -> decltype(__a.destroy(__p), true_type()); 1326227825Stheraven 1327227825Stheraventemplate <class _Alloc, class _Pointer> 1328227825Stheravenauto 1329227825Stheraven__has_destroy_test(const _Alloc& __a, _Pointer&& __p) 1330227825Stheraven -> false_type; 1331227825Stheraven 1332227825Stheraventemplate <class _Alloc, class _Pointer> 1333227825Stheravenstruct __has_destroy 1334227825Stheraven : integral_constant<bool, 1335227825Stheraven is_same< 1336227825Stheraven decltype(__has_destroy_test(declval<_Alloc>(), 1337227825Stheraven declval<_Pointer>())), 1338227825Stheraven true_type>::value> 1339227825Stheraven{ 1340227825Stheraven}; 1341227825Stheraven 1342227825Stheraventemplate <class _Alloc> 1343227825Stheravenauto 1344227825Stheraven__has_max_size_test(_Alloc&& __a) 1345227825Stheraven -> decltype(__a.max_size(), true_type()); 1346227825Stheraven 1347227825Stheraventemplate <class _Alloc> 1348227825Stheravenauto 1349227825Stheraven__has_max_size_test(const volatile _Alloc& __a) 1350227825Stheraven -> false_type; 1351227825Stheraven 1352227825Stheraventemplate <class _Alloc> 1353227825Stheravenstruct __has_max_size 1354227825Stheraven : integral_constant<bool, 1355227825Stheraven is_same< 1356227825Stheraven decltype(__has_max_size_test(declval<_Alloc&>())), 1357227825Stheraven true_type>::value> 1358227825Stheraven{ 1359227825Stheraven}; 1360227825Stheraven 1361227825Stheraventemplate <class _Alloc> 1362227825Stheravenauto 1363227825Stheraven__has_select_on_container_copy_construction_test(_Alloc&& __a) 1364227825Stheraven -> decltype(__a.select_on_container_copy_construction(), true_type()); 1365227825Stheraven 1366227825Stheraventemplate <class _Alloc> 1367227825Stheravenauto 1368227825Stheraven__has_select_on_container_copy_construction_test(const volatile _Alloc& __a) 1369227825Stheraven -> false_type; 1370227825Stheraven 1371227825Stheraventemplate <class _Alloc> 1372227825Stheravenstruct __has_select_on_container_copy_construction 1373227825Stheraven : integral_constant<bool, 1374227825Stheraven is_same< 1375227825Stheraven decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())), 1376227825Stheraven true_type>::value> 1377227825Stheraven{ 1378227825Stheraven}; 1379227825Stheraven 1380227825Stheraven#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1381227825Stheraven 1382227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1383227825Stheraven 1384227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1385227825Stheravenstruct __has_construct 1386227825Stheraven : false_type 1387227825Stheraven{ 1388227825Stheraven}; 1389227825Stheraven 1390227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1391227825Stheraven 1392227825Stheraventemplate <class _Alloc, class _Pointer> 1393227825Stheravenstruct __has_destroy 1394227825Stheraven : false_type 1395227825Stheraven{ 1396227825Stheraven}; 1397227825Stheraven 1398227825Stheraventemplate <class _Alloc> 1399227825Stheravenstruct __has_max_size 1400227825Stheraven : true_type 1401227825Stheraven{ 1402227825Stheraven}; 1403227825Stheraven 1404227825Stheraventemplate <class _Alloc> 1405227825Stheravenstruct __has_select_on_container_copy_construction 1406227825Stheraven : false_type 1407227825Stheraven{ 1408227825Stheraven}; 1409227825Stheraven 1410227825Stheraven#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1411227825Stheraven 1412227825Stheraventemplate <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> 1413227825Stheravenstruct __alloc_traits_difference_type 1414227825Stheraven{ 1415227825Stheraven typedef typename pointer_traits<_Ptr>::difference_type type; 1416227825Stheraven}; 1417227825Stheraven 1418227825Stheraventemplate <class _Alloc, class _Ptr> 1419227825Stheravenstruct __alloc_traits_difference_type<_Alloc, _Ptr, true> 1420227825Stheraven{ 1421227825Stheraven typedef typename _Alloc::difference_type type; 1422227825Stheraven}; 1423227825Stheraven 1424227825Stheraventemplate <class _Alloc> 1425227825Stheravenstruct _LIBCPP_VISIBLE allocator_traits 1426227825Stheraven{ 1427227825Stheraven typedef _Alloc allocator_type; 1428227825Stheraven typedef typename allocator_type::value_type value_type; 1429227825Stheraven 1430227825Stheraven typedef typename __pointer_type<value_type, allocator_type>::type pointer; 1431227825Stheraven typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer; 1432227825Stheraven typedef typename __void_pointer<pointer, allocator_type>::type void_pointer; 1433227825Stheraven typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer; 1434227825Stheraven 1435227825Stheraven typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type; 1436227825Stheraven typedef typename __size_type<allocator_type, difference_type>::type size_type; 1437227825Stheraven 1438227825Stheraven typedef typename __propagate_on_container_copy_assignment<allocator_type>::type 1439227825Stheraven propagate_on_container_copy_assignment; 1440227825Stheraven typedef typename __propagate_on_container_move_assignment<allocator_type>::type 1441227825Stheraven propagate_on_container_move_assignment; 1442227825Stheraven typedef typename __propagate_on_container_swap<allocator_type>::type 1443227825Stheraven propagate_on_container_swap; 1444227825Stheraven 1445227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1446227825Stheraven template <class _Tp> using rebind_alloc = 1447227825Stheraven typename __allocator_traits_rebind<allocator_type, _Tp>::type; 1448227825Stheraven template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; 1449227825Stheraven#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1450227825Stheraven template <class _Tp> struct rebind_alloc 1451227825Stheraven {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;}; 1452227825Stheraven template <class _Tp> struct rebind_traits 1453227825Stheraven {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;}; 1454227825Stheraven#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1455227825Stheraven 1456227825Stheraven _LIBCPP_INLINE_VISIBILITY 1457227825Stheraven static pointer allocate(allocator_type& __a, size_type __n) 1458227825Stheraven {return __a.allocate(__n);} 1459227825Stheraven _LIBCPP_INLINE_VISIBILITY 1460227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) 1461227825Stheraven {return allocate(__a, __n, __hint, 1462227825Stheraven __has_allocate_hint<allocator_type, size_type, const_void_pointer>());} 1463227825Stheraven 1464227825Stheraven _LIBCPP_INLINE_VISIBILITY 1465227825Stheraven static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT 1466227825Stheraven {__a.deallocate(__p, __n);} 1467227825Stheraven 1468227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1469227825Stheraven template <class _Tp, class... _Args> 1470227825Stheraven _LIBCPP_INLINE_VISIBILITY 1471227825Stheraven static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) 1472227825Stheraven {__construct(__has_construct<allocator_type, pointer, _Args...>(), 1473227825Stheraven __a, __p, _VSTD::forward<_Args>(__args)...);} 1474227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1475227825Stheraven template <class _Tp> 1476227825Stheraven _LIBCPP_INLINE_VISIBILITY 1477227825Stheraven static void construct(allocator_type& __a, _Tp* __p) 1478227825Stheraven { 1479227825Stheraven ::new ((void*)__p) _Tp(); 1480227825Stheraven } 1481227825Stheraven template <class _Tp, class _A0> 1482227825Stheraven _LIBCPP_INLINE_VISIBILITY 1483227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0) 1484227825Stheraven { 1485227825Stheraven ::new ((void*)__p) _Tp(__a0); 1486227825Stheraven } 1487227825Stheraven template <class _Tp, class _A0, class _A1> 1488227825Stheraven _LIBCPP_INLINE_VISIBILITY 1489227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, 1490227825Stheraven const _A1& __a1) 1491227825Stheraven { 1492227825Stheraven ::new ((void*)__p) _Tp(__a0, __a1); 1493227825Stheraven } 1494227825Stheraven template <class _Tp, class _A0, class _A1, class _A2> 1495227825Stheraven _LIBCPP_INLINE_VISIBILITY 1496227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, 1497227825Stheraven const _A1& __a1, const _A2& __a2) 1498227825Stheraven { 1499227825Stheraven ::new ((void*)__p) _Tp(__a0, __a1, __a2); 1500227825Stheraven } 1501227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1502227825Stheraven 1503227825Stheraven template <class _Tp> 1504227825Stheraven _LIBCPP_INLINE_VISIBILITY 1505227825Stheraven static void destroy(allocator_type& __a, _Tp* __p) 1506227825Stheraven {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} 1507227825Stheraven 1508227825Stheraven _LIBCPP_INLINE_VISIBILITY 1509227825Stheraven static size_type max_size(const allocator_type& __a) 1510227825Stheraven {return __max_size(__has_max_size<const allocator_type>(), __a);} 1511227825Stheraven 1512227825Stheraven _LIBCPP_INLINE_VISIBILITY 1513227825Stheraven static allocator_type 1514227825Stheraven select_on_container_copy_construction(const allocator_type& __a) 1515227825Stheraven {return select_on_container_copy_construction( 1516227825Stheraven __has_select_on_container_copy_construction<const allocator_type>(), 1517227825Stheraven __a);} 1518227825Stheraven 1519227825Stheravenprivate: 1520227825Stheraven 1521227825Stheraven _LIBCPP_INLINE_VISIBILITY 1522227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, 1523227825Stheraven const_void_pointer __hint, true_type) 1524227825Stheraven {return __a.allocate(__n, __hint);} 1525227825Stheraven _LIBCPP_INLINE_VISIBILITY 1526227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, 1527227825Stheraven const_void_pointer __hint, false_type) 1528227825Stheraven {return __a.allocate(__n);} 1529227825Stheraven 1530227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1531227825Stheraven template <class _Tp, class... _Args> 1532227825Stheraven _LIBCPP_INLINE_VISIBILITY 1533227825Stheraven static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) 1534227825Stheraven {__a.construct(__p, _VSTD::forward<_Args>(__args)...);} 1535227825Stheraven template <class _Tp, class... _Args> 1536227825Stheraven _LIBCPP_INLINE_VISIBILITY 1537227825Stheraven static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) 1538227825Stheraven { 1539227825Stheraven ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); 1540227825Stheraven } 1541227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1542227825Stheraven 1543227825Stheraven template <class _Tp> 1544227825Stheraven _LIBCPP_INLINE_VISIBILITY 1545227825Stheraven static void __destroy(true_type, allocator_type& __a, _Tp* __p) 1546227825Stheraven {__a.destroy(__p);} 1547227825Stheraven template <class _Tp> 1548227825Stheraven _LIBCPP_INLINE_VISIBILITY 1549227825Stheraven static void __destroy(false_type, allocator_type&, _Tp* __p) 1550227825Stheraven { 1551227825Stheraven __p->~_Tp(); 1552227825Stheraven } 1553227825Stheraven 1554227825Stheraven _LIBCPP_INLINE_VISIBILITY 1555227825Stheraven static size_type __max_size(true_type, const allocator_type& __a) 1556227825Stheraven {return __a.max_size();} 1557227825Stheraven _LIBCPP_INLINE_VISIBILITY 1558227825Stheraven static size_type __max_size(false_type, const allocator_type&) 1559227825Stheraven {return numeric_limits<size_type>::max();} 1560227825Stheraven 1561227825Stheraven _LIBCPP_INLINE_VISIBILITY 1562227825Stheraven static allocator_type 1563227825Stheraven select_on_container_copy_construction(true_type, const allocator_type& __a) 1564227825Stheraven {return __a.select_on_container_copy_construction();} 1565227825Stheraven _LIBCPP_INLINE_VISIBILITY 1566227825Stheraven static allocator_type 1567227825Stheraven select_on_container_copy_construction(false_type, const allocator_type& __a) 1568227825Stheraven {return __a;} 1569227825Stheraven}; 1570227825Stheraven 1571227825Stheraven// uses_allocator 1572227825Stheraven 1573227825Stheraventemplate <class _Tp> 1574227825Stheravenstruct __has_allocator_type 1575227825Stheraven{ 1576227825Stheravenprivate: 1577227825Stheraven struct __two {char _; char __;}; 1578227825Stheraven template <class _Up> static __two __test(...); 1579227825Stheraven template <class _Up> static char __test(typename _Up::allocator_type* = 0); 1580227825Stheravenpublic: 1581227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1582227825Stheraven}; 1583227825Stheraven 1584227825Stheraventemplate <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value> 1585227825Stheravenstruct __uses_allocator 1586227825Stheraven : public integral_constant<bool, 1587227825Stheraven is_convertible<_Alloc, typename _Tp::allocator_type>::value> 1588227825Stheraven{ 1589227825Stheraven}; 1590227825Stheraven 1591227825Stheraventemplate <class _Tp, class _Alloc> 1592227825Stheravenstruct __uses_allocator<_Tp, _Alloc, false> 1593227825Stheraven : public false_type 1594227825Stheraven{ 1595227825Stheraven}; 1596227825Stheraven 1597227825Stheraventemplate <class _Tp, class _Alloc> 1598227825Stheravenstruct _LIBCPP_VISIBLE uses_allocator 1599227825Stheraven : public __uses_allocator<_Tp, _Alloc> 1600227825Stheraven{ 1601227825Stheraven}; 1602227825Stheraven 1603227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1604227825Stheraven 1605227825Stheraven// uses-allocator construction 1606227825Stheraven 1607227825Stheraventemplate <class _Tp, class _Alloc, class ..._Args> 1608227825Stheravenstruct __uses_alloc_ctor_imp 1609227825Stheraven{ 1610227825Stheraven static const bool __ua = uses_allocator<_Tp, _Alloc>::value; 1611227825Stheraven static const bool __ic = 1612227825Stheraven is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; 1613227825Stheraven static const int value = __ua ? 2 - __ic : 0; 1614227825Stheraven}; 1615227825Stheraven 1616227825Stheraventemplate <class _Tp, class _Alloc, class ..._Args> 1617227825Stheravenstruct __uses_alloc_ctor 1618227825Stheraven : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value> 1619227825Stheraven {}; 1620227825Stheraven 1621227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1622227825Stheraven 1623227825Stheraven// allocator 1624227825Stheraven 1625227825Stheraventemplate <class _Tp> 1626227825Stheravenclass _LIBCPP_VISIBLE allocator 1627227825Stheraven{ 1628227825Stheravenpublic: 1629227825Stheraven typedef size_t size_type; 1630227825Stheraven typedef ptrdiff_t difference_type; 1631227825Stheraven typedef _Tp* pointer; 1632227825Stheraven typedef const _Tp* const_pointer; 1633227825Stheraven typedef _Tp& reference; 1634227825Stheraven typedef const _Tp& const_reference; 1635227825Stheraven typedef _Tp value_type; 1636227825Stheraven 1637227825Stheraven typedef true_type propagate_on_container_move_assignment; 1638227825Stheraven 1639227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 1640227825Stheraven 1641227825Stheraven _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 1642227825Stheraven template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 1643227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT 1644227825Stheraven {return _VSTD::addressof(__x);} 1645227825Stheraven _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 1646227825Stheraven {return _VSTD::addressof(__x);} 1647227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1648227825Stheraven {return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));} 1649227825Stheraven _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1650227825Stheraven {::operator delete((void*)__p);} 1651227825Stheraven _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 1652227825Stheraven {return size_type(~0) / sizeof(_Tp);} 1653227825Stheraven#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1654227825Stheraven template <class _Up, class... _Args> 1655227825Stheraven _LIBCPP_INLINE_VISIBILITY 1656227825Stheraven void 1657227825Stheraven construct(_Up* __p, _Args&&... __args) 1658227825Stheraven { 1659227825Stheraven ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 1660227825Stheraven } 1661227825Stheraven#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1662227825Stheraven _LIBCPP_INLINE_VISIBILITY 1663227825Stheraven void 1664227825Stheraven construct(pointer __p) 1665227825Stheraven { 1666227825Stheraven ::new((void*)__p) _Tp(); 1667227825Stheraven } 1668227825Stheraven# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1669227825Stheraven template <class _A0> 1670227825Stheraven _LIBCPP_INLINE_VISIBILITY 1671227825Stheraven typename enable_if 1672227825Stheraven < 1673227825Stheraven !is_convertible<_A0, __rv<_A0> >::value, 1674227825Stheraven void 1675227825Stheraven >::type 1676227825Stheraven construct(pointer __p, _A0& __a0) 1677227825Stheraven { 1678227825Stheraven ::new((void*)__p) _Tp(__a0); 1679227825Stheraven } 1680227825Stheraven template <class _A0> 1681227825Stheraven _LIBCPP_INLINE_VISIBILITY 1682227825Stheraven typename enable_if 1683227825Stheraven < 1684227825Stheraven !is_convertible<_A0, __rv<_A0> >::value, 1685227825Stheraven void 1686227825Stheraven >::type 1687227825Stheraven construct(pointer __p, const _A0& __a0) 1688227825Stheraven { 1689227825Stheraven ::new((void*)__p) _Tp(__a0); 1690227825Stheraven } 1691227825Stheraven template <class _A0> 1692227825Stheraven _LIBCPP_INLINE_VISIBILITY 1693227825Stheraven typename enable_if 1694227825Stheraven < 1695227825Stheraven is_convertible<_A0, __rv<_A0> >::value, 1696227825Stheraven void 1697227825Stheraven >::type 1698227825Stheraven construct(pointer __p, _A0 __a0) 1699227825Stheraven { 1700227825Stheraven ::new((void*)__p) _Tp(_VSTD::move(__a0)); 1701227825Stheraven } 1702227825Stheraven# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1703227825Stheraven template <class _A0, class _A1> 1704227825Stheraven _LIBCPP_INLINE_VISIBILITY 1705227825Stheraven void 1706227825Stheraven construct(pointer __p, _A0& __a0, _A1& __a1) 1707227825Stheraven { 1708227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1709227825Stheraven } 1710227825Stheraven template <class _A0, class _A1> 1711227825Stheraven _LIBCPP_INLINE_VISIBILITY 1712227825Stheraven void 1713227825Stheraven construct(pointer __p, const _A0& __a0, _A1& __a1) 1714227825Stheraven { 1715227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1716227825Stheraven } 1717227825Stheraven template <class _A0, class _A1> 1718227825Stheraven _LIBCPP_INLINE_VISIBILITY 1719227825Stheraven void 1720227825Stheraven construct(pointer __p, _A0& __a0, const _A1& __a1) 1721227825Stheraven { 1722227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1723227825Stheraven } 1724227825Stheraven template <class _A0, class _A1> 1725227825Stheraven _LIBCPP_INLINE_VISIBILITY 1726227825Stheraven void 1727227825Stheraven construct(pointer __p, const _A0& __a0, const _A1& __a1) 1728227825Stheraven { 1729227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1730227825Stheraven } 1731227825Stheraven#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1732227825Stheraven _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 1733227825Stheraven}; 1734227825Stheraven 1735227825Stheraventemplate <class _Tp, class _Up> 1736227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1737227825Stheravenbool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} 1738227825Stheraven 1739227825Stheraventemplate <class _Tp, class _Up> 1740227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1741227825Stheravenbool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} 1742227825Stheraven 1743227825Stheraventemplate <class _OutputIterator, class _Tp> 1744227825Stheravenclass _LIBCPP_VISIBLE raw_storage_iterator 1745227825Stheraven : public iterator<output_iterator_tag, 1746227825Stheraven _Tp, // purposefully not C++03 1747227825Stheraven ptrdiff_t, // purposefully not C++03 1748227825Stheraven _Tp*, // purposefully not C++03 1749227825Stheraven raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03 1750227825Stheraven{ 1751227825Stheravenprivate: 1752227825Stheraven _OutputIterator __x_; 1753227825Stheravenpublic: 1754227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} 1755227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} 1756227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) 1757227825Stheraven {::new(&*__x_) _Tp(__element); return *this;} 1758227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} 1759227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) 1760227825Stheraven {raw_storage_iterator __t(*this); ++__x_; return __t;} 1761227825Stheraven}; 1762227825Stheraven 1763227825Stheraventemplate <class _Tp> 1764227825Stheravenpair<_Tp*, ptrdiff_t> 1765227825Stheravenget_temporary_buffer(ptrdiff_t __n) _NOEXCEPT 1766227825Stheraven{ 1767227825Stheraven pair<_Tp*, ptrdiff_t> __r(0, 0); 1768227825Stheraven const ptrdiff_t __m = (~ptrdiff_t(0) ^ 1769227825Stheraven ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) 1770227825Stheraven / sizeof(_Tp); 1771227825Stheraven if (__n > __m) 1772227825Stheraven __n = __m; 1773227825Stheraven while (__n > 0) 1774227825Stheraven { 1775227825Stheraven __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); 1776227825Stheraven if (__r.first) 1777227825Stheraven { 1778227825Stheraven __r.second = __n; 1779227825Stheraven break; 1780227825Stheraven } 1781227825Stheraven __n /= 2; 1782227825Stheraven } 1783227825Stheraven return __r; 1784227825Stheraven} 1785227825Stheraven 1786227825Stheraventemplate <class _Tp> 1787227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1788227825Stheravenvoid return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);} 1789227825Stheraven 1790227825Stheraventemplate <class _Tp> 1791227825Stheravenstruct auto_ptr_ref 1792227825Stheraven{ 1793227825Stheraven _Tp* __ptr_; 1794227825Stheraven}; 1795227825Stheraven 1796227825Stheraventemplate<class _Tp> 1797227825Stheravenclass _LIBCPP_VISIBLE auto_ptr 1798227825Stheraven{ 1799227825Stheravenprivate: 1800227825Stheraven _Tp* __ptr_; 1801227825Stheravenpublic: 1802227825Stheraven typedef _Tp element_type; 1803227825Stheraven 1804227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} 1805227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} 1806227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() 1807227825Stheraven : __ptr_(__p.release()) {} 1808227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() 1809227825Stheraven {reset(__p.release()); return *this;} 1810227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() 1811227825Stheraven {reset(__p.release()); return *this;} 1812227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() 1813227825Stheraven {reset(__p.__ptr_); return *this;} 1814227825Stheraven _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} 1815227825Stheraven 1816227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() 1817227825Stheraven {return *__ptr_;} 1818227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} 1819227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} 1820227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() 1821227825Stheraven { 1822227825Stheraven _Tp* __t = __ptr_; 1823227825Stheraven __ptr_ = 0; 1824227825Stheraven return __t; 1825227825Stheraven } 1826227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() 1827227825Stheraven { 1828227825Stheraven if (__ptr_ != __p) 1829227825Stheraven delete __ptr_; 1830227825Stheraven __ptr_ = __p; 1831227825Stheraven } 1832227825Stheraven 1833227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} 1834227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() 1835227825Stheraven {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} 1836227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() 1837227825Stheraven {return auto_ptr<_Up>(release());} 1838227825Stheraven}; 1839227825Stheraven 1840227825Stheraventemplate <> 1841227825Stheravenclass _LIBCPP_VISIBLE auto_ptr<void> 1842227825Stheraven{ 1843227825Stheravenpublic: 1844227825Stheraven typedef void element_type; 1845227825Stheraven}; 1846227825Stheraven 1847227825Stheraventemplate <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, 1848227825Stheraven typename remove_cv<_T2>::type>::value, 1849227825Stheraven bool = is_empty<_T1>::value, 1850227825Stheraven bool = is_empty<_T2>::value> 1851227825Stheravenstruct __libcpp_compressed_pair_switch; 1852227825Stheraven 1853227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1854227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};}; 1855227825Stheraven 1856227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1857227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false> {enum {value = 1};}; 1858227825Stheraven 1859227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1860227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true> {enum {value = 2};}; 1861227825Stheraven 1862227825Stheraventemplate <class _T1, class _T2> 1863227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true> {enum {value = 3};}; 1864227825Stheraven 1865227825Stheraventemplate <class _T1, class _T2> 1866227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true> {enum {value = 1};}; 1867227825Stheraven 1868227825Stheraventemplate <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value> 1869227825Stheravenclass __libcpp_compressed_pair_imp; 1870227825Stheraven 1871227825Stheraventemplate <class _T1, class _T2> 1872227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 0> 1873227825Stheraven{ 1874227825Stheravenprivate: 1875227825Stheraven _T1 __first_; 1876227825Stheraven _T2 __second_; 1877227825Stheravenpublic: 1878227825Stheraven typedef _T1 _T1_param; 1879227825Stheraven typedef _T2 _T2_param; 1880227825Stheraven 1881227825Stheraven typedef typename remove_reference<_T1>::type& _T1_reference; 1882227825Stheraven typedef typename remove_reference<_T2>::type& _T2_reference; 1883227825Stheraven 1884227825Stheraven typedef const typename remove_reference<_T1>::type& _T1_const_reference; 1885227825Stheraven typedef const typename remove_reference<_T2>::type& _T2_const_reference; 1886227825Stheraven 1887227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 1888227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1, int = 0) 1889227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)) {} 1890227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2, int* = 0) 1891227825Stheraven : __second_(_VSTD::forward<_T2_param>(__t2)) {} 1892227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 1893227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 1894227825Stheraven 1895227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1896227825Stheraven 1897227825Stheraven _LIBCPP_INLINE_VISIBILITY 1898227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 1899227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 1900227825Stheraven is_nothrow_copy_constructible<_T2>::value) 1901227825Stheraven : __first_(__p.first()), 1902227825Stheraven __second_(__p.second()) {} 1903227825Stheraven 1904227825Stheraven _LIBCPP_INLINE_VISIBILITY 1905227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 1906227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 1907227825Stheraven is_nothrow_copy_assignable<_T2>::value) 1908227825Stheraven { 1909227825Stheraven __first_ = __p.first(); 1910227825Stheraven __second_ = __p.second(); 1911227825Stheraven return *this; 1912227825Stheraven } 1913227825Stheraven 1914227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1915227825Stheraven 1916227825Stheraven _LIBCPP_INLINE_VISIBILITY 1917227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 1918227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 1919227825Stheraven is_nothrow_move_constructible<_T2>::value) 1920227825Stheraven : __first_(_VSTD::forward<_T1>(__p.first())), 1921227825Stheraven __second_(_VSTD::forward<_T2>(__p.second())) {} 1922227825Stheraven 1923227825Stheraven _LIBCPP_INLINE_VISIBILITY 1924227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 1925227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 1926227825Stheraven is_nothrow_move_assignable<_T2>::value) 1927227825Stheraven { 1928227825Stheraven __first_ = _VSTD::forward<_T1>(__p.first()); 1929227825Stheraven __second_ = _VSTD::forward<_T2>(__p.second()); 1930227825Stheraven return *this; 1931227825Stheraven } 1932227825Stheraven 1933227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 1934227825Stheraven 1935227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1936227825Stheraven 1937227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 1938227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 1939227825Stheraven 1940227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 1941227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 1942227825Stheraven 1943227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 1944227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 1945227825Stheraven __is_nothrow_swappable<_T1>::value) 1946227825Stheraven { 1947227825Stheraven using _VSTD::swap; 1948227825Stheraven swap(__first_, __x.__first_); 1949227825Stheraven swap(__second_, __x.__second_); 1950227825Stheraven } 1951227825Stheraven}; 1952227825Stheraven 1953227825Stheraventemplate <class _T1, class _T2> 1954227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 1> 1955227825Stheraven : private _T1 1956227825Stheraven{ 1957227825Stheravenprivate: 1958227825Stheraven _T2 __second_; 1959227825Stheravenpublic: 1960227825Stheraven typedef _T1 _T1_param; 1961227825Stheraven typedef _T2 _T2_param; 1962227825Stheraven 1963227825Stheraven typedef _T1& _T1_reference; 1964227825Stheraven typedef typename remove_reference<_T2>::type& _T2_reference; 1965227825Stheraven 1966227825Stheraven typedef const _T1& _T1_const_reference; 1967227825Stheraven typedef const typename remove_reference<_T2>::type& _T2_const_reference; 1968227825Stheraven 1969227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 1970227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1, int = 0) 1971227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)) {} 1972227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2, int* = 0) 1973227825Stheraven : __second_(_VSTD::forward<_T2_param>(__t2)) {} 1974227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 1975227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 1976227825Stheraven 1977227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1978227825Stheraven 1979227825Stheraven _LIBCPP_INLINE_VISIBILITY 1980227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 1981227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 1982227825Stheraven is_nothrow_copy_constructible<_T2>::value) 1983227825Stheraven : _T1(__p.first()), __second_(__p.second()) {} 1984227825Stheraven 1985227825Stheraven _LIBCPP_INLINE_VISIBILITY 1986227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 1987227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 1988227825Stheraven is_nothrow_copy_assignable<_T2>::value) 1989227825Stheraven { 1990227825Stheraven _T1::operator=(__p.first()); 1991227825Stheraven __second_ = __p.second(); 1992227825Stheraven return *this; 1993227825Stheraven } 1994227825Stheraven 1995227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 1996227825Stheraven 1997227825Stheraven _LIBCPP_INLINE_VISIBILITY 1998227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 1999227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2000227825Stheraven is_nothrow_move_constructible<_T2>::value) 2001227825Stheraven : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {} 2002227825Stheraven 2003227825Stheraven _LIBCPP_INLINE_VISIBILITY 2004227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2005227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2006227825Stheraven is_nothrow_move_assignable<_T2>::value) 2007227825Stheraven { 2008227825Stheraven _T1::operator=(_VSTD::move(__p.first())); 2009227825Stheraven __second_ = _VSTD::forward<_T2>(__p.second()); 2010227825Stheraven return *this; 2011227825Stheraven } 2012227825Stheraven 2013227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2014227825Stheraven 2015227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2016227825Stheraven 2017227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 2018227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 2019227825Stheraven 2020227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 2021227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 2022227825Stheraven 2023227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2024227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2025227825Stheraven __is_nothrow_swappable<_T1>::value) 2026227825Stheraven { 2027227825Stheraven using _VSTD::swap; 2028227825Stheraven swap(__second_, __x.__second_); 2029227825Stheraven } 2030227825Stheraven}; 2031227825Stheraven 2032227825Stheraventemplate <class _T1, class _T2> 2033227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 2> 2034227825Stheraven : private _T2 2035227825Stheraven{ 2036227825Stheravenprivate: 2037227825Stheraven _T1 __first_; 2038227825Stheravenpublic: 2039227825Stheraven typedef _T1 _T1_param; 2040227825Stheraven typedef _T2 _T2_param; 2041227825Stheraven 2042227825Stheraven typedef typename remove_reference<_T1>::type& _T1_reference; 2043227825Stheraven typedef _T2& _T2_reference; 2044227825Stheraven 2045227825Stheraven typedef const typename remove_reference<_T1>::type& _T1_const_reference; 2046227825Stheraven typedef const _T2& _T2_const_reference; 2047227825Stheraven 2048227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2049227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2050227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)) {} 2051227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2052227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)) {} 2053227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2054227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2055227825Stheraven is_nothrow_move_constructible<_T2>::value) 2056227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} 2057227825Stheraven 2058227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2059227825Stheraven 2060227825Stheraven _LIBCPP_INLINE_VISIBILITY 2061227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2062227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2063227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2064227825Stheraven : _T2(__p.second()), __first_(__p.first()) {} 2065227825Stheraven 2066227825Stheraven _LIBCPP_INLINE_VISIBILITY 2067227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2068227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2069227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2070227825Stheraven { 2071227825Stheraven _T2::operator=(__p.second()); 2072227825Stheraven __first_ = __p.first(); 2073227825Stheraven return *this; 2074227825Stheraven } 2075227825Stheraven 2076227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2077227825Stheraven 2078227825Stheraven _LIBCPP_INLINE_VISIBILITY 2079227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2080227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2081227825Stheraven is_nothrow_move_constructible<_T2>::value) 2082227825Stheraven : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {} 2083227825Stheraven 2084227825Stheraven _LIBCPP_INLINE_VISIBILITY 2085227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2086227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2087227825Stheraven is_nothrow_move_assignable<_T2>::value) 2088227825Stheraven { 2089227825Stheraven _T2::operator=(_VSTD::forward<_T2>(__p.second())); 2090227825Stheraven __first_ = _VSTD::move(__p.first()); 2091227825Stheraven return *this; 2092227825Stheraven } 2093227825Stheraven 2094227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2095227825Stheraven 2096227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2097227825Stheraven 2098227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 2099227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 2100227825Stheraven 2101227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 2102227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 2103227825Stheraven 2104227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2105227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2106227825Stheraven __is_nothrow_swappable<_T1>::value) 2107227825Stheraven { 2108227825Stheraven using _VSTD::swap; 2109227825Stheraven swap(__first_, __x.__first_); 2110227825Stheraven } 2111227825Stheraven}; 2112227825Stheraven 2113227825Stheraventemplate <class _T1, class _T2> 2114227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 3> 2115227825Stheraven : private _T1, 2116227825Stheraven private _T2 2117227825Stheraven{ 2118227825Stheravenpublic: 2119227825Stheraven typedef _T1 _T1_param; 2120227825Stheraven typedef _T2 _T2_param; 2121227825Stheraven 2122227825Stheraven typedef _T1& _T1_reference; 2123227825Stheraven typedef _T2& _T2_reference; 2124227825Stheraven 2125227825Stheraven typedef const _T1& _T1_const_reference; 2126227825Stheraven typedef const _T2& _T2_const_reference; 2127227825Stheraven 2128227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2129227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2130227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)) {} 2131227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2132227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)) {} 2133227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2134227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} 2135227825Stheraven 2136227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2137227825Stheraven 2138227825Stheraven _LIBCPP_INLINE_VISIBILITY 2139227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2140227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2141227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2142227825Stheraven : _T1(__p.first()), _T2(__p.second()) {} 2143227825Stheraven 2144227825Stheraven _LIBCPP_INLINE_VISIBILITY 2145227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2146227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2147227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2148227825Stheraven { 2149227825Stheraven _T1::operator=(__p.first()); 2150227825Stheraven _T2::operator=(__p.second()); 2151227825Stheraven return *this; 2152227825Stheraven } 2153227825Stheraven 2154227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2155227825Stheraven 2156227825Stheraven _LIBCPP_INLINE_VISIBILITY 2157227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2158227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2159227825Stheraven is_nothrow_move_constructible<_T2>::value) 2160227825Stheraven : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {} 2161227825Stheraven 2162227825Stheraven _LIBCPP_INLINE_VISIBILITY 2163227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2164227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2165227825Stheraven is_nothrow_move_assignable<_T2>::value) 2166227825Stheraven { 2167227825Stheraven _T1::operator=(_VSTD::move(__p.first())); 2168227825Stheraven _T2::operator=(_VSTD::move(__p.second())); 2169227825Stheraven return *this; 2170227825Stheraven } 2171227825Stheraven 2172227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2173227825Stheraven 2174227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2175227825Stheraven 2176227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 2177227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 2178227825Stheraven 2179227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 2180227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 2181227825Stheraven 2182227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2183227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2184227825Stheraven __is_nothrow_swappable<_T1>::value) 2185227825Stheraven { 2186227825Stheraven } 2187227825Stheraven}; 2188227825Stheraven 2189227825Stheraventemplate <class _T1, class _T2> 2190227825Stheravenclass __compressed_pair 2191227825Stheraven : private __libcpp_compressed_pair_imp<_T1, _T2> 2192227825Stheraven{ 2193227825Stheraven typedef __libcpp_compressed_pair_imp<_T1, _T2> base; 2194227825Stheravenpublic: 2195227825Stheraven typedef typename base::_T1_param _T1_param; 2196227825Stheraven typedef typename base::_T2_param _T2_param; 2197227825Stheraven 2198227825Stheraven typedef typename base::_T1_reference _T1_reference; 2199227825Stheraven typedef typename base::_T2_reference _T2_reference; 2200227825Stheraven 2201227825Stheraven typedef typename base::_T1_const_reference _T1_const_reference; 2202227825Stheraven typedef typename base::_T2_const_reference _T2_const_reference; 2203227825Stheraven 2204227825Stheraven _LIBCPP_INLINE_VISIBILITY __compressed_pair() {} 2205227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1, int = 0) 2206227825Stheraven : base(_VSTD::forward<_T1_param>(__t1)) {} 2207227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2, int* = 0) 2208227825Stheraven : base(_VSTD::forward<_T2_param>(__t2)) {} 2209227825Stheraven _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) 2210227825Stheraven : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} 2211227825Stheraven 2212227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2213227825Stheraven 2214227825Stheraven _LIBCPP_INLINE_VISIBILITY 2215227825Stheraven __compressed_pair(const __compressed_pair& __p) 2216227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2217227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2218227825Stheraven : base(__p) {} 2219227825Stheraven 2220227825Stheraven _LIBCPP_INLINE_VISIBILITY 2221227825Stheraven __compressed_pair& operator=(const __compressed_pair& __p) 2222227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2223227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2224227825Stheraven { 2225227825Stheraven base::operator=(__p); 2226227825Stheraven return *this; 2227227825Stheraven } 2228227825Stheraven 2229227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2230227825Stheraven _LIBCPP_INLINE_VISIBILITY 2231227825Stheraven __compressed_pair(__compressed_pair&& __p) 2232227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2233227825Stheraven is_nothrow_move_constructible<_T2>::value) 2234227825Stheraven : base(_VSTD::move(__p)) {} 2235227825Stheraven 2236227825Stheraven _LIBCPP_INLINE_VISIBILITY 2237227825Stheraven __compressed_pair& operator=(__compressed_pair&& __p) 2238227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2239227825Stheraven is_nothrow_move_assignable<_T2>::value) 2240227825Stheraven { 2241227825Stheraven base::operator=(_VSTD::move(__p)); 2242227825Stheraven return *this; 2243227825Stheraven } 2244227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2245227825Stheraven 2246227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2247227825Stheraven 2248227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return base::first();} 2249227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();} 2250227825Stheraven 2251227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return base::second();} 2252227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();} 2253227825Stheraven 2254227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) 2255227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2256227825Stheraven __is_nothrow_swappable<_T1>::value) 2257227825Stheraven {base::swap(__x);} 2258227825Stheraven}; 2259227825Stheraven 2260227825Stheraventemplate <class _T1, class _T2> 2261227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2262227825Stheravenvoid 2263227825Stheravenswap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) 2264227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2265227825Stheraven __is_nothrow_swappable<_T1>::value) 2266227825Stheraven {__x.swap(__y);} 2267227825Stheraven 2268227825Stheraventemplate <class _Tp> 2269227825Stheravenstruct _LIBCPP_VISIBLE default_delete 2270227825Stheraven{ 2271227825Stheraven _LIBCPP_INLINE_VISIBILITY default_delete() _NOEXCEPT {} 2272227825Stheraven template <class _Up> 2273227825Stheraven _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, 2274227825Stheraven typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 2275227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT 2276227825Stheraven { 2277227825Stheraven static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 2278227825Stheraven delete __ptr; 2279227825Stheraven } 2280227825Stheraven}; 2281227825Stheraven 2282227825Stheraventemplate <class _Tp> 2283227825Stheravenstruct _LIBCPP_VISIBLE default_delete<_Tp[]> 2284227825Stheraven{ 2285227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT 2286227825Stheraven { 2287227825Stheraven static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 2288227825Stheraven delete [] __ptr; 2289227825Stheraven } 2290227825Stheravenprivate: 2291227825Stheraven template <class _Up> void operator() (_Up*) const; 2292227825Stheraven}; 2293227825Stheraven 2294227825Stheraventemplate <class _Tp, class _Dp = default_delete<_Tp> > 2295227825Stheravenclass _LIBCPP_VISIBLE unique_ptr 2296227825Stheraven{ 2297227825Stheravenpublic: 2298227825Stheraven typedef _Tp element_type; 2299227825Stheraven typedef _Dp deleter_type; 2300227825Stheraven typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 2301227825Stheravenprivate: 2302227825Stheraven __compressed_pair<pointer, deleter_type> __ptr_; 2303227825Stheraven 2304227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2305227825Stheraven unique_ptr(const unique_ptr&); 2306227825Stheraven unique_ptr& operator=(const unique_ptr&); 2307227825Stheraven template <class _Up, class _Ep> 2308227825Stheraven unique_ptr(const unique_ptr<_Up, _Ep>&); 2309227825Stheraven template <class _Up, class _Ep> 2310227825Stheraven unique_ptr& operator=(const unique_ptr<_Up, _Ep>&); 2311227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2312227825Stheraven unique_ptr(unique_ptr&); 2313227825Stheraven template <class _Up, class _Ep> 2314227825Stheraven unique_ptr(unique_ptr<_Up, _Ep>&); 2315227825Stheraven unique_ptr& operator=(unique_ptr&); 2316227825Stheraven template <class _Up, class _Ep> 2317227825Stheraven unique_ptr& operator=(unique_ptr<_Up, _Ep>&); 2318227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2319227825Stheraven 2320227825Stheraven struct __nat {int __for_bool_;}; 2321227825Stheraven 2322227825Stheraven typedef typename remove_reference<deleter_type>::type& _Dp_reference; 2323227825Stheraven typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 2324227825Stheravenpublic: 2325227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT 2326227825Stheraven : __ptr_(pointer()) 2327227825Stheraven { 2328227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2329227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2330227825Stheraven } 2331227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT 2332227825Stheraven : __ptr_(pointer()) 2333227825Stheraven { 2334227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2335227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2336227825Stheraven } 2337227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT 2338227825Stheraven : __ptr_(_VSTD::move(__p)) 2339227825Stheraven { 2340227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2341227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2342227825Stheraven } 2343227825Stheraven 2344227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2345227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional< 2346227825Stheraven is_reference<deleter_type>::value, 2347227825Stheraven deleter_type, 2348227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2349227825Stheraven _NOEXCEPT 2350227825Stheraven : __ptr_(__p, __d) {} 2351227825Stheraven 2352227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d) 2353227825Stheraven _NOEXCEPT 2354227825Stheraven : __ptr_(__p, _VSTD::move(__d)) 2355227825Stheraven { 2356227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2357227825Stheraven } 2358227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 2359227825Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2360227825Stheraven template <class _Up, class _Ep> 2361227825Stheraven _LIBCPP_INLINE_VISIBILITY 2362227825Stheraven unique_ptr(unique_ptr<_Up, _Ep>&& __u, 2363227825Stheraven typename enable_if 2364227825Stheraven < 2365227825Stheraven !is_array<_Up>::value && 2366227825Stheraven is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2367227825Stheraven is_convertible<_Ep, deleter_type>::value && 2368227825Stheraven ( 2369227825Stheraven !is_reference<deleter_type>::value || 2370227825Stheraven is_same<deleter_type, _Ep>::value 2371227825Stheraven ), 2372227825Stheraven __nat 2373227825Stheraven >::type = __nat()) _NOEXCEPT 2374227825Stheraven : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} 2375227825Stheraven 2376227825Stheraven template <class _Up> 2377227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, 2378227825Stheraven typename enable_if< 2379227825Stheraven is_convertible<_Up*, _Tp*>::value && 2380227825Stheraven is_same<_Dp, default_delete<_Tp> >::value, 2381227825Stheraven __nat 2382227825Stheraven >::type = __nat()) _NOEXCEPT 2383227825Stheraven : __ptr_(__p.release()) 2384227825Stheraven { 2385227825Stheraven } 2386227825Stheraven 2387227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 2388227825Stheraven { 2389227825Stheraven reset(__u.release()); 2390227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2391227825Stheraven return *this; 2392227825Stheraven } 2393227825Stheraven 2394227825Stheraven template <class _Up, class _Ep> 2395227825Stheraven _LIBCPP_INLINE_VISIBILITY 2396227825Stheraven typename enable_if 2397227825Stheraven < 2398227825Stheraven !is_array<_Up>::value, 2399227825Stheraven unique_ptr& 2400227825Stheraven >::type 2401227825Stheraven operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 2402227825Stheraven { 2403227825Stheraven reset(__u.release()); 2404227825Stheraven __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 2405227825Stheraven return *this; 2406227825Stheraven } 2407227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2408227825Stheraven 2409227825Stheraven _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 2410227825Stheraven { 2411227825Stheraven return __rv<unique_ptr>(*this); 2412227825Stheraven } 2413227825Stheraven 2414227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 2415227825Stheraven : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 2416227825Stheraven 2417227825Stheraven template <class _Up, class _Ep> 2418227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) 2419227825Stheraven { 2420227825Stheraven reset(__u.release()); 2421227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2422227825Stheraven return *this; 2423227825Stheraven } 2424227825Stheraven 2425227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 2426227825Stheraven : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {} 2427227825Stheraven 2428227825Stheraven template <class _Up> 2429227825Stheraven _LIBCPP_INLINE_VISIBILITY 2430227825Stheraven typename enable_if< 2431227825Stheraven is_convertible<_Up*, _Tp*>::value && 2432227825Stheraven is_same<_Dp, default_delete<_Tp> >::value, 2433227825Stheraven unique_ptr& 2434227825Stheraven >::type 2435227825Stheraven operator=(auto_ptr<_Up> __p) 2436227825Stheraven {reset(__p.release()); return *this;} 2437227825Stheraven 2438227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2439227825Stheraven _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 2440227825Stheraven 2441227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 2442227825Stheraven { 2443227825Stheraven reset(); 2444227825Stheraven return *this; 2445227825Stheraven } 2446227825Stheraven 2447227825Stheraven _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const 2448227825Stheraven {return *__ptr_.first();} 2449227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();} 2450227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 2451227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 2452227825Stheraven {return __ptr_.second();} 2453227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 2454227825Stheraven {return __ptr_.second();} 2455227825Stheraven _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const 2456227825Stheraven _NOEXCEPT 2457227825Stheraven {return __ptr_.first() ? &__nat::__for_bool_ : 0;} 2458227825Stheraven 2459227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 2460227825Stheraven { 2461227825Stheraven pointer __t = __ptr_.first(); 2462227825Stheraven __ptr_.first() = pointer(); 2463227825Stheraven return __t; 2464227825Stheraven } 2465227825Stheraven 2466227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT 2467227825Stheraven { 2468227825Stheraven pointer __tmp = __ptr_.first(); 2469227825Stheraven __ptr_.first() = __p; 2470227825Stheraven if (__tmp) 2471227825Stheraven __ptr_.second()(__tmp); 2472227825Stheraven } 2473227825Stheraven 2474227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT 2475227825Stheraven {__ptr_.swap(__u.__ptr_);} 2476227825Stheraven}; 2477227825Stheraven 2478227825Stheraventemplate <class _Tp, class _Dp> 2479227825Stheravenclass _LIBCPP_VISIBLE unique_ptr<_Tp[], _Dp> 2480227825Stheraven{ 2481227825Stheravenpublic: 2482227825Stheraven typedef _Tp element_type; 2483227825Stheraven typedef _Dp deleter_type; 2484227825Stheraven typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 2485227825Stheravenprivate: 2486227825Stheraven __compressed_pair<pointer, deleter_type> __ptr_; 2487227825Stheraven 2488227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2489227825Stheraven unique_ptr(const unique_ptr&); 2490227825Stheraven unique_ptr& operator=(const unique_ptr&); 2491227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2492227825Stheraven unique_ptr(unique_ptr&); 2493227825Stheraven template <class _Up> 2494227825Stheraven unique_ptr(unique_ptr<_Up>&); 2495227825Stheraven unique_ptr& operator=(unique_ptr&); 2496227825Stheraven template <class _Up> 2497227825Stheraven unique_ptr& operator=(unique_ptr<_Up>&); 2498227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2499227825Stheraven 2500227825Stheraven struct __nat {int __for_bool_;}; 2501227825Stheraven 2502227825Stheraven typedef typename remove_reference<deleter_type>::type& _Dp_reference; 2503227825Stheraven typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 2504227825Stheravenpublic: 2505227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT 2506227825Stheraven : __ptr_(pointer()) 2507227825Stheraven { 2508227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2509227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2510227825Stheraven } 2511227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT 2512227825Stheraven : __ptr_(pointer()) 2513227825Stheraven { 2514227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2515227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2516227825Stheraven } 2517227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2518227825Stheraven template <class _P, 2519227825Stheraven class = typename enable_if<is_same<_P, pointer>::value>::type 2520227825Stheraven > 2521227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_P __p) _NOEXCEPT 2522227825Stheraven : __ptr_(__p) 2523227825Stheraven { 2524227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2525227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2526227825Stheraven } 2527227825Stheraven 2528227825Stheraven template <class _P, 2529227825Stheraven class = typename enable_if<is_same<_P, pointer>::value>::type 2530227825Stheraven > 2531227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(_P __p, typename conditional< 2532227825Stheraven is_reference<deleter_type>::value, 2533227825Stheraven deleter_type, 2534227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2535227825Stheraven _NOEXCEPT 2536227825Stheraven : __ptr_(__p, __d) {} 2537227825Stheraven 2538227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional< 2539227825Stheraven is_reference<deleter_type>::value, 2540227825Stheraven deleter_type, 2541227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2542227825Stheraven _NOEXCEPT 2543227825Stheraven : __ptr_(pointer(), __d) {} 2544227825Stheraven 2545227825Stheraven template <class _P, 2546227825Stheraven class = typename enable_if<is_same<_P, pointer>::value || 2547227825Stheraven is_same<_P, nullptr_t>::value>::type 2548227825Stheraven > 2549227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(_P __p, typename remove_reference<deleter_type>::type&& __d) 2550227825Stheraven _NOEXCEPT 2551227825Stheraven : __ptr_(__p, _VSTD::move(__d)) 2552227825Stheraven { 2553227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2554227825Stheraven } 2555227825Stheraven 2556227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d) 2557227825Stheraven _NOEXCEPT 2558227825Stheraven : __ptr_(pointer(), _VSTD::move(__d)) 2559227825Stheraven { 2560227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2561227825Stheraven } 2562227825Stheraven 2563227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 2564227825Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2565227825Stheraven 2566227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 2567227825Stheraven { 2568227825Stheraven reset(__u.release()); 2569227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2570227825Stheraven return *this; 2571227825Stheraven } 2572227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2573227825Stheraven 2574227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) 2575227825Stheraven : __ptr_(__p) 2576227825Stheraven { 2577227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2578227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2579227825Stheraven } 2580227825Stheraven 2581227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 2582227825Stheraven : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {} 2583227825Stheraven 2584227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d) 2585227825Stheraven : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {} 2586227825Stheraven 2587227825Stheraven _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 2588227825Stheraven { 2589227825Stheraven return __rv<unique_ptr>(*this); 2590227825Stheraven } 2591227825Stheraven 2592227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 2593227825Stheraven : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 2594227825Stheraven 2595227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u) 2596227825Stheraven { 2597227825Stheraven reset(__u->release()); 2598227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter()); 2599227825Stheraven return *this; 2600227825Stheraven } 2601227825Stheraven 2602227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2603227825Stheraven _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 2604227825Stheraven 2605227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 2606227825Stheraven { 2607227825Stheraven reset(); 2608227825Stheraven return *this; 2609227825Stheraven } 2610227825Stheraven 2611227825Stheraven _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const 2612227825Stheraven {return __ptr_.first()[__i];} 2613227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 2614227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 2615227825Stheraven {return __ptr_.second();} 2616227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 2617227825Stheraven {return __ptr_.second();} 2618227825Stheraven _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const _NOEXCEPT 2619227825Stheraven {return __ptr_.first() ? &__nat::__for_bool_ : 0;} 2620227825Stheraven 2621227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 2622227825Stheraven { 2623227825Stheraven pointer __t = __ptr_.first(); 2624227825Stheraven __ptr_.first() = pointer(); 2625227825Stheraven return __t; 2626227825Stheraven } 2627227825Stheraven 2628227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2629227825Stheraven template <class _P, 2630227825Stheraven class = typename enable_if<is_same<_P, pointer>::value>::type 2631227825Stheraven > 2632227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(_P __p) _NOEXCEPT 2633227825Stheraven { 2634227825Stheraven pointer __tmp = __ptr_.first(); 2635227825Stheraven __ptr_.first() = __p; 2636227825Stheraven if (__tmp) 2637227825Stheraven __ptr_.second()(__tmp); 2638227825Stheraven } 2639227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT 2640227825Stheraven { 2641227825Stheraven pointer __tmp = __ptr_.first(); 2642227825Stheraven __ptr_.first() = nullptr; 2643227825Stheraven if (__tmp) 2644227825Stheraven __ptr_.second()(__tmp); 2645227825Stheraven } 2646227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT 2647227825Stheraven { 2648227825Stheraven pointer __tmp = __ptr_.first(); 2649227825Stheraven __ptr_.first() = nullptr; 2650227825Stheraven if (__tmp) 2651227825Stheraven __ptr_.second()(__tmp); 2652227825Stheraven } 2653227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2654227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) 2655227825Stheraven { 2656227825Stheraven pointer __tmp = __ptr_.first(); 2657227825Stheraven __ptr_.first() = __p; 2658227825Stheraven if (__tmp) 2659227825Stheraven __ptr_.second()(__tmp); 2660227825Stheraven } 2661227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2662227825Stheraven 2663227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} 2664227825Stheravenprivate: 2665227825Stheraven 2666227825Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2667227825Stheraven template <class _Up> 2668227825Stheraven explicit unique_ptr(_Up); 2669227825Stheraven template <class _Up> 2670227825Stheraven unique_ptr(_Up __u, 2671227825Stheraven typename conditional< 2672227825Stheraven is_reference<deleter_type>::value, 2673227825Stheraven deleter_type, 2674227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type, 2675227825Stheraven typename enable_if 2676227825Stheraven < 2677227825Stheraven is_convertible<_Up, pointer>::value, 2678227825Stheraven __nat 2679227825Stheraven >::type = __nat()); 2680227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2681227825Stheraven}; 2682227825Stheraven 2683227825Stheraventemplate <class _Tp, class _Dp> 2684227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2685227825Stheravenvoid 2686227825Stheravenswap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);} 2687227825Stheraven 2688227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2689227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2690227825Stheravenbool 2691227825Stheravenoperator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();} 2692227825Stheraven 2693227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2694227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2695227825Stheravenbool 2696227825Stheravenoperator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);} 2697227825Stheraven 2698227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2699227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2700227825Stheravenbool 2701227825Stheravenoperator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() < __y.get();} 2702227825Stheraven 2703227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2704227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2705227825Stheravenbool 2706227825Stheravenoperator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;} 2707227825Stheraven 2708227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2709227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2710227825Stheravenbool 2711227825Stheravenoperator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);} 2712227825Stheraven 2713227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2714227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2715227825Stheravenbool 2716227825Stheravenoperator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} 2717227825Stheraven 2718227825Stheraventemplate <class _Tp> struct hash; 2719227825Stheraven 2720227825Stheraventemplate<class _Tp> 2721227825Stheravenstruct _LIBCPP_VISIBLE hash<_Tp*> 2722227825Stheraven : public unary_function<_Tp*, size_t> 2723227825Stheraven{ 2724227825Stheraven _LIBCPP_INLINE_VISIBILITY 2725227825Stheraven size_t operator()(_Tp* __v) const _NOEXCEPT 2726227825Stheraven { 2727227825Stheraven const size_t* const __p = reinterpret_cast<const size_t*>(&__v); 2728227825Stheraven return *__p; 2729227825Stheraven } 2730227825Stheraven}; 2731227825Stheraven 2732227825Stheraventemplate <class _Tp, class _Dp> 2733227825Stheravenstruct _LIBCPP_VISIBLE hash<unique_ptr<_Tp, _Dp> > 2734227825Stheraven{ 2735227825Stheraven typedef unique_ptr<_Tp, _Dp> argument_type; 2736227825Stheraven typedef size_t result_type; 2737227825Stheraven _LIBCPP_INLINE_VISIBILITY 2738227825Stheraven result_type operator()(const argument_type& __ptr) const _NOEXCEPT 2739227825Stheraven { 2740227825Stheraven typedef typename argument_type::pointer pointer; 2741227825Stheraven return hash<pointer>()(__ptr.get()); 2742227825Stheraven } 2743227825Stheraven}; 2744227825Stheraven 2745227825Stheravenstruct __destruct_n 2746227825Stheraven{ 2747227825Stheravenprivate: 2748227825Stheraven size_t size; 2749227825Stheraven 2750227825Stheraven template <class _Tp> 2751227825Stheraven _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT 2752227825Stheraven {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} 2753227825Stheraven 2754227825Stheraven template <class _Tp> 2755227825Stheraven _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT 2756227825Stheraven {} 2757227825Stheraven 2758227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT 2759227825Stheraven {++size;} 2760227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT 2761227825Stheraven {} 2762227825Stheraven 2763227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT 2764227825Stheraven {size = __s;} 2765227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT 2766227825Stheraven {} 2767227825Stheravenpublic: 2768227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT 2769227825Stheraven : size(__s) {} 2770227825Stheraven 2771227825Stheraven template <class _Tp> 2772227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT 2773227825Stheraven {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 2774227825Stheraven 2775227825Stheraven template <class _Tp> 2776227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT 2777227825Stheraven {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 2778227825Stheraven 2779227825Stheraven template <class _Tp> 2780227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT 2781227825Stheraven {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 2782227825Stheraven}; 2783227825Stheraven 2784227825Stheraventemplate <class _Alloc> 2785227825Stheravenclass __allocator_destructor 2786227825Stheraven{ 2787227825Stheraven typedef allocator_traits<_Alloc> __alloc_traits; 2788227825Stheravenpublic: 2789227825Stheraven typedef typename __alloc_traits::pointer pointer; 2790227825Stheraven typedef typename __alloc_traits::size_type size_type; 2791227825Stheravenprivate: 2792227825Stheraven _Alloc& __alloc_; 2793227825Stheraven size_type __s_; 2794227825Stheravenpublic: 2795227825Stheraven _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) 2796227825Stheraven _NOEXCEPT 2797227825Stheraven : __alloc_(__a), __s_(__s) {} 2798227825Stheraven _LIBCPP_INLINE_VISIBILITY 2799227825Stheraven void operator()(pointer __p) _NOEXCEPT 2800227825Stheraven {__alloc_traits::deallocate(__alloc_, __p, __s_);} 2801227825Stheraven}; 2802227825Stheraven 2803227825Stheraventemplate <class _InputIterator, class _ForwardIterator> 2804227825Stheraven_ForwardIterator 2805227825Stheravenuninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) 2806227825Stheraven{ 2807227825Stheraven __destruct_n __d(0); 2808227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 2809227825Stheraven unique_ptr<value_type, __destruct_n&> __h(&*__r, __d); 2810227825Stheraven for (; __f != __l; ++__f, ++__r, __d.__incr((value_type*)0)) 2811227825Stheraven ::new(&*__r) value_type(*__f); 2812227825Stheraven __h.release(); 2813227825Stheraven return __r; 2814227825Stheraven} 2815227825Stheraven 2816227825Stheraventemplate <class _InputIterator, class _Size, class _ForwardIterator> 2817227825Stheraven_ForwardIterator 2818227825Stheravenuninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) 2819227825Stheraven{ 2820227825Stheraven __destruct_n __d(0); 2821227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 2822227825Stheraven unique_ptr<value_type, __destruct_n&> __h(&*__r, __d); 2823227825Stheraven for (; __n > 0; ++__f, ++__r, __d.__incr((value_type*)0), --__n) 2824227825Stheraven ::new(&*__r) value_type(*__f); 2825227825Stheraven __h.release(); 2826227825Stheraven return __r; 2827227825Stheraven} 2828227825Stheraven 2829227825Stheraventemplate <class _ForwardIterator, class _Tp> 2830227825Stheravenvoid 2831227825Stheravenuninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) 2832227825Stheraven{ 2833227825Stheraven __destruct_n __d(0); 2834227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 2835227825Stheraven unique_ptr<value_type, __destruct_n&> __h(&*__f, __d); 2836227825Stheraven for (; __f != __l; ++__f, __d.__incr((value_type*)0)) 2837227825Stheraven ::new(&*__f) value_type(__x); 2838227825Stheraven __h.release(); 2839227825Stheraven} 2840227825Stheraven 2841227825Stheraventemplate <class _ForwardIterator, class _Size, class _Tp> 2842227825Stheraven_ForwardIterator 2843227825Stheravenuninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) 2844227825Stheraven{ 2845227825Stheraven __destruct_n __d(0); 2846227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 2847227825Stheraven unique_ptr<value_type, __destruct_n&> __h(&*__f, __d); 2848227825Stheraven for (; __n > 0; ++__f, --__n, __d.__incr((value_type*)0)) 2849227825Stheraven ::new(&*__f) value_type(__x); 2850227825Stheraven __h.release(); 2851227825Stheraven return __f; 2852227825Stheraven} 2853227825Stheraven 2854227825Stheravenclass _LIBCPP_EXCEPTION_ABI bad_weak_ptr 2855227825Stheraven : public std::exception 2856227825Stheraven{ 2857227825Stheravenpublic: 2858227825Stheraven virtual ~bad_weak_ptr() _NOEXCEPT; 2859227825Stheraven virtual const char* what() const _NOEXCEPT; 2860227825Stheraven}; 2861227825Stheraven 2862227825Stheraventemplate<class _Tp> class weak_ptr; 2863227825Stheraven 2864227825Stheravenclass __shared_count 2865227825Stheraven{ 2866227825Stheraven __shared_count(const __shared_count&); 2867227825Stheraven __shared_count& operator=(const __shared_count&); 2868227825Stheraven 2869227825Stheravenprotected: 2870227825Stheraven long __shared_owners_; 2871227825Stheraven virtual ~__shared_count(); 2872227825Stheravenprivate: 2873227825Stheraven virtual void __on_zero_shared() _NOEXCEPT = 0; 2874227825Stheraven 2875227825Stheravenpublic: 2876227825Stheraven _LIBCPP_INLINE_VISIBILITY 2877227825Stheraven explicit __shared_count(long __refs = 0) _NOEXCEPT 2878227825Stheraven : __shared_owners_(__refs) {} 2879227825Stheraven 2880227825Stheraven void __add_shared() _NOEXCEPT; 2881227825Stheraven bool __release_shared() _NOEXCEPT; 2882227825Stheraven _LIBCPP_INLINE_VISIBILITY 2883227825Stheraven long use_count() const _NOEXCEPT {return __shared_owners_ + 1;} 2884227825Stheraven}; 2885227825Stheraven 2886227825Stheravenclass __shared_weak_count 2887227825Stheraven : private __shared_count 2888227825Stheraven{ 2889227825Stheraven long __shared_weak_owners_; 2890227825Stheraven 2891227825Stheravenpublic: 2892227825Stheraven _LIBCPP_INLINE_VISIBILITY 2893227825Stheraven explicit __shared_weak_count(long __refs = 0) _NOEXCEPT 2894227825Stheraven : __shared_count(__refs), 2895227825Stheraven __shared_weak_owners_(__refs) {} 2896227825Stheravenprotected: 2897227825Stheraven virtual ~__shared_weak_count(); 2898227825Stheraven 2899227825Stheravenpublic: 2900227825Stheraven void __add_shared() _NOEXCEPT; 2901227825Stheraven void __add_weak() _NOEXCEPT; 2902227825Stheraven void __release_shared() _NOEXCEPT; 2903227825Stheraven void __release_weak() _NOEXCEPT; 2904227825Stheraven _LIBCPP_INLINE_VISIBILITY 2905227825Stheraven long use_count() const _NOEXCEPT {return __shared_count::use_count();} 2906227825Stheraven __shared_weak_count* lock() _NOEXCEPT; 2907227825Stheraven 2908227825Stheraven virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 2909227825Stheravenprivate: 2910227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT = 0; 2911227825Stheraven}; 2912227825Stheraven 2913227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 2914227825Stheravenclass __shared_ptr_pointer 2915227825Stheraven : public __shared_weak_count 2916227825Stheraven{ 2917227825Stheraven __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; 2918227825Stheravenpublic: 2919227825Stheraven _LIBCPP_INLINE_VISIBILITY 2920227825Stheraven __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) 2921227825Stheraven : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {} 2922227825Stheraven 2923227825Stheraven#ifndef _LIBCPP_NO_RTTI 2924227825Stheraven virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 2925227825Stheraven#endif 2926227825Stheraven 2927227825Stheravenprivate: 2928227825Stheraven virtual void __on_zero_shared() _NOEXCEPT; 2929227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT; 2930227825Stheraven}; 2931227825Stheraven 2932227825Stheraven#ifndef _LIBCPP_NO_RTTI 2933227825Stheraven 2934227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 2935227825Stheravenconst void* 2936227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT 2937227825Stheraven{ 2938227825Stheraven return __t == typeid(_Dp) ? &__data_.first().second() : 0; 2939227825Stheraven} 2940227825Stheraven 2941227825Stheraven#endif // _LIBCPP_NO_RTTI 2942227825Stheraven 2943227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 2944227825Stheravenvoid 2945227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT 2946227825Stheraven{ 2947227825Stheraven __data_.first().second()(__data_.first().first()); 2948227825Stheraven __data_.first().second().~_Dp(); 2949227825Stheraven} 2950227825Stheraven 2951227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 2952227825Stheravenvoid 2953227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 2954227825Stheraven{ 2955227825Stheraven typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second()); 2956227825Stheraven __data_.second().~_Alloc(); 2957227825Stheraven __a.deallocate(this, 1); 2958227825Stheraven} 2959227825Stheraven 2960227825Stheraventemplate <class _Tp, class _Alloc> 2961227825Stheravenclass __shared_ptr_emplace 2962227825Stheraven : public __shared_weak_count 2963227825Stheraven{ 2964227825Stheraven __compressed_pair<_Alloc, _Tp> __data_; 2965227825Stheravenpublic: 2966227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2967227825Stheraven 2968227825Stheraven _LIBCPP_INLINE_VISIBILITY 2969227825Stheraven __shared_ptr_emplace(_Alloc __a) 2970227825Stheraven : __data_(_VSTD::move(__a)) {} 2971227825Stheraven 2972227825Stheraven template <class ..._Args> 2973227825Stheraven _LIBCPP_INLINE_VISIBILITY 2974227825Stheraven __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) 2975227825Stheraven : __data_(_VSTD::move(__a), _Tp(_VSTD::forward<_Args>(__args)...)) {} 2976227825Stheraven 2977227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 2978227825Stheraven 2979227825Stheraven _LIBCPP_INLINE_VISIBILITY 2980227825Stheraven __shared_ptr_emplace(_Alloc __a) 2981227825Stheraven : __data_(__a) {} 2982227825Stheraven 2983227825Stheraven template <class _A0> 2984227825Stheraven _LIBCPP_INLINE_VISIBILITY 2985227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0) 2986227825Stheraven : __data_(__a, _Tp(__a0)) {} 2987227825Stheraven 2988227825Stheraven template <class _A0, class _A1> 2989227825Stheraven _LIBCPP_INLINE_VISIBILITY 2990227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1) 2991227825Stheraven : __data_(__a, _Tp(__a0, __a1)) {} 2992227825Stheraven 2993227825Stheraven template <class _A0, class _A1, class _A2> 2994227825Stheraven _LIBCPP_INLINE_VISIBILITY 2995227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2) 2996227825Stheraven : __data_(__a, _Tp(__a0, __a1, __a2)) {} 2997227825Stheraven 2998227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2999227825Stheraven 3000227825Stheravenprivate: 3001227825Stheraven virtual void __on_zero_shared() _NOEXCEPT; 3002227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT; 3003227825Stheravenpublic: 3004227825Stheraven _LIBCPP_INLINE_VISIBILITY 3005227825Stheraven _Tp* get() _NOEXCEPT {return &__data_.second();} 3006227825Stheraven}; 3007227825Stheraven 3008227825Stheraventemplate <class _Tp, class _Alloc> 3009227825Stheravenvoid 3010227825Stheraven__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT 3011227825Stheraven{ 3012227825Stheraven __data_.second().~_Tp(); 3013227825Stheraven} 3014227825Stheraven 3015227825Stheraventemplate <class _Tp, class _Alloc> 3016227825Stheravenvoid 3017227825Stheraven__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 3018227825Stheraven{ 3019227825Stheraven typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first()); 3020227825Stheraven __data_.first().~_Alloc(); 3021227825Stheraven __a.deallocate(this, 1); 3022227825Stheraven} 3023227825Stheraven 3024227825Stheraventemplate<class _Tp> class enable_shared_from_this; 3025227825Stheraven 3026227825Stheraventemplate<class _Tp> 3027227825Stheravenclass _LIBCPP_VISIBLE shared_ptr 3028227825Stheraven{ 3029227825Stheravenpublic: 3030227825Stheraven typedef _Tp element_type; 3031227825Stheravenprivate: 3032227825Stheraven element_type* __ptr_; 3033227825Stheraven __shared_weak_count* __cntrl_; 3034227825Stheraven 3035227825Stheraven struct __nat {int __for_bool_;}; 3036227825Stheravenpublic: 3037227825Stheraven shared_ptr() _NOEXCEPT; 3038227825Stheraven shared_ptr(nullptr_t) _NOEXCEPT; 3039227825Stheraven template<class _Yp> explicit shared_ptr(_Yp* __p); 3040227825Stheraven template<class _Yp, class _Dp> shared_ptr(_Yp* __p, _Dp __d); 3041227825Stheraven template<class _Yp, class _Dp, class _Alloc> shared_ptr(_Yp* __p, _Dp __d, _Alloc __a); 3042227825Stheraven template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); 3043227825Stheraven template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); 3044227825Stheraven template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; 3045227825Stheraven shared_ptr(const shared_ptr& __r) _NOEXCEPT; 3046227825Stheraven template<class _Yp> 3047227825Stheraven shared_ptr(const shared_ptr<_Yp>& __r, 3048227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 3049227825Stheraven _NOEXCEPT; 3050227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3051227825Stheraven shared_ptr(shared_ptr&& __r) _NOEXCEPT; 3052227825Stheraven template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r, 3053227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 3054227825Stheraven _NOEXCEPT; 3055227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3056227825Stheraven template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, 3057227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); 3058227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3059227825Stheraven template<class _Yp> shared_ptr(auto_ptr<_Yp>&& __r); 3060227825Stheraven#else 3061227825Stheraven template<class _Yp> shared_ptr(auto_ptr<_Yp> __r); 3062227825Stheraven#endif 3063227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3064227825Stheravenprivate: 3065227825Stheraven template <class _Yp, class _Dp> shared_ptr(const unique_ptr<_Yp, _Dp>& __r);// = delete; 3066227825Stheravenpublic: 3067227825Stheraven template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>&&, 3068227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3069227825Stheraven template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>&&, 3070227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3071227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3072227825Stheraven template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>, 3073227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3074227825Stheraven template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>, 3075227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3076227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3077227825Stheraven 3078227825Stheraven ~shared_ptr(); 3079227825Stheraven 3080227825Stheraven shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; 3081227825Stheraven template<class _Yp> shared_ptr& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; 3082227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3083227825Stheraven shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; 3084227825Stheraven template<class _Yp> shared_ptr& operator=(shared_ptr<_Yp>&& __r); 3085227825Stheraven template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp>&& __r); 3086227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3087227825Stheraven template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp> __r); 3088227825Stheraven#endif 3089227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3090227825Stheravenprivate: 3091227825Stheraven template <class _Yp, class _Dp> shared_ptr& operator=(const unique_ptr<_Yp, _Dp>& __r);// = delete; 3092227825Stheravenpublic: 3093227825Stheraven template <class _Yp, class _Dp> shared_ptr& operator=(unique_ptr<_Yp, _Dp>&& __r); 3094227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3095227825Stheraven template <class _Yp, class _Dp> shared_ptr& operator=(unique_ptr<_Yp, _Dp> __r); 3096227825Stheraven#endif 3097227825Stheraven 3098227825Stheraven void swap(shared_ptr& __r) _NOEXCEPT; 3099227825Stheraven void reset() _NOEXCEPT; 3100227825Stheraven template<class _Yp> void reset(_Yp* __p) _NOEXCEPT; 3101227825Stheraven template<class _Yp, class _Dp> void reset(_Yp* __p, _Dp __d); 3102227825Stheraven template<class _Yp, class _Dp, class _Alloc> void reset(_Yp* __p, _Dp __d, _Alloc __a); 3103227825Stheraven 3104227825Stheraven _LIBCPP_INLINE_VISIBILITY 3105227825Stheraven element_type* get() const _NOEXCEPT {return __ptr_;} 3106227825Stheraven _LIBCPP_INLINE_VISIBILITY 3107227825Stheraven typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT 3108227825Stheraven {return *__ptr_;} 3109227825Stheraven _LIBCPP_INLINE_VISIBILITY 3110227825Stheraven element_type* operator->() const _NOEXCEPT {return __ptr_;} 3111227825Stheraven _LIBCPP_INLINE_VISIBILITY 3112227825Stheraven long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} 3113227825Stheraven _LIBCPP_INLINE_VISIBILITY 3114227825Stheraven bool unique() const _NOEXCEPT {return use_count() == 1;} 3115227825Stheraven _LIBCPP_INLINE_VISIBILITY 3116227825Stheraven /*explicit*/ operator bool() const _NOEXCEPT {return get() != 0;} 3117227825Stheraven template <class _U> 3118227825Stheraven _LIBCPP_INLINE_VISIBILITY 3119227825Stheraven bool owner_before(shared_ptr<_U> const& __p) const 3120227825Stheraven {return __cntrl_ < __p.__cntrl_;} 3121227825Stheraven template <class _U> 3122227825Stheraven _LIBCPP_INLINE_VISIBILITY 3123227825Stheraven bool owner_before(weak_ptr<_U> const& __p) const 3124227825Stheraven {return __cntrl_ < __p.__cntrl_;} 3125227825Stheraven 3126227825Stheraven#ifndef _LIBCPP_NO_RTTI 3127227825Stheraven template <class _Dp> 3128227825Stheraven _LIBCPP_INLINE_VISIBILITY 3129227825Stheraven _Dp* __get_deleter() const _NOEXCEPT 3130227825Stheraven {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} 3131227825Stheraven#endif // _LIBCPP_NO_RTTI 3132227825Stheraven 3133227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 3134227825Stheraven 3135227825Stheraven template<class ..._Args> 3136227825Stheraven static 3137227825Stheraven shared_ptr<_Tp> 3138227825Stheraven make_shared(_Args&& ...__args); 3139227825Stheraven 3140227825Stheraven template<class _Alloc, class ..._Args> 3141227825Stheraven static 3142227825Stheraven shared_ptr<_Tp> 3143227825Stheraven allocate_shared(const _Alloc& __a, _Args&& ...__args); 3144227825Stheraven 3145227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 3146227825Stheraven 3147227825Stheraven static shared_ptr<_Tp> make_shared(); 3148227825Stheraven 3149227825Stheraven template<class _A0> 3150227825Stheraven static shared_ptr<_Tp> make_shared(_A0&); 3151227825Stheraven 3152227825Stheraven template<class _A0, class _A1> 3153227825Stheraven static shared_ptr<_Tp> make_shared(_A0&, _A1&); 3154227825Stheraven 3155227825Stheraven template<class _A0, class _A1, class _A2> 3156227825Stheraven static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&); 3157227825Stheraven 3158227825Stheraven template<class _Alloc> 3159227825Stheraven static shared_ptr<_Tp> 3160227825Stheraven allocate_shared(const _Alloc& __a); 3161227825Stheraven 3162227825Stheraven template<class _Alloc, class _A0> 3163227825Stheraven static shared_ptr<_Tp> 3164227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0); 3165227825Stheraven 3166227825Stheraven template<class _Alloc, class _A0, class _A1> 3167227825Stheraven static shared_ptr<_Tp> 3168227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1); 3169227825Stheraven 3170227825Stheraven template<class _Alloc, class _A0, class _A1, class _A2> 3171227825Stheraven static shared_ptr<_Tp> 3172227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2); 3173227825Stheraven 3174227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 3175227825Stheraven 3176227825Stheravenprivate: 3177227825Stheraven 3178227825Stheraven template <class _Yp> 3179227825Stheraven _LIBCPP_INLINE_VISIBILITY 3180227825Stheraven void 3181227825Stheraven __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT 3182227825Stheraven { 3183227825Stheraven if (__e) 3184227825Stheraven __e->__weak_this_ = *this; 3185227825Stheraven } 3186227825Stheraven 3187227825Stheraven _LIBCPP_INLINE_VISIBILITY 3188227825Stheraven void __enable_weak_this(const void*) _NOEXCEPT {} 3189227825Stheraven 3190227825Stheraven template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; 3191227825Stheraven template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; 3192227825Stheraven}; 3193227825Stheraven 3194227825Stheraventemplate<class _Tp> 3195227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3196227825Stheravenshared_ptr<_Tp>::shared_ptr() _NOEXCEPT 3197227825Stheraven : __ptr_(0), 3198227825Stheraven __cntrl_(0) 3199227825Stheraven{ 3200227825Stheraven} 3201227825Stheraven 3202227825Stheraventemplate<class _Tp> 3203227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3204227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT 3205227825Stheraven : __ptr_(0), 3206227825Stheraven __cntrl_(0) 3207227825Stheraven{ 3208227825Stheraven} 3209227825Stheraven 3210227825Stheraventemplate<class _Tp> 3211227825Stheraventemplate<class _Yp> 3212227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p) 3213227825Stheraven : __ptr_(__p) 3214227825Stheraven{ 3215227825Stheraven unique_ptr<_Yp> __hold(__p); 3216227825Stheraven typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 3217227825Stheraven __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); 3218227825Stheraven __hold.release(); 3219227825Stheraven __enable_weak_this(__p); 3220227825Stheraven} 3221227825Stheraven 3222227825Stheraventemplate<class _Tp> 3223227825Stheraventemplate<class _Yp, class _Dp> 3224227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d) 3225227825Stheraven : __ptr_(__p) 3226227825Stheraven{ 3227227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3228227825Stheraven try 3229227825Stheraven { 3230227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 3231227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 3232227825Stheraven __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); 3233227825Stheraven __enable_weak_this(__p); 3234227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3235227825Stheraven } 3236227825Stheraven catch (...) 3237227825Stheraven { 3238227825Stheraven __d(__p); 3239227825Stheraven throw; 3240227825Stheraven } 3241227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 3242227825Stheraven} 3243227825Stheraven 3244227825Stheraventemplate<class _Tp> 3245227825Stheraventemplate<class _Dp> 3246227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) 3247227825Stheraven : __ptr_(0) 3248227825Stheraven{ 3249227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3250227825Stheraven try 3251227825Stheraven { 3252227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 3253227825Stheraven typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; 3254227825Stheraven __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); 3255227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3256227825Stheraven } 3257227825Stheraven catch (...) 3258227825Stheraven { 3259227825Stheraven __d(__p); 3260227825Stheraven throw; 3261227825Stheraven } 3262227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 3263227825Stheraven} 3264227825Stheraven 3265227825Stheraventemplate<class _Tp> 3266227825Stheraventemplate<class _Yp, class _Dp, class _Alloc> 3267227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) 3268227825Stheraven : __ptr_(__p) 3269227825Stheraven{ 3270227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3271227825Stheraven try 3272227825Stheraven { 3273227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 3274227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; 3275227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 3276227825Stheraven typedef __allocator_destructor<_A2> _D2; 3277227825Stheraven _A2 __a2(__a); 3278227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 3279227825Stheraven ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); 3280227825Stheraven __cntrl_ = __hold2.release(); 3281227825Stheraven __enable_weak_this(__p); 3282227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3283227825Stheraven } 3284227825Stheraven catch (...) 3285227825Stheraven { 3286227825Stheraven __d(__p); 3287227825Stheraven throw; 3288227825Stheraven } 3289227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 3290227825Stheraven} 3291227825Stheraven 3292227825Stheraventemplate<class _Tp> 3293227825Stheraventemplate<class _Dp, class _Alloc> 3294227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) 3295227825Stheraven : __ptr_(0) 3296227825Stheraven{ 3297227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3298227825Stheraven try 3299227825Stheraven { 3300227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 3301227825Stheraven typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; 3302227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 3303227825Stheraven typedef __allocator_destructor<_A2> _D2; 3304227825Stheraven _A2 __a2(__a); 3305227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 3306227825Stheraven ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); 3307227825Stheraven __cntrl_ = __hold2.release(); 3308227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3309227825Stheraven } 3310227825Stheraven catch (...) 3311227825Stheraven { 3312227825Stheraven __d(__p); 3313227825Stheraven throw; 3314227825Stheraven } 3315227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 3316227825Stheraven} 3317227825Stheraven 3318227825Stheraventemplate<class _Tp> 3319227825Stheraventemplate<class _Yp> 3320227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3321227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT 3322227825Stheraven : __ptr_(__p), 3323227825Stheraven __cntrl_(__r.__cntrl_) 3324227825Stheraven{ 3325227825Stheraven if (__cntrl_) 3326227825Stheraven __cntrl_->__add_shared(); 3327227825Stheraven} 3328227825Stheraven 3329227825Stheraventemplate<class _Tp> 3330227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3331227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT 3332227825Stheraven : __ptr_(__r.__ptr_), 3333227825Stheraven __cntrl_(__r.__cntrl_) 3334227825Stheraven{ 3335227825Stheraven if (__cntrl_) 3336227825Stheraven __cntrl_->__add_shared(); 3337227825Stheraven} 3338227825Stheraven 3339227825Stheraventemplate<class _Tp> 3340227825Stheraventemplate<class _Yp> 3341227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3342227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, 3343227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 3344227825Stheraven _NOEXCEPT 3345227825Stheraven : __ptr_(__r.__ptr_), 3346227825Stheraven __cntrl_(__r.__cntrl_) 3347227825Stheraven{ 3348227825Stheraven if (__cntrl_) 3349227825Stheraven __cntrl_->__add_shared(); 3350227825Stheraven} 3351227825Stheraven 3352227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3353227825Stheraven 3354227825Stheraventemplate<class _Tp> 3355227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3356227825Stheravenshared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT 3357227825Stheraven : __ptr_(__r.__ptr_), 3358227825Stheraven __cntrl_(__r.__cntrl_) 3359227825Stheraven{ 3360227825Stheraven __r.__ptr_ = 0; 3361227825Stheraven __r.__cntrl_ = 0; 3362227825Stheraven} 3363227825Stheraven 3364227825Stheraventemplate<class _Tp> 3365227825Stheraventemplate<class _Yp> 3366227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3367227825Stheravenshared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, 3368227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 3369227825Stheraven _NOEXCEPT 3370227825Stheraven : __ptr_(__r.__ptr_), 3371227825Stheraven __cntrl_(__r.__cntrl_) 3372227825Stheraven{ 3373227825Stheraven __r.__ptr_ = 0; 3374227825Stheraven __r.__cntrl_ = 0; 3375227825Stheraven} 3376227825Stheraven 3377227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3378227825Stheraven 3379227825Stheraventemplate<class _Tp> 3380227825Stheraventemplate<class _Yp> 3381227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3382227825Stheravenshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r) 3383227825Stheraven#else 3384227825Stheravenshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) 3385227825Stheraven#endif 3386227825Stheraven : __ptr_(__r.get()) 3387227825Stheraven{ 3388227825Stheraven typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 3389227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); 3390227825Stheraven __enable_weak_this(__r.get()); 3391227825Stheraven __r.release(); 3392227825Stheraven} 3393227825Stheraven 3394227825Stheraventemplate<class _Tp> 3395227825Stheraventemplate <class _Yp, class _Dp> 3396227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3397227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 3398227825Stheraven#else 3399227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 3400227825Stheraven#endif 3401227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type) 3402227825Stheraven : __ptr_(__r.get()) 3403227825Stheraven{ 3404227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 3405227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); 3406227825Stheraven __enable_weak_this(__r.get()); 3407227825Stheraven __r.release(); 3408227825Stheraven} 3409227825Stheraven 3410227825Stheraventemplate<class _Tp> 3411227825Stheraventemplate <class _Yp, class _Dp> 3412227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3413227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 3414227825Stheraven#else 3415227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 3416227825Stheraven#endif 3417227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type) 3418227825Stheraven : __ptr_(__r.get()) 3419227825Stheraven{ 3420227825Stheraven typedef __shared_ptr_pointer<_Yp*, 3421227825Stheraven reference_wrapper<typename remove_reference<_Dp>::type>, 3422227825Stheraven allocator<_Yp> > _CntrlBlk; 3423227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); 3424227825Stheraven __enable_weak_this(__r.get()); 3425227825Stheraven __r.release(); 3426227825Stheraven} 3427227825Stheraven 3428227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 3429227825Stheraven 3430227825Stheraventemplate<class _Tp> 3431227825Stheraventemplate<class ..._Args> 3432227825Stheravenshared_ptr<_Tp> 3433227825Stheravenshared_ptr<_Tp>::make_shared(_Args&& ...__args) 3434227825Stheraven{ 3435227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 3436227825Stheraven typedef allocator<_CntrlBlk> _A2; 3437227825Stheraven typedef __allocator_destructor<_A2> _D2; 3438227825Stheraven _A2 __a2; 3439227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 3440227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); 3441227825Stheraven shared_ptr<_Tp> __r; 3442227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3443227825Stheraven __r.__cntrl_ = __hold2.release(); 3444227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3445227825Stheraven return __r; 3446227825Stheraven} 3447227825Stheraven 3448227825Stheraventemplate<class _Tp> 3449227825Stheraventemplate<class _Alloc, class ..._Args> 3450227825Stheravenshared_ptr<_Tp> 3451227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) 3452227825Stheraven{ 3453227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 3454227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 3455227825Stheraven typedef __allocator_destructor<_A2> _D2; 3456227825Stheraven _A2 __a2(__a); 3457227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 3458227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); 3459227825Stheraven shared_ptr<_Tp> __r; 3460227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3461227825Stheraven __r.__cntrl_ = __hold2.release(); 3462227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3463227825Stheraven return __r; 3464227825Stheraven} 3465227825Stheraven 3466227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 3467227825Stheraven 3468227825Stheraventemplate<class _Tp> 3469227825Stheravenshared_ptr<_Tp> 3470227825Stheravenshared_ptr<_Tp>::make_shared() 3471227825Stheraven{ 3472227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 3473227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 3474227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 3475227825Stheraven _Alloc2 __alloc2; 3476227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 3477227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2); 3478227825Stheraven shared_ptr<_Tp> __r; 3479227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3480227825Stheraven __r.__cntrl_ = __hold2.release(); 3481227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3482227825Stheraven return __r; 3483227825Stheraven} 3484227825Stheraven 3485227825Stheraventemplate<class _Tp> 3486227825Stheraventemplate<class _A0> 3487227825Stheravenshared_ptr<_Tp> 3488227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0) 3489227825Stheraven{ 3490227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 3491227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 3492227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 3493227825Stheraven _Alloc2 __alloc2; 3494227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 3495227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); 3496227825Stheraven shared_ptr<_Tp> __r; 3497227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3498227825Stheraven __r.__cntrl_ = __hold2.release(); 3499227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3500227825Stheraven return __r; 3501227825Stheraven} 3502227825Stheraven 3503227825Stheraventemplate<class _Tp> 3504227825Stheraventemplate<class _A0, class _A1> 3505227825Stheravenshared_ptr<_Tp> 3506227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) 3507227825Stheraven{ 3508227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 3509227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 3510227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 3511227825Stheraven _Alloc2 __alloc2; 3512227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 3513227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); 3514227825Stheraven shared_ptr<_Tp> __r; 3515227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3516227825Stheraven __r.__cntrl_ = __hold2.release(); 3517227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3518227825Stheraven return __r; 3519227825Stheraven} 3520227825Stheraven 3521227825Stheraventemplate<class _Tp> 3522227825Stheraventemplate<class _A0, class _A1, class _A2> 3523227825Stheravenshared_ptr<_Tp> 3524227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) 3525227825Stheraven{ 3526227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 3527227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 3528227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 3529227825Stheraven _Alloc2 __alloc2; 3530227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 3531227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); 3532227825Stheraven shared_ptr<_Tp> __r; 3533227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3534227825Stheraven __r.__cntrl_ = __hold2.release(); 3535227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3536227825Stheraven return __r; 3537227825Stheraven} 3538227825Stheraven 3539227825Stheraventemplate<class _Tp> 3540227825Stheraventemplate<class _Alloc> 3541227825Stheravenshared_ptr<_Tp> 3542227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a) 3543227825Stheraven{ 3544227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 3545227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 3546227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 3547227825Stheraven _Alloc2 __alloc2(__a); 3548227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 3549227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a); 3550227825Stheraven shared_ptr<_Tp> __r; 3551227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3552227825Stheraven __r.__cntrl_ = __hold2.release(); 3553227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3554227825Stheraven return __r; 3555227825Stheraven} 3556227825Stheraven 3557227825Stheraventemplate<class _Tp> 3558227825Stheraventemplate<class _Alloc, class _A0> 3559227825Stheravenshared_ptr<_Tp> 3560227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) 3561227825Stheraven{ 3562227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 3563227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 3564227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 3565227825Stheraven _Alloc2 __alloc2(__a); 3566227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 3567227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0); 3568227825Stheraven shared_ptr<_Tp> __r; 3569227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3570227825Stheraven __r.__cntrl_ = __hold2.release(); 3571227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3572227825Stheraven return __r; 3573227825Stheraven} 3574227825Stheraven 3575227825Stheraventemplate<class _Tp> 3576227825Stheraventemplate<class _Alloc, class _A0, class _A1> 3577227825Stheravenshared_ptr<_Tp> 3578227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 3579227825Stheraven{ 3580227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 3581227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 3582227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 3583227825Stheraven _Alloc2 __alloc2(__a); 3584227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 3585227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1); 3586227825Stheraven shared_ptr<_Tp> __r; 3587227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3588227825Stheraven __r.__cntrl_ = __hold2.release(); 3589227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3590227825Stheraven return __r; 3591227825Stheraven} 3592227825Stheraven 3593227825Stheraventemplate<class _Tp> 3594227825Stheraventemplate<class _Alloc, class _A0, class _A1, class _A2> 3595227825Stheravenshared_ptr<_Tp> 3596227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 3597227825Stheraven{ 3598227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 3599227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 3600227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 3601227825Stheraven _Alloc2 __alloc2(__a); 3602227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 3603227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2); 3604227825Stheraven shared_ptr<_Tp> __r; 3605227825Stheraven __r.__ptr_ = __hold2.get()->get(); 3606227825Stheraven __r.__cntrl_ = __hold2.release(); 3607227825Stheraven __r.__enable_weak_this(__r.__ptr_); 3608227825Stheraven return __r; 3609227825Stheraven} 3610227825Stheraven 3611227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 3612227825Stheraven 3613227825Stheraventemplate<class _Tp> 3614227825Stheravenshared_ptr<_Tp>::~shared_ptr() 3615227825Stheraven{ 3616227825Stheraven if (__cntrl_) 3617227825Stheraven __cntrl_->__release_shared(); 3618227825Stheraven} 3619227825Stheraven 3620227825Stheraventemplate<class _Tp> 3621227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3622227825Stheravenshared_ptr<_Tp>& 3623227825Stheravenshared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT 3624227825Stheraven{ 3625227825Stheraven shared_ptr(__r).swap(*this); 3626227825Stheraven return *this; 3627227825Stheraven} 3628227825Stheraven 3629227825Stheraventemplate<class _Tp> 3630227825Stheraventemplate<class _Yp> 3631227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3632227825Stheravenshared_ptr<_Tp>& 3633227825Stheravenshared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT 3634227825Stheraven{ 3635227825Stheraven shared_ptr(__r).swap(*this); 3636227825Stheraven return *this; 3637227825Stheraven} 3638227825Stheraven 3639227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3640227825Stheraven 3641227825Stheraventemplate<class _Tp> 3642227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3643227825Stheravenshared_ptr<_Tp>& 3644227825Stheravenshared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT 3645227825Stheraven{ 3646227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 3647227825Stheraven return *this; 3648227825Stheraven} 3649227825Stheraven 3650227825Stheraventemplate<class _Tp> 3651227825Stheraventemplate<class _Yp> 3652227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3653227825Stheravenshared_ptr<_Tp>& 3654227825Stheravenshared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) 3655227825Stheraven{ 3656227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 3657227825Stheraven return *this; 3658227825Stheraven} 3659227825Stheraven 3660227825Stheraventemplate<class _Tp> 3661227825Stheraventemplate<class _Yp> 3662227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3663227825Stheravenshared_ptr<_Tp>& 3664227825Stheravenshared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) 3665227825Stheraven{ 3666227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 3667227825Stheraven return *this; 3668227825Stheraven} 3669227825Stheraven 3670227825Stheraventemplate<class _Tp> 3671227825Stheraventemplate <class _Yp, class _Dp> 3672227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3673227825Stheravenshared_ptr<_Tp>& 3674227825Stheravenshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) 3675227825Stheraven{ 3676227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 3677227825Stheraven return *this; 3678227825Stheraven} 3679227825Stheraven 3680227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3681227825Stheraven 3682227825Stheraventemplate<class _Tp> 3683227825Stheraventemplate<class _Yp> 3684227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3685227825Stheravenshared_ptr<_Tp>& 3686227825Stheravenshared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) 3687227825Stheraven{ 3688227825Stheraven shared_ptr(__r).swap(*this); 3689227825Stheraven return *this; 3690227825Stheraven} 3691227825Stheraven 3692227825Stheraventemplate<class _Tp> 3693227825Stheraventemplate <class _Yp, class _Dp> 3694227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3695227825Stheravenshared_ptr<_Tp>& 3696227825Stheravenshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) 3697227825Stheraven{ 3698227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 3699227825Stheraven return *this; 3700227825Stheraven} 3701227825Stheraven 3702227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3703227825Stheraven 3704227825Stheraventemplate<class _Tp> 3705227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3706227825Stheravenvoid 3707227825Stheravenshared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT 3708227825Stheraven{ 3709227825Stheraven _VSTD::swap(__ptr_, __r.__ptr_); 3710227825Stheraven _VSTD::swap(__cntrl_, __r.__cntrl_); 3711227825Stheraven} 3712227825Stheraven 3713227825Stheraventemplate<class _Tp> 3714227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3715227825Stheravenvoid 3716227825Stheravenshared_ptr<_Tp>::reset() _NOEXCEPT 3717227825Stheraven{ 3718227825Stheraven shared_ptr().swap(*this); 3719227825Stheraven} 3720227825Stheraven 3721227825Stheraventemplate<class _Tp> 3722227825Stheraventemplate<class _Yp> 3723227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3724227825Stheravenvoid 3725227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p) 3726227825Stheraven{ 3727227825Stheraven shared_ptr(__p).swap(*this); 3728227825Stheraven} 3729227825Stheraven 3730227825Stheraventemplate<class _Tp> 3731227825Stheraventemplate<class _Yp, class _Dp> 3732227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3733227825Stheravenvoid 3734227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) 3735227825Stheraven{ 3736227825Stheraven shared_ptr(__p, __d).swap(*this); 3737227825Stheraven} 3738227825Stheraven 3739227825Stheraventemplate<class _Tp> 3740227825Stheraventemplate<class _Yp, class _Dp, class _Alloc> 3741227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3742227825Stheravenvoid 3743227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) 3744227825Stheraven{ 3745227825Stheraven shared_ptr(__p, __d, __a).swap(*this); 3746227825Stheraven} 3747227825Stheraven 3748227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 3749227825Stheraven 3750227825Stheraventemplate<class _Tp, class ..._Args> 3751227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3752227825Stheravenshared_ptr<_Tp> 3753227825Stheravenmake_shared(_Args&& ...__args) 3754227825Stheraven{ 3755227825Stheraven return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...); 3756227825Stheraven} 3757227825Stheraven 3758227825Stheraventemplate<class _Tp, class _Alloc, class ..._Args> 3759227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3760227825Stheravenshared_ptr<_Tp> 3761227825Stheravenallocate_shared(const _Alloc& __a, _Args&& ...__args) 3762227825Stheraven{ 3763227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...); 3764227825Stheraven} 3765227825Stheraven 3766227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 3767227825Stheraven 3768227825Stheraventemplate<class _Tp> 3769227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3770227825Stheravenshared_ptr<_Tp> 3771227825Stheravenmake_shared() 3772227825Stheraven{ 3773227825Stheraven return shared_ptr<_Tp>::make_shared(); 3774227825Stheraven} 3775227825Stheraven 3776227825Stheraventemplate<class _Tp, class _A0> 3777227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3778227825Stheravenshared_ptr<_Tp> 3779227825Stheravenmake_shared(_A0& __a0) 3780227825Stheraven{ 3781227825Stheraven return shared_ptr<_Tp>::make_shared(__a0); 3782227825Stheraven} 3783227825Stheraven 3784227825Stheraventemplate<class _Tp, class _A0, class _A1> 3785227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3786227825Stheravenshared_ptr<_Tp> 3787227825Stheravenmake_shared(_A0& __a0, _A1& __a1) 3788227825Stheraven{ 3789227825Stheraven return shared_ptr<_Tp>::make_shared(__a0, __a1); 3790227825Stheraven} 3791227825Stheraven 3792227825Stheraventemplate<class _Tp, class _A0, class _A1, class _A2> 3793227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3794227825Stheravenshared_ptr<_Tp> 3795227825Stheravenmake_shared(_A0& __a0, _A1& __a1, _A2& __a2) 3796227825Stheraven{ 3797227825Stheraven return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2); 3798227825Stheraven} 3799227825Stheraven 3800227825Stheraventemplate<class _Tp, class _Alloc> 3801227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3802227825Stheravenshared_ptr<_Tp> 3803227825Stheravenallocate_shared(const _Alloc& __a) 3804227825Stheraven{ 3805227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a); 3806227825Stheraven} 3807227825Stheraven 3808227825Stheraventemplate<class _Tp, class _Alloc, class _A0> 3809227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3810227825Stheravenshared_ptr<_Tp> 3811227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0) 3812227825Stheraven{ 3813227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0); 3814227825Stheraven} 3815227825Stheraven 3816227825Stheraventemplate<class _Tp, class _Alloc, class _A0, class _A1> 3817227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3818227825Stheravenshared_ptr<_Tp> 3819227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 3820227825Stheraven{ 3821227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1); 3822227825Stheraven} 3823227825Stheraven 3824227825Stheraventemplate<class _Tp, class _Alloc, class _A0, class _A1, class _A2> 3825227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3826227825Stheravenshared_ptr<_Tp> 3827227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 3828227825Stheraven{ 3829227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2); 3830227825Stheraven} 3831227825Stheraven 3832227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 3833227825Stheraven 3834227825Stheraventemplate<class _Tp, class _Up> 3835227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3836227825Stheravenbool 3837227825Stheravenoperator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 3838227825Stheraven{ 3839227825Stheraven return __x.get() == __y.get(); 3840227825Stheraven} 3841227825Stheraven 3842227825Stheraventemplate<class _Tp, class _Up> 3843227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3844227825Stheravenbool 3845227825Stheravenoperator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 3846227825Stheraven{ 3847227825Stheraven return !(__x == __y); 3848227825Stheraven} 3849227825Stheraven 3850227825Stheraventemplate<class _Tp, class _Up> 3851227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3852227825Stheravenbool 3853227825Stheravenoperator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 3854227825Stheraven{ 3855227825Stheraven return __x.get() < __y.get(); 3856227825Stheraven} 3857227825Stheraven 3858227825Stheraventemplate<class _Tp> 3859227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3860227825Stheravenvoid 3861227825Stheravenswap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT 3862227825Stheraven{ 3863227825Stheraven __x.swap(__y); 3864227825Stheraven} 3865227825Stheraven 3866227825Stheraventemplate<class _Tp, class _Up> 3867227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3868227825Stheravenshared_ptr<_Tp> 3869227825Stheravenstatic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 3870227825Stheraven{ 3871227825Stheraven return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); 3872227825Stheraven} 3873227825Stheraven 3874227825Stheraventemplate<class _Tp, class _Up> 3875227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3876227825Stheravenshared_ptr<_Tp> 3877227825Stheravendynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 3878227825Stheraven{ 3879227825Stheraven _Tp* __p = dynamic_cast<_Tp*>(__r.get()); 3880227825Stheraven return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); 3881227825Stheraven} 3882227825Stheraven 3883227825Stheraventemplate<class _Tp, class _Up> 3884227825Stheravenshared_ptr<_Tp> 3885227825Stheravenconst_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 3886227825Stheraven{ 3887227825Stheraven return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get())); 3888227825Stheraven} 3889227825Stheraven 3890227825Stheraven#ifndef _LIBCPP_NO_RTTI 3891227825Stheraven 3892227825Stheraventemplate<class _Dp, class _Tp> 3893227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3894227825Stheraven_Dp* 3895227825Stheravenget_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT 3896227825Stheraven{ 3897227825Stheraven return __p.template __get_deleter<_Dp>(); 3898227825Stheraven} 3899227825Stheraven 3900227825Stheraven#endif // _LIBCPP_NO_RTTI 3901227825Stheraven 3902227825Stheraventemplate<class _Tp> 3903227825Stheravenclass _LIBCPP_VISIBLE weak_ptr 3904227825Stheraven{ 3905227825Stheravenpublic: 3906227825Stheraven typedef _Tp element_type; 3907227825Stheravenprivate: 3908227825Stheraven element_type* __ptr_; 3909227825Stheraven __shared_weak_count* __cntrl_; 3910227825Stheraven 3911227825Stheravenpublic: 3912227825Stheraven weak_ptr() _NOEXCEPT; 3913227825Stheraven template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r, 3914227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 3915227825Stheraven _NOEXCEPT; 3916227825Stheraven weak_ptr(weak_ptr const& __r) _NOEXCEPT; 3917227825Stheraven template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r, 3918227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 3919227825Stheraven _NOEXCEPT; 3920227825Stheraven 3921227825Stheraven ~weak_ptr(); 3922227825Stheraven 3923227825Stheraven weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; 3924227825Stheraven template<class _Yp> weak_ptr& operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; 3925227825Stheraven template<class _Yp> weak_ptr& operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; 3926227825Stheraven 3927227825Stheraven void swap(weak_ptr& __r) _NOEXCEPT; 3928227825Stheraven void reset() _NOEXCEPT; 3929227825Stheraven 3930227825Stheraven _LIBCPP_INLINE_VISIBILITY 3931227825Stheraven long use_count() const _NOEXCEPT 3932227825Stheraven {return __cntrl_ ? __cntrl_->use_count() : 0;} 3933227825Stheraven _LIBCPP_INLINE_VISIBILITY 3934227825Stheraven bool expired() const _NOEXCEPT 3935227825Stheraven {return __cntrl_ == 0 || __cntrl_->use_count() == 0;} 3936227825Stheraven shared_ptr<_Tp> lock() const _NOEXCEPT; 3937227825Stheraven template<class _Up> 3938227825Stheraven _LIBCPP_INLINE_VISIBILITY 3939227825Stheraven bool owner_before(const shared_ptr<_Up>& __r) const 3940227825Stheraven {return __cntrl_ < __r.__cntrl_;} 3941227825Stheraven template<class _Up> 3942227825Stheraven _LIBCPP_INLINE_VISIBILITY 3943227825Stheraven bool owner_before(const weak_ptr<_Up>& __r) const 3944227825Stheraven {return __cntrl_ < __r.__cntrl_;} 3945227825Stheraven 3946227825Stheraven template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; 3947227825Stheraven template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; 3948227825Stheraven}; 3949227825Stheraven 3950227825Stheraventemplate<class _Tp> 3951227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3952227825Stheravenweak_ptr<_Tp>::weak_ptr() _NOEXCEPT 3953227825Stheraven : __ptr_(0), 3954227825Stheraven __cntrl_(0) 3955227825Stheraven{ 3956227825Stheraven} 3957227825Stheraven 3958227825Stheraventemplate<class _Tp> 3959227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3960227825Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT 3961227825Stheraven : __ptr_(__r.__ptr_), 3962227825Stheraven __cntrl_(__r.__cntrl_) 3963227825Stheraven{ 3964227825Stheraven if (__cntrl_) 3965227825Stheraven __cntrl_->__add_weak(); 3966227825Stheraven} 3967227825Stheraven 3968227825Stheraventemplate<class _Tp> 3969227825Stheraventemplate<class _Yp> 3970227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3971227825Stheravenweak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, 3972227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 3973227825Stheraven _NOEXCEPT 3974227825Stheraven : __ptr_(__r.__ptr_), 3975227825Stheraven __cntrl_(__r.__cntrl_) 3976227825Stheraven{ 3977227825Stheraven if (__cntrl_) 3978227825Stheraven __cntrl_->__add_weak(); 3979227825Stheraven} 3980227825Stheraven 3981227825Stheraventemplate<class _Tp> 3982227825Stheraventemplate<class _Yp> 3983227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 3984227825Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, 3985227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 3986227825Stheraven _NOEXCEPT 3987227825Stheraven : __ptr_(__r.__ptr_), 3988227825Stheraven __cntrl_(__r.__cntrl_) 3989227825Stheraven{ 3990227825Stheraven if (__cntrl_) 3991227825Stheraven __cntrl_->__add_weak(); 3992227825Stheraven} 3993227825Stheraven 3994227825Stheraventemplate<class _Tp> 3995227825Stheravenweak_ptr<_Tp>::~weak_ptr() 3996227825Stheraven{ 3997227825Stheraven if (__cntrl_) 3998227825Stheraven __cntrl_->__release_weak(); 3999227825Stheraven} 4000227825Stheraven 4001227825Stheraventemplate<class _Tp> 4002227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4003227825Stheravenweak_ptr<_Tp>& 4004227825Stheravenweak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT 4005227825Stheraven{ 4006227825Stheraven weak_ptr(__r).swap(*this); 4007227825Stheraven return *this; 4008227825Stheraven} 4009227825Stheraven 4010227825Stheraventemplate<class _Tp> 4011227825Stheraventemplate<class _Yp> 4012227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4013227825Stheravenweak_ptr<_Tp>& 4014227825Stheravenweak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT 4015227825Stheraven{ 4016227825Stheraven weak_ptr(__r).swap(*this); 4017227825Stheraven return *this; 4018227825Stheraven} 4019227825Stheraven 4020227825Stheraventemplate<class _Tp> 4021227825Stheraventemplate<class _Yp> 4022227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4023227825Stheravenweak_ptr<_Tp>& 4024227825Stheravenweak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT 4025227825Stheraven{ 4026227825Stheraven weak_ptr(__r).swap(*this); 4027227825Stheraven return *this; 4028227825Stheraven} 4029227825Stheraven 4030227825Stheraventemplate<class _Tp> 4031227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4032227825Stheravenvoid 4033227825Stheravenweak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT 4034227825Stheraven{ 4035227825Stheraven _VSTD::swap(__ptr_, __r.__ptr_); 4036227825Stheraven _VSTD::swap(__cntrl_, __r.__cntrl_); 4037227825Stheraven} 4038227825Stheraven 4039227825Stheraventemplate<class _Tp> 4040227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4041227825Stheravenvoid 4042227825Stheravenswap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT 4043227825Stheraven{ 4044227825Stheraven __x.swap(__y); 4045227825Stheraven} 4046227825Stheraven 4047227825Stheraventemplate<class _Tp> 4048227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4049227825Stheravenvoid 4050227825Stheravenweak_ptr<_Tp>::reset() _NOEXCEPT 4051227825Stheraven{ 4052227825Stheraven weak_ptr().swap(*this); 4053227825Stheraven} 4054227825Stheraven 4055227825Stheraventemplate<class _Tp> 4056227825Stheraventemplate<class _Yp> 4057227825Stheravenshared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, 4058227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 4059227825Stheraven : __ptr_(__r.__ptr_), 4060227825Stheraven __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) 4061227825Stheraven{ 4062227825Stheraven if (__cntrl_ == 0) 4063227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4064227825Stheraven throw bad_weak_ptr(); 4065227825Stheraven#else 4066227825Stheraven assert(!"bad_weak_ptr"); 4067227825Stheraven#endif 4068227825Stheraven} 4069227825Stheraven 4070227825Stheraventemplate<class _Tp> 4071227825Stheravenshared_ptr<_Tp> 4072227825Stheravenweak_ptr<_Tp>::lock() const _NOEXCEPT 4073227825Stheraven{ 4074227825Stheraven shared_ptr<_Tp> __r; 4075227825Stheraven __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_; 4076227825Stheraven if (__r.__cntrl_) 4077227825Stheraven __r.__ptr_ = __ptr_; 4078227825Stheraven return __r; 4079227825Stheraven} 4080227825Stheraven 4081227825Stheraventemplate <class _Tp> struct owner_less; 4082227825Stheraven 4083227825Stheraventemplate <class _Tp> 4084227825Stheravenstruct _LIBCPP_VISIBLE owner_less<shared_ptr<_Tp> > 4085227825Stheraven : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> 4086227825Stheraven{ 4087227825Stheraven typedef bool result_type; 4088227825Stheraven _LIBCPP_INLINE_VISIBILITY 4089227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 4090227825Stheraven {return __x.owner_before(__y);} 4091227825Stheraven _LIBCPP_INLINE_VISIBILITY 4092227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 4093227825Stheraven {return __x.owner_before(__y);} 4094227825Stheraven _LIBCPP_INLINE_VISIBILITY 4095227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 4096227825Stheraven {return __x.owner_before(__y);} 4097227825Stheraven}; 4098227825Stheraven 4099227825Stheraventemplate <class _Tp> 4100227825Stheravenstruct _LIBCPP_VISIBLE owner_less<weak_ptr<_Tp> > 4101227825Stheraven : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> 4102227825Stheraven{ 4103227825Stheraven typedef bool result_type; 4104227825Stheraven _LIBCPP_INLINE_VISIBILITY 4105227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 4106227825Stheraven {return __x.owner_before(__y);} 4107227825Stheraven _LIBCPP_INLINE_VISIBILITY 4108227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 4109227825Stheraven {return __x.owner_before(__y);} 4110227825Stheraven _LIBCPP_INLINE_VISIBILITY 4111227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 4112227825Stheraven {return __x.owner_before(__y);} 4113227825Stheraven}; 4114227825Stheraven 4115227825Stheraventemplate<class _Tp> 4116227825Stheravenclass _LIBCPP_VISIBLE enable_shared_from_this 4117227825Stheraven{ 4118227825Stheraven mutable weak_ptr<_Tp> __weak_this_; 4119227825Stheravenprotected: 4120227825Stheraven _LIBCPP_INLINE_VISIBILITY 4121227825Stheraven enable_shared_from_this() _NOEXCEPT {} 4122227825Stheraven _LIBCPP_INLINE_VISIBILITY 4123227825Stheraven enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {} 4124227825Stheraven _LIBCPP_INLINE_VISIBILITY 4125227825Stheraven enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT 4126227825Stheraven {return *this;} 4127227825Stheraven _LIBCPP_INLINE_VISIBILITY 4128227825Stheraven ~enable_shared_from_this() {} 4129227825Stheravenpublic: 4130227825Stheraven _LIBCPP_INLINE_VISIBILITY 4131227825Stheraven shared_ptr<_Tp> shared_from_this() 4132227825Stheraven {return shared_ptr<_Tp>(__weak_this_);} 4133227825Stheraven _LIBCPP_INLINE_VISIBILITY 4134227825Stheraven shared_ptr<_Tp const> shared_from_this() const 4135227825Stheraven {return shared_ptr<const _Tp>(__weak_this_);} 4136227825Stheraven 4137227825Stheraven template <class _Up> friend class shared_ptr; 4138227825Stheraven}; 4139227825Stheraven 4140227825Stheraventemplate <class _Tp> 4141227825Stheravenstruct _LIBCPP_VISIBLE hash<shared_ptr<_Tp> > 4142227825Stheraven{ 4143227825Stheraven typedef shared_ptr<_Tp> argument_type; 4144227825Stheraven typedef size_t result_type; 4145227825Stheraven _LIBCPP_INLINE_VISIBILITY 4146227825Stheraven result_type operator()(const argument_type& __ptr) const _NOEXCEPT 4147227825Stheraven { 4148227825Stheraven return hash<_Tp*>()(__ptr.get()); 4149227825Stheraven } 4150227825Stheraven}; 4151227825Stheraven 4152227825Stheraventemplate<class _CharT, class _Traits, class _Y> 4153227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4154227825Stheravenbasic_ostream<_CharT, _Traits>& 4155227825Stheravenoperator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Y> const& __p); 4156227825Stheraven 4157227825Stheraven//enum class 4158227825Stheravenstruct _LIBCPP_VISIBLE pointer_safety 4159227825Stheraven{ 4160227825Stheraven enum _ 4161227825Stheraven { 4162227825Stheraven relaxed, 4163227825Stheraven preferred, 4164227825Stheraven strict 4165227825Stheraven }; 4166227825Stheraven 4167227825Stheraven _ __v_; 4168227825Stheraven 4169227825Stheraven _LIBCPP_INLINE_VISIBILITY 4170227825Stheraven pointer_safety(_ __v) : __v_(__v) {} 4171227825Stheraven _LIBCPP_INLINE_VISIBILITY 4172227825Stheraven operator int() const {return __v_;} 4173227825Stheraven}; 4174227825Stheraven 4175227825Stheravenvoid declare_reachable(void* __p); 4176227825Stheravenvoid declare_no_pointers(char* __p, size_t __n); 4177227825Stheravenvoid undeclare_no_pointers(char* __p, size_t __n); 4178227825Stheravenpointer_safety get_pointer_safety() _NOEXCEPT; 4179227825Stheravenvoid* __undeclare_reachable(void* __p); 4180227825Stheraven 4181227825Stheraventemplate <class _Tp> 4182227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4183227825Stheraven_Tp* 4184227825Stheravenundeclare_reachable(_Tp* __p) 4185227825Stheraven{ 4186227825Stheraven return static_cast<_Tp*>(__undeclare_reachable(__p)); 4187227825Stheraven} 4188227825Stheraven 4189227825Stheravenvoid* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); 4190227825Stheraven 4191227825Stheraven_LIBCPP_END_NAMESPACE_STD 4192227825Stheraven 4193227825Stheraven#endif // _LIBCPP_MEMORY 4194