memory revision 242945
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> 599232950Stheraven#include <tuple> 600232950Stheraven#include <cstring> 601227825Stheraven#if defined(_LIBCPP_NO_EXCEPTIONS) 602227825Stheraven #include <cassert> 603227825Stheraven#endif 604227825Stheraven 605241903Sdim#if __has_feature(cxx_atomic) 606241903Sdim# include <atomic> 607241903Sdim#endif 608241903Sdim 609232950Stheraven#include <__undef_min_max> 610232950Stheraven 611227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 612227825Stheraven#pragma GCC system_header 613227825Stheraven#endif 614227825Stheraven 615227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 616227825Stheraven 617227825Stheraven// addressof 618227825Stheraven 619227825Stheraventemplate <class _Tp> 620227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 621227825Stheraven_Tp* 622227825Stheravenaddressof(_Tp& __x) _NOEXCEPT 623227825Stheraven{ 624227825Stheraven return (_Tp*)&(char&)__x; 625227825Stheraven} 626227825Stheraven 627227825Stheraven#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) 628227825Stheraven// Objective-C++ Automatic Reference Counting uses qualified pointers 629227825Stheraven// that require special addressof() signatures. When 630227825Stheraven// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler 631227825Stheraven// itself is providing these definitions. Otherwise, we provide them. 632227825Stheraventemplate <class _Tp> 633227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 634227825Stheraven__strong _Tp* 635227825Stheravenaddressof(__strong _Tp& __x) _NOEXCEPT 636227825Stheraven{ 637227825Stheraven return &__x; 638227825Stheraven} 639227825Stheraven 640227825Stheraven#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK 641227825Stheraventemplate <class _Tp> 642227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 643227825Stheraven__weak _Tp* 644227825Stheravenaddressof(__weak _Tp& __x) _NOEXCEPT 645227825Stheraven{ 646227825Stheraven return &__x; 647227825Stheraven} 648227825Stheraven#endif 649227825Stheraven 650227825Stheraventemplate <class _Tp> 651227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 652227825Stheraven__autoreleasing _Tp* 653227825Stheravenaddressof(__autoreleasing _Tp& __x) _NOEXCEPT 654227825Stheraven{ 655227825Stheraven return &__x; 656227825Stheraven} 657227825Stheraven 658227825Stheraventemplate <class _Tp> 659227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 660227825Stheraven__unsafe_unretained _Tp* 661227825Stheravenaddressof(__unsafe_unretained _Tp& __x) _NOEXCEPT 662227825Stheraven{ 663227825Stheraven return &__x; 664227825Stheraven} 665227825Stheraven#endif 666227825Stheraven 667227825Stheraventemplate <class _Tp> class allocator; 668227825Stheraven 669227825Stheraventemplate <> 670227825Stheravenclass _LIBCPP_VISIBLE allocator<void> 671227825Stheraven{ 672227825Stheravenpublic: 673227825Stheraven typedef void* pointer; 674227825Stheraven typedef const void* const_pointer; 675227825Stheraven typedef void value_type; 676227825Stheraven 677227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 678227825Stheraven}; 679227825Stheraven 680232950Stheraventemplate <> 681232950Stheravenclass _LIBCPP_VISIBLE allocator<const void> 682232950Stheraven{ 683232950Stheravenpublic: 684232950Stheraven typedef const void* pointer; 685232950Stheraven typedef const void* const_pointer; 686232950Stheraven typedef const void value_type; 687232950Stheraven 688232950Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 689232950Stheraven}; 690232950Stheraven 691227825Stheraven// pointer_traits 692227825Stheraven 693227825Stheraventemplate <class _Tp> 694227825Stheravenstruct __has_element_type 695227825Stheraven{ 696227825Stheravenprivate: 697242945Stheraven struct __two {char __lx; char __lxx;}; 698227825Stheraven template <class _Up> static __two __test(...); 699227825Stheraven template <class _Up> static char __test(typename _Up::element_type* = 0); 700227825Stheravenpublic: 701227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 702227825Stheraven}; 703227825Stheraven 704227825Stheraventemplate <class _Ptr, bool = __has_element_type<_Ptr>::value> 705227825Stheravenstruct __pointer_traits_element_type; 706227825Stheraven 707227825Stheraventemplate <class _Ptr> 708227825Stheravenstruct __pointer_traits_element_type<_Ptr, true> 709227825Stheraven{ 710227825Stheraven typedef typename _Ptr::element_type type; 711227825Stheraven}; 712227825Stheraven 713227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 714227825Stheraven 715227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 716227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> 717227825Stheraven{ 718227825Stheraven typedef typename _Sp<_Tp, _Args...>::element_type type; 719227825Stheraven}; 720227825Stheraven 721227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 722227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> 723227825Stheraven{ 724227825Stheraven typedef _Tp type; 725227825Stheraven}; 726227825Stheraven 727227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 728227825Stheraven 729227825Stheraventemplate <template <class> class _Sp, class _Tp> 730227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp>, true> 731227825Stheraven{ 732227825Stheraven typedef typename _Sp<_Tp>::element_type type; 733227825Stheraven}; 734227825Stheraven 735227825Stheraventemplate <template <class> class _Sp, class _Tp> 736227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp>, false> 737227825Stheraven{ 738227825Stheraven typedef _Tp type; 739227825Stheraven}; 740227825Stheraven 741227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0> 742227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, true> 743227825Stheraven{ 744227825Stheraven typedef typename _Sp<_Tp, _A0>::element_type type; 745227825Stheraven}; 746227825Stheraven 747227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0> 748227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, false> 749227825Stheraven{ 750227825Stheraven typedef _Tp type; 751227825Stheraven}; 752227825Stheraven 753227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 754227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true> 755227825Stheraven{ 756227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::element_type type; 757227825Stheraven}; 758227825Stheraven 759227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 760227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false> 761227825Stheraven{ 762227825Stheraven typedef _Tp type; 763227825Stheraven}; 764227825Stheraven 765227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 766227825Stheraven class _A1, class _A2> 767227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true> 768227825Stheraven{ 769227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type; 770227825Stheraven}; 771227825Stheraven 772227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 773227825Stheraven class _A1, class _A2> 774227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false> 775227825Stheraven{ 776227825Stheraven typedef _Tp type; 777227825Stheraven}; 778227825Stheraven 779227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 780227825Stheraven 781227825Stheraventemplate <class _Tp> 782227825Stheravenstruct __has_difference_type 783227825Stheraven{ 784227825Stheravenprivate: 785242945Stheraven struct __two {char __lx; char __lxx;}; 786227825Stheraven template <class _Up> static __two __test(...); 787227825Stheraven template <class _Up> static char __test(typename _Up::difference_type* = 0); 788227825Stheravenpublic: 789227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 790227825Stheraven}; 791227825Stheraven 792227825Stheraventemplate <class _Ptr, bool = __has_difference_type<_Ptr>::value> 793227825Stheravenstruct __pointer_traits_difference_type 794227825Stheraven{ 795227825Stheraven typedef ptrdiff_t type; 796227825Stheraven}; 797227825Stheraven 798227825Stheraventemplate <class _Ptr> 799227825Stheravenstruct __pointer_traits_difference_type<_Ptr, true> 800227825Stheraven{ 801227825Stheraven typedef typename _Ptr::difference_type type; 802227825Stheraven}; 803227825Stheraven 804227825Stheraventemplate <class _Tp, class _Up> 805227825Stheravenstruct __has_rebind 806227825Stheraven{ 807227825Stheravenprivate: 808242945Stheraven struct __two {char __lx; char __lxx;}; 809227825Stheraven template <class _Xp> static __two __test(...); 810227825Stheraven template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); 811227825Stheravenpublic: 812227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 813227825Stheraven}; 814227825Stheraven 815227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 816227825Stheravenstruct __pointer_traits_rebind 817227825Stheraven{ 818227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 819227825Stheraven typedef typename _Tp::template rebind<_Up> type; 820227825Stheraven#else 821227825Stheraven typedef typename _Tp::template rebind<_Up>::other type; 822227825Stheraven#endif 823227825Stheraven}; 824227825Stheraven 825227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 826227825Stheraven 827227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 828227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> 829227825Stheraven{ 830227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 831227825Stheraven typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; 832227825Stheraven#else 833227825Stheraven typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; 834227825Stheraven#endif 835227825Stheraven}; 836227825Stheraven 837227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 838227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> 839227825Stheraven{ 840227825Stheraven typedef _Sp<_Up, _Args...> type; 841227825Stheraven}; 842227825Stheraven 843227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 844227825Stheraven 845227825Stheraventemplate <template <class> class _Sp, class _Tp, class _Up> 846227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> 847227825Stheraven{ 848227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 849227825Stheraven typedef typename _Sp<_Tp>::template rebind<_Up> type; 850227825Stheraven#else 851227825Stheraven typedef typename _Sp<_Tp>::template rebind<_Up>::other type; 852227825Stheraven#endif 853227825Stheraven}; 854227825Stheraven 855227825Stheraventemplate <template <class> class _Sp, class _Tp, class _Up> 856227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, false> 857227825Stheraven{ 858227825Stheraven typedef _Sp<_Up> type; 859227825Stheraven}; 860227825Stheraven 861227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 862227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> 863227825Stheraven{ 864227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 865227825Stheraven typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; 866227825Stheraven#else 867227825Stheraven typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; 868227825Stheraven#endif 869227825Stheraven}; 870227825Stheraven 871227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 872227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false> 873227825Stheraven{ 874227825Stheraven typedef _Sp<_Up, _A0> type; 875227825Stheraven}; 876227825Stheraven 877227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 878227825Stheraven class _A1, class _Up> 879227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> 880227825Stheraven{ 881227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 882227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; 883227825Stheraven#else 884227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; 885227825Stheraven#endif 886227825Stheraven}; 887227825Stheraven 888227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 889227825Stheraven class _A1, class _Up> 890227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false> 891227825Stheraven{ 892227825Stheraven typedef _Sp<_Up, _A0, _A1> type; 893227825Stheraven}; 894227825Stheraven 895227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 896227825Stheraven class _A1, class _A2, class _Up> 897227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> 898227825Stheraven{ 899227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 900227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; 901227825Stheraven#else 902227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 903227825Stheraven#endif 904227825Stheraven}; 905227825Stheraven 906227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 907227825Stheraven class _A1, class _A2, class _Up> 908227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> 909227825Stheraven{ 910227825Stheraven typedef _Sp<_Up, _A0, _A1, _A2> type; 911227825Stheraven}; 912227825Stheraven 913227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 914227825Stheraven 915227825Stheraventemplate <class _Ptr> 916227825Stheravenstruct _LIBCPP_VISIBLE pointer_traits 917227825Stheraven{ 918227825Stheraven typedef _Ptr pointer; 919227825Stheraven typedef typename __pointer_traits_element_type<pointer>::type element_type; 920227825Stheraven typedef typename __pointer_traits_difference_type<pointer>::type difference_type; 921227825Stheraven 922227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 923227825Stheraven template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; 924227825Stheraven#else 925227825Stheraven template <class _Up> struct rebind 926227825Stheraven {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; 927227825Stheraven#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 928227825Stheraven 929227825Stheravenprivate: 930227825Stheraven struct __nat {}; 931227825Stheravenpublic: 932227825Stheraven _LIBCPP_INLINE_VISIBILITY 933227825Stheraven static pointer pointer_to(typename conditional<is_void<element_type>::value, 934227825Stheraven __nat, element_type>::type& __r) 935227825Stheraven {return pointer::pointer_to(__r);} 936227825Stheraven}; 937227825Stheraven 938227825Stheraventemplate <class _Tp> 939227825Stheravenstruct _LIBCPP_VISIBLE pointer_traits<_Tp*> 940227825Stheraven{ 941227825Stheraven typedef _Tp* pointer; 942227825Stheraven typedef _Tp element_type; 943227825Stheraven typedef ptrdiff_t difference_type; 944227825Stheraven 945227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 946227825Stheraven template <class _Up> using rebind = _Up*; 947227825Stheraven#else 948227825Stheraven template <class _Up> struct rebind {typedef _Up* other;}; 949227825Stheraven#endif 950227825Stheraven 951227825Stheravenprivate: 952227825Stheraven struct __nat {}; 953227825Stheravenpublic: 954227825Stheraven _LIBCPP_INLINE_VISIBILITY 955227825Stheraven static pointer pointer_to(typename conditional<is_void<element_type>::value, 956227825Stheraven __nat, element_type>::type& __r) _NOEXCEPT 957227825Stheraven {return _VSTD::addressof(__r);} 958227825Stheraven}; 959227825Stheraven 960227825Stheraven// allocator_traits 961227825Stheraven 962227825Stheravennamespace __has_pointer_type_imp 963227825Stheraven{ 964227825Stheraven template <class _Up> static __two test(...); 965227825Stheraven template <class _Up> static char test(typename _Up::pointer* = 0); 966227825Stheraven} 967227825Stheraven 968227825Stheraventemplate <class _Tp> 969227825Stheravenstruct __has_pointer_type 970227825Stheraven : public integral_constant<bool, sizeof(__has_pointer_type_imp::test<_Tp>(0)) == 1> 971227825Stheraven{ 972227825Stheraven}; 973227825Stheraven 974227825Stheravennamespace __pointer_type_imp 975227825Stheraven{ 976227825Stheraven 977227825Stheraventemplate <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value> 978227825Stheravenstruct __pointer_type 979227825Stheraven{ 980227825Stheraven typedef typename _Dp::pointer type; 981227825Stheraven}; 982227825Stheraven 983227825Stheraventemplate <class _Tp, class _Dp> 984227825Stheravenstruct __pointer_type<_Tp, _Dp, false> 985227825Stheraven{ 986227825Stheraven typedef _Tp* type; 987227825Stheraven}; 988227825Stheraven 989227825Stheraven} // __pointer_type_imp 990227825Stheraven 991227825Stheraventemplate <class _Tp, class _Dp> 992227825Stheravenstruct __pointer_type 993227825Stheraven{ 994227825Stheraven typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type; 995227825Stheraven}; 996227825Stheraven 997227825Stheraventemplate <class _Tp> 998227825Stheravenstruct __has_const_pointer 999227825Stheraven{ 1000227825Stheravenprivate: 1001242945Stheraven struct __two {char __lx; char __lxx;}; 1002227825Stheraven template <class _Up> static __two __test(...); 1003227825Stheraven template <class _Up> static char __test(typename _Up::const_pointer* = 0); 1004227825Stheravenpublic: 1005227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1006227825Stheraven}; 1007227825Stheraven 1008227825Stheraventemplate <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value> 1009227825Stheravenstruct __const_pointer 1010227825Stheraven{ 1011227825Stheraven typedef typename _Alloc::const_pointer type; 1012227825Stheraven}; 1013227825Stheraven 1014227825Stheraventemplate <class _Tp, class _Ptr, class _Alloc> 1015227825Stheravenstruct __const_pointer<_Tp, _Ptr, _Alloc, false> 1016227825Stheraven{ 1017227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1018227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; 1019227825Stheraven#else 1020227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; 1021227825Stheraven#endif 1022227825Stheraven}; 1023227825Stheraven 1024227825Stheraventemplate <class _Tp> 1025227825Stheravenstruct __has_void_pointer 1026227825Stheraven{ 1027227825Stheravenprivate: 1028242945Stheraven struct __two {char __lx; char __lxx;}; 1029227825Stheraven template <class _Up> static __two __test(...); 1030227825Stheraven template <class _Up> static char __test(typename _Up::void_pointer* = 0); 1031227825Stheravenpublic: 1032227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1033227825Stheraven}; 1034227825Stheraven 1035227825Stheraventemplate <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value> 1036227825Stheravenstruct __void_pointer 1037227825Stheraven{ 1038227825Stheraven typedef typename _Alloc::void_pointer type; 1039227825Stheraven}; 1040227825Stheraven 1041227825Stheraventemplate <class _Ptr, class _Alloc> 1042227825Stheravenstruct __void_pointer<_Ptr, _Alloc, false> 1043227825Stheraven{ 1044227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1045227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<void> type; 1046227825Stheraven#else 1047227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; 1048227825Stheraven#endif 1049227825Stheraven}; 1050227825Stheraven 1051227825Stheraventemplate <class _Tp> 1052227825Stheravenstruct __has_const_void_pointer 1053227825Stheraven{ 1054227825Stheravenprivate: 1055242945Stheraven struct __two {char __lx; char __lxx;}; 1056227825Stheraven template <class _Up> static __two __test(...); 1057227825Stheraven template <class _Up> static char __test(typename _Up::const_void_pointer* = 0); 1058227825Stheravenpublic: 1059227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1060227825Stheraven}; 1061227825Stheraven 1062227825Stheraventemplate <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value> 1063227825Stheravenstruct __const_void_pointer 1064227825Stheraven{ 1065227825Stheraven typedef typename _Alloc::const_void_pointer type; 1066227825Stheraven}; 1067227825Stheraven 1068227825Stheraventemplate <class _Ptr, class _Alloc> 1069227825Stheravenstruct __const_void_pointer<_Ptr, _Alloc, false> 1070227825Stheraven{ 1071227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1072227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const void> type; 1073227825Stheraven#else 1074227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; 1075227825Stheraven#endif 1076227825Stheraven}; 1077227825Stheraven 1078232950Stheraventemplate <class _Tp> 1079227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1080232950Stheraven_Tp* 1081232950Stheraven__to_raw_pointer(_Tp* __p) _NOEXCEPT 1082227825Stheraven{ 1083227825Stheraven return __p; 1084227825Stheraven} 1085227825Stheraven 1086227825Stheraventemplate <class _Pointer> 1087227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1088227825Stheraventypename pointer_traits<_Pointer>::element_type* 1089227825Stheraven__to_raw_pointer(_Pointer __p) _NOEXCEPT 1090227825Stheraven{ 1091227825Stheraven return _VSTD::__to_raw_pointer(__p.operator->()); 1092227825Stheraven} 1093227825Stheraven 1094227825Stheraventemplate <class _Tp> 1095227825Stheravenstruct __has_size_type 1096227825Stheraven{ 1097227825Stheravenprivate: 1098242945Stheraven struct __two {char __lx; char __lxx;}; 1099227825Stheraven template <class _Up> static __two __test(...); 1100227825Stheraven template <class _Up> static char __test(typename _Up::size_type* = 0); 1101227825Stheravenpublic: 1102227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1103227825Stheraven}; 1104227825Stheraven 1105227825Stheraventemplate <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> 1106227825Stheravenstruct __size_type 1107227825Stheraven{ 1108227825Stheraven typedef typename make_unsigned<_DiffType>::type type; 1109227825Stheraven}; 1110227825Stheraven 1111227825Stheraventemplate <class _Alloc, class _DiffType> 1112227825Stheravenstruct __size_type<_Alloc, _DiffType, true> 1113227825Stheraven{ 1114227825Stheraven typedef typename _Alloc::size_type type; 1115227825Stheraven}; 1116227825Stheraven 1117227825Stheraventemplate <class _Tp> 1118227825Stheravenstruct __has_propagate_on_container_copy_assignment 1119227825Stheraven{ 1120227825Stheravenprivate: 1121242945Stheraven struct __two {char __lx; char __lxx;}; 1122227825Stheraven template <class _Up> static __two __test(...); 1123227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0); 1124227825Stheravenpublic: 1125227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1126227825Stheraven}; 1127227825Stheraven 1128227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value> 1129227825Stheravenstruct __propagate_on_container_copy_assignment 1130227825Stheraven{ 1131227825Stheraven typedef false_type type; 1132227825Stheraven}; 1133227825Stheraven 1134227825Stheraventemplate <class _Alloc> 1135227825Stheravenstruct __propagate_on_container_copy_assignment<_Alloc, true> 1136227825Stheraven{ 1137227825Stheraven typedef typename _Alloc::propagate_on_container_copy_assignment type; 1138227825Stheraven}; 1139227825Stheraven 1140227825Stheraventemplate <class _Tp> 1141227825Stheravenstruct __has_propagate_on_container_move_assignment 1142227825Stheraven{ 1143227825Stheravenprivate: 1144242945Stheraven struct __two {char __lx; char __lxx;}; 1145227825Stheraven template <class _Up> static __two __test(...); 1146227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0); 1147227825Stheravenpublic: 1148227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1149227825Stheraven}; 1150227825Stheraven 1151227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value> 1152227825Stheravenstruct __propagate_on_container_move_assignment 1153227825Stheraven{ 1154227825Stheraven typedef false_type type; 1155227825Stheraven}; 1156227825Stheraven 1157227825Stheraventemplate <class _Alloc> 1158227825Stheravenstruct __propagate_on_container_move_assignment<_Alloc, true> 1159227825Stheraven{ 1160227825Stheraven typedef typename _Alloc::propagate_on_container_move_assignment type; 1161227825Stheraven}; 1162227825Stheraven 1163227825Stheraventemplate <class _Tp> 1164227825Stheravenstruct __has_propagate_on_container_swap 1165227825Stheraven{ 1166227825Stheravenprivate: 1167242945Stheraven struct __two {char __lx; char __lxx;}; 1168227825Stheraven template <class _Up> static __two __test(...); 1169227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0); 1170227825Stheravenpublic: 1171227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1172227825Stheraven}; 1173227825Stheraven 1174227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> 1175227825Stheravenstruct __propagate_on_container_swap 1176227825Stheraven{ 1177227825Stheraven typedef false_type type; 1178227825Stheraven}; 1179227825Stheraven 1180227825Stheraventemplate <class _Alloc> 1181227825Stheravenstruct __propagate_on_container_swap<_Alloc, true> 1182227825Stheraven{ 1183227825Stheraven typedef typename _Alloc::propagate_on_container_swap type; 1184227825Stheraven}; 1185227825Stheraven 1186227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 1187227825Stheravenstruct __has_rebind_other 1188227825Stheraven{ 1189227825Stheravenprivate: 1190242945Stheraven struct __two {char __lx; char __lxx;}; 1191227825Stheraven template <class _Xp> static __two __test(...); 1192227825Stheraven template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); 1193227825Stheravenpublic: 1194227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1195227825Stheraven}; 1196227825Stheraven 1197227825Stheraventemplate <class _Tp, class _Up> 1198227825Stheravenstruct __has_rebind_other<_Tp, _Up, false> 1199227825Stheraven{ 1200227825Stheraven static const bool value = false; 1201227825Stheraven}; 1202227825Stheraven 1203227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> 1204227825Stheravenstruct __allocator_traits_rebind 1205227825Stheraven{ 1206227825Stheraven typedef typename _Tp::template rebind<_Up>::other type; 1207227825Stheraven}; 1208227825Stheraven 1209227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1210227825Stheraven 1211227825Stheraventemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 1212227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> 1213227825Stheraven{ 1214227825Stheraven typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; 1215227825Stheraven}; 1216227825Stheraven 1217227825Stheraventemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 1218227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> 1219227825Stheraven{ 1220227825Stheraven typedef _Alloc<_Up, _Args...> type; 1221227825Stheraven}; 1222227825Stheraven 1223227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1224227825Stheraven 1225227825Stheraventemplate <template <class> class _Alloc, class _Tp, class _Up> 1226227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true> 1227227825Stheraven{ 1228227825Stheraven typedef typename _Alloc<_Tp>::template rebind<_Up>::other type; 1229227825Stheraven}; 1230227825Stheraven 1231227825Stheraventemplate <template <class> class _Alloc, class _Tp, class _Up> 1232227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false> 1233227825Stheraven{ 1234227825Stheraven typedef _Alloc<_Up> type; 1235227825Stheraven}; 1236227825Stheraven 1237227825Stheraventemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 1238227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true> 1239227825Stheraven{ 1240227825Stheraven typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type; 1241227825Stheraven}; 1242227825Stheraven 1243227825Stheraventemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 1244227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false> 1245227825Stheraven{ 1246227825Stheraven typedef _Alloc<_Up, _A0> type; 1247227825Stheraven}; 1248227825Stheraven 1249227825Stheraventemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 1250227825Stheraven class _A1, class _Up> 1251227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true> 1252227825Stheraven{ 1253227825Stheraven typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type; 1254227825Stheraven}; 1255227825Stheraven 1256227825Stheraventemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 1257227825Stheraven class _A1, class _Up> 1258227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false> 1259227825Stheraven{ 1260227825Stheraven typedef _Alloc<_Up, _A0, _A1> type; 1261227825Stheraven}; 1262227825Stheraven 1263227825Stheraventemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 1264227825Stheraven class _A1, class _A2, class _Up> 1265227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true> 1266227825Stheraven{ 1267227825Stheraven typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 1268227825Stheraven}; 1269227825Stheraven 1270227825Stheraventemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 1271227825Stheraven class _A1, class _A2, class _Up> 1272227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> 1273227825Stheraven{ 1274227825Stheraven typedef _Alloc<_Up, _A0, _A1, _A2> type; 1275227825Stheraven}; 1276227825Stheraven 1277227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1278227825Stheraven 1279227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 1280227825Stheraven 1281227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1282227825Stheravenauto 1283227825Stheraven__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 1284227825Stheraven -> decltype(__a.allocate(__sz, __p), true_type()); 1285227825Stheraven 1286227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1287227825Stheravenauto 1288227825Stheraven__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 1289227825Stheraven -> false_type; 1290227825Stheraven 1291227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1292227825Stheravenstruct __has_allocate_hint 1293227825Stheraven : integral_constant<bool, 1294227825Stheraven is_same< 1295227825Stheraven decltype(__has_allocate_hint_test(declval<_Alloc>(), 1296227825Stheraven declval<_SizeType>(), 1297227825Stheraven declval<_ConstVoidPtr>())), 1298227825Stheraven true_type>::value> 1299227825Stheraven{ 1300227825Stheraven}; 1301227825Stheraven 1302227825Stheraven#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1303227825Stheraven 1304227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1305227825Stheravenstruct __has_allocate_hint 1306227825Stheraven : true_type 1307227825Stheraven{ 1308227825Stheraven}; 1309227825Stheraven 1310227825Stheraven#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1311227825Stheraven 1312227825Stheraven#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1313227825Stheraven 1314227825Stheraventemplate <class _Alloc, class _Tp, class ..._Args> 1315227825Stheravendecltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), 1316227825Stheraven _VSTD::declval<_Args>()...), 1317227825Stheraven true_type()) 1318227825Stheraven__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args); 1319227825Stheraven 1320227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1321227825Stheravenfalse_type 1322227825Stheraven__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args); 1323227825Stheraven 1324227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1325227825Stheravenstruct __has_construct 1326227825Stheraven : integral_constant<bool, 1327227825Stheraven is_same< 1328227825Stheraven decltype(__has_construct_test(declval<_Alloc>(), 1329227825Stheraven declval<_Pointer>(), 1330227825Stheraven declval<_Args>()...)), 1331227825Stheraven true_type>::value> 1332227825Stheraven{ 1333227825Stheraven}; 1334227825Stheraven 1335227825Stheraventemplate <class _Alloc, class _Pointer> 1336227825Stheravenauto 1337227825Stheraven__has_destroy_test(_Alloc&& __a, _Pointer&& __p) 1338227825Stheraven -> decltype(__a.destroy(__p), true_type()); 1339227825Stheraven 1340227825Stheraventemplate <class _Alloc, class _Pointer> 1341227825Stheravenauto 1342227825Stheraven__has_destroy_test(const _Alloc& __a, _Pointer&& __p) 1343227825Stheraven -> false_type; 1344227825Stheraven 1345227825Stheraventemplate <class _Alloc, class _Pointer> 1346227825Stheravenstruct __has_destroy 1347227825Stheraven : integral_constant<bool, 1348227825Stheraven is_same< 1349227825Stheraven decltype(__has_destroy_test(declval<_Alloc>(), 1350227825Stheraven declval<_Pointer>())), 1351227825Stheraven true_type>::value> 1352227825Stheraven{ 1353227825Stheraven}; 1354227825Stheraven 1355227825Stheraventemplate <class _Alloc> 1356227825Stheravenauto 1357227825Stheraven__has_max_size_test(_Alloc&& __a) 1358227825Stheraven -> decltype(__a.max_size(), true_type()); 1359227825Stheraven 1360227825Stheraventemplate <class _Alloc> 1361227825Stheravenauto 1362227825Stheraven__has_max_size_test(const volatile _Alloc& __a) 1363227825Stheraven -> false_type; 1364227825Stheraven 1365227825Stheraventemplate <class _Alloc> 1366227825Stheravenstruct __has_max_size 1367227825Stheraven : integral_constant<bool, 1368227825Stheraven is_same< 1369227825Stheraven decltype(__has_max_size_test(declval<_Alloc&>())), 1370227825Stheraven true_type>::value> 1371227825Stheraven{ 1372227825Stheraven}; 1373227825Stheraven 1374227825Stheraventemplate <class _Alloc> 1375227825Stheravenauto 1376227825Stheraven__has_select_on_container_copy_construction_test(_Alloc&& __a) 1377227825Stheraven -> decltype(__a.select_on_container_copy_construction(), true_type()); 1378227825Stheraven 1379227825Stheraventemplate <class _Alloc> 1380227825Stheravenauto 1381227825Stheraven__has_select_on_container_copy_construction_test(const volatile _Alloc& __a) 1382227825Stheraven -> false_type; 1383227825Stheraven 1384227825Stheraventemplate <class _Alloc> 1385227825Stheravenstruct __has_select_on_container_copy_construction 1386227825Stheraven : integral_constant<bool, 1387227825Stheraven is_same< 1388227825Stheraven decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())), 1389227825Stheraven true_type>::value> 1390227825Stheraven{ 1391227825Stheraven}; 1392227825Stheraven 1393227825Stheraven#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1394227825Stheraven 1395227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1396227825Stheraven 1397227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1398227825Stheravenstruct __has_construct 1399227825Stheraven : false_type 1400227825Stheraven{ 1401227825Stheraven}; 1402227825Stheraven 1403232950Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1404232950Stheraven 1405232950Stheraventemplate <class _Alloc, class _Pointer, class _Args> 1406232950Stheravenstruct __has_construct 1407232950Stheraven : false_type 1408232950Stheraven{ 1409232950Stheraven}; 1410232950Stheraven 1411227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1412227825Stheraven 1413227825Stheraventemplate <class _Alloc, class _Pointer> 1414227825Stheravenstruct __has_destroy 1415227825Stheraven : false_type 1416227825Stheraven{ 1417227825Stheraven}; 1418227825Stheraven 1419227825Stheraventemplate <class _Alloc> 1420227825Stheravenstruct __has_max_size 1421227825Stheraven : true_type 1422227825Stheraven{ 1423227825Stheraven}; 1424227825Stheraven 1425227825Stheraventemplate <class _Alloc> 1426227825Stheravenstruct __has_select_on_container_copy_construction 1427227825Stheraven : false_type 1428227825Stheraven{ 1429227825Stheraven}; 1430227825Stheraven 1431227825Stheraven#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1432227825Stheraven 1433227825Stheraventemplate <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> 1434227825Stheravenstruct __alloc_traits_difference_type 1435227825Stheraven{ 1436227825Stheraven typedef typename pointer_traits<_Ptr>::difference_type type; 1437227825Stheraven}; 1438227825Stheraven 1439227825Stheraventemplate <class _Alloc, class _Ptr> 1440227825Stheravenstruct __alloc_traits_difference_type<_Alloc, _Ptr, true> 1441227825Stheraven{ 1442227825Stheraven typedef typename _Alloc::difference_type type; 1443227825Stheraven}; 1444227825Stheraven 1445227825Stheraventemplate <class _Alloc> 1446227825Stheravenstruct _LIBCPP_VISIBLE allocator_traits 1447227825Stheraven{ 1448227825Stheraven typedef _Alloc allocator_type; 1449227825Stheraven typedef typename allocator_type::value_type value_type; 1450227825Stheraven 1451227825Stheraven typedef typename __pointer_type<value_type, allocator_type>::type pointer; 1452227825Stheraven typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer; 1453227825Stheraven typedef typename __void_pointer<pointer, allocator_type>::type void_pointer; 1454227825Stheraven typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer; 1455227825Stheraven 1456227825Stheraven typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type; 1457227825Stheraven typedef typename __size_type<allocator_type, difference_type>::type size_type; 1458227825Stheraven 1459227825Stheraven typedef typename __propagate_on_container_copy_assignment<allocator_type>::type 1460227825Stheraven propagate_on_container_copy_assignment; 1461227825Stheraven typedef typename __propagate_on_container_move_assignment<allocator_type>::type 1462227825Stheraven propagate_on_container_move_assignment; 1463227825Stheraven typedef typename __propagate_on_container_swap<allocator_type>::type 1464227825Stheraven propagate_on_container_swap; 1465227825Stheraven 1466227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1467227825Stheraven template <class _Tp> using rebind_alloc = 1468227825Stheraven typename __allocator_traits_rebind<allocator_type, _Tp>::type; 1469227825Stheraven template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; 1470227825Stheraven#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1471227825Stheraven template <class _Tp> struct rebind_alloc 1472227825Stheraven {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;}; 1473227825Stheraven template <class _Tp> struct rebind_traits 1474227825Stheraven {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;}; 1475227825Stheraven#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1476227825Stheraven 1477227825Stheraven _LIBCPP_INLINE_VISIBILITY 1478227825Stheraven static pointer allocate(allocator_type& __a, size_type __n) 1479227825Stheraven {return __a.allocate(__n);} 1480227825Stheraven _LIBCPP_INLINE_VISIBILITY 1481227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) 1482227825Stheraven {return allocate(__a, __n, __hint, 1483227825Stheraven __has_allocate_hint<allocator_type, size_type, const_void_pointer>());} 1484227825Stheraven 1485227825Stheraven _LIBCPP_INLINE_VISIBILITY 1486227825Stheraven static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT 1487227825Stheraven {__a.deallocate(__p, __n);} 1488227825Stheraven 1489227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1490227825Stheraven template <class _Tp, class... _Args> 1491227825Stheraven _LIBCPP_INLINE_VISIBILITY 1492227825Stheraven static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) 1493227825Stheraven {__construct(__has_construct<allocator_type, pointer, _Args...>(), 1494227825Stheraven __a, __p, _VSTD::forward<_Args>(__args)...);} 1495227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1496227825Stheraven template <class _Tp> 1497227825Stheraven _LIBCPP_INLINE_VISIBILITY 1498227825Stheraven static void construct(allocator_type& __a, _Tp* __p) 1499227825Stheraven { 1500227825Stheraven ::new ((void*)__p) _Tp(); 1501227825Stheraven } 1502227825Stheraven template <class _Tp, class _A0> 1503227825Stheraven _LIBCPP_INLINE_VISIBILITY 1504227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0) 1505227825Stheraven { 1506227825Stheraven ::new ((void*)__p) _Tp(__a0); 1507227825Stheraven } 1508227825Stheraven template <class _Tp, class _A0, class _A1> 1509227825Stheraven _LIBCPP_INLINE_VISIBILITY 1510227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, 1511227825Stheraven const _A1& __a1) 1512227825Stheraven { 1513227825Stheraven ::new ((void*)__p) _Tp(__a0, __a1); 1514227825Stheraven } 1515227825Stheraven template <class _Tp, class _A0, class _A1, class _A2> 1516227825Stheraven _LIBCPP_INLINE_VISIBILITY 1517227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, 1518227825Stheraven const _A1& __a1, const _A2& __a2) 1519227825Stheraven { 1520227825Stheraven ::new ((void*)__p) _Tp(__a0, __a1, __a2); 1521227825Stheraven } 1522227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1523227825Stheraven 1524227825Stheraven template <class _Tp> 1525227825Stheraven _LIBCPP_INLINE_VISIBILITY 1526227825Stheraven static void destroy(allocator_type& __a, _Tp* __p) 1527227825Stheraven {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} 1528227825Stheraven 1529227825Stheraven _LIBCPP_INLINE_VISIBILITY 1530227825Stheraven static size_type max_size(const allocator_type& __a) 1531227825Stheraven {return __max_size(__has_max_size<const allocator_type>(), __a);} 1532227825Stheraven 1533227825Stheraven _LIBCPP_INLINE_VISIBILITY 1534227825Stheraven static allocator_type 1535227825Stheraven select_on_container_copy_construction(const allocator_type& __a) 1536227825Stheraven {return select_on_container_copy_construction( 1537227825Stheraven __has_select_on_container_copy_construction<const allocator_type>(), 1538227825Stheraven __a);} 1539227825Stheraven 1540232950Stheraven template <class _Ptr> 1541232950Stheraven _LIBCPP_INLINE_VISIBILITY 1542232950Stheraven static 1543232950Stheraven void 1544232950Stheraven __construct_forward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) 1545232950Stheraven { 1546232950Stheraven for (; __begin1 != __end1; ++__begin1, ++__begin2) 1547232950Stheraven construct(__a, _VSTD::__to_raw_pointer(__begin2), _VSTD::move_if_noexcept(*__begin1)); 1548232950Stheraven } 1549232950Stheraven 1550232950Stheraven template <class _Tp> 1551232950Stheraven _LIBCPP_INLINE_VISIBILITY 1552232950Stheraven static 1553232950Stheraven typename enable_if 1554232950Stheraven < 1555232950Stheraven (is_same<allocator_type, allocator<_Tp> >::value 1556232950Stheraven || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 1557232950Stheraven is_trivially_move_constructible<_Tp>::value, 1558232950Stheraven void 1559232950Stheraven >::type 1560232950Stheraven __construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) 1561232950Stheraven { 1562232950Stheraven ptrdiff_t _Np = __end1 - __begin1; 1563232950Stheraven _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); 1564232950Stheraven __begin2 += _Np; 1565232950Stheraven } 1566232950Stheraven 1567232950Stheraven template <class _Ptr> 1568232950Stheraven _LIBCPP_INLINE_VISIBILITY 1569232950Stheraven static 1570232950Stheraven void 1571232950Stheraven __construct_backward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) 1572232950Stheraven { 1573232950Stheraven while (__end1 != __begin1) 1574232950Stheraven construct(__a, _VSTD::__to_raw_pointer(--__end2), _VSTD::move_if_noexcept(*--__end1)); 1575232950Stheraven } 1576232950Stheraven 1577232950Stheraven template <class _Tp> 1578232950Stheraven _LIBCPP_INLINE_VISIBILITY 1579232950Stheraven static 1580232950Stheraven typename enable_if 1581232950Stheraven < 1582232950Stheraven (is_same<allocator_type, allocator<_Tp> >::value 1583232950Stheraven || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 1584232950Stheraven is_trivially_move_constructible<_Tp>::value, 1585232950Stheraven void 1586232950Stheraven >::type 1587232950Stheraven __construct_backward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) 1588232950Stheraven { 1589232950Stheraven ptrdiff_t _Np = __end1 - __begin1; 1590232950Stheraven __end2 -= _Np; 1591232950Stheraven _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp)); 1592232950Stheraven } 1593232950Stheraven 1594227825Stheravenprivate: 1595227825Stheraven 1596227825Stheraven _LIBCPP_INLINE_VISIBILITY 1597227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, 1598227825Stheraven const_void_pointer __hint, true_type) 1599227825Stheraven {return __a.allocate(__n, __hint);} 1600227825Stheraven _LIBCPP_INLINE_VISIBILITY 1601227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, 1602232950Stheraven const_void_pointer, false_type) 1603227825Stheraven {return __a.allocate(__n);} 1604227825Stheraven 1605227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1606227825Stheraven template <class _Tp, class... _Args> 1607227825Stheraven _LIBCPP_INLINE_VISIBILITY 1608227825Stheraven static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) 1609227825Stheraven {__a.construct(__p, _VSTD::forward<_Args>(__args)...);} 1610227825Stheraven template <class _Tp, class... _Args> 1611227825Stheraven _LIBCPP_INLINE_VISIBILITY 1612227825Stheraven static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) 1613227825Stheraven { 1614227825Stheraven ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); 1615227825Stheraven } 1616227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1617227825Stheraven 1618227825Stheraven template <class _Tp> 1619227825Stheraven _LIBCPP_INLINE_VISIBILITY 1620227825Stheraven static void __destroy(true_type, allocator_type& __a, _Tp* __p) 1621227825Stheraven {__a.destroy(__p);} 1622227825Stheraven template <class _Tp> 1623227825Stheraven _LIBCPP_INLINE_VISIBILITY 1624227825Stheraven static void __destroy(false_type, allocator_type&, _Tp* __p) 1625227825Stheraven { 1626227825Stheraven __p->~_Tp(); 1627227825Stheraven } 1628227825Stheraven 1629227825Stheraven _LIBCPP_INLINE_VISIBILITY 1630227825Stheraven static size_type __max_size(true_type, const allocator_type& __a) 1631227825Stheraven {return __a.max_size();} 1632227825Stheraven _LIBCPP_INLINE_VISIBILITY 1633227825Stheraven static size_type __max_size(false_type, const allocator_type&) 1634227825Stheraven {return numeric_limits<size_type>::max();} 1635227825Stheraven 1636227825Stheraven _LIBCPP_INLINE_VISIBILITY 1637227825Stheraven static allocator_type 1638227825Stheraven select_on_container_copy_construction(true_type, const allocator_type& __a) 1639227825Stheraven {return __a.select_on_container_copy_construction();} 1640227825Stheraven _LIBCPP_INLINE_VISIBILITY 1641227825Stheraven static allocator_type 1642227825Stheraven select_on_container_copy_construction(false_type, const allocator_type& __a) 1643227825Stheraven {return __a;} 1644227825Stheraven}; 1645227825Stheraven 1646232950Stheraven// allocator 1647227825Stheraven 1648227825Stheraventemplate <class _Tp> 1649232950Stheravenclass _LIBCPP_VISIBLE allocator 1650227825Stheraven{ 1651227825Stheravenpublic: 1652232950Stheraven typedef size_t size_type; 1653232950Stheraven typedef ptrdiff_t difference_type; 1654232950Stheraven typedef _Tp* pointer; 1655232950Stheraven typedef const _Tp* const_pointer; 1656232950Stheraven typedef _Tp& reference; 1657232950Stheraven typedef const _Tp& const_reference; 1658232950Stheraven typedef _Tp value_type; 1659227825Stheraven 1660232950Stheraven typedef true_type propagate_on_container_move_assignment; 1661227825Stheraven 1662232950Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 1663227825Stheraven 1664232950Stheraven _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 1665232950Stheraven template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 1666232950Stheraven _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT 1667232950Stheraven {return _VSTD::addressof(__x);} 1668232950Stheraven _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 1669232950Stheraven {return _VSTD::addressof(__x);} 1670232950Stheraven _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1671232950Stheraven {return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));} 1672232950Stheraven _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1673232950Stheraven {::operator delete((void*)__p);} 1674232950Stheraven _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 1675232950Stheraven {return size_type(~0) / sizeof(_Tp);} 1676232950Stheraven#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1677232950Stheraven template <class _Up, class... _Args> 1678232950Stheraven _LIBCPP_INLINE_VISIBILITY 1679232950Stheraven void 1680232950Stheraven construct(_Up* __p, _Args&&... __args) 1681232950Stheraven { 1682232950Stheraven ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 1683232950Stheraven } 1684232950Stheraven#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1685232950Stheraven _LIBCPP_INLINE_VISIBILITY 1686232950Stheraven void 1687232950Stheraven construct(pointer __p) 1688232950Stheraven { 1689232950Stheraven ::new((void*)__p) _Tp(); 1690232950Stheraven } 1691232950Stheraven# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1692234976Stheraven 1693232950Stheraven template <class _A0> 1694232950Stheraven _LIBCPP_INLINE_VISIBILITY 1695234976Stheraven void 1696232950Stheraven construct(pointer __p, _A0& __a0) 1697232950Stheraven { 1698232950Stheraven ::new((void*)__p) _Tp(__a0); 1699232950Stheraven } 1700232950Stheraven template <class _A0> 1701232950Stheraven _LIBCPP_INLINE_VISIBILITY 1702234976Stheraven void 1703232950Stheraven construct(pointer __p, const _A0& __a0) 1704232950Stheraven { 1705232950Stheraven ::new((void*)__p) _Tp(__a0); 1706232950Stheraven } 1707232950Stheraven# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1708232950Stheraven template <class _A0, class _A1> 1709232950Stheraven _LIBCPP_INLINE_VISIBILITY 1710232950Stheraven void 1711232950Stheraven construct(pointer __p, _A0& __a0, _A1& __a1) 1712232950Stheraven { 1713232950Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1714232950Stheraven } 1715232950Stheraven template <class _A0, class _A1> 1716232950Stheraven _LIBCPP_INLINE_VISIBILITY 1717232950Stheraven void 1718232950Stheraven construct(pointer __p, const _A0& __a0, _A1& __a1) 1719232950Stheraven { 1720232950Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1721232950Stheraven } 1722232950Stheraven template <class _A0, class _A1> 1723232950Stheraven _LIBCPP_INLINE_VISIBILITY 1724232950Stheraven void 1725232950Stheraven construct(pointer __p, _A0& __a0, const _A1& __a1) 1726232950Stheraven { 1727232950Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1728232950Stheraven } 1729232950Stheraven template <class _A0, class _A1> 1730232950Stheraven _LIBCPP_INLINE_VISIBILITY 1731232950Stheraven void 1732232950Stheraven construct(pointer __p, const _A0& __a0, const _A1& __a1) 1733232950Stheraven { 1734232950Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1735232950Stheraven } 1736232950Stheraven#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1737232950Stheraven _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 1738227825Stheraven}; 1739227825Stheraven 1740227825Stheraventemplate <class _Tp> 1741232950Stheravenclass _LIBCPP_VISIBLE allocator<const _Tp> 1742227825Stheraven{ 1743227825Stheravenpublic: 1744227825Stheraven typedef size_t size_type; 1745227825Stheraven typedef ptrdiff_t difference_type; 1746232950Stheraven typedef const _Tp* pointer; 1747227825Stheraven typedef const _Tp* const_pointer; 1748232950Stheraven typedef const _Tp& reference; 1749227825Stheraven typedef const _Tp& const_reference; 1750227825Stheraven typedef _Tp value_type; 1751227825Stheraven 1752227825Stheraven typedef true_type propagate_on_container_move_assignment; 1753227825Stheraven 1754227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 1755227825Stheraven 1756227825Stheraven _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 1757227825Stheraven template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 1758227825Stheraven _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 1759227825Stheraven {return _VSTD::addressof(__x);} 1760227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1761227825Stheraven {return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));} 1762227825Stheraven _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1763227825Stheraven {::operator delete((void*)__p);} 1764227825Stheraven _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 1765227825Stheraven {return size_type(~0) / sizeof(_Tp);} 1766227825Stheraven#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1767227825Stheraven template <class _Up, class... _Args> 1768227825Stheraven _LIBCPP_INLINE_VISIBILITY 1769227825Stheraven void 1770227825Stheraven construct(_Up* __p, _Args&&... __args) 1771227825Stheraven { 1772227825Stheraven ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 1773227825Stheraven } 1774227825Stheraven#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1775227825Stheraven _LIBCPP_INLINE_VISIBILITY 1776227825Stheraven void 1777227825Stheraven construct(pointer __p) 1778227825Stheraven { 1779227825Stheraven ::new((void*)__p) _Tp(); 1780227825Stheraven } 1781227825Stheraven# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1782234976Stheraven 1783227825Stheraven template <class _A0> 1784227825Stheraven _LIBCPP_INLINE_VISIBILITY 1785234976Stheraven void 1786227825Stheraven construct(pointer __p, _A0& __a0) 1787227825Stheraven { 1788227825Stheraven ::new((void*)__p) _Tp(__a0); 1789227825Stheraven } 1790227825Stheraven template <class _A0> 1791227825Stheraven _LIBCPP_INLINE_VISIBILITY 1792234976Stheraven void 1793227825Stheraven construct(pointer __p, const _A0& __a0) 1794227825Stheraven { 1795227825Stheraven ::new((void*)__p) _Tp(__a0); 1796227825Stheraven } 1797227825Stheraven# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1798227825Stheraven template <class _A0, class _A1> 1799227825Stheraven _LIBCPP_INLINE_VISIBILITY 1800227825Stheraven void 1801227825Stheraven construct(pointer __p, _A0& __a0, _A1& __a1) 1802227825Stheraven { 1803227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1804227825Stheraven } 1805227825Stheraven template <class _A0, class _A1> 1806227825Stheraven _LIBCPP_INLINE_VISIBILITY 1807227825Stheraven void 1808227825Stheraven construct(pointer __p, const _A0& __a0, _A1& __a1) 1809227825Stheraven { 1810227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1811227825Stheraven } 1812227825Stheraven template <class _A0, class _A1> 1813227825Stheraven _LIBCPP_INLINE_VISIBILITY 1814227825Stheraven void 1815227825Stheraven construct(pointer __p, _A0& __a0, const _A1& __a1) 1816227825Stheraven { 1817227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1818227825Stheraven } 1819227825Stheraven template <class _A0, class _A1> 1820227825Stheraven _LIBCPP_INLINE_VISIBILITY 1821227825Stheraven void 1822227825Stheraven construct(pointer __p, const _A0& __a0, const _A1& __a1) 1823227825Stheraven { 1824227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1825227825Stheraven } 1826227825Stheraven#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1827227825Stheraven _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 1828227825Stheraven}; 1829227825Stheraven 1830227825Stheraventemplate <class _Tp, class _Up> 1831227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1832227825Stheravenbool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} 1833227825Stheraven 1834227825Stheraventemplate <class _Tp, class _Up> 1835227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1836227825Stheravenbool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} 1837227825Stheraven 1838227825Stheraventemplate <class _OutputIterator, class _Tp> 1839227825Stheravenclass _LIBCPP_VISIBLE raw_storage_iterator 1840227825Stheraven : public iterator<output_iterator_tag, 1841227825Stheraven _Tp, // purposefully not C++03 1842227825Stheraven ptrdiff_t, // purposefully not C++03 1843227825Stheraven _Tp*, // purposefully not C++03 1844227825Stheraven raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03 1845227825Stheraven{ 1846227825Stheravenprivate: 1847227825Stheraven _OutputIterator __x_; 1848227825Stheravenpublic: 1849227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} 1850227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} 1851227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) 1852227825Stheraven {::new(&*__x_) _Tp(__element); return *this;} 1853227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} 1854227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) 1855227825Stheraven {raw_storage_iterator __t(*this); ++__x_; return __t;} 1856227825Stheraven}; 1857227825Stheraven 1858227825Stheraventemplate <class _Tp> 1859227825Stheravenpair<_Tp*, ptrdiff_t> 1860227825Stheravenget_temporary_buffer(ptrdiff_t __n) _NOEXCEPT 1861227825Stheraven{ 1862227825Stheraven pair<_Tp*, ptrdiff_t> __r(0, 0); 1863227825Stheraven const ptrdiff_t __m = (~ptrdiff_t(0) ^ 1864227825Stheraven ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) 1865227825Stheraven / sizeof(_Tp); 1866227825Stheraven if (__n > __m) 1867227825Stheraven __n = __m; 1868227825Stheraven while (__n > 0) 1869227825Stheraven { 1870227825Stheraven __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); 1871227825Stheraven if (__r.first) 1872227825Stheraven { 1873227825Stheraven __r.second = __n; 1874227825Stheraven break; 1875227825Stheraven } 1876227825Stheraven __n /= 2; 1877227825Stheraven } 1878227825Stheraven return __r; 1879227825Stheraven} 1880227825Stheraven 1881227825Stheraventemplate <class _Tp> 1882227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1883227825Stheravenvoid return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);} 1884227825Stheraven 1885227825Stheraventemplate <class _Tp> 1886227825Stheravenstruct auto_ptr_ref 1887227825Stheraven{ 1888227825Stheraven _Tp* __ptr_; 1889227825Stheraven}; 1890227825Stheraven 1891227825Stheraventemplate<class _Tp> 1892227825Stheravenclass _LIBCPP_VISIBLE auto_ptr 1893227825Stheraven{ 1894227825Stheravenprivate: 1895227825Stheraven _Tp* __ptr_; 1896227825Stheravenpublic: 1897227825Stheraven typedef _Tp element_type; 1898227825Stheraven 1899227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} 1900227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} 1901227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() 1902227825Stheraven : __ptr_(__p.release()) {} 1903227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() 1904227825Stheraven {reset(__p.release()); return *this;} 1905227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() 1906227825Stheraven {reset(__p.release()); return *this;} 1907227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() 1908227825Stheraven {reset(__p.__ptr_); return *this;} 1909227825Stheraven _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} 1910227825Stheraven 1911227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() 1912227825Stheraven {return *__ptr_;} 1913227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} 1914227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} 1915227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() 1916227825Stheraven { 1917227825Stheraven _Tp* __t = __ptr_; 1918227825Stheraven __ptr_ = 0; 1919227825Stheraven return __t; 1920227825Stheraven } 1921227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() 1922227825Stheraven { 1923227825Stheraven if (__ptr_ != __p) 1924227825Stheraven delete __ptr_; 1925227825Stheraven __ptr_ = __p; 1926227825Stheraven } 1927227825Stheraven 1928227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} 1929227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() 1930227825Stheraven {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} 1931227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() 1932227825Stheraven {return auto_ptr<_Up>(release());} 1933227825Stheraven}; 1934227825Stheraven 1935227825Stheraventemplate <> 1936227825Stheravenclass _LIBCPP_VISIBLE auto_ptr<void> 1937227825Stheraven{ 1938227825Stheravenpublic: 1939227825Stheraven typedef void element_type; 1940227825Stheraven}; 1941227825Stheraven 1942227825Stheraventemplate <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, 1943227825Stheraven typename remove_cv<_T2>::type>::value, 1944232950Stheraven bool = is_empty<_T1>::value 1945232950Stheraven#if __has_feature(is_final) 1946232950Stheraven && !__is_final(_T1) 1947232950Stheraven#endif 1948232950Stheraven , 1949232950Stheraven bool = is_empty<_T2>::value 1950232950Stheraven#if __has_feature(is_final) 1951232950Stheraven && !__is_final(_T2) 1952232950Stheraven#endif 1953232950Stheraven > 1954227825Stheravenstruct __libcpp_compressed_pair_switch; 1955227825Stheraven 1956227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1957227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};}; 1958227825Stheraven 1959227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1960227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false> {enum {value = 1};}; 1961227825Stheraven 1962227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1963227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true> {enum {value = 2};}; 1964227825Stheraven 1965227825Stheraventemplate <class _T1, class _T2> 1966227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true> {enum {value = 3};}; 1967227825Stheraven 1968227825Stheraventemplate <class _T1, class _T2> 1969227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true> {enum {value = 1};}; 1970227825Stheraven 1971227825Stheraventemplate <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value> 1972227825Stheravenclass __libcpp_compressed_pair_imp; 1973227825Stheraven 1974227825Stheraventemplate <class _T1, class _T2> 1975227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 0> 1976227825Stheraven{ 1977227825Stheravenprivate: 1978227825Stheraven _T1 __first_; 1979227825Stheraven _T2 __second_; 1980227825Stheravenpublic: 1981227825Stheraven typedef _T1 _T1_param; 1982227825Stheraven typedef _T2 _T2_param; 1983227825Stheraven 1984227825Stheraven typedef typename remove_reference<_T1>::type& _T1_reference; 1985227825Stheraven typedef typename remove_reference<_T2>::type& _T2_reference; 1986227825Stheraven 1987227825Stheraven typedef const typename remove_reference<_T1>::type& _T1_const_reference; 1988227825Stheraven typedef const typename remove_reference<_T2>::type& _T2_const_reference; 1989227825Stheraven 1990227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 1991232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 1992227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)) {} 1993232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 1994227825Stheraven : __second_(_VSTD::forward<_T2_param>(__t2)) {} 1995227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 1996227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 1997227825Stheraven 1998227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1999227825Stheraven 2000227825Stheraven _LIBCPP_INLINE_VISIBILITY 2001227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2002227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2003227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2004227825Stheraven : __first_(__p.first()), 2005227825Stheraven __second_(__p.second()) {} 2006227825Stheraven 2007227825Stheraven _LIBCPP_INLINE_VISIBILITY 2008227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2009227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2010227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2011227825Stheraven { 2012227825Stheraven __first_ = __p.first(); 2013227825Stheraven __second_ = __p.second(); 2014227825Stheraven return *this; 2015227825Stheraven } 2016227825Stheraven 2017227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2018227825Stheraven 2019227825Stheraven _LIBCPP_INLINE_VISIBILITY 2020227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2021227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2022227825Stheraven is_nothrow_move_constructible<_T2>::value) 2023227825Stheraven : __first_(_VSTD::forward<_T1>(__p.first())), 2024227825Stheraven __second_(_VSTD::forward<_T2>(__p.second())) {} 2025227825Stheraven 2026227825Stheraven _LIBCPP_INLINE_VISIBILITY 2027227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2028227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2029227825Stheraven is_nothrow_move_assignable<_T2>::value) 2030227825Stheraven { 2031227825Stheraven __first_ = _VSTD::forward<_T1>(__p.first()); 2032227825Stheraven __second_ = _VSTD::forward<_T2>(__p.second()); 2033227825Stheraven return *this; 2034227825Stheraven } 2035227825Stheraven 2036232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2037232950Stheraven 2038232950Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2039232950Stheraven _LIBCPP_INLINE_VISIBILITY 2040232950Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2041232950Stheraven tuple<_Args1...> __first_args, 2042232950Stheraven tuple<_Args2...> __second_args, 2043232950Stheraven __tuple_indices<_I1...>, 2044232950Stheraven __tuple_indices<_I2...>) 2045232950Stheraven : __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), 2046232950Stheraven __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) 2047232950Stheraven {} 2048232950Stheraven 2049232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2050232950Stheraven 2051227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2052227825Stheraven 2053227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2054227825Stheraven 2055227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 2056227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 2057227825Stheraven 2058227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 2059227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 2060227825Stheraven 2061227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2062227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2063227825Stheraven __is_nothrow_swappable<_T1>::value) 2064227825Stheraven { 2065227825Stheraven using _VSTD::swap; 2066227825Stheraven swap(__first_, __x.__first_); 2067227825Stheraven swap(__second_, __x.__second_); 2068227825Stheraven } 2069227825Stheraven}; 2070227825Stheraven 2071227825Stheraventemplate <class _T1, class _T2> 2072227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 1> 2073227825Stheraven : private _T1 2074227825Stheraven{ 2075227825Stheravenprivate: 2076227825Stheraven _T2 __second_; 2077227825Stheravenpublic: 2078227825Stheraven typedef _T1 _T1_param; 2079227825Stheraven typedef _T2 _T2_param; 2080227825Stheraven 2081227825Stheraven typedef _T1& _T1_reference; 2082227825Stheraven typedef typename remove_reference<_T2>::type& _T2_reference; 2083227825Stheraven 2084227825Stheraven typedef const _T1& _T1_const_reference; 2085227825Stheraven typedef const typename remove_reference<_T2>::type& _T2_const_reference; 2086227825Stheraven 2087227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2088232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2089227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)) {} 2090232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2091227825Stheraven : __second_(_VSTD::forward<_T2_param>(__t2)) {} 2092227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2093227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 2094227825Stheraven 2095227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2096227825Stheraven 2097227825Stheraven _LIBCPP_INLINE_VISIBILITY 2098227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2099227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2100227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2101227825Stheraven : _T1(__p.first()), __second_(__p.second()) {} 2102227825Stheraven 2103227825Stheraven _LIBCPP_INLINE_VISIBILITY 2104227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2105227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2106227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2107227825Stheraven { 2108227825Stheraven _T1::operator=(__p.first()); 2109227825Stheraven __second_ = __p.second(); 2110227825Stheraven return *this; 2111227825Stheraven } 2112227825Stheraven 2113227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2114227825Stheraven 2115227825Stheraven _LIBCPP_INLINE_VISIBILITY 2116227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2117227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2118227825Stheraven is_nothrow_move_constructible<_T2>::value) 2119227825Stheraven : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {} 2120227825Stheraven 2121227825Stheraven _LIBCPP_INLINE_VISIBILITY 2122227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2123227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2124227825Stheraven is_nothrow_move_assignable<_T2>::value) 2125227825Stheraven { 2126227825Stheraven _T1::operator=(_VSTD::move(__p.first())); 2127227825Stheraven __second_ = _VSTD::forward<_T2>(__p.second()); 2128227825Stheraven return *this; 2129227825Stheraven } 2130227825Stheraven 2131232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2132232950Stheraven 2133232950Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2134232950Stheraven _LIBCPP_INLINE_VISIBILITY 2135232950Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2136232950Stheraven tuple<_Args1...> __first_args, 2137232950Stheraven tuple<_Args2...> __second_args, 2138232950Stheraven __tuple_indices<_I1...>, 2139232950Stheraven __tuple_indices<_I2...>) 2140232950Stheraven : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), 2141232950Stheraven __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) 2142232950Stheraven {} 2143232950Stheraven 2144232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2145232950Stheraven 2146227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2147227825Stheraven 2148227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2149227825Stheraven 2150227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 2151227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 2152227825Stheraven 2153227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 2154227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 2155227825Stheraven 2156227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2157227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2158227825Stheraven __is_nothrow_swappable<_T1>::value) 2159227825Stheraven { 2160227825Stheraven using _VSTD::swap; 2161227825Stheraven swap(__second_, __x.__second_); 2162227825Stheraven } 2163227825Stheraven}; 2164227825Stheraven 2165227825Stheraventemplate <class _T1, class _T2> 2166227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 2> 2167227825Stheraven : private _T2 2168227825Stheraven{ 2169227825Stheravenprivate: 2170227825Stheraven _T1 __first_; 2171227825Stheravenpublic: 2172227825Stheraven typedef _T1 _T1_param; 2173227825Stheraven typedef _T2 _T2_param; 2174227825Stheraven 2175227825Stheraven typedef typename remove_reference<_T1>::type& _T1_reference; 2176227825Stheraven typedef _T2& _T2_reference; 2177227825Stheraven 2178227825Stheraven typedef const typename remove_reference<_T1>::type& _T1_const_reference; 2179227825Stheraven typedef const _T2& _T2_const_reference; 2180227825Stheraven 2181227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2182227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2183227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)) {} 2184227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2185227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)) {} 2186227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2187227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2188227825Stheraven is_nothrow_move_constructible<_T2>::value) 2189227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} 2190227825Stheraven 2191227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2192227825Stheraven 2193227825Stheraven _LIBCPP_INLINE_VISIBILITY 2194227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2195227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2196227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2197227825Stheraven : _T2(__p.second()), __first_(__p.first()) {} 2198227825Stheraven 2199227825Stheraven _LIBCPP_INLINE_VISIBILITY 2200227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2201227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2202227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2203227825Stheraven { 2204227825Stheraven _T2::operator=(__p.second()); 2205227825Stheraven __first_ = __p.first(); 2206227825Stheraven return *this; 2207227825Stheraven } 2208227825Stheraven 2209227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2210227825Stheraven 2211227825Stheraven _LIBCPP_INLINE_VISIBILITY 2212227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2213227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2214227825Stheraven is_nothrow_move_constructible<_T2>::value) 2215227825Stheraven : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {} 2216227825Stheraven 2217227825Stheraven _LIBCPP_INLINE_VISIBILITY 2218227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2219227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2220227825Stheraven is_nothrow_move_assignable<_T2>::value) 2221227825Stheraven { 2222227825Stheraven _T2::operator=(_VSTD::forward<_T2>(__p.second())); 2223227825Stheraven __first_ = _VSTD::move(__p.first()); 2224227825Stheraven return *this; 2225227825Stheraven } 2226227825Stheraven 2227232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2228232950Stheraven 2229232950Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2230232950Stheraven _LIBCPP_INLINE_VISIBILITY 2231232950Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2232232950Stheraven tuple<_Args1...> __first_args, 2233232950Stheraven tuple<_Args2...> __second_args, 2234232950Stheraven __tuple_indices<_I1...>, 2235232950Stheraven __tuple_indices<_I2...>) 2236232950Stheraven : _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...), 2237232950Stheraven __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...) 2238232950Stheraven 2239232950Stheraven {} 2240232950Stheraven 2241232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2242232950Stheraven 2243227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2244227825Stheraven 2245227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2246227825Stheraven 2247227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 2248227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 2249227825Stheraven 2250227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 2251227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 2252227825Stheraven 2253227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2254227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2255227825Stheraven __is_nothrow_swappable<_T1>::value) 2256227825Stheraven { 2257227825Stheraven using _VSTD::swap; 2258227825Stheraven swap(__first_, __x.__first_); 2259227825Stheraven } 2260227825Stheraven}; 2261227825Stheraven 2262227825Stheraventemplate <class _T1, class _T2> 2263227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 3> 2264227825Stheraven : private _T1, 2265227825Stheraven private _T2 2266227825Stheraven{ 2267227825Stheravenpublic: 2268227825Stheraven typedef _T1 _T1_param; 2269227825Stheraven typedef _T2 _T2_param; 2270227825Stheraven 2271227825Stheraven typedef _T1& _T1_reference; 2272227825Stheraven typedef _T2& _T2_reference; 2273227825Stheraven 2274227825Stheraven typedef const _T1& _T1_const_reference; 2275227825Stheraven typedef const _T2& _T2_const_reference; 2276227825Stheraven 2277227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2278227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2279227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)) {} 2280227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2281227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)) {} 2282227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2283227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} 2284227825Stheraven 2285227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2286227825Stheraven 2287227825Stheraven _LIBCPP_INLINE_VISIBILITY 2288227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2289227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2290227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2291227825Stheraven : _T1(__p.first()), _T2(__p.second()) {} 2292227825Stheraven 2293227825Stheraven _LIBCPP_INLINE_VISIBILITY 2294227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2295227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2296227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2297227825Stheraven { 2298227825Stheraven _T1::operator=(__p.first()); 2299227825Stheraven _T2::operator=(__p.second()); 2300227825Stheraven return *this; 2301227825Stheraven } 2302227825Stheraven 2303227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2304227825Stheraven 2305227825Stheraven _LIBCPP_INLINE_VISIBILITY 2306227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2307227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2308227825Stheraven is_nothrow_move_constructible<_T2>::value) 2309227825Stheraven : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {} 2310227825Stheraven 2311227825Stheraven _LIBCPP_INLINE_VISIBILITY 2312227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2313227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2314227825Stheraven is_nothrow_move_assignable<_T2>::value) 2315227825Stheraven { 2316227825Stheraven _T1::operator=(_VSTD::move(__p.first())); 2317227825Stheraven _T2::operator=(_VSTD::move(__p.second())); 2318227825Stheraven return *this; 2319227825Stheraven } 2320227825Stheraven 2321232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2322232950Stheraven 2323232950Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2324232950Stheraven _LIBCPP_INLINE_VISIBILITY 2325232950Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2326232950Stheraven tuple<_Args1...> __first_args, 2327232950Stheraven tuple<_Args2...> __second_args, 2328232950Stheraven __tuple_indices<_I1...>, 2329232950Stheraven __tuple_indices<_I2...>) 2330232950Stheraven : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), 2331232950Stheraven _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) 2332232950Stheraven {} 2333232950Stheraven 2334232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2335232950Stheraven 2336227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2337227825Stheraven 2338227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2339227825Stheraven 2340227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 2341227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 2342227825Stheraven 2343227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 2344227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 2345227825Stheraven 2346232950Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&) 2347227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2348227825Stheraven __is_nothrow_swappable<_T1>::value) 2349227825Stheraven { 2350227825Stheraven } 2351227825Stheraven}; 2352227825Stheraven 2353227825Stheraventemplate <class _T1, class _T2> 2354227825Stheravenclass __compressed_pair 2355227825Stheraven : private __libcpp_compressed_pair_imp<_T1, _T2> 2356227825Stheraven{ 2357227825Stheraven typedef __libcpp_compressed_pair_imp<_T1, _T2> base; 2358227825Stheravenpublic: 2359227825Stheraven typedef typename base::_T1_param _T1_param; 2360227825Stheraven typedef typename base::_T2_param _T2_param; 2361227825Stheraven 2362227825Stheraven typedef typename base::_T1_reference _T1_reference; 2363227825Stheraven typedef typename base::_T2_reference _T2_reference; 2364227825Stheraven 2365227825Stheraven typedef typename base::_T1_const_reference _T1_const_reference; 2366227825Stheraven typedef typename base::_T2_const_reference _T2_const_reference; 2367227825Stheraven 2368227825Stheraven _LIBCPP_INLINE_VISIBILITY __compressed_pair() {} 2369232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1) 2370227825Stheraven : base(_VSTD::forward<_T1_param>(__t1)) {} 2371232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2) 2372227825Stheraven : base(_VSTD::forward<_T2_param>(__t2)) {} 2373227825Stheraven _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) 2374227825Stheraven : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} 2375227825Stheraven 2376227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2377227825Stheraven 2378227825Stheraven _LIBCPP_INLINE_VISIBILITY 2379227825Stheraven __compressed_pair(const __compressed_pair& __p) 2380227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2381227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2382227825Stheraven : base(__p) {} 2383227825Stheraven 2384227825Stheraven _LIBCPP_INLINE_VISIBILITY 2385227825Stheraven __compressed_pair& operator=(const __compressed_pair& __p) 2386227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2387227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2388227825Stheraven { 2389227825Stheraven base::operator=(__p); 2390227825Stheraven return *this; 2391227825Stheraven } 2392227825Stheraven 2393227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2394227825Stheraven _LIBCPP_INLINE_VISIBILITY 2395227825Stheraven __compressed_pair(__compressed_pair&& __p) 2396227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2397227825Stheraven is_nothrow_move_constructible<_T2>::value) 2398227825Stheraven : base(_VSTD::move(__p)) {} 2399227825Stheraven 2400227825Stheraven _LIBCPP_INLINE_VISIBILITY 2401227825Stheraven __compressed_pair& operator=(__compressed_pair&& __p) 2402227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2403227825Stheraven is_nothrow_move_assignable<_T2>::value) 2404227825Stheraven { 2405227825Stheraven base::operator=(_VSTD::move(__p)); 2406227825Stheraven return *this; 2407227825Stheraven } 2408232950Stheraven 2409232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2410232950Stheraven 2411232950Stheraven template <class... _Args1, class... _Args2> 2412232950Stheraven _LIBCPP_INLINE_VISIBILITY 2413232950Stheraven __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, 2414232950Stheraven tuple<_Args2...> __second_args) 2415232950Stheraven : base(__pc, _VSTD::move(__first_args), _VSTD::move(__second_args), 2416232950Stheraven typename __make_tuple_indices<sizeof...(_Args1)>::type(), 2417232950Stheraven typename __make_tuple_indices<sizeof...(_Args2) >::type()) 2418232950Stheraven {} 2419232950Stheraven 2420232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2421232950Stheraven 2422227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2423227825Stheraven 2424227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2425227825Stheraven 2426227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return base::first();} 2427227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();} 2428227825Stheraven 2429227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return base::second();} 2430227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();} 2431227825Stheraven 2432227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) 2433227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2434227825Stheraven __is_nothrow_swappable<_T1>::value) 2435227825Stheraven {base::swap(__x);} 2436227825Stheraven}; 2437227825Stheraven 2438227825Stheraventemplate <class _T1, class _T2> 2439227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2440227825Stheravenvoid 2441227825Stheravenswap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) 2442227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2443227825Stheraven __is_nothrow_swappable<_T1>::value) 2444227825Stheraven {__x.swap(__y);} 2445227825Stheraven 2446232950Stheraven// __same_or_less_cv_qualified 2447232950Stheraven 2448232950Stheraventemplate <class _Ptr1, class _Ptr2, 2449232950Stheraven bool = is_same<typename remove_cv<typename pointer_traits<_Ptr1>::element_type>::type, 2450232950Stheraven typename remove_cv<typename pointer_traits<_Ptr2>::element_type>::type 2451232950Stheraven >::value 2452232950Stheraven > 2453232950Stheravenstruct __same_or_less_cv_qualified_imp 2454232950Stheraven : is_convertible<_Ptr1, _Ptr2> {}; 2455232950Stheraven 2456232950Stheraventemplate <class _Ptr1, class _Ptr2> 2457232950Stheravenstruct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false> 2458232950Stheraven : false_type {}; 2459232950Stheraven 2460232950Stheraventemplate <class _Ptr1, class _Ptr2, bool = is_scalar<_Ptr1>::value && 2461232950Stheraven !is_pointer<_Ptr1>::value> 2462232950Stheravenstruct __same_or_less_cv_qualified 2463232950Stheraven : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {}; 2464232950Stheraven 2465232950Stheraventemplate <class _Ptr1, class _Ptr2> 2466232950Stheravenstruct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true> 2467232950Stheraven : false_type {}; 2468232950Stheraven 2469232950Stheraven// default_delete 2470232950Stheraven 2471227825Stheraventemplate <class _Tp> 2472227825Stheravenstruct _LIBCPP_VISIBLE default_delete 2473227825Stheraven{ 2474241903Sdim#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2475241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; 2476241903Sdim#else 2477241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} 2478241903Sdim#endif 2479227825Stheraven template <class _Up> 2480227825Stheraven _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, 2481227825Stheraven typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 2482227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT 2483227825Stheraven { 2484227825Stheraven static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 2485227825Stheraven delete __ptr; 2486227825Stheraven } 2487227825Stheraven}; 2488227825Stheraven 2489227825Stheraventemplate <class _Tp> 2490227825Stheravenstruct _LIBCPP_VISIBLE default_delete<_Tp[]> 2491227825Stheraven{ 2492232950Stheravenpublic: 2493241903Sdim#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2494241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; 2495241903Sdim#else 2496241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} 2497241903Sdim#endif 2498232950Stheraven template <class _Up> 2499232950Stheraven _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&, 2500232950Stheraven typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 2501232950Stheraven template <class _Up> 2502232950Stheraven _LIBCPP_INLINE_VISIBILITY 2503232950Stheraven void operator() (_Up* __ptr, 2504232950Stheraven typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT 2505227825Stheraven { 2506227825Stheraven static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 2507227825Stheraven delete [] __ptr; 2508227825Stheraven } 2509227825Stheraven}; 2510227825Stheraven 2511227825Stheraventemplate <class _Tp, class _Dp = default_delete<_Tp> > 2512227825Stheravenclass _LIBCPP_VISIBLE unique_ptr 2513227825Stheraven{ 2514227825Stheravenpublic: 2515227825Stheraven typedef _Tp element_type; 2516227825Stheraven typedef _Dp deleter_type; 2517227825Stheraven typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 2518227825Stheravenprivate: 2519227825Stheraven __compressed_pair<pointer, deleter_type> __ptr_; 2520227825Stheraven 2521232950Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2522227825Stheraven unique_ptr(unique_ptr&); 2523227825Stheraven template <class _Up, class _Ep> 2524227825Stheraven unique_ptr(unique_ptr<_Up, _Ep>&); 2525227825Stheraven unique_ptr& operator=(unique_ptr&); 2526227825Stheraven template <class _Up, class _Ep> 2527227825Stheraven unique_ptr& operator=(unique_ptr<_Up, _Ep>&); 2528227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2529227825Stheraven 2530227825Stheraven struct __nat {int __for_bool_;}; 2531227825Stheraven 2532227825Stheraven typedef typename remove_reference<deleter_type>::type& _Dp_reference; 2533227825Stheraven typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 2534227825Stheravenpublic: 2535241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT 2536227825Stheraven : __ptr_(pointer()) 2537227825Stheraven { 2538227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2539227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2540227825Stheraven } 2541241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT 2542227825Stheraven : __ptr_(pointer()) 2543227825Stheraven { 2544227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2545227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2546227825Stheraven } 2547227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT 2548227825Stheraven : __ptr_(_VSTD::move(__p)) 2549227825Stheraven { 2550227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2551227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2552227825Stheraven } 2553227825Stheraven 2554227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2555227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional< 2556227825Stheraven is_reference<deleter_type>::value, 2557227825Stheraven deleter_type, 2558227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2559227825Stheraven _NOEXCEPT 2560227825Stheraven : __ptr_(__p, __d) {} 2561227825Stheraven 2562227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d) 2563227825Stheraven _NOEXCEPT 2564227825Stheraven : __ptr_(__p, _VSTD::move(__d)) 2565227825Stheraven { 2566227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2567227825Stheraven } 2568227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 2569227825Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2570227825Stheraven template <class _Up, class _Ep> 2571227825Stheraven _LIBCPP_INLINE_VISIBILITY 2572227825Stheraven unique_ptr(unique_ptr<_Up, _Ep>&& __u, 2573227825Stheraven typename enable_if 2574227825Stheraven < 2575227825Stheraven !is_array<_Up>::value && 2576227825Stheraven is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2577227825Stheraven is_convertible<_Ep, deleter_type>::value && 2578227825Stheraven ( 2579227825Stheraven !is_reference<deleter_type>::value || 2580227825Stheraven is_same<deleter_type, _Ep>::value 2581227825Stheraven ), 2582227825Stheraven __nat 2583227825Stheraven >::type = __nat()) _NOEXCEPT 2584227825Stheraven : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} 2585227825Stheraven 2586227825Stheraven template <class _Up> 2587227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, 2588227825Stheraven typename enable_if< 2589227825Stheraven is_convertible<_Up*, _Tp*>::value && 2590227825Stheraven is_same<_Dp, default_delete<_Tp> >::value, 2591227825Stheraven __nat 2592227825Stheraven >::type = __nat()) _NOEXCEPT 2593227825Stheraven : __ptr_(__p.release()) 2594227825Stheraven { 2595227825Stheraven } 2596227825Stheraven 2597227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 2598227825Stheraven { 2599227825Stheraven reset(__u.release()); 2600227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2601227825Stheraven return *this; 2602227825Stheraven } 2603227825Stheraven 2604227825Stheraven template <class _Up, class _Ep> 2605227825Stheraven _LIBCPP_INLINE_VISIBILITY 2606227825Stheraven typename enable_if 2607227825Stheraven < 2608232950Stheraven !is_array<_Up>::value && 2609232950Stheraven is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2610232950Stheraven is_assignable<deleter_type&, _Ep&&>::value, 2611227825Stheraven unique_ptr& 2612227825Stheraven >::type 2613227825Stheraven operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 2614227825Stheraven { 2615227825Stheraven reset(__u.release()); 2616227825Stheraven __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 2617227825Stheraven return *this; 2618227825Stheraven } 2619227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2620227825Stheraven 2621227825Stheraven _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 2622227825Stheraven { 2623227825Stheraven return __rv<unique_ptr>(*this); 2624227825Stheraven } 2625227825Stheraven 2626227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 2627227825Stheraven : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 2628227825Stheraven 2629227825Stheraven template <class _Up, class _Ep> 2630227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) 2631227825Stheraven { 2632227825Stheraven reset(__u.release()); 2633227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2634227825Stheraven return *this; 2635227825Stheraven } 2636227825Stheraven 2637227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 2638227825Stheraven : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {} 2639227825Stheraven 2640227825Stheraven template <class _Up> 2641227825Stheraven _LIBCPP_INLINE_VISIBILITY 2642227825Stheraven typename enable_if< 2643227825Stheraven is_convertible<_Up*, _Tp*>::value && 2644227825Stheraven is_same<_Dp, default_delete<_Tp> >::value, 2645227825Stheraven unique_ptr& 2646227825Stheraven >::type 2647227825Stheraven operator=(auto_ptr<_Up> __p) 2648227825Stheraven {reset(__p.release()); return *this;} 2649227825Stheraven 2650227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2651227825Stheraven _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 2652227825Stheraven 2653227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 2654227825Stheraven { 2655227825Stheraven reset(); 2656227825Stheraven return *this; 2657227825Stheraven } 2658227825Stheraven 2659227825Stheraven _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const 2660227825Stheraven {return *__ptr_.first();} 2661227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();} 2662227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 2663227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 2664227825Stheraven {return __ptr_.second();} 2665227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 2666227825Stheraven {return __ptr_.second();} 2667232950Stheraven _LIBCPP_INLINE_VISIBILITY 2668232950Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT 2669232950Stheraven {return __ptr_.first() != nullptr;} 2670227825Stheraven 2671227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 2672227825Stheraven { 2673227825Stheraven pointer __t = __ptr_.first(); 2674227825Stheraven __ptr_.first() = pointer(); 2675227825Stheraven return __t; 2676227825Stheraven } 2677227825Stheraven 2678227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT 2679227825Stheraven { 2680227825Stheraven pointer __tmp = __ptr_.first(); 2681227825Stheraven __ptr_.first() = __p; 2682227825Stheraven if (__tmp) 2683227825Stheraven __ptr_.second()(__tmp); 2684227825Stheraven } 2685227825Stheraven 2686227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT 2687227825Stheraven {__ptr_.swap(__u.__ptr_);} 2688227825Stheraven}; 2689227825Stheraven 2690227825Stheraventemplate <class _Tp, class _Dp> 2691227825Stheravenclass _LIBCPP_VISIBLE unique_ptr<_Tp[], _Dp> 2692227825Stheraven{ 2693227825Stheravenpublic: 2694227825Stheraven typedef _Tp element_type; 2695227825Stheraven typedef _Dp deleter_type; 2696227825Stheraven typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 2697227825Stheravenprivate: 2698227825Stheraven __compressed_pair<pointer, deleter_type> __ptr_; 2699227825Stheraven 2700232950Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2701227825Stheraven unique_ptr(unique_ptr&); 2702227825Stheraven template <class _Up> 2703227825Stheraven unique_ptr(unique_ptr<_Up>&); 2704227825Stheraven unique_ptr& operator=(unique_ptr&); 2705227825Stheraven template <class _Up> 2706227825Stheraven unique_ptr& operator=(unique_ptr<_Up>&); 2707227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2708227825Stheraven 2709227825Stheraven struct __nat {int __for_bool_;}; 2710227825Stheraven 2711227825Stheraven typedef typename remove_reference<deleter_type>::type& _Dp_reference; 2712227825Stheraven typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 2713227825Stheravenpublic: 2714241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT 2715227825Stheraven : __ptr_(pointer()) 2716227825Stheraven { 2717227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2718227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2719227825Stheraven } 2720241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT 2721227825Stheraven : __ptr_(pointer()) 2722227825Stheraven { 2723227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2724227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2725227825Stheraven } 2726227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2727232950Stheraven template <class _Pp, 2728232950Stheraven class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type 2729227825Stheraven > 2730232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT 2731227825Stheraven : __ptr_(__p) 2732227825Stheraven { 2733227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2734227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2735227825Stheraven } 2736227825Stheraven 2737232950Stheraven template <class _Pp, 2738232950Stheraven class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type 2739227825Stheraven > 2740232950Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional< 2741227825Stheraven is_reference<deleter_type>::value, 2742227825Stheraven deleter_type, 2743227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2744227825Stheraven _NOEXCEPT 2745227825Stheraven : __ptr_(__p, __d) {} 2746227825Stheraven 2747227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional< 2748227825Stheraven is_reference<deleter_type>::value, 2749227825Stheraven deleter_type, 2750227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2751227825Stheraven _NOEXCEPT 2752227825Stheraven : __ptr_(pointer(), __d) {} 2753227825Stheraven 2754232950Stheraven template <class _Pp, 2755232950Stheraven class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type 2756227825Stheraven > 2757232950Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename remove_reference<deleter_type>::type&& __d) 2758227825Stheraven _NOEXCEPT 2759227825Stheraven : __ptr_(__p, _VSTD::move(__d)) 2760227825Stheraven { 2761227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2762227825Stheraven } 2763227825Stheraven 2764227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d) 2765227825Stheraven _NOEXCEPT 2766227825Stheraven : __ptr_(pointer(), _VSTD::move(__d)) 2767227825Stheraven { 2768227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2769227825Stheraven } 2770227825Stheraven 2771227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 2772227825Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2773227825Stheraven 2774227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 2775227825Stheraven { 2776227825Stheraven reset(__u.release()); 2777227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2778227825Stheraven return *this; 2779227825Stheraven } 2780232950Stheraven 2781232950Stheraven template <class _Up, class _Ep> 2782232950Stheraven _LIBCPP_INLINE_VISIBILITY 2783232950Stheraven unique_ptr(unique_ptr<_Up, _Ep>&& __u, 2784232950Stheraven typename enable_if 2785232950Stheraven < 2786232950Stheraven is_array<_Up>::value && 2787232950Stheraven __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value 2788232950Stheraven && is_convertible<_Ep, deleter_type>::value && 2789232950Stheraven ( 2790232950Stheraven !is_reference<deleter_type>::value || 2791232950Stheraven is_same<deleter_type, _Ep>::value 2792232950Stheraven ), 2793232950Stheraven __nat 2794232950Stheraven >::type = __nat() 2795232950Stheraven ) _NOEXCEPT 2796232950Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2797232950Stheraven 2798232950Stheraven 2799232950Stheraven template <class _Up, class _Ep> 2800232950Stheraven _LIBCPP_INLINE_VISIBILITY 2801232950Stheraven typename enable_if 2802232950Stheraven < 2803232950Stheraven is_array<_Up>::value && 2804232950Stheraven __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2805232950Stheraven is_assignable<deleter_type&, _Ep&&>::value, 2806232950Stheraven unique_ptr& 2807232950Stheraven >::type 2808232950Stheraven operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 2809232950Stheraven { 2810232950Stheraven reset(__u.release()); 2811232950Stheraven __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 2812232950Stheraven return *this; 2813232950Stheraven } 2814227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2815227825Stheraven 2816227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) 2817227825Stheraven : __ptr_(__p) 2818227825Stheraven { 2819227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2820227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2821227825Stheraven } 2822227825Stheraven 2823227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 2824227825Stheraven : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {} 2825227825Stheraven 2826227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d) 2827227825Stheraven : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {} 2828227825Stheraven 2829227825Stheraven _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 2830227825Stheraven { 2831227825Stheraven return __rv<unique_ptr>(*this); 2832227825Stheraven } 2833227825Stheraven 2834227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 2835227825Stheraven : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 2836227825Stheraven 2837227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u) 2838227825Stheraven { 2839227825Stheraven reset(__u->release()); 2840227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter()); 2841227825Stheraven return *this; 2842227825Stheraven } 2843227825Stheraven 2844227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2845227825Stheraven _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 2846227825Stheraven 2847227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 2848227825Stheraven { 2849227825Stheraven reset(); 2850227825Stheraven return *this; 2851227825Stheraven } 2852227825Stheraven 2853227825Stheraven _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const 2854227825Stheraven {return __ptr_.first()[__i];} 2855227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 2856227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 2857227825Stheraven {return __ptr_.second();} 2858227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 2859227825Stheraven {return __ptr_.second();} 2860232950Stheraven _LIBCPP_INLINE_VISIBILITY 2861232950Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT 2862232950Stheraven {return __ptr_.first() != nullptr;} 2863227825Stheraven 2864227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 2865227825Stheraven { 2866227825Stheraven pointer __t = __ptr_.first(); 2867227825Stheraven __ptr_.first() = pointer(); 2868227825Stheraven return __t; 2869227825Stheraven } 2870227825Stheraven 2871227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2872232950Stheraven template <class _Pp, 2873232950Stheraven class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type 2874227825Stheraven > 2875232950Stheraven _LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT 2876227825Stheraven { 2877227825Stheraven pointer __tmp = __ptr_.first(); 2878227825Stheraven __ptr_.first() = __p; 2879227825Stheraven if (__tmp) 2880227825Stheraven __ptr_.second()(__tmp); 2881227825Stheraven } 2882227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT 2883227825Stheraven { 2884227825Stheraven pointer __tmp = __ptr_.first(); 2885227825Stheraven __ptr_.first() = nullptr; 2886227825Stheraven if (__tmp) 2887227825Stheraven __ptr_.second()(__tmp); 2888227825Stheraven } 2889227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT 2890227825Stheraven { 2891227825Stheraven pointer __tmp = __ptr_.first(); 2892227825Stheraven __ptr_.first() = nullptr; 2893227825Stheraven if (__tmp) 2894227825Stheraven __ptr_.second()(__tmp); 2895227825Stheraven } 2896227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2897227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) 2898227825Stheraven { 2899227825Stheraven pointer __tmp = __ptr_.first(); 2900227825Stheraven __ptr_.first() = __p; 2901227825Stheraven if (__tmp) 2902227825Stheraven __ptr_.second()(__tmp); 2903227825Stheraven } 2904227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2905227825Stheraven 2906227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} 2907227825Stheravenprivate: 2908227825Stheraven 2909227825Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2910227825Stheraven template <class _Up> 2911227825Stheraven explicit unique_ptr(_Up); 2912227825Stheraven template <class _Up> 2913227825Stheraven unique_ptr(_Up __u, 2914227825Stheraven typename conditional< 2915227825Stheraven is_reference<deleter_type>::value, 2916227825Stheraven deleter_type, 2917227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type, 2918227825Stheraven typename enable_if 2919227825Stheraven < 2920227825Stheraven is_convertible<_Up, pointer>::value, 2921227825Stheraven __nat 2922227825Stheraven >::type = __nat()); 2923227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2924227825Stheraven}; 2925227825Stheraven 2926227825Stheraventemplate <class _Tp, class _Dp> 2927227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2928227825Stheravenvoid 2929227825Stheravenswap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);} 2930227825Stheraven 2931227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2932227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2933227825Stheravenbool 2934227825Stheravenoperator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();} 2935227825Stheraven 2936227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2937227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2938227825Stheravenbool 2939227825Stheravenoperator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);} 2940227825Stheraven 2941227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2942227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2943227825Stheravenbool 2944232950Stheravenoperator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) 2945232950Stheraven{ 2946232950Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 2947232950Stheraven typedef typename unique_ptr<_T2, _D2>::pointer _P2; 2948232950Stheraven typedef typename common_type<_P1, _P2>::type _V; 2949232950Stheraven return less<_V>()(__x.get(), __y.get()); 2950232950Stheraven} 2951227825Stheraven 2952227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2953227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2954227825Stheravenbool 2955227825Stheravenoperator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;} 2956227825Stheraven 2957227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2958227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2959227825Stheravenbool 2960227825Stheravenoperator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);} 2961227825Stheraven 2962227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2963227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2964227825Stheravenbool 2965227825Stheravenoperator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} 2966227825Stheraven 2967232950Stheraventemplate <class _T1, class _D1> 2968232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2969232950Stheravenbool 2970241903Sdimoperator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT 2971232950Stheraven{ 2972232950Stheraven return !__x; 2973232950Stheraven} 2974232950Stheraven 2975232950Stheraventemplate <class _T1, class _D1> 2976232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2977232950Stheravenbool 2978241903Sdimoperator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT 2979232950Stheraven{ 2980232950Stheraven return !__x; 2981232950Stheraven} 2982232950Stheraven 2983232950Stheraventemplate <class _T1, class _D1> 2984232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2985232950Stheravenbool 2986241903Sdimoperator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT 2987232950Stheraven{ 2988232950Stheraven return static_cast<bool>(__x); 2989232950Stheraven} 2990232950Stheraven 2991232950Stheraventemplate <class _T1, class _D1> 2992232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2993232950Stheravenbool 2994241903Sdimoperator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT 2995232950Stheraven{ 2996232950Stheraven return static_cast<bool>(__x); 2997232950Stheraven} 2998232950Stheraven 2999232950Stheraventemplate <class _T1, class _D1> 3000232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3001232950Stheravenbool 3002232950Stheravenoperator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) 3003232950Stheraven{ 3004232950Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 3005232950Stheraven return less<_P1>()(__x.get(), nullptr); 3006232950Stheraven} 3007232950Stheraven 3008232950Stheraventemplate <class _T1, class _D1> 3009232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3010232950Stheravenbool 3011232950Stheravenoperator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3012232950Stheraven{ 3013232950Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 3014232950Stheraven return less<_P1>()(nullptr, __x.get()); 3015232950Stheraven} 3016232950Stheraven 3017232950Stheraventemplate <class _T1, class _D1> 3018232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3019232950Stheravenbool 3020232950Stheravenoperator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) 3021232950Stheraven{ 3022232950Stheraven return nullptr < __x; 3023232950Stheraven} 3024232950Stheraven 3025232950Stheraventemplate <class _T1, class _D1> 3026232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3027232950Stheravenbool 3028232950Stheravenoperator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3029232950Stheraven{ 3030232950Stheraven return __x < nullptr; 3031232950Stheraven} 3032232950Stheraven 3033232950Stheraventemplate <class _T1, class _D1> 3034232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3035232950Stheravenbool 3036232950Stheravenoperator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) 3037232950Stheraven{ 3038232950Stheraven return !(nullptr < __x); 3039232950Stheraven} 3040232950Stheraven 3041232950Stheraventemplate <class _T1, class _D1> 3042232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3043232950Stheravenbool 3044232950Stheravenoperator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3045232950Stheraven{ 3046232950Stheraven return !(__x < nullptr); 3047232950Stheraven} 3048232950Stheraven 3049232950Stheraventemplate <class _T1, class _D1> 3050232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3051232950Stheravenbool 3052232950Stheravenoperator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) 3053232950Stheraven{ 3054232950Stheraven return !(__x < nullptr); 3055232950Stheraven} 3056232950Stheraven 3057232950Stheraventemplate <class _T1, class _D1> 3058232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3059232950Stheravenbool 3060232950Stheravenoperator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3061232950Stheraven{ 3062232950Stheraven return !(nullptr < __x); 3063232950Stheraven} 3064232950Stheraven 3065234976Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3066234976Stheraven 3067234976Stheraventemplate <class _Tp, class _Dp> 3068234976Stheraveninline _LIBCPP_INLINE_VISIBILITY 3069234976Stheravenunique_ptr<_Tp, _Dp> 3070234976Stheravenmove(unique_ptr<_Tp, _Dp>& __t) 3071234976Stheraven{ 3072234976Stheraven return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t)); 3073234976Stheraven} 3074234976Stheraven 3075234976Stheraven#endif 3076234976Stheraven 3077227825Stheraventemplate <class _Tp> struct hash; 3078227825Stheraven 3079232950Stheraven// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t 3080232950Stheraven// is 64 bits. This is because cityhash64 uses 64bit x 64bit 3081232950Stheraven// multiplication, which can be very slow on 32-bit systems. 3082232950Stheraventemplate <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__> 3083232950Stheravenstruct __murmur2_or_cityhash; 3084232950Stheraven 3085232950Stheraventemplate <class _Size> 3086232950Stheravenstruct __murmur2_or_cityhash<_Size, 32> 3087227825Stheraven{ 3088232950Stheraven _Size operator()(const void* __key, _Size __len); 3089232950Stheraven}; 3090232950Stheraven 3091232950Stheraven// murmur2 3092232950Stheraventemplate <class _Size> 3093232950Stheraven_Size 3094232950Stheraven__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) 3095232950Stheraven{ 3096232950Stheraven const _Size __m = 0x5bd1e995; 3097232950Stheraven const _Size __r = 24; 3098232950Stheraven _Size __h = __len; 3099232950Stheraven const unsigned char* __data = static_cast<const unsigned char*>(__key); 3100232950Stheraven for (; __len >= 4; __data += 4, __len -= 4) 3101232950Stheraven { 3102232950Stheraven _Size __k = *(const _Size*)__data; 3103232950Stheraven __k *= __m; 3104232950Stheraven __k ^= __k >> __r; 3105232950Stheraven __k *= __m; 3106232950Stheraven __h *= __m; 3107232950Stheraven __h ^= __k; 3108232950Stheraven } 3109232950Stheraven switch (__len) 3110232950Stheraven { 3111232950Stheraven case 3: 3112232950Stheraven __h ^= __data[2] << 16; 3113232950Stheraven case 2: 3114232950Stheraven __h ^= __data[1] << 8; 3115232950Stheraven case 1: 3116232950Stheraven __h ^= __data[0]; 3117232950Stheraven __h *= __m; 3118232950Stheraven } 3119232950Stheraven __h ^= __h >> 13; 3120232950Stheraven __h *= __m; 3121232950Stheraven __h ^= __h >> 15; 3122232950Stheraven return __h; 3123232950Stheraven} 3124232950Stheraven 3125232950Stheraventemplate <class _Size> 3126232950Stheravenstruct __murmur2_or_cityhash<_Size, 64> 3127232950Stheraven{ 3128232950Stheraven _Size operator()(const void* __key, _Size __len); 3129232950Stheraven 3130232950Stheraven private: 3131232950Stheraven // Some primes between 2^63 and 2^64. 3132232950Stheraven static const _Size __k0 = 0xc3a5c85c97cb3127ULL; 3133232950Stheraven static const _Size __k1 = 0xb492b66fbe98f273ULL; 3134232950Stheraven static const _Size __k2 = 0x9ae16a3b2f90404fULL; 3135232950Stheraven static const _Size __k3 = 0xc949d7c7509e6557ULL; 3136232950Stheraven 3137232950Stheraven static _Size __rotate(_Size __val, int __shift) { 3138232950Stheraven return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); 3139232950Stheraven } 3140232950Stheraven 3141232950Stheraven static _Size __rotate_by_at_least_1(_Size __val, int __shift) { 3142232950Stheraven return (__val >> __shift) | (__val << (64 - __shift)); 3143232950Stheraven } 3144232950Stheraven 3145232950Stheraven static _Size __shift_mix(_Size __val) { 3146232950Stheraven return __val ^ (__val >> 47); 3147232950Stheraven } 3148232950Stheraven 3149232950Stheraven static _Size __hash_len_16(_Size __u, _Size __v) { 3150232950Stheraven const _Size __mul = 0x9ddfea08eb382d69ULL; 3151232950Stheraven _Size __a = (__u ^ __v) * __mul; 3152232950Stheraven __a ^= (__a >> 47); 3153232950Stheraven _Size __b = (__v ^ __a) * __mul; 3154232950Stheraven __b ^= (__b >> 47); 3155232950Stheraven __b *= __mul; 3156232950Stheraven return __b; 3157232950Stheraven } 3158232950Stheraven 3159232950Stheraven static _Size __hash_len_0_to_16(const char* __s, _Size __len) { 3160232950Stheraven if (__len > 8) { 3161232950Stheraven const _Size __a = *(const _Size*)__s; 3162232950Stheraven const _Size __b = *(const _Size*)(__s + __len - 8); 3163232950Stheraven return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; 3164232950Stheraven } 3165232950Stheraven if (__len >= 4) { 3166232950Stheraven const uint32_t __a = *(const uint32_t*)(__s); 3167232950Stheraven const uint32_t __b = *(const uint32_t*)(__s + __len - 4); 3168232950Stheraven return __hash_len_16(__len + (__a << 3), __b); 3169232950Stheraven } 3170232950Stheraven if (__len > 0) { 3171232950Stheraven const unsigned char __a = __s[0]; 3172232950Stheraven const unsigned char __b = __s[__len >> 1]; 3173232950Stheraven const unsigned char __c = __s[__len - 1]; 3174232950Stheraven const uint32_t __y = static_cast<uint32_t>(__a) + 3175232950Stheraven (static_cast<uint32_t>(__b) << 8); 3176232950Stheraven const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2); 3177232950Stheraven return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; 3178232950Stheraven } 3179232950Stheraven return __k2; 3180232950Stheraven } 3181232950Stheraven 3182232950Stheraven static _Size __hash_len_17_to_32(const char *__s, _Size __len) { 3183232950Stheraven const _Size __a = *(const _Size*)(__s) * __k1; 3184232950Stheraven const _Size __b = *(const _Size*)(__s + 8); 3185232950Stheraven const _Size __c = *(const _Size*)(__s + __len - 8) * __k2; 3186232950Stheraven const _Size __d = *(const _Size*)(__s + __len - 16) * __k0; 3187232950Stheraven return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, 3188232950Stheraven __a + __rotate(__b ^ __k3, 20) - __c + __len); 3189232950Stheraven } 3190232950Stheraven 3191232950Stheraven // Return a 16-byte hash for 48 bytes. Quick and dirty. 3192232950Stheraven // Callers do best to use "random-looking" values for a and b. 3193232950Stheraven static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 3194232950Stheraven _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) { 3195232950Stheraven __a += __w; 3196232950Stheraven __b = __rotate(__b + __a + __z, 21); 3197232950Stheraven const _Size __c = __a; 3198232950Stheraven __a += __x; 3199232950Stheraven __a += __y; 3200232950Stheraven __b += __rotate(__a, 44); 3201232950Stheraven return pair<_Size, _Size>(__a + __z, __b + __c); 3202232950Stheraven } 3203232950Stheraven 3204232950Stheraven // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. 3205232950Stheraven static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 3206232950Stheraven const char* __s, _Size __a, _Size __b) { 3207232950Stheraven return __weak_hash_len_32_with_seeds(*(const _Size*)(__s), 3208232950Stheraven *(const _Size*)(__s + 8), 3209232950Stheraven *(const _Size*)(__s + 16), 3210232950Stheraven *(const _Size*)(__s + 24), 3211232950Stheraven __a, 3212232950Stheraven __b); 3213232950Stheraven } 3214232950Stheraven 3215232950Stheraven // Return an 8-byte hash for 33 to 64 bytes. 3216232950Stheraven static _Size __hash_len_33_to_64(const char *__s, size_t __len) { 3217232950Stheraven _Size __z = *(const _Size*)(__s + 24); 3218232950Stheraven _Size __a = *(const _Size*)(__s) + 3219232950Stheraven (__len + *(const _Size*)(__s + __len - 16)) * __k0; 3220232950Stheraven _Size __b = __rotate(__a + __z, 52); 3221232950Stheraven _Size __c = __rotate(__a, 37); 3222232950Stheraven __a += *(const _Size*)(__s + 8); 3223232950Stheraven __c += __rotate(__a, 7); 3224232950Stheraven __a += *(const _Size*)(__s + 16); 3225232950Stheraven _Size __vf = __a + __z; 3226232950Stheraven _Size __vs = __b + __rotate(__a, 31) + __c; 3227232950Stheraven __a = *(const _Size*)(__s + 16) + *(const _Size*)(__s + __len - 32); 3228232950Stheraven __z += *(const _Size*)(__s + __len - 8); 3229232950Stheraven __b = __rotate(__a + __z, 52); 3230232950Stheraven __c = __rotate(__a, 37); 3231232950Stheraven __a += *(const _Size*)(__s + __len - 24); 3232232950Stheraven __c += __rotate(__a, 7); 3233232950Stheraven __a += *(const _Size*)(__s + __len - 16); 3234232950Stheraven _Size __wf = __a + __z; 3235232950Stheraven _Size __ws = __b + __rotate(__a, 31) + __c; 3236232950Stheraven _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); 3237232950Stheraven return __shift_mix(__r * __k0 + __vs) * __k2; 3238232950Stheraven } 3239232950Stheraven}; 3240232950Stheraven 3241232950Stheraven// cityhash64 3242232950Stheraventemplate <class _Size> 3243232950Stheraven_Size 3244232950Stheraven__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) 3245232950Stheraven{ 3246232950Stheraven const char* __s = static_cast<const char*>(__key); 3247232950Stheraven if (__len <= 32) { 3248232950Stheraven if (__len <= 16) { 3249232950Stheraven return __hash_len_0_to_16(__s, __len); 3250232950Stheraven } else { 3251232950Stheraven return __hash_len_17_to_32(__s, __len); 3252232950Stheraven } 3253232950Stheraven } else if (__len <= 64) { 3254232950Stheraven return __hash_len_33_to_64(__s, __len); 3255232950Stheraven } 3256232950Stheraven 3257232950Stheraven // For strings over 64 bytes we hash the end first, and then as we 3258232950Stheraven // loop we keep 56 bytes of state: v, w, x, y, and z. 3259232950Stheraven _Size __x = *(const _Size*)(__s + __len - 40); 3260232950Stheraven _Size __y = *(const _Size*)(__s + __len - 16) + 3261232950Stheraven *(const _Size*)(__s + __len - 56); 3262232950Stheraven _Size __z = __hash_len_16(*(const _Size*)(__s + __len - 48) + __len, 3263232950Stheraven *(const _Size*)(__s + __len - 24)); 3264232950Stheraven pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); 3265232950Stheraven pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); 3266232950Stheraven __x = __x * __k1 + *(const _Size*)(__s); 3267232950Stheraven 3268232950Stheraven // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. 3269232950Stheraven __len = (__len - 1) & ~static_cast<_Size>(63); 3270232950Stheraven do { 3271232950Stheraven __x = __rotate(__x + __y + __v.first + *(const _Size*)(__s + 8), 37) * __k1; 3272232950Stheraven __y = __rotate(__y + __v.second + *(const _Size*)(__s + 48), 42) * __k1; 3273232950Stheraven __x ^= __w.second; 3274232950Stheraven __y += __v.first + *(const _Size*)(__s + 40); 3275232950Stheraven __z = __rotate(__z + __w.first, 33) * __k1; 3276232950Stheraven __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); 3277232950Stheraven __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, 3278232950Stheraven __y + *(const _Size*)(__s + 16)); 3279232950Stheraven std::swap(__z, __x); 3280232950Stheraven __s += 64; 3281232950Stheraven __len -= 64; 3282232950Stheraven } while (__len != 0); 3283232950Stheraven return __hash_len_16( 3284232950Stheraven __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, 3285232950Stheraven __hash_len_16(__v.second, __w.second) + __x); 3286232950Stheraven} 3287232950Stheraven 3288232950Stheraventemplate <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> 3289232950Stheravenstruct __scalar_hash; 3290232950Stheraven 3291232950Stheraventemplate <class _Tp> 3292232950Stheravenstruct __scalar_hash<_Tp, 0> 3293232950Stheraven : public unary_function<_Tp, size_t> 3294232950Stheraven{ 3295227825Stheraven _LIBCPP_INLINE_VISIBILITY 3296232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3297227825Stheraven { 3298232950Stheraven union 3299232950Stheraven { 3300232950Stheraven _Tp __t; 3301232950Stheraven size_t __a; 3302232950Stheraven } __u; 3303232950Stheraven __u.__a = 0; 3304232950Stheraven __u.__t = __v; 3305232950Stheraven return __u.__a; 3306227825Stheraven } 3307227825Stheraven}; 3308227825Stheraven 3309232950Stheraventemplate <class _Tp> 3310232950Stheravenstruct __scalar_hash<_Tp, 1> 3311232950Stheraven : public unary_function<_Tp, size_t> 3312232950Stheraven{ 3313232950Stheraven _LIBCPP_INLINE_VISIBILITY 3314232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3315232950Stheraven { 3316232950Stheraven union 3317232950Stheraven { 3318232950Stheraven _Tp __t; 3319232950Stheraven size_t __a; 3320232950Stheraven } __u; 3321232950Stheraven __u.__t = __v; 3322232950Stheraven return __u.__a; 3323232950Stheraven } 3324232950Stheraven}; 3325232950Stheraven 3326232950Stheraventemplate <class _Tp> 3327232950Stheravenstruct __scalar_hash<_Tp, 2> 3328232950Stheraven : public unary_function<_Tp, size_t> 3329232950Stheraven{ 3330232950Stheraven _LIBCPP_INLINE_VISIBILITY 3331232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3332232950Stheraven { 3333232950Stheraven union 3334232950Stheraven { 3335232950Stheraven _Tp __t; 3336232950Stheraven struct 3337232950Stheraven { 3338232950Stheraven size_t __a; 3339232950Stheraven size_t __b; 3340232950Stheraven }; 3341232950Stheraven } __u; 3342232950Stheraven __u.__t = __v; 3343232950Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3344232950Stheraven } 3345232950Stheraven}; 3346232950Stheraven 3347232950Stheraventemplate <class _Tp> 3348232950Stheravenstruct __scalar_hash<_Tp, 3> 3349232950Stheraven : public unary_function<_Tp, size_t> 3350232950Stheraven{ 3351232950Stheraven _LIBCPP_INLINE_VISIBILITY 3352232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3353232950Stheraven { 3354232950Stheraven union 3355232950Stheraven { 3356232950Stheraven _Tp __t; 3357232950Stheraven struct 3358232950Stheraven { 3359232950Stheraven size_t __a; 3360232950Stheraven size_t __b; 3361232950Stheraven size_t __c; 3362232950Stheraven }; 3363232950Stheraven } __u; 3364232950Stheraven __u.__t = __v; 3365232950Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3366232950Stheraven } 3367232950Stheraven}; 3368232950Stheraven 3369232950Stheraventemplate <class _Tp> 3370232950Stheravenstruct __scalar_hash<_Tp, 4> 3371232950Stheraven : public unary_function<_Tp, size_t> 3372232950Stheraven{ 3373232950Stheraven _LIBCPP_INLINE_VISIBILITY 3374232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3375232950Stheraven { 3376232950Stheraven union 3377232950Stheraven { 3378232950Stheraven _Tp __t; 3379232950Stheraven struct 3380232950Stheraven { 3381232950Stheraven size_t __a; 3382232950Stheraven size_t __b; 3383232950Stheraven size_t __c; 3384232950Stheraven size_t __d; 3385232950Stheraven }; 3386232950Stheraven } __u; 3387232950Stheraven __u.__t = __v; 3388232950Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3389232950Stheraven } 3390232950Stheraven}; 3391232950Stheraven 3392232950Stheraventemplate<class _Tp> 3393232950Stheravenstruct _LIBCPP_VISIBLE hash<_Tp*> 3394241903Sdim : public unary_function<_Tp*, size_t> 3395232950Stheraven{ 3396241903Sdim _LIBCPP_INLINE_VISIBILITY 3397241903Sdim size_t operator()(_Tp* __v) const _NOEXCEPT 3398241903Sdim { 3399241903Sdim union 3400241903Sdim { 3401241903Sdim _Tp* __t; 3402241903Sdim size_t __a; 3403241903Sdim } __u; 3404241903Sdim __u.__t = __v; 3405241903Sdim return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3406241903Sdim } 3407232950Stheraven}; 3408232950Stheraven 3409227825Stheraventemplate <class _Tp, class _Dp> 3410227825Stheravenstruct _LIBCPP_VISIBLE hash<unique_ptr<_Tp, _Dp> > 3411227825Stheraven{ 3412227825Stheraven typedef unique_ptr<_Tp, _Dp> argument_type; 3413227825Stheraven typedef size_t result_type; 3414227825Stheraven _LIBCPP_INLINE_VISIBILITY 3415227825Stheraven result_type operator()(const argument_type& __ptr) const _NOEXCEPT 3416227825Stheraven { 3417227825Stheraven typedef typename argument_type::pointer pointer; 3418227825Stheraven return hash<pointer>()(__ptr.get()); 3419227825Stheraven } 3420227825Stheraven}; 3421227825Stheraven 3422227825Stheravenstruct __destruct_n 3423227825Stheraven{ 3424227825Stheravenprivate: 3425227825Stheraven size_t size; 3426227825Stheraven 3427227825Stheraven template <class _Tp> 3428227825Stheraven _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT 3429227825Stheraven {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} 3430227825Stheraven 3431227825Stheraven template <class _Tp> 3432227825Stheraven _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT 3433227825Stheraven {} 3434227825Stheraven 3435227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT 3436227825Stheraven {++size;} 3437227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT 3438227825Stheraven {} 3439227825Stheraven 3440227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT 3441227825Stheraven {size = __s;} 3442227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT 3443227825Stheraven {} 3444227825Stheravenpublic: 3445227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT 3446227825Stheraven : size(__s) {} 3447227825Stheraven 3448227825Stheraven template <class _Tp> 3449227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT 3450227825Stheraven {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3451227825Stheraven 3452227825Stheraven template <class _Tp> 3453227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT 3454227825Stheraven {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3455227825Stheraven 3456227825Stheraven template <class _Tp> 3457227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT 3458227825Stheraven {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3459227825Stheraven}; 3460227825Stheraven 3461227825Stheraventemplate <class _Alloc> 3462227825Stheravenclass __allocator_destructor 3463227825Stheraven{ 3464227825Stheraven typedef allocator_traits<_Alloc> __alloc_traits; 3465227825Stheravenpublic: 3466227825Stheraven typedef typename __alloc_traits::pointer pointer; 3467227825Stheraven typedef typename __alloc_traits::size_type size_type; 3468227825Stheravenprivate: 3469227825Stheraven _Alloc& __alloc_; 3470227825Stheraven size_type __s_; 3471227825Stheravenpublic: 3472227825Stheraven _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) 3473227825Stheraven _NOEXCEPT 3474227825Stheraven : __alloc_(__a), __s_(__s) {} 3475227825Stheraven _LIBCPP_INLINE_VISIBILITY 3476227825Stheraven void operator()(pointer __p) _NOEXCEPT 3477227825Stheraven {__alloc_traits::deallocate(__alloc_, __p, __s_);} 3478227825Stheraven}; 3479227825Stheraven 3480227825Stheraventemplate <class _InputIterator, class _ForwardIterator> 3481227825Stheraven_ForwardIterator 3482227825Stheravenuninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) 3483227825Stheraven{ 3484227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3485232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3486232950Stheraven _ForwardIterator __s = __r; 3487232950Stheraven try 3488232950Stheraven { 3489232950Stheraven#endif 3490232950Stheraven for (; __f != __l; ++__f, ++__r) 3491232950Stheraven ::new(&*__r) value_type(*__f); 3492232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3493232950Stheraven } 3494232950Stheraven catch (...) 3495232950Stheraven { 3496232950Stheraven for (; __s != __r; ++__s) 3497232950Stheraven __s->~value_type(); 3498232950Stheraven throw; 3499232950Stheraven } 3500232950Stheraven#endif 3501227825Stheraven return __r; 3502227825Stheraven} 3503227825Stheraven 3504227825Stheraventemplate <class _InputIterator, class _Size, class _ForwardIterator> 3505227825Stheraven_ForwardIterator 3506227825Stheravenuninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) 3507227825Stheraven{ 3508227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3509232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3510232950Stheraven _ForwardIterator __s = __r; 3511232950Stheraven try 3512232950Stheraven { 3513232950Stheraven#endif 3514232950Stheraven for (; __n > 0; ++__f, ++__r, --__n) 3515232950Stheraven ::new(&*__r) value_type(*__f); 3516232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3517232950Stheraven } 3518232950Stheraven catch (...) 3519232950Stheraven { 3520232950Stheraven for (; __s != __r; ++__s) 3521232950Stheraven __s->~value_type(); 3522232950Stheraven throw; 3523232950Stheraven } 3524232950Stheraven#endif 3525227825Stheraven return __r; 3526227825Stheraven} 3527227825Stheraven 3528227825Stheraventemplate <class _ForwardIterator, class _Tp> 3529227825Stheravenvoid 3530227825Stheravenuninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) 3531227825Stheraven{ 3532227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3533232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3534232950Stheraven _ForwardIterator __s = __f; 3535232950Stheraven try 3536232950Stheraven { 3537232950Stheraven#endif 3538232950Stheraven for (; __f != __l; ++__f) 3539232950Stheraven ::new(&*__f) value_type(__x); 3540232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3541232950Stheraven } 3542232950Stheraven catch (...) 3543232950Stheraven { 3544232950Stheraven for (; __s != __f; ++__s) 3545232950Stheraven __s->~value_type(); 3546232950Stheraven throw; 3547232950Stheraven } 3548232950Stheraven#endif 3549227825Stheraven} 3550227825Stheraven 3551227825Stheraventemplate <class _ForwardIterator, class _Size, class _Tp> 3552227825Stheraven_ForwardIterator 3553227825Stheravenuninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) 3554227825Stheraven{ 3555227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3556232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3557232950Stheraven _ForwardIterator __s = __f; 3558232950Stheraven try 3559232950Stheraven { 3560232950Stheraven#endif 3561232950Stheraven for (; __n > 0; ++__f, --__n) 3562232950Stheraven ::new(&*__f) value_type(__x); 3563232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3564232950Stheraven } 3565232950Stheraven catch (...) 3566232950Stheraven { 3567232950Stheraven for (; __s != __f; ++__s) 3568232950Stheraven __s->~value_type(); 3569232950Stheraven throw; 3570232950Stheraven } 3571232950Stheraven#endif 3572227825Stheraven return __f; 3573227825Stheraven} 3574227825Stheraven 3575227825Stheravenclass _LIBCPP_EXCEPTION_ABI bad_weak_ptr 3576227825Stheraven : public std::exception 3577227825Stheraven{ 3578227825Stheravenpublic: 3579227825Stheraven virtual ~bad_weak_ptr() _NOEXCEPT; 3580227825Stheraven virtual const char* what() const _NOEXCEPT; 3581227825Stheraven}; 3582227825Stheraven 3583241903Sdimtemplate<class _Tp> class _LIBCPP_VISIBLE weak_ptr; 3584227825Stheraven 3585227825Stheravenclass __shared_count 3586227825Stheraven{ 3587227825Stheraven __shared_count(const __shared_count&); 3588227825Stheraven __shared_count& operator=(const __shared_count&); 3589227825Stheraven 3590227825Stheravenprotected: 3591227825Stheraven long __shared_owners_; 3592227825Stheraven virtual ~__shared_count(); 3593227825Stheravenprivate: 3594227825Stheraven virtual void __on_zero_shared() _NOEXCEPT = 0; 3595227825Stheraven 3596227825Stheravenpublic: 3597227825Stheraven _LIBCPP_INLINE_VISIBILITY 3598227825Stheraven explicit __shared_count(long __refs = 0) _NOEXCEPT 3599227825Stheraven : __shared_owners_(__refs) {} 3600227825Stheraven 3601227825Stheraven void __add_shared() _NOEXCEPT; 3602227825Stheraven bool __release_shared() _NOEXCEPT; 3603227825Stheraven _LIBCPP_INLINE_VISIBILITY 3604227825Stheraven long use_count() const _NOEXCEPT {return __shared_owners_ + 1;} 3605227825Stheraven}; 3606227825Stheraven 3607227825Stheravenclass __shared_weak_count 3608227825Stheraven : private __shared_count 3609227825Stheraven{ 3610227825Stheraven long __shared_weak_owners_; 3611227825Stheraven 3612227825Stheravenpublic: 3613227825Stheraven _LIBCPP_INLINE_VISIBILITY 3614227825Stheraven explicit __shared_weak_count(long __refs = 0) _NOEXCEPT 3615227825Stheraven : __shared_count(__refs), 3616227825Stheraven __shared_weak_owners_(__refs) {} 3617227825Stheravenprotected: 3618227825Stheraven virtual ~__shared_weak_count(); 3619227825Stheraven 3620227825Stheravenpublic: 3621227825Stheraven void __add_shared() _NOEXCEPT; 3622227825Stheraven void __add_weak() _NOEXCEPT; 3623227825Stheraven void __release_shared() _NOEXCEPT; 3624227825Stheraven void __release_weak() _NOEXCEPT; 3625227825Stheraven _LIBCPP_INLINE_VISIBILITY 3626227825Stheraven long use_count() const _NOEXCEPT {return __shared_count::use_count();} 3627227825Stheraven __shared_weak_count* lock() _NOEXCEPT; 3628227825Stheraven 3629241903Sdim // purposefully not protected with #ifndef _LIBCPP_NO_RTTI because doing so 3630241903Sdim // breaks ABI for those clients who need to compile their projects with 3631241903Sdim // -fno-rtti and yet link against a libc++.dylib compiled without -fno-rtti. 3632227825Stheraven virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 3633227825Stheravenprivate: 3634227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT = 0; 3635227825Stheraven}; 3636227825Stheraven 3637227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3638227825Stheravenclass __shared_ptr_pointer 3639227825Stheraven : public __shared_weak_count 3640227825Stheraven{ 3641227825Stheraven __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; 3642227825Stheravenpublic: 3643227825Stheraven _LIBCPP_INLINE_VISIBILITY 3644227825Stheraven __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) 3645227825Stheraven : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {} 3646227825Stheraven 3647227825Stheraven#ifndef _LIBCPP_NO_RTTI 3648227825Stheraven virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 3649227825Stheraven#endif 3650227825Stheraven 3651227825Stheravenprivate: 3652227825Stheraven virtual void __on_zero_shared() _NOEXCEPT; 3653227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT; 3654227825Stheraven}; 3655227825Stheraven 3656227825Stheraven#ifndef _LIBCPP_NO_RTTI 3657227825Stheraven 3658227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3659227825Stheravenconst void* 3660227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT 3661227825Stheraven{ 3662227825Stheraven return __t == typeid(_Dp) ? &__data_.first().second() : 0; 3663227825Stheraven} 3664227825Stheraven 3665227825Stheraven#endif // _LIBCPP_NO_RTTI 3666227825Stheraven 3667227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3668227825Stheravenvoid 3669227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT 3670227825Stheraven{ 3671227825Stheraven __data_.first().second()(__data_.first().first()); 3672227825Stheraven __data_.first().second().~_Dp(); 3673227825Stheraven} 3674227825Stheraven 3675227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3676227825Stheravenvoid 3677227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 3678227825Stheraven{ 3679227825Stheraven typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second()); 3680227825Stheraven __data_.second().~_Alloc(); 3681227825Stheraven __a.deallocate(this, 1); 3682227825Stheraven} 3683227825Stheraven 3684227825Stheraventemplate <class _Tp, class _Alloc> 3685227825Stheravenclass __shared_ptr_emplace 3686227825Stheraven : public __shared_weak_count 3687227825Stheraven{ 3688227825Stheraven __compressed_pair<_Alloc, _Tp> __data_; 3689227825Stheravenpublic: 3690227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 3691227825Stheraven 3692227825Stheraven _LIBCPP_INLINE_VISIBILITY 3693227825Stheraven __shared_ptr_emplace(_Alloc __a) 3694227825Stheraven : __data_(_VSTD::move(__a)) {} 3695227825Stheraven 3696227825Stheraven template <class ..._Args> 3697227825Stheraven _LIBCPP_INLINE_VISIBILITY 3698227825Stheraven __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) 3699232950Stheraven : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), 3700232950Stheraven _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} 3701227825Stheraven 3702227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 3703227825Stheraven 3704227825Stheraven _LIBCPP_INLINE_VISIBILITY 3705227825Stheraven __shared_ptr_emplace(_Alloc __a) 3706227825Stheraven : __data_(__a) {} 3707227825Stheraven 3708227825Stheraven template <class _A0> 3709227825Stheraven _LIBCPP_INLINE_VISIBILITY 3710227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0) 3711227825Stheraven : __data_(__a, _Tp(__a0)) {} 3712227825Stheraven 3713227825Stheraven template <class _A0, class _A1> 3714227825Stheraven _LIBCPP_INLINE_VISIBILITY 3715227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1) 3716227825Stheraven : __data_(__a, _Tp(__a0, __a1)) {} 3717227825Stheraven 3718227825Stheraven template <class _A0, class _A1, class _A2> 3719227825Stheraven _LIBCPP_INLINE_VISIBILITY 3720227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2) 3721227825Stheraven : __data_(__a, _Tp(__a0, __a1, __a2)) {} 3722227825Stheraven 3723227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 3724227825Stheraven 3725227825Stheravenprivate: 3726227825Stheraven virtual void __on_zero_shared() _NOEXCEPT; 3727227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT; 3728227825Stheravenpublic: 3729227825Stheraven _LIBCPP_INLINE_VISIBILITY 3730227825Stheraven _Tp* get() _NOEXCEPT {return &__data_.second();} 3731227825Stheraven}; 3732227825Stheraven 3733227825Stheraventemplate <class _Tp, class _Alloc> 3734227825Stheravenvoid 3735227825Stheraven__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT 3736227825Stheraven{ 3737227825Stheraven __data_.second().~_Tp(); 3738227825Stheraven} 3739227825Stheraven 3740227825Stheraventemplate <class _Tp, class _Alloc> 3741227825Stheravenvoid 3742227825Stheraven__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 3743227825Stheraven{ 3744227825Stheraven typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first()); 3745227825Stheraven __data_.first().~_Alloc(); 3746227825Stheraven __a.deallocate(this, 1); 3747227825Stheraven} 3748227825Stheraven 3749241903Sdimtemplate<class _Tp> class _LIBCPP_VISIBLE enable_shared_from_this; 3750227825Stheraven 3751227825Stheraventemplate<class _Tp> 3752227825Stheravenclass _LIBCPP_VISIBLE shared_ptr 3753227825Stheraven{ 3754227825Stheravenpublic: 3755227825Stheraven typedef _Tp element_type; 3756227825Stheravenprivate: 3757227825Stheraven element_type* __ptr_; 3758227825Stheraven __shared_weak_count* __cntrl_; 3759227825Stheraven 3760227825Stheraven struct __nat {int __for_bool_;}; 3761227825Stheravenpublic: 3762241903Sdim _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; 3763241903Sdim _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; 3764232950Stheraven template<class _Yp, 3765232950Stheraven class = typename enable_if 3766232950Stheraven < 3767232950Stheraven is_convertible<_Yp*, element_type*>::value 3768232950Stheraven >::type 3769232950Stheraven > 3770232950Stheraven explicit shared_ptr(_Yp* __p); 3771232950Stheraven template<class _Yp, class _Dp, 3772232950Stheraven class = typename enable_if 3773232950Stheraven < 3774232950Stheraven is_convertible<_Yp*, element_type*>::value 3775232950Stheraven >::type 3776232950Stheraven > 3777232950Stheraven shared_ptr(_Yp* __p, _Dp __d); 3778232950Stheraven template<class _Yp, class _Dp, class _Alloc, 3779232950Stheraven class = typename enable_if 3780232950Stheraven < 3781232950Stheraven is_convertible<_Yp*, element_type*>::value 3782232950Stheraven >::type 3783232950Stheraven > 3784232950Stheraven shared_ptr(_Yp* __p, _Dp __d, _Alloc __a); 3785227825Stheraven template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); 3786227825Stheraven template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); 3787227825Stheraven template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; 3788227825Stheraven shared_ptr(const shared_ptr& __r) _NOEXCEPT; 3789227825Stheraven template<class _Yp> 3790227825Stheraven shared_ptr(const shared_ptr<_Yp>& __r, 3791227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 3792227825Stheraven _NOEXCEPT; 3793227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3794227825Stheraven shared_ptr(shared_ptr&& __r) _NOEXCEPT; 3795227825Stheraven template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r, 3796227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 3797227825Stheraven _NOEXCEPT; 3798227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3799227825Stheraven template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, 3800227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); 3801227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3802232950Stheraven template<class _Yp, 3803232950Stheraven class = typename enable_if 3804232950Stheraven < 3805232950Stheraven is_convertible<_Yp*, element_type*>::value 3806232950Stheraven >::type 3807232950Stheraven > 3808232950Stheraven shared_ptr(auto_ptr<_Yp>&& __r); 3809227825Stheraven#else 3810232950Stheraven template<class _Yp, 3811232950Stheraven class = typename enable_if 3812232950Stheraven < 3813232950Stheraven is_convertible<_Yp*, element_type*>::value 3814232950Stheraven >::type 3815232950Stheraven > 3816232950Stheraven shared_ptr(auto_ptr<_Yp> __r); 3817227825Stheraven#endif 3818227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3819232950Stheraven template <class _Yp, class _Dp, 3820232950Stheraven class = typename enable_if 3821232950Stheraven < 3822232950Stheraven !is_array<_Yp>::value && 3823232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value 3824232950Stheraven >::type 3825232950Stheraven > 3826232950Stheraven shared_ptr(unique_ptr<_Yp, _Dp>&&, 3827227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3828232950Stheraven template <class _Yp, class _Dp, 3829232950Stheraven class = typename enable_if 3830232950Stheraven < 3831232950Stheraven !is_array<_Yp>::value && 3832232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value 3833232950Stheraven >::type 3834232950Stheraven > 3835232950Stheraven shared_ptr(unique_ptr<_Yp, _Dp>&&, 3836227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3837227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3838232950Stheraven template <class _Yp, class _Dp, 3839232950Stheraven class = typename enable_if 3840232950Stheraven < 3841232950Stheraven !is_array<_Yp>::value && 3842232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value 3843232950Stheraven >::type 3844232950Stheraven > shared_ptr(unique_ptr<_Yp, _Dp>, 3845227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3846232950Stheraven template <class _Yp, class _Dp, 3847232950Stheraven class = typename enable_if 3848232950Stheraven < 3849232950Stheraven !is_array<_Yp>::value && 3850232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value 3851232950Stheraven >::type 3852232950Stheraven > 3853232950Stheraven shared_ptr(unique_ptr<_Yp, _Dp>, 3854227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3855227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3856227825Stheraven 3857227825Stheraven ~shared_ptr(); 3858227825Stheraven 3859227825Stheraven shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; 3860232950Stheraven template<class _Yp> 3861232950Stheraven typename enable_if 3862232950Stheraven < 3863232950Stheraven is_convertible<_Yp*, element_type*>::value, 3864232950Stheraven shared_ptr& 3865232950Stheraven >::type 3866232950Stheraven operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; 3867227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3868227825Stheraven shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; 3869232950Stheraven template<class _Yp> 3870232950Stheraven typename enable_if 3871232950Stheraven < 3872232950Stheraven is_convertible<_Yp*, element_type*>::value, 3873232950Stheraven shared_ptr<_Tp>& 3874232950Stheraven >::type 3875232950Stheraven operator=(shared_ptr<_Yp>&& __r); 3876232950Stheraven template<class _Yp> 3877232950Stheraven typename enable_if 3878232950Stheraven < 3879232950Stheraven !is_array<_Yp>::value && 3880232950Stheraven is_convertible<_Yp*, element_type*>::value, 3881232950Stheraven shared_ptr& 3882232950Stheraven >::type 3883232950Stheraven operator=(auto_ptr<_Yp>&& __r); 3884227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3885232950Stheraven template<class _Yp> 3886232950Stheraven typename enable_if 3887232950Stheraven < 3888232950Stheraven !is_array<_Yp>::value && 3889232950Stheraven is_convertible<_Yp*, element_type*>::value, 3890232950Stheraven shared_ptr& 3891232950Stheraven >::type 3892232950Stheraven operator=(auto_ptr<_Yp> __r); 3893227825Stheraven#endif 3894232950Stheraven template <class _Yp, class _Dp> 3895232950Stheraven typename enable_if 3896232950Stheraven < 3897232950Stheraven !is_array<_Yp>::value && 3898232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3899232950Stheraven shared_ptr& 3900232950Stheraven >::type 3901227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3902232950Stheraven operator=(unique_ptr<_Yp, _Dp>&& __r); 3903227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3904232950Stheraven operator=(unique_ptr<_Yp, _Dp> __r); 3905227825Stheraven#endif 3906227825Stheraven 3907227825Stheraven void swap(shared_ptr& __r) _NOEXCEPT; 3908227825Stheraven void reset() _NOEXCEPT; 3909232950Stheraven template<class _Yp> 3910232950Stheraven typename enable_if 3911232950Stheraven < 3912232950Stheraven is_convertible<_Yp*, element_type*>::value, 3913232950Stheraven void 3914232950Stheraven >::type 3915232950Stheraven reset(_Yp* __p); 3916232950Stheraven template<class _Yp, class _Dp> 3917232950Stheraven typename enable_if 3918232950Stheraven < 3919232950Stheraven is_convertible<_Yp*, element_type*>::value, 3920232950Stheraven void 3921232950Stheraven >::type 3922232950Stheraven reset(_Yp* __p, _Dp __d); 3923232950Stheraven template<class _Yp, class _Dp, class _Alloc> 3924232950Stheraven typename enable_if 3925232950Stheraven < 3926232950Stheraven is_convertible<_Yp*, element_type*>::value, 3927232950Stheraven void 3928232950Stheraven >::type 3929232950Stheraven reset(_Yp* __p, _Dp __d, _Alloc __a); 3930227825Stheraven 3931227825Stheraven _LIBCPP_INLINE_VISIBILITY 3932227825Stheraven element_type* get() const _NOEXCEPT {return __ptr_;} 3933227825Stheraven _LIBCPP_INLINE_VISIBILITY 3934227825Stheraven typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT 3935227825Stheraven {return *__ptr_;} 3936227825Stheraven _LIBCPP_INLINE_VISIBILITY 3937227825Stheraven element_type* operator->() const _NOEXCEPT {return __ptr_;} 3938227825Stheraven _LIBCPP_INLINE_VISIBILITY 3939227825Stheraven long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} 3940227825Stheraven _LIBCPP_INLINE_VISIBILITY 3941227825Stheraven bool unique() const _NOEXCEPT {return use_count() == 1;} 3942227825Stheraven _LIBCPP_INLINE_VISIBILITY 3943232950Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;} 3944232950Stheraven template <class _Up> 3945227825Stheraven _LIBCPP_INLINE_VISIBILITY 3946232950Stheraven bool owner_before(shared_ptr<_Up> const& __p) const 3947227825Stheraven {return __cntrl_ < __p.__cntrl_;} 3948232950Stheraven template <class _Up> 3949227825Stheraven _LIBCPP_INLINE_VISIBILITY 3950232950Stheraven bool owner_before(weak_ptr<_Up> const& __p) const 3951227825Stheraven {return __cntrl_ < __p.__cntrl_;} 3952241903Sdim _LIBCPP_INLINE_VISIBILITY 3953241903Sdim bool 3954241903Sdim __owner_equivalent(const shared_ptr& __p) const 3955241903Sdim {return __cntrl_ == __p.__cntrl_;} 3956227825Stheraven 3957227825Stheraven#ifndef _LIBCPP_NO_RTTI 3958227825Stheraven template <class _Dp> 3959227825Stheraven _LIBCPP_INLINE_VISIBILITY 3960227825Stheraven _Dp* __get_deleter() const _NOEXCEPT 3961227825Stheraven {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} 3962227825Stheraven#endif // _LIBCPP_NO_RTTI 3963227825Stheraven 3964227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 3965227825Stheraven 3966227825Stheraven template<class ..._Args> 3967227825Stheraven static 3968227825Stheraven shared_ptr<_Tp> 3969227825Stheraven make_shared(_Args&& ...__args); 3970227825Stheraven 3971227825Stheraven template<class _Alloc, class ..._Args> 3972227825Stheraven static 3973227825Stheraven shared_ptr<_Tp> 3974227825Stheraven allocate_shared(const _Alloc& __a, _Args&& ...__args); 3975227825Stheraven 3976227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 3977227825Stheraven 3978227825Stheraven static shared_ptr<_Tp> make_shared(); 3979227825Stheraven 3980227825Stheraven template<class _A0> 3981227825Stheraven static shared_ptr<_Tp> make_shared(_A0&); 3982227825Stheraven 3983227825Stheraven template<class _A0, class _A1> 3984227825Stheraven static shared_ptr<_Tp> make_shared(_A0&, _A1&); 3985227825Stheraven 3986227825Stheraven template<class _A0, class _A1, class _A2> 3987227825Stheraven static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&); 3988227825Stheraven 3989227825Stheraven template<class _Alloc> 3990227825Stheraven static shared_ptr<_Tp> 3991227825Stheraven allocate_shared(const _Alloc& __a); 3992227825Stheraven 3993227825Stheraven template<class _Alloc, class _A0> 3994227825Stheraven static shared_ptr<_Tp> 3995227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0); 3996227825Stheraven 3997227825Stheraven template<class _Alloc, class _A0, class _A1> 3998227825Stheraven static shared_ptr<_Tp> 3999227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1); 4000227825Stheraven 4001227825Stheraven template<class _Alloc, class _A0, class _A1, class _A2> 4002227825Stheraven static shared_ptr<_Tp> 4003227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2); 4004227825Stheraven 4005227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4006227825Stheraven 4007227825Stheravenprivate: 4008227825Stheraven 4009227825Stheraven template <class _Yp> 4010227825Stheraven _LIBCPP_INLINE_VISIBILITY 4011227825Stheraven void 4012227825Stheraven __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT 4013227825Stheraven { 4014227825Stheraven if (__e) 4015227825Stheraven __e->__weak_this_ = *this; 4016227825Stheraven } 4017227825Stheraven 4018227825Stheraven _LIBCPP_INLINE_VISIBILITY 4019227825Stheraven void __enable_weak_this(const void*) _NOEXCEPT {} 4020227825Stheraven 4021227825Stheraven template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; 4022227825Stheraven template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; 4023227825Stheraven}; 4024227825Stheraven 4025227825Stheraventemplate<class _Tp> 4026227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4027241903Sdim_LIBCPP_CONSTEXPR 4028227825Stheravenshared_ptr<_Tp>::shared_ptr() _NOEXCEPT 4029227825Stheraven : __ptr_(0), 4030227825Stheraven __cntrl_(0) 4031227825Stheraven{ 4032227825Stheraven} 4033227825Stheraven 4034227825Stheraventemplate<class _Tp> 4035227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4036241903Sdim_LIBCPP_CONSTEXPR 4037227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT 4038227825Stheraven : __ptr_(0), 4039227825Stheraven __cntrl_(0) 4040227825Stheraven{ 4041227825Stheraven} 4042227825Stheraven 4043227825Stheraventemplate<class _Tp> 4044232950Stheraventemplate<class _Yp, class> 4045227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p) 4046227825Stheraven : __ptr_(__p) 4047227825Stheraven{ 4048227825Stheraven unique_ptr<_Yp> __hold(__p); 4049227825Stheraven typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 4050227825Stheraven __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); 4051227825Stheraven __hold.release(); 4052227825Stheraven __enable_weak_this(__p); 4053227825Stheraven} 4054227825Stheraven 4055227825Stheraventemplate<class _Tp> 4056232950Stheraventemplate<class _Yp, class _Dp, class> 4057227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d) 4058227825Stheraven : __ptr_(__p) 4059227825Stheraven{ 4060227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4061227825Stheraven try 4062227825Stheraven { 4063227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4064227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 4065227825Stheraven __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); 4066227825Stheraven __enable_weak_this(__p); 4067227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4068227825Stheraven } 4069227825Stheraven catch (...) 4070227825Stheraven { 4071227825Stheraven __d(__p); 4072227825Stheraven throw; 4073227825Stheraven } 4074227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4075227825Stheraven} 4076227825Stheraven 4077227825Stheraventemplate<class _Tp> 4078227825Stheraventemplate<class _Dp> 4079227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) 4080227825Stheraven : __ptr_(0) 4081227825Stheraven{ 4082227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4083227825Stheraven try 4084227825Stheraven { 4085227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4086227825Stheraven typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; 4087227825Stheraven __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); 4088227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4089227825Stheraven } 4090227825Stheraven catch (...) 4091227825Stheraven { 4092227825Stheraven __d(__p); 4093227825Stheraven throw; 4094227825Stheraven } 4095227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4096227825Stheraven} 4097227825Stheraven 4098227825Stheraventemplate<class _Tp> 4099232950Stheraventemplate<class _Yp, class _Dp, class _Alloc, class> 4100227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) 4101227825Stheraven : __ptr_(__p) 4102227825Stheraven{ 4103227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4104227825Stheraven try 4105227825Stheraven { 4106227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4107227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; 4108227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 4109227825Stheraven typedef __allocator_destructor<_A2> _D2; 4110227825Stheraven _A2 __a2(__a); 4111227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4112227825Stheraven ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); 4113227825Stheraven __cntrl_ = __hold2.release(); 4114227825Stheraven __enable_weak_this(__p); 4115227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4116227825Stheraven } 4117227825Stheraven catch (...) 4118227825Stheraven { 4119227825Stheraven __d(__p); 4120227825Stheraven throw; 4121227825Stheraven } 4122227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4123227825Stheraven} 4124227825Stheraven 4125227825Stheraventemplate<class _Tp> 4126227825Stheraventemplate<class _Dp, class _Alloc> 4127227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) 4128227825Stheraven : __ptr_(0) 4129227825Stheraven{ 4130227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4131227825Stheraven try 4132227825Stheraven { 4133227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4134227825Stheraven typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; 4135227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 4136227825Stheraven typedef __allocator_destructor<_A2> _D2; 4137227825Stheraven _A2 __a2(__a); 4138227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4139227825Stheraven ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); 4140227825Stheraven __cntrl_ = __hold2.release(); 4141227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4142227825Stheraven } 4143227825Stheraven catch (...) 4144227825Stheraven { 4145227825Stheraven __d(__p); 4146227825Stheraven throw; 4147227825Stheraven } 4148227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4149227825Stheraven} 4150227825Stheraven 4151227825Stheraventemplate<class _Tp> 4152227825Stheraventemplate<class _Yp> 4153227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4154227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT 4155227825Stheraven : __ptr_(__p), 4156227825Stheraven __cntrl_(__r.__cntrl_) 4157227825Stheraven{ 4158227825Stheraven if (__cntrl_) 4159227825Stheraven __cntrl_->__add_shared(); 4160227825Stheraven} 4161227825Stheraven 4162227825Stheraventemplate<class _Tp> 4163227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4164227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT 4165227825Stheraven : __ptr_(__r.__ptr_), 4166227825Stheraven __cntrl_(__r.__cntrl_) 4167227825Stheraven{ 4168227825Stheraven if (__cntrl_) 4169227825Stheraven __cntrl_->__add_shared(); 4170227825Stheraven} 4171227825Stheraven 4172227825Stheraventemplate<class _Tp> 4173227825Stheraventemplate<class _Yp> 4174227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4175227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, 4176227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 4177227825Stheraven _NOEXCEPT 4178227825Stheraven : __ptr_(__r.__ptr_), 4179227825Stheraven __cntrl_(__r.__cntrl_) 4180227825Stheraven{ 4181227825Stheraven if (__cntrl_) 4182227825Stheraven __cntrl_->__add_shared(); 4183227825Stheraven} 4184227825Stheraven 4185227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4186227825Stheraven 4187227825Stheraventemplate<class _Tp> 4188227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4189227825Stheravenshared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT 4190227825Stheraven : __ptr_(__r.__ptr_), 4191227825Stheraven __cntrl_(__r.__cntrl_) 4192227825Stheraven{ 4193227825Stheraven __r.__ptr_ = 0; 4194227825Stheraven __r.__cntrl_ = 0; 4195227825Stheraven} 4196227825Stheraven 4197227825Stheraventemplate<class _Tp> 4198227825Stheraventemplate<class _Yp> 4199227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4200227825Stheravenshared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, 4201227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 4202227825Stheraven _NOEXCEPT 4203227825Stheraven : __ptr_(__r.__ptr_), 4204227825Stheraven __cntrl_(__r.__cntrl_) 4205227825Stheraven{ 4206227825Stheraven __r.__ptr_ = 0; 4207227825Stheraven __r.__cntrl_ = 0; 4208227825Stheraven} 4209227825Stheraven 4210227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4211227825Stheraven 4212227825Stheraventemplate<class _Tp> 4213232950Stheraventemplate<class _Yp, class> 4214227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4215227825Stheravenshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r) 4216227825Stheraven#else 4217227825Stheravenshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) 4218227825Stheraven#endif 4219227825Stheraven : __ptr_(__r.get()) 4220227825Stheraven{ 4221227825Stheraven typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 4222227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); 4223227825Stheraven __enable_weak_this(__r.get()); 4224227825Stheraven __r.release(); 4225227825Stheraven} 4226227825Stheraven 4227227825Stheraventemplate<class _Tp> 4228232950Stheraventemplate <class _Yp, class _Dp, class> 4229227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4230227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 4231227825Stheraven#else 4232227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 4233227825Stheraven#endif 4234227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type) 4235227825Stheraven : __ptr_(__r.get()) 4236227825Stheraven{ 4237227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 4238227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); 4239227825Stheraven __enable_weak_this(__r.get()); 4240227825Stheraven __r.release(); 4241227825Stheraven} 4242227825Stheraven 4243227825Stheraventemplate<class _Tp> 4244232950Stheraventemplate <class _Yp, class _Dp, class> 4245227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4246227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 4247227825Stheraven#else 4248227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 4249227825Stheraven#endif 4250227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type) 4251227825Stheraven : __ptr_(__r.get()) 4252227825Stheraven{ 4253227825Stheraven typedef __shared_ptr_pointer<_Yp*, 4254227825Stheraven reference_wrapper<typename remove_reference<_Dp>::type>, 4255227825Stheraven allocator<_Yp> > _CntrlBlk; 4256227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); 4257227825Stheraven __enable_weak_this(__r.get()); 4258227825Stheraven __r.release(); 4259227825Stheraven} 4260227825Stheraven 4261227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 4262227825Stheraven 4263227825Stheraventemplate<class _Tp> 4264227825Stheraventemplate<class ..._Args> 4265227825Stheravenshared_ptr<_Tp> 4266227825Stheravenshared_ptr<_Tp>::make_shared(_Args&& ...__args) 4267227825Stheraven{ 4268227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4269227825Stheraven typedef allocator<_CntrlBlk> _A2; 4270227825Stheraven typedef __allocator_destructor<_A2> _D2; 4271227825Stheraven _A2 __a2; 4272227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4273227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); 4274227825Stheraven shared_ptr<_Tp> __r; 4275227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4276227825Stheraven __r.__cntrl_ = __hold2.release(); 4277227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4278227825Stheraven return __r; 4279227825Stheraven} 4280227825Stheraven 4281227825Stheraventemplate<class _Tp> 4282227825Stheraventemplate<class _Alloc, class ..._Args> 4283227825Stheravenshared_ptr<_Tp> 4284227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) 4285227825Stheraven{ 4286227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4287227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 4288227825Stheraven typedef __allocator_destructor<_A2> _D2; 4289227825Stheraven _A2 __a2(__a); 4290227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4291227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); 4292227825Stheraven shared_ptr<_Tp> __r; 4293227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4294227825Stheraven __r.__cntrl_ = __hold2.release(); 4295227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4296227825Stheraven return __r; 4297227825Stheraven} 4298227825Stheraven 4299227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 4300227825Stheraven 4301227825Stheraventemplate<class _Tp> 4302227825Stheravenshared_ptr<_Tp> 4303227825Stheravenshared_ptr<_Tp>::make_shared() 4304227825Stheraven{ 4305227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4306227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4307227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4308227825Stheraven _Alloc2 __alloc2; 4309227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4310227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2); 4311227825Stheraven shared_ptr<_Tp> __r; 4312227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4313227825Stheraven __r.__cntrl_ = __hold2.release(); 4314227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4315227825Stheraven return __r; 4316227825Stheraven} 4317227825Stheraven 4318227825Stheraventemplate<class _Tp> 4319227825Stheraventemplate<class _A0> 4320227825Stheravenshared_ptr<_Tp> 4321227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0) 4322227825Stheraven{ 4323227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4324227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4325227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4326227825Stheraven _Alloc2 __alloc2; 4327227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4328227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); 4329227825Stheraven shared_ptr<_Tp> __r; 4330227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4331227825Stheraven __r.__cntrl_ = __hold2.release(); 4332227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4333227825Stheraven return __r; 4334227825Stheraven} 4335227825Stheraven 4336227825Stheraventemplate<class _Tp> 4337227825Stheraventemplate<class _A0, class _A1> 4338227825Stheravenshared_ptr<_Tp> 4339227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) 4340227825Stheraven{ 4341227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4342227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4343227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4344227825Stheraven _Alloc2 __alloc2; 4345227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4346227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); 4347227825Stheraven shared_ptr<_Tp> __r; 4348227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4349227825Stheraven __r.__cntrl_ = __hold2.release(); 4350227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4351227825Stheraven return __r; 4352227825Stheraven} 4353227825Stheraven 4354227825Stheraventemplate<class _Tp> 4355227825Stheraventemplate<class _A0, class _A1, class _A2> 4356227825Stheravenshared_ptr<_Tp> 4357227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) 4358227825Stheraven{ 4359227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4360227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4361227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4362227825Stheraven _Alloc2 __alloc2; 4363227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4364227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); 4365227825Stheraven shared_ptr<_Tp> __r; 4366227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4367227825Stheraven __r.__cntrl_ = __hold2.release(); 4368227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4369227825Stheraven return __r; 4370227825Stheraven} 4371227825Stheraven 4372227825Stheraventemplate<class _Tp> 4373227825Stheraventemplate<class _Alloc> 4374227825Stheravenshared_ptr<_Tp> 4375227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a) 4376227825Stheraven{ 4377227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4378227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 4379227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4380227825Stheraven _Alloc2 __alloc2(__a); 4381227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4382227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a); 4383227825Stheraven shared_ptr<_Tp> __r; 4384227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4385227825Stheraven __r.__cntrl_ = __hold2.release(); 4386227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4387227825Stheraven return __r; 4388227825Stheraven} 4389227825Stheraven 4390227825Stheraventemplate<class _Tp> 4391227825Stheraventemplate<class _Alloc, class _A0> 4392227825Stheravenshared_ptr<_Tp> 4393227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) 4394227825Stheraven{ 4395227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4396227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 4397227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4398227825Stheraven _Alloc2 __alloc2(__a); 4399227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4400227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0); 4401227825Stheraven shared_ptr<_Tp> __r; 4402227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4403227825Stheraven __r.__cntrl_ = __hold2.release(); 4404227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4405227825Stheraven return __r; 4406227825Stheraven} 4407227825Stheraven 4408227825Stheraventemplate<class _Tp> 4409227825Stheraventemplate<class _Alloc, class _A0, class _A1> 4410227825Stheravenshared_ptr<_Tp> 4411227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 4412227825Stheraven{ 4413227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4414227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 4415227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4416227825Stheraven _Alloc2 __alloc2(__a); 4417227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4418227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1); 4419227825Stheraven shared_ptr<_Tp> __r; 4420227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4421227825Stheraven __r.__cntrl_ = __hold2.release(); 4422227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4423227825Stheraven return __r; 4424227825Stheraven} 4425227825Stheraven 4426227825Stheraventemplate<class _Tp> 4427227825Stheraventemplate<class _Alloc, class _A0, class _A1, class _A2> 4428227825Stheravenshared_ptr<_Tp> 4429227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 4430227825Stheraven{ 4431227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4432227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 4433227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4434227825Stheraven _Alloc2 __alloc2(__a); 4435227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4436227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2); 4437227825Stheraven shared_ptr<_Tp> __r; 4438227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4439227825Stheraven __r.__cntrl_ = __hold2.release(); 4440227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4441227825Stheraven return __r; 4442227825Stheraven} 4443227825Stheraven 4444227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4445227825Stheraven 4446227825Stheraventemplate<class _Tp> 4447227825Stheravenshared_ptr<_Tp>::~shared_ptr() 4448227825Stheraven{ 4449227825Stheraven if (__cntrl_) 4450227825Stheraven __cntrl_->__release_shared(); 4451227825Stheraven} 4452227825Stheraven 4453227825Stheraventemplate<class _Tp> 4454227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4455227825Stheravenshared_ptr<_Tp>& 4456227825Stheravenshared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT 4457227825Stheraven{ 4458227825Stheraven shared_ptr(__r).swap(*this); 4459227825Stheraven return *this; 4460227825Stheraven} 4461227825Stheraven 4462227825Stheraventemplate<class _Tp> 4463227825Stheraventemplate<class _Yp> 4464227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4465232950Stheraventypename enable_if 4466232950Stheraven< 4467232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4468232950Stheraven shared_ptr<_Tp>& 4469232950Stheraven>::type 4470227825Stheravenshared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT 4471227825Stheraven{ 4472227825Stheraven shared_ptr(__r).swap(*this); 4473227825Stheraven return *this; 4474227825Stheraven} 4475227825Stheraven 4476227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4477227825Stheraven 4478227825Stheraventemplate<class _Tp> 4479227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4480227825Stheravenshared_ptr<_Tp>& 4481227825Stheravenshared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT 4482227825Stheraven{ 4483227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4484227825Stheraven return *this; 4485227825Stheraven} 4486227825Stheraven 4487227825Stheraventemplate<class _Tp> 4488227825Stheraventemplate<class _Yp> 4489227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4490232950Stheraventypename enable_if 4491232950Stheraven< 4492232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4493232950Stheraven shared_ptr<_Tp>& 4494232950Stheraven>::type 4495227825Stheravenshared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) 4496227825Stheraven{ 4497227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4498227825Stheraven return *this; 4499227825Stheraven} 4500227825Stheraven 4501227825Stheraventemplate<class _Tp> 4502227825Stheraventemplate<class _Yp> 4503227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4504232950Stheraventypename enable_if 4505232950Stheraven< 4506232950Stheraven !is_array<_Yp>::value && 4507232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4508232950Stheraven shared_ptr<_Tp>& 4509232950Stheraven>::type 4510227825Stheravenshared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) 4511227825Stheraven{ 4512227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4513227825Stheraven return *this; 4514227825Stheraven} 4515227825Stheraven 4516227825Stheraventemplate<class _Tp> 4517227825Stheraventemplate <class _Yp, class _Dp> 4518227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4519232950Stheraventypename enable_if 4520232950Stheraven< 4521232950Stheraven !is_array<_Yp>::value && 4522232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, 4523232950Stheraven shared_ptr<_Tp>& 4524232950Stheraven>::type 4525227825Stheravenshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) 4526227825Stheraven{ 4527227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4528227825Stheraven return *this; 4529227825Stheraven} 4530227825Stheraven 4531227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4532227825Stheraven 4533227825Stheraventemplate<class _Tp> 4534227825Stheraventemplate<class _Yp> 4535227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4536232950Stheraventypename enable_if 4537232950Stheraven< 4538232950Stheraven !is_array<_Yp>::value && 4539232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4540232950Stheraven shared_ptr<_Tp>& 4541232950Stheraven>::type 4542227825Stheravenshared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) 4543227825Stheraven{ 4544227825Stheraven shared_ptr(__r).swap(*this); 4545227825Stheraven return *this; 4546227825Stheraven} 4547227825Stheraven 4548227825Stheraventemplate<class _Tp> 4549227825Stheraventemplate <class _Yp, class _Dp> 4550227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4551232950Stheraventypename enable_if 4552232950Stheraven< 4553232950Stheraven !is_array<_Yp>::value && 4554232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, 4555232950Stheraven shared_ptr<_Tp>& 4556232950Stheraven>::type 4557227825Stheravenshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) 4558227825Stheraven{ 4559227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4560227825Stheraven return *this; 4561227825Stheraven} 4562227825Stheraven 4563227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4564227825Stheraven 4565227825Stheraventemplate<class _Tp> 4566227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4567227825Stheravenvoid 4568227825Stheravenshared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT 4569227825Stheraven{ 4570227825Stheraven _VSTD::swap(__ptr_, __r.__ptr_); 4571227825Stheraven _VSTD::swap(__cntrl_, __r.__cntrl_); 4572227825Stheraven} 4573227825Stheraven 4574227825Stheraventemplate<class _Tp> 4575227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4576227825Stheravenvoid 4577227825Stheravenshared_ptr<_Tp>::reset() _NOEXCEPT 4578227825Stheraven{ 4579227825Stheraven shared_ptr().swap(*this); 4580227825Stheraven} 4581227825Stheraven 4582227825Stheraventemplate<class _Tp> 4583227825Stheraventemplate<class _Yp> 4584227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4585232950Stheraventypename enable_if 4586232950Stheraven< 4587232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4588232950Stheraven void 4589232950Stheraven>::type 4590227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p) 4591227825Stheraven{ 4592227825Stheraven shared_ptr(__p).swap(*this); 4593227825Stheraven} 4594227825Stheraven 4595227825Stheraventemplate<class _Tp> 4596227825Stheraventemplate<class _Yp, class _Dp> 4597227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4598232950Stheraventypename enable_if 4599232950Stheraven< 4600232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4601232950Stheraven void 4602232950Stheraven>::type 4603227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) 4604227825Stheraven{ 4605227825Stheraven shared_ptr(__p, __d).swap(*this); 4606227825Stheraven} 4607227825Stheraven 4608227825Stheraventemplate<class _Tp> 4609227825Stheraventemplate<class _Yp, class _Dp, class _Alloc> 4610227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4611232950Stheraventypename enable_if 4612232950Stheraven< 4613232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4614232950Stheraven void 4615232950Stheraven>::type 4616227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) 4617227825Stheraven{ 4618227825Stheraven shared_ptr(__p, __d, __a).swap(*this); 4619227825Stheraven} 4620227825Stheraven 4621227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 4622227825Stheraven 4623227825Stheraventemplate<class _Tp, class ..._Args> 4624227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4625232950Stheraventypename enable_if 4626232950Stheraven< 4627232950Stheraven !is_array<_Tp>::value, 4628232950Stheraven shared_ptr<_Tp> 4629232950Stheraven>::type 4630227825Stheravenmake_shared(_Args&& ...__args) 4631227825Stheraven{ 4632227825Stheraven return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...); 4633227825Stheraven} 4634227825Stheraven 4635227825Stheraventemplate<class _Tp, class _Alloc, class ..._Args> 4636227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4637232950Stheraventypename enable_if 4638232950Stheraven< 4639232950Stheraven !is_array<_Tp>::value, 4640232950Stheraven shared_ptr<_Tp> 4641232950Stheraven>::type 4642227825Stheravenallocate_shared(const _Alloc& __a, _Args&& ...__args) 4643227825Stheraven{ 4644227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...); 4645227825Stheraven} 4646227825Stheraven 4647227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 4648227825Stheraven 4649227825Stheraventemplate<class _Tp> 4650227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4651227825Stheravenshared_ptr<_Tp> 4652227825Stheravenmake_shared() 4653227825Stheraven{ 4654227825Stheraven return shared_ptr<_Tp>::make_shared(); 4655227825Stheraven} 4656227825Stheraven 4657227825Stheraventemplate<class _Tp, class _A0> 4658227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4659227825Stheravenshared_ptr<_Tp> 4660227825Stheravenmake_shared(_A0& __a0) 4661227825Stheraven{ 4662227825Stheraven return shared_ptr<_Tp>::make_shared(__a0); 4663227825Stheraven} 4664227825Stheraven 4665227825Stheraventemplate<class _Tp, class _A0, class _A1> 4666227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4667227825Stheravenshared_ptr<_Tp> 4668227825Stheravenmake_shared(_A0& __a0, _A1& __a1) 4669227825Stheraven{ 4670227825Stheraven return shared_ptr<_Tp>::make_shared(__a0, __a1); 4671227825Stheraven} 4672227825Stheraven 4673227825Stheraventemplate<class _Tp, class _A0, class _A1, class _A2> 4674227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4675227825Stheravenshared_ptr<_Tp> 4676227825Stheravenmake_shared(_A0& __a0, _A1& __a1, _A2& __a2) 4677227825Stheraven{ 4678227825Stheraven return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2); 4679227825Stheraven} 4680227825Stheraven 4681227825Stheraventemplate<class _Tp, class _Alloc> 4682227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4683227825Stheravenshared_ptr<_Tp> 4684227825Stheravenallocate_shared(const _Alloc& __a) 4685227825Stheraven{ 4686227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a); 4687227825Stheraven} 4688227825Stheraven 4689227825Stheraventemplate<class _Tp, class _Alloc, class _A0> 4690227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4691227825Stheravenshared_ptr<_Tp> 4692227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0) 4693227825Stheraven{ 4694227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0); 4695227825Stheraven} 4696227825Stheraven 4697227825Stheraventemplate<class _Tp, class _Alloc, class _A0, class _A1> 4698227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4699227825Stheravenshared_ptr<_Tp> 4700227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 4701227825Stheraven{ 4702227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1); 4703227825Stheraven} 4704227825Stheraven 4705227825Stheraventemplate<class _Tp, class _Alloc, class _A0, class _A1, class _A2> 4706227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4707227825Stheravenshared_ptr<_Tp> 4708227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 4709227825Stheraven{ 4710227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2); 4711227825Stheraven} 4712227825Stheraven 4713227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4714227825Stheraven 4715227825Stheraventemplate<class _Tp, class _Up> 4716227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4717227825Stheravenbool 4718227825Stheravenoperator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4719227825Stheraven{ 4720227825Stheraven return __x.get() == __y.get(); 4721227825Stheraven} 4722227825Stheraven 4723227825Stheraventemplate<class _Tp, class _Up> 4724227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4725227825Stheravenbool 4726227825Stheravenoperator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4727227825Stheraven{ 4728227825Stheraven return !(__x == __y); 4729227825Stheraven} 4730227825Stheraven 4731227825Stheraventemplate<class _Tp, class _Up> 4732227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4733227825Stheravenbool 4734227825Stheravenoperator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4735227825Stheraven{ 4736232950Stheraven typedef typename common_type<_Tp*, _Up*>::type _V; 4737232950Stheraven return less<_V>()(__x.get(), __y.get()); 4738227825Stheraven} 4739227825Stheraven 4740232950Stheraventemplate<class _Tp, class _Up> 4741232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4742232950Stheravenbool 4743232950Stheravenoperator>(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4744232950Stheraven{ 4745232950Stheraven return __y < __x; 4746232950Stheraven} 4747232950Stheraven 4748232950Stheraventemplate<class _Tp, class _Up> 4749232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4750232950Stheravenbool 4751232950Stheravenoperator<=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4752232950Stheraven{ 4753232950Stheraven return !(__y < __x); 4754232950Stheraven} 4755232950Stheraven 4756232950Stheraventemplate<class _Tp, class _Up> 4757232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4758232950Stheravenbool 4759232950Stheravenoperator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4760232950Stheraven{ 4761232950Stheraven return !(__x < __y); 4762232950Stheraven} 4763232950Stheraven 4764227825Stheraventemplate<class _Tp> 4765227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4766232950Stheravenbool 4767232950Stheravenoperator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4768232950Stheraven{ 4769232950Stheraven return !__x; 4770232950Stheraven} 4771232950Stheraven 4772232950Stheraventemplate<class _Tp> 4773232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4774232950Stheravenbool 4775232950Stheravenoperator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4776232950Stheraven{ 4777232950Stheraven return !__x; 4778232950Stheraven} 4779232950Stheraven 4780232950Stheraventemplate<class _Tp> 4781232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4782232950Stheravenbool 4783232950Stheravenoperator!=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4784232950Stheraven{ 4785232950Stheraven return static_cast<bool>(__x); 4786232950Stheraven} 4787232950Stheraven 4788232950Stheraventemplate<class _Tp> 4789232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4790232950Stheravenbool 4791232950Stheravenoperator!=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4792232950Stheraven{ 4793232950Stheraven return static_cast<bool>(__x); 4794232950Stheraven} 4795232950Stheraven 4796232950Stheraventemplate<class _Tp> 4797232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4798232950Stheravenbool 4799232950Stheravenoperator<(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4800232950Stheraven{ 4801232950Stheraven return less<_Tp*>()(__x.get(), nullptr); 4802232950Stheraven} 4803232950Stheraven 4804232950Stheraventemplate<class _Tp> 4805232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4806232950Stheravenbool 4807232950Stheravenoperator<(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4808232950Stheraven{ 4809232950Stheraven return less<_Tp*>()(nullptr, __x.get()); 4810232950Stheraven} 4811232950Stheraven 4812232950Stheraventemplate<class _Tp> 4813232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4814232950Stheravenbool 4815232950Stheravenoperator>(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4816232950Stheraven{ 4817232950Stheraven return nullptr < __x; 4818232950Stheraven} 4819232950Stheraven 4820232950Stheraventemplate<class _Tp> 4821232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4822232950Stheravenbool 4823232950Stheravenoperator>(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4824232950Stheraven{ 4825232950Stheraven return __x < nullptr; 4826232950Stheraven} 4827232950Stheraven 4828232950Stheraventemplate<class _Tp> 4829232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4830232950Stheravenbool 4831232950Stheravenoperator<=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4832232950Stheraven{ 4833232950Stheraven return !(nullptr < __x); 4834232950Stheraven} 4835232950Stheraven 4836232950Stheraventemplate<class _Tp> 4837232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4838232950Stheravenbool 4839232950Stheravenoperator<=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4840232950Stheraven{ 4841232950Stheraven return !(__x < nullptr); 4842232950Stheraven} 4843232950Stheraven 4844232950Stheraventemplate<class _Tp> 4845232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4846232950Stheravenbool 4847232950Stheravenoperator>=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4848232950Stheraven{ 4849232950Stheraven return !(__x < nullptr); 4850232950Stheraven} 4851232950Stheraven 4852232950Stheraventemplate<class _Tp> 4853232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4854232950Stheravenbool 4855232950Stheravenoperator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4856232950Stheraven{ 4857232950Stheraven return !(nullptr < __x); 4858232950Stheraven} 4859232950Stheraven 4860232950Stheraventemplate<class _Tp> 4861232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4862227825Stheravenvoid 4863227825Stheravenswap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT 4864227825Stheraven{ 4865227825Stheraven __x.swap(__y); 4866227825Stheraven} 4867227825Stheraven 4868227825Stheraventemplate<class _Tp, class _Up> 4869227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4870232950Stheraventypename enable_if 4871232950Stheraven< 4872232950Stheraven !is_array<_Tp>::value && !is_array<_Up>::value, 4873232950Stheraven shared_ptr<_Tp> 4874232950Stheraven>::type 4875227825Stheravenstatic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 4876227825Stheraven{ 4877227825Stheraven return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); 4878227825Stheraven} 4879227825Stheraven 4880227825Stheraventemplate<class _Tp, class _Up> 4881227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4882232950Stheraventypename enable_if 4883232950Stheraven< 4884232950Stheraven !is_array<_Tp>::value && !is_array<_Up>::value, 4885232950Stheraven shared_ptr<_Tp> 4886232950Stheraven>::type 4887227825Stheravendynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 4888227825Stheraven{ 4889227825Stheraven _Tp* __p = dynamic_cast<_Tp*>(__r.get()); 4890227825Stheraven return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); 4891227825Stheraven} 4892227825Stheraven 4893227825Stheraventemplate<class _Tp, class _Up> 4894232950Stheraventypename enable_if 4895232950Stheraven< 4896232950Stheraven is_array<_Tp>::value == is_array<_Up>::value, 4897232950Stheraven shared_ptr<_Tp> 4898232950Stheraven>::type 4899227825Stheravenconst_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 4900227825Stheraven{ 4901232950Stheraven typedef typename remove_extent<_Tp>::type _RTp; 4902232950Stheraven return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); 4903227825Stheraven} 4904227825Stheraven 4905227825Stheraven#ifndef _LIBCPP_NO_RTTI 4906227825Stheraven 4907227825Stheraventemplate<class _Dp, class _Tp> 4908227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4909227825Stheraven_Dp* 4910227825Stheravenget_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT 4911227825Stheraven{ 4912227825Stheraven return __p.template __get_deleter<_Dp>(); 4913227825Stheraven} 4914227825Stheraven 4915227825Stheraven#endif // _LIBCPP_NO_RTTI 4916227825Stheraven 4917227825Stheraventemplate<class _Tp> 4918227825Stheravenclass _LIBCPP_VISIBLE weak_ptr 4919227825Stheraven{ 4920227825Stheravenpublic: 4921227825Stheraven typedef _Tp element_type; 4922227825Stheravenprivate: 4923227825Stheraven element_type* __ptr_; 4924227825Stheraven __shared_weak_count* __cntrl_; 4925227825Stheraven 4926227825Stheravenpublic: 4927241903Sdim _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; 4928227825Stheraven template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r, 4929227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 4930227825Stheraven _NOEXCEPT; 4931227825Stheraven weak_ptr(weak_ptr const& __r) _NOEXCEPT; 4932227825Stheraven template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r, 4933227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 4934227825Stheraven _NOEXCEPT; 4935227825Stheraven 4936232950Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4937232950Stheraven weak_ptr(weak_ptr&& __r) _NOEXCEPT; 4938232950Stheraven template<class _Yp> weak_ptr(weak_ptr<_Yp>&& __r, 4939232950Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 4940232950Stheraven _NOEXCEPT; 4941232950Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4942227825Stheraven ~weak_ptr(); 4943227825Stheraven 4944227825Stheraven weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; 4945232950Stheraven template<class _Yp> 4946232950Stheraven typename enable_if 4947232950Stheraven < 4948232950Stheraven is_convertible<_Yp*, element_type*>::value, 4949232950Stheraven weak_ptr& 4950232950Stheraven >::type 4951232950Stheraven operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; 4952227825Stheraven 4953232950Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4954232950Stheraven 4955232950Stheraven weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT; 4956232950Stheraven template<class _Yp> 4957232950Stheraven typename enable_if 4958232950Stheraven < 4959232950Stheraven is_convertible<_Yp*, element_type*>::value, 4960232950Stheraven weak_ptr& 4961232950Stheraven >::type 4962232950Stheraven operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT; 4963232950Stheraven 4964232950Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4965232950Stheraven 4966232950Stheraven template<class _Yp> 4967232950Stheraven typename enable_if 4968232950Stheraven < 4969232950Stheraven is_convertible<_Yp*, element_type*>::value, 4970232950Stheraven weak_ptr& 4971232950Stheraven >::type 4972232950Stheraven operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; 4973232950Stheraven 4974227825Stheraven void swap(weak_ptr& __r) _NOEXCEPT; 4975227825Stheraven void reset() _NOEXCEPT; 4976227825Stheraven 4977227825Stheraven _LIBCPP_INLINE_VISIBILITY 4978227825Stheraven long use_count() const _NOEXCEPT 4979227825Stheraven {return __cntrl_ ? __cntrl_->use_count() : 0;} 4980227825Stheraven _LIBCPP_INLINE_VISIBILITY 4981227825Stheraven bool expired() const _NOEXCEPT 4982227825Stheraven {return __cntrl_ == 0 || __cntrl_->use_count() == 0;} 4983227825Stheraven shared_ptr<_Tp> lock() const _NOEXCEPT; 4984227825Stheraven template<class _Up> 4985227825Stheraven _LIBCPP_INLINE_VISIBILITY 4986227825Stheraven bool owner_before(const shared_ptr<_Up>& __r) const 4987227825Stheraven {return __cntrl_ < __r.__cntrl_;} 4988227825Stheraven template<class _Up> 4989227825Stheraven _LIBCPP_INLINE_VISIBILITY 4990227825Stheraven bool owner_before(const weak_ptr<_Up>& __r) const 4991227825Stheraven {return __cntrl_ < __r.__cntrl_;} 4992227825Stheraven 4993227825Stheraven template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; 4994227825Stheraven template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; 4995227825Stheraven}; 4996227825Stheraven 4997227825Stheraventemplate<class _Tp> 4998227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4999241903Sdim_LIBCPP_CONSTEXPR 5000227825Stheravenweak_ptr<_Tp>::weak_ptr() _NOEXCEPT 5001227825Stheraven : __ptr_(0), 5002227825Stheraven __cntrl_(0) 5003227825Stheraven{ 5004227825Stheraven} 5005227825Stheraven 5006227825Stheraventemplate<class _Tp> 5007227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5008227825Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT 5009227825Stheraven : __ptr_(__r.__ptr_), 5010227825Stheraven __cntrl_(__r.__cntrl_) 5011227825Stheraven{ 5012227825Stheraven if (__cntrl_) 5013227825Stheraven __cntrl_->__add_weak(); 5014227825Stheraven} 5015227825Stheraven 5016227825Stheraventemplate<class _Tp> 5017227825Stheraventemplate<class _Yp> 5018227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5019227825Stheravenweak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, 5020227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5021227825Stheraven _NOEXCEPT 5022227825Stheraven : __ptr_(__r.__ptr_), 5023227825Stheraven __cntrl_(__r.__cntrl_) 5024227825Stheraven{ 5025227825Stheraven if (__cntrl_) 5026227825Stheraven __cntrl_->__add_weak(); 5027227825Stheraven} 5028227825Stheraven 5029227825Stheraventemplate<class _Tp> 5030227825Stheraventemplate<class _Yp> 5031227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5032227825Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, 5033227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5034227825Stheraven _NOEXCEPT 5035227825Stheraven : __ptr_(__r.__ptr_), 5036227825Stheraven __cntrl_(__r.__cntrl_) 5037227825Stheraven{ 5038227825Stheraven if (__cntrl_) 5039227825Stheraven __cntrl_->__add_weak(); 5040227825Stheraven} 5041227825Stheraven 5042232950Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5043232950Stheraven 5044227825Stheraventemplate<class _Tp> 5045232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 5046232950Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT 5047232950Stheraven : __ptr_(__r.__ptr_), 5048232950Stheraven __cntrl_(__r.__cntrl_) 5049232950Stheraven{ 5050232950Stheraven __r.__ptr_ = 0; 5051232950Stheraven __r.__cntrl_ = 0; 5052232950Stheraven} 5053232950Stheraven 5054232950Stheraventemplate<class _Tp> 5055232950Stheraventemplate<class _Yp> 5056232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 5057232950Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, 5058232950Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5059232950Stheraven _NOEXCEPT 5060232950Stheraven : __ptr_(__r.__ptr_), 5061232950Stheraven __cntrl_(__r.__cntrl_) 5062232950Stheraven{ 5063232950Stheraven __r.__ptr_ = 0; 5064232950Stheraven __r.__cntrl_ = 0; 5065232950Stheraven} 5066232950Stheraven 5067232950Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5068232950Stheraven 5069232950Stheraventemplate<class _Tp> 5070227825Stheravenweak_ptr<_Tp>::~weak_ptr() 5071227825Stheraven{ 5072227825Stheraven if (__cntrl_) 5073227825Stheraven __cntrl_->__release_weak(); 5074227825Stheraven} 5075227825Stheraven 5076227825Stheraventemplate<class _Tp> 5077227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5078227825Stheravenweak_ptr<_Tp>& 5079227825Stheravenweak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT 5080227825Stheraven{ 5081227825Stheraven weak_ptr(__r).swap(*this); 5082227825Stheraven return *this; 5083227825Stheraven} 5084227825Stheraven 5085227825Stheraventemplate<class _Tp> 5086227825Stheraventemplate<class _Yp> 5087227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5088232950Stheraventypename enable_if 5089232950Stheraven< 5090232950Stheraven is_convertible<_Yp*, _Tp*>::value, 5091232950Stheraven weak_ptr<_Tp>& 5092232950Stheraven>::type 5093227825Stheravenweak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT 5094227825Stheraven{ 5095227825Stheraven weak_ptr(__r).swap(*this); 5096227825Stheraven return *this; 5097227825Stheraven} 5098227825Stheraven 5099232950Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5100232950Stheraven 5101227825Stheraventemplate<class _Tp> 5102232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 5103232950Stheravenweak_ptr<_Tp>& 5104232950Stheravenweak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT 5105232950Stheraven{ 5106232950Stheraven weak_ptr(_VSTD::move(__r)).swap(*this); 5107232950Stheraven return *this; 5108232950Stheraven} 5109232950Stheraven 5110232950Stheraventemplate<class _Tp> 5111227825Stheraventemplate<class _Yp> 5112227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5113232950Stheraventypename enable_if 5114232950Stheraven< 5115232950Stheraven is_convertible<_Yp*, _Tp*>::value, 5116232950Stheraven weak_ptr<_Tp>& 5117232950Stheraven>::type 5118232950Stheravenweak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT 5119232950Stheraven{ 5120232950Stheraven weak_ptr(_VSTD::move(__r)).swap(*this); 5121232950Stheraven return *this; 5122232950Stheraven} 5123232950Stheraven 5124232950Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5125232950Stheraven 5126232950Stheraventemplate<class _Tp> 5127232950Stheraventemplate<class _Yp> 5128232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 5129232950Stheraventypename enable_if 5130232950Stheraven< 5131232950Stheraven is_convertible<_Yp*, _Tp*>::value, 5132232950Stheraven weak_ptr<_Tp>& 5133232950Stheraven>::type 5134227825Stheravenweak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT 5135227825Stheraven{ 5136227825Stheraven weak_ptr(__r).swap(*this); 5137227825Stheraven return *this; 5138227825Stheraven} 5139227825Stheraven 5140227825Stheraventemplate<class _Tp> 5141227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5142227825Stheravenvoid 5143227825Stheravenweak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT 5144227825Stheraven{ 5145227825Stheraven _VSTD::swap(__ptr_, __r.__ptr_); 5146227825Stheraven _VSTD::swap(__cntrl_, __r.__cntrl_); 5147227825Stheraven} 5148227825Stheraven 5149227825Stheraventemplate<class _Tp> 5150227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5151227825Stheravenvoid 5152227825Stheravenswap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT 5153227825Stheraven{ 5154227825Stheraven __x.swap(__y); 5155227825Stheraven} 5156227825Stheraven 5157227825Stheraventemplate<class _Tp> 5158227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5159227825Stheravenvoid 5160227825Stheravenweak_ptr<_Tp>::reset() _NOEXCEPT 5161227825Stheraven{ 5162227825Stheraven weak_ptr().swap(*this); 5163227825Stheraven} 5164227825Stheraven 5165227825Stheraventemplate<class _Tp> 5166227825Stheraventemplate<class _Yp> 5167227825Stheravenshared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, 5168227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 5169227825Stheraven : __ptr_(__r.__ptr_), 5170227825Stheraven __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) 5171227825Stheraven{ 5172227825Stheraven if (__cntrl_ == 0) 5173227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 5174227825Stheraven throw bad_weak_ptr(); 5175227825Stheraven#else 5176227825Stheraven assert(!"bad_weak_ptr"); 5177227825Stheraven#endif 5178227825Stheraven} 5179227825Stheraven 5180227825Stheraventemplate<class _Tp> 5181227825Stheravenshared_ptr<_Tp> 5182227825Stheravenweak_ptr<_Tp>::lock() const _NOEXCEPT 5183227825Stheraven{ 5184227825Stheraven shared_ptr<_Tp> __r; 5185227825Stheraven __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_; 5186227825Stheraven if (__r.__cntrl_) 5187227825Stheraven __r.__ptr_ = __ptr_; 5188227825Stheraven return __r; 5189227825Stheraven} 5190227825Stheraven 5191227825Stheraventemplate <class _Tp> struct owner_less; 5192227825Stheraven 5193227825Stheraventemplate <class _Tp> 5194227825Stheravenstruct _LIBCPP_VISIBLE owner_less<shared_ptr<_Tp> > 5195227825Stheraven : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> 5196227825Stheraven{ 5197227825Stheraven typedef bool result_type; 5198227825Stheraven _LIBCPP_INLINE_VISIBILITY 5199227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5200227825Stheraven {return __x.owner_before(__y);} 5201227825Stheraven _LIBCPP_INLINE_VISIBILITY 5202227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5203227825Stheraven {return __x.owner_before(__y);} 5204227825Stheraven _LIBCPP_INLINE_VISIBILITY 5205227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5206227825Stheraven {return __x.owner_before(__y);} 5207227825Stheraven}; 5208227825Stheraven 5209227825Stheraventemplate <class _Tp> 5210227825Stheravenstruct _LIBCPP_VISIBLE owner_less<weak_ptr<_Tp> > 5211227825Stheraven : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> 5212227825Stheraven{ 5213227825Stheraven typedef bool result_type; 5214227825Stheraven _LIBCPP_INLINE_VISIBILITY 5215227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5216227825Stheraven {return __x.owner_before(__y);} 5217227825Stheraven _LIBCPP_INLINE_VISIBILITY 5218227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5219227825Stheraven {return __x.owner_before(__y);} 5220227825Stheraven _LIBCPP_INLINE_VISIBILITY 5221227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5222227825Stheraven {return __x.owner_before(__y);} 5223227825Stheraven}; 5224227825Stheraven 5225227825Stheraventemplate<class _Tp> 5226227825Stheravenclass _LIBCPP_VISIBLE enable_shared_from_this 5227227825Stheraven{ 5228227825Stheraven mutable weak_ptr<_Tp> __weak_this_; 5229227825Stheravenprotected: 5230241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 5231227825Stheraven enable_shared_from_this() _NOEXCEPT {} 5232227825Stheraven _LIBCPP_INLINE_VISIBILITY 5233227825Stheraven enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {} 5234227825Stheraven _LIBCPP_INLINE_VISIBILITY 5235227825Stheraven enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT 5236227825Stheraven {return *this;} 5237227825Stheraven _LIBCPP_INLINE_VISIBILITY 5238227825Stheraven ~enable_shared_from_this() {} 5239227825Stheravenpublic: 5240227825Stheraven _LIBCPP_INLINE_VISIBILITY 5241227825Stheraven shared_ptr<_Tp> shared_from_this() 5242227825Stheraven {return shared_ptr<_Tp>(__weak_this_);} 5243227825Stheraven _LIBCPP_INLINE_VISIBILITY 5244227825Stheraven shared_ptr<_Tp const> shared_from_this() const 5245227825Stheraven {return shared_ptr<const _Tp>(__weak_this_);} 5246227825Stheraven 5247227825Stheraven template <class _Up> friend class shared_ptr; 5248227825Stheraven}; 5249227825Stheraven 5250227825Stheraventemplate <class _Tp> 5251227825Stheravenstruct _LIBCPP_VISIBLE hash<shared_ptr<_Tp> > 5252227825Stheraven{ 5253227825Stheraven typedef shared_ptr<_Tp> argument_type; 5254227825Stheraven typedef size_t result_type; 5255227825Stheraven _LIBCPP_INLINE_VISIBILITY 5256227825Stheraven result_type operator()(const argument_type& __ptr) const _NOEXCEPT 5257227825Stheraven { 5258227825Stheraven return hash<_Tp*>()(__ptr.get()); 5259227825Stheraven } 5260227825Stheraven}; 5261227825Stheraven 5262232950Stheraventemplate<class _CharT, class _Traits, class _Yp> 5263227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5264227825Stheravenbasic_ostream<_CharT, _Traits>& 5265232950Stheravenoperator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); 5266227825Stheraven 5267241903Sdim#if __has_feature(cxx_atomic) 5268241903Sdim 5269241903Sdimclass __sp_mut 5270241903Sdim{ 5271242945Stheraven void* __lx; 5272241903Sdimpublic: 5273241903Sdim void lock() _NOEXCEPT; 5274241903Sdim void unlock() _NOEXCEPT; 5275241903Sdim 5276241903Sdimprivate: 5277241903Sdim _LIBCPP_CONSTEXPR __sp_mut(void*) _NOEXCEPT; 5278241903Sdim __sp_mut(const __sp_mut&); 5279241903Sdim __sp_mut& operator=(const __sp_mut&); 5280241903Sdim 5281241903Sdim friend _LIBCPP_VISIBLE __sp_mut& __get_sp_mut(const void*); 5282241903Sdim}; 5283241903Sdim 5284241903Sdim_LIBCPP_VISIBLE __sp_mut& __get_sp_mut(const void*); 5285241903Sdim 5286241903Sdimtemplate <class _Tp> 5287241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5288241903Sdimbool 5289241903Sdimatomic_is_lock_free(const shared_ptr<_Tp>*) 5290241903Sdim{ 5291241903Sdim return false; 5292241903Sdim} 5293241903Sdim 5294241903Sdimtemplate <class _Tp> 5295241903Sdimshared_ptr<_Tp> 5296241903Sdimatomic_load(const shared_ptr<_Tp>* __p) 5297241903Sdim{ 5298241903Sdim __sp_mut& __m = __get_sp_mut(__p); 5299241903Sdim __m.lock(); 5300241903Sdim shared_ptr<_Tp> __q = *__p; 5301241903Sdim __m.unlock(); 5302241903Sdim return __q; 5303241903Sdim} 5304241903Sdim 5305241903Sdimtemplate <class _Tp> 5306241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5307241903Sdimshared_ptr<_Tp> 5308241903Sdimatomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) 5309241903Sdim{ 5310241903Sdim return atomic_load(__p); 5311241903Sdim} 5312241903Sdim 5313241903Sdimtemplate <class _Tp> 5314241903Sdimvoid 5315241903Sdimatomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) 5316241903Sdim{ 5317241903Sdim __sp_mut& __m = __get_sp_mut(__p); 5318241903Sdim __m.lock(); 5319241903Sdim __p->swap(__r); 5320241903Sdim __m.unlock(); 5321241903Sdim} 5322241903Sdim 5323241903Sdimtemplate <class _Tp> 5324241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5325241903Sdimvoid 5326241903Sdimatomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) 5327241903Sdim{ 5328241903Sdim atomic_store(__p, __r); 5329241903Sdim} 5330241903Sdim 5331241903Sdimtemplate <class _Tp> 5332241903Sdimshared_ptr<_Tp> 5333241903Sdimatomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) 5334241903Sdim{ 5335241903Sdim __sp_mut& __m = __get_sp_mut(__p); 5336241903Sdim __m.lock(); 5337241903Sdim __p->swap(__r); 5338241903Sdim __m.unlock(); 5339241903Sdim return __r; 5340241903Sdim} 5341241903Sdim 5342241903Sdimtemplate <class _Tp> 5343241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5344241903Sdimshared_ptr<_Tp> 5345241903Sdimatomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) 5346241903Sdim{ 5347241903Sdim return atomic_exchange(__p, __r); 5348241903Sdim} 5349241903Sdim 5350241903Sdimtemplate <class _Tp> 5351241903Sdimbool 5352241903Sdimatomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) 5353241903Sdim{ 5354241903Sdim __sp_mut& __m = __get_sp_mut(__p); 5355241903Sdim __m.lock(); 5356241903Sdim if (__p->__owner_equivalent(*__v)) 5357241903Sdim { 5358241903Sdim *__p = __w; 5359241903Sdim __m.unlock(); 5360241903Sdim return true; 5361241903Sdim } 5362241903Sdim *__v = *__p; 5363241903Sdim __m.unlock(); 5364241903Sdim return false; 5365241903Sdim} 5366241903Sdim 5367241903Sdimtemplate <class _Tp> 5368241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5369241903Sdimbool 5370241903Sdimatomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) 5371241903Sdim{ 5372241903Sdim return atomic_compare_exchange_strong(__p, __v, __w); 5373241903Sdim} 5374241903Sdim 5375241903Sdimtemplate <class _Tp> 5376241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5377241903Sdimbool 5378241903Sdimatomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, 5379241903Sdim shared_ptr<_Tp> __w, memory_order, memory_order) 5380241903Sdim{ 5381241903Sdim return atomic_compare_exchange_strong(__p, __v, __w); 5382241903Sdim} 5383241903Sdim 5384241903Sdimtemplate <class _Tp> 5385241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5386241903Sdimbool 5387241903Sdimatomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, 5388241903Sdim shared_ptr<_Tp> __w, memory_order, memory_order) 5389241903Sdim{ 5390241903Sdim return atomic_compare_exchange_weak(__p, __v, __w); 5391241903Sdim} 5392241903Sdim 5393241903Sdim#endif // __has_feature(cxx_atomic) 5394241903Sdim 5395227825Stheraven//enum class 5396227825Stheravenstruct _LIBCPP_VISIBLE pointer_safety 5397227825Stheraven{ 5398242945Stheraven enum __lx 5399227825Stheraven { 5400227825Stheraven relaxed, 5401227825Stheraven preferred, 5402227825Stheraven strict 5403227825Stheraven }; 5404227825Stheraven 5405242945Stheraven __lx __v_; 5406227825Stheraven 5407227825Stheraven _LIBCPP_INLINE_VISIBILITY 5408242945Stheraven pointer_safety(__lx __v) : __v_(__v) {} 5409227825Stheraven _LIBCPP_INLINE_VISIBILITY 5410227825Stheraven operator int() const {return __v_;} 5411227825Stheraven}; 5412227825Stheraven 5413227825Stheravenvoid declare_reachable(void* __p); 5414227825Stheravenvoid declare_no_pointers(char* __p, size_t __n); 5415227825Stheravenvoid undeclare_no_pointers(char* __p, size_t __n); 5416227825Stheravenpointer_safety get_pointer_safety() _NOEXCEPT; 5417227825Stheravenvoid* __undeclare_reachable(void* __p); 5418227825Stheraven 5419227825Stheraventemplate <class _Tp> 5420227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5421227825Stheraven_Tp* 5422227825Stheravenundeclare_reachable(_Tp* __p) 5423227825Stheraven{ 5424227825Stheraven return static_cast<_Tp*>(__undeclare_reachable(__p)); 5425227825Stheraven} 5426227825Stheraven 5427227825Stheravenvoid* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); 5428227825Stheraven 5429227825Stheraven_LIBCPP_END_NAMESPACE_STD 5430227825Stheraven 5431227825Stheraven#endif // _LIBCPP_MEMORY 5432