memory revision 288943
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; 78288943Sdim typedef Alloc::is_always_equal 79288943Sdim | is_empty is_always_equal; 80227825Stheraven 81227825Stheraven template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>; 82227825Stheraven template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; 83227825Stheraven 84227825Stheraven static pointer allocate(allocator_type& a, size_type n); 85227825Stheraven static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); 86227825Stheraven 87227825Stheraven static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; 88227825Stheraven 89227825Stheraven template <class T, class... Args> 90227825Stheraven static void construct(allocator_type& a, T* p, Args&&... args); 91227825Stheraven 92227825Stheraven template <class T> 93227825Stheraven static void destroy(allocator_type& a, T* p); 94227825Stheraven 95261272Sdim static size_type max_size(const allocator_type& a); // noexcept in C++14 96227825Stheraven 97227825Stheraven static allocator_type 98227825Stheraven select_on_container_copy_construction(const allocator_type& a); 99227825Stheraven}; 100227825Stheraven 101227825Stheraventemplate <> 102227825Stheravenclass allocator<void> 103227825Stheraven{ 104227825Stheravenpublic: 105227825Stheraven typedef void* pointer; 106227825Stheraven typedef const void* const_pointer; 107227825Stheraven typedef void value_type; 108227825Stheraven 109227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 110227825Stheraven}; 111227825Stheraven 112227825Stheraventemplate <class T> 113227825Stheravenclass allocator 114227825Stheraven{ 115227825Stheravenpublic: 116227825Stheraven typedef size_t size_type; 117227825Stheraven typedef ptrdiff_t difference_type; 118227825Stheraven typedef T* pointer; 119227825Stheraven typedef const T* const_pointer; 120227825Stheraven typedef typename add_lvalue_reference<T>::type reference; 121227825Stheraven typedef typename add_lvalue_reference<const T>::type const_reference; 122227825Stheraven typedef T value_type; 123227825Stheraven 124227825Stheraven template <class U> struct rebind {typedef allocator<U> other;}; 125227825Stheraven 126227825Stheraven allocator() noexcept; 127227825Stheraven allocator(const allocator&) noexcept; 128227825Stheraven template <class U> allocator(const allocator<U>&) noexcept; 129227825Stheraven ~allocator(); 130227825Stheraven pointer address(reference x) const noexcept; 131227825Stheraven const_pointer address(const_reference x) const noexcept; 132227825Stheraven pointer allocate(size_type, allocator<void>::const_pointer hint = 0); 133227825Stheraven void deallocate(pointer p, size_type n) noexcept; 134227825Stheraven size_type max_size() const noexcept; 135227825Stheraven template<class U, class... Args> 136227825Stheraven void construct(U* p, Args&&... args); 137227825Stheraven template <class U> 138227825Stheraven void destroy(U* p); 139227825Stheraven}; 140227825Stheraven 141227825Stheraventemplate <class T, class U> 142227825Stheravenbool operator==(const allocator<T>&, const allocator<U>&) noexcept; 143227825Stheraven 144227825Stheraventemplate <class T, class U> 145227825Stheravenbool operator!=(const allocator<T>&, const allocator<U>&) noexcept; 146227825Stheraven 147227825Stheraventemplate <class OutputIterator, class T> 148227825Stheravenclass raw_storage_iterator 149227825Stheraven : public iterator<output_iterator_tag, 150227825Stheraven T, // purposefully not C++03 151227825Stheraven ptrdiff_t, // purposefully not C++03 152227825Stheraven T*, // purposefully not C++03 153227825Stheraven raw_storage_iterator&> // purposefully not C++03 154227825Stheraven{ 155227825Stheravenpublic: 156227825Stheraven explicit raw_storage_iterator(OutputIterator x); 157227825Stheraven raw_storage_iterator& operator*(); 158227825Stheraven raw_storage_iterator& operator=(const T& element); 159227825Stheraven raw_storage_iterator& operator++(); 160227825Stheraven raw_storage_iterator operator++(int); 161227825Stheraven}; 162227825Stheraven 163227825Stheraventemplate <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; 164227825Stheraventemplate <class T> void return_temporary_buffer(T* p) noexcept; 165227825Stheraven 166227825Stheraventemplate <class T> T* addressof(T& r) noexcept; 167227825Stheraven 168227825Stheraventemplate <class InputIterator, class ForwardIterator> 169227825StheravenForwardIterator 170227825Stheravenuninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); 171227825Stheraven 172227825Stheraventemplate <class InputIterator, class Size, class ForwardIterator> 173227825StheravenForwardIterator 174227825Stheravenuninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); 175227825Stheraven 176227825Stheraventemplate <class ForwardIterator, class T> 177227825Stheravenvoid uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); 178227825Stheraven 179227825Stheraventemplate <class ForwardIterator, class Size, class T> 180227825StheravenForwardIterator 181227825Stheravenuninitialized_fill_n(ForwardIterator first, Size n, const T& x); 182227825Stheraven 183227825Stheraventemplate <class Y> struct auto_ptr_ref {}; 184227825Stheraven 185227825Stheraventemplate<class X> 186227825Stheravenclass auto_ptr 187227825Stheraven{ 188227825Stheravenpublic: 189227825Stheraven typedef X element_type; 190227825Stheraven 191227825Stheraven explicit auto_ptr(X* p =0) throw(); 192227825Stheraven auto_ptr(auto_ptr&) throw(); 193227825Stheraven template<class Y> auto_ptr(auto_ptr<Y>&) throw(); 194227825Stheraven auto_ptr& operator=(auto_ptr&) throw(); 195227825Stheraven template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw(); 196227825Stheraven auto_ptr& operator=(auto_ptr_ref<X> r) throw(); 197227825Stheraven ~auto_ptr() throw(); 198227825Stheraven 199227825Stheraven typename add_lvalue_reference<X>::type operator*() const throw(); 200227825Stheraven X* operator->() const throw(); 201227825Stheraven X* get() const throw(); 202227825Stheraven X* release() throw(); 203227825Stheraven void reset(X* p =0) throw(); 204227825Stheraven 205227825Stheraven auto_ptr(auto_ptr_ref<X>) throw(); 206227825Stheraven template<class Y> operator auto_ptr_ref<Y>() throw(); 207227825Stheraven template<class Y> operator auto_ptr<Y>() throw(); 208227825Stheraven}; 209227825Stheraven 210227825Stheraventemplate <class T> 211227825Stheravenstruct default_delete 212227825Stheraven{ 213227825Stheraven constexpr default_delete() noexcept = default; 214227825Stheraven template <class U> default_delete(const default_delete<U>&) noexcept; 215227825Stheraven 216227825Stheraven void operator()(T*) const noexcept; 217227825Stheraven}; 218227825Stheraven 219227825Stheraventemplate <class T> 220227825Stheravenstruct default_delete<T[]> 221227825Stheraven{ 222227825Stheraven constexpr default_delete() noexcept = default; 223227825Stheraven void operator()(T*) const noexcept; 224227825Stheraven template <class U> void operator()(U*) const = delete; 225227825Stheraven}; 226227825Stheraven 227227825Stheraventemplate <class T, class D = default_delete<T>> 228227825Stheravenclass unique_ptr 229227825Stheraven{ 230227825Stheravenpublic: 231227825Stheraven typedef see below pointer; 232227825Stheraven typedef T element_type; 233227825Stheraven typedef D deleter_type; 234227825Stheraven 235227825Stheraven // constructors 236227825Stheraven constexpr unique_ptr() noexcept; 237227825Stheraven explicit unique_ptr(pointer p) noexcept; 238227825Stheraven unique_ptr(pointer p, see below d1) noexcept; 239227825Stheraven unique_ptr(pointer p, see below d2) noexcept; 240227825Stheraven unique_ptr(unique_ptr&& u) noexcept; 241227825Stheraven unique_ptr(nullptr_t) noexcept : unique_ptr() { } 242227825Stheraven template <class U, class E> 243227825Stheraven unique_ptr(unique_ptr<U, E>&& u) noexcept; 244227825Stheraven template <class U> 245227825Stheraven unique_ptr(auto_ptr<U>&& u) noexcept; 246227825Stheraven 247227825Stheraven // destructor 248227825Stheraven ~unique_ptr(); 249227825Stheraven 250227825Stheraven // assignment 251227825Stheraven unique_ptr& operator=(unique_ptr&& u) noexcept; 252227825Stheraven template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept; 253227825Stheraven unique_ptr& operator=(nullptr_t) noexcept; 254227825Stheraven 255227825Stheraven // observers 256227825Stheraven typename add_lvalue_reference<T>::type operator*() const; 257227825Stheraven pointer operator->() const noexcept; 258227825Stheraven pointer get() const noexcept; 259227825Stheraven deleter_type& get_deleter() noexcept; 260227825Stheraven const deleter_type& get_deleter() const noexcept; 261227825Stheraven explicit operator bool() const noexcept; 262227825Stheraven 263227825Stheraven // modifiers 264227825Stheraven pointer release() noexcept; 265227825Stheraven void reset(pointer p = pointer()) noexcept; 266227825Stheraven void swap(unique_ptr& u) noexcept; 267227825Stheraven}; 268227825Stheraven 269227825Stheraventemplate <class T, class D> 270227825Stheravenclass unique_ptr<T[], D> 271227825Stheraven{ 272227825Stheravenpublic: 273227825Stheraven typedef implementation-defined pointer; 274227825Stheraven typedef T element_type; 275227825Stheraven typedef D deleter_type; 276227825Stheraven 277227825Stheraven // constructors 278227825Stheraven constexpr unique_ptr() noexcept; 279227825Stheraven explicit unique_ptr(pointer p) noexcept; 280227825Stheraven unique_ptr(pointer p, see below d) noexcept; 281227825Stheraven unique_ptr(pointer p, see below d) noexcept; 282227825Stheraven unique_ptr(unique_ptr&& u) noexcept; 283227825Stheraven unique_ptr(nullptr_t) noexcept : unique_ptr() { } 284227825Stheraven 285227825Stheraven // destructor 286227825Stheraven ~unique_ptr(); 287227825Stheraven 288227825Stheraven // assignment 289227825Stheraven unique_ptr& operator=(unique_ptr&& u) noexcept; 290227825Stheraven unique_ptr& operator=(nullptr_t) noexcept; 291227825Stheraven 292227825Stheraven // observers 293227825Stheraven T& operator[](size_t i) const; 294227825Stheraven pointer get() const noexcept; 295227825Stheraven deleter_type& get_deleter() noexcept; 296227825Stheraven const deleter_type& get_deleter() const noexcept; 297227825Stheraven explicit operator bool() const noexcept; 298227825Stheraven 299227825Stheraven // modifiers 300227825Stheraven pointer release() noexcept; 301227825Stheraven void reset(pointer p = pointer()) noexcept; 302227825Stheraven void reset(nullptr_t) noexcept; 303227825Stheraven template <class U> void reset(U) = delete; 304227825Stheraven void swap(unique_ptr& u) noexcept; 305227825Stheraven}; 306227825Stheraven 307227825Stheraventemplate <class T, class D> 308227825Stheraven void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept; 309227825Stheraven 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); 320227825Stheraventemplate <class T1, class D1, class T2, class D2> 321227825Stheraven bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 322227825Stheraven 323227825Stheraventemplate <class T, class D> 324227825Stheraven bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; 325227825Stheraventemplate <class T, class D> 326227825Stheraven bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; 327227825Stheraventemplate <class T, class D> 328227825Stheraven bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; 329227825Stheraventemplate <class T, class D> 330227825Stheraven bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; 331227825Stheraven 332227825Stheraventemplate <class T, class D> 333227825Stheraven bool operator<(const unique_ptr<T, D>& x, nullptr_t); 334227825Stheraventemplate <class T, class D> 335227825Stheraven bool operator<(nullptr_t, const unique_ptr<T, D>& y); 336227825Stheraventemplate <class T, class D> 337227825Stheraven bool operator<=(const unique_ptr<T, D>& x, nullptr_t); 338227825Stheraventemplate <class T, class D> 339227825Stheraven bool operator<=(nullptr_t, const unique_ptr<T, D>& y); 340227825Stheraventemplate <class T, class D> 341227825Stheraven bool operator>(const unique_ptr<T, D>& x, nullptr_t); 342227825Stheraventemplate <class T, class D> 343227825Stheraven bool operator>(nullptr_t, const unique_ptr<T, D>& y); 344227825Stheraventemplate <class T, class D> 345227825Stheraven bool operator>=(const unique_ptr<T, D>& x, nullptr_t); 346227825Stheraventemplate <class T, class D> 347227825Stheraven bool operator>=(nullptr_t, const unique_ptr<T, D>& y); 348227825Stheraven 349227825Stheravenclass bad_weak_ptr 350227825Stheraven : public std::exception 351227825Stheraven{ 352227825Stheraven bad_weak_ptr() noexcept; 353227825Stheraven}; 354227825Stheraven 355253146Stheraventemplate<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // C++14 356253146Stheraventemplate<class T> unique_ptr<T> make_unique(size_t n); // C++14 357253146Stheraventemplate<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N] 358253146Stheraven 359227825Stheraventemplate<class T> 360227825Stheravenclass shared_ptr 361227825Stheraven{ 362227825Stheravenpublic: 363227825Stheraven typedef T element_type; 364227825Stheraven 365227825Stheraven // constructors: 366227825Stheraven constexpr shared_ptr() noexcept; 367227825Stheraven template<class Y> explicit shared_ptr(Y* p); 368227825Stheraven template<class Y, class D> shared_ptr(Y* p, D d); 369227825Stheraven template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); 370227825Stheraven template <class D> shared_ptr(nullptr_t p, D d); 371227825Stheraven template <class D, class A> shared_ptr(nullptr_t p, D d, A a); 372227825Stheraven template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept; 373227825Stheraven shared_ptr(const shared_ptr& r) noexcept; 374227825Stheraven template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept; 375227825Stheraven shared_ptr(shared_ptr&& r) noexcept; 376227825Stheraven template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept; 377227825Stheraven template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); 378227825Stheraven template<class Y> shared_ptr(auto_ptr<Y>&& r); 379227825Stheraven template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r); 380227825Stheraven shared_ptr(nullptr_t) : shared_ptr() { } 381227825Stheraven 382227825Stheraven // destructor: 383227825Stheraven ~shared_ptr(); 384227825Stheraven 385227825Stheraven // assignment: 386227825Stheraven shared_ptr& operator=(const shared_ptr& r) noexcept; 387227825Stheraven template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept; 388227825Stheraven shared_ptr& operator=(shared_ptr&& r) noexcept; 389227825Stheraven template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r); 390227825Stheraven template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); 391227825Stheraven template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); 392227825Stheraven 393227825Stheraven // modifiers: 394227825Stheraven void swap(shared_ptr& r) noexcept; 395227825Stheraven void reset() noexcept; 396227825Stheraven template<class Y> void reset(Y* p); 397227825Stheraven template<class Y, class D> void reset(Y* p, D d); 398227825Stheraven template<class Y, class D, class A> void reset(Y* p, D d, A a); 399227825Stheraven 400227825Stheraven // observers: 401227825Stheraven T* get() const noexcept; 402227825Stheraven T& operator*() const noexcept; 403227825Stheraven T* operator->() const noexcept; 404227825Stheraven long use_count() const noexcept; 405227825Stheraven bool unique() const noexcept; 406227825Stheraven explicit operator bool() const noexcept; 407227825Stheraven template<class U> bool owner_before(shared_ptr<U> const& b) const; 408227825Stheraven template<class U> bool owner_before(weak_ptr<U> const& b) const; 409227825Stheraven}; 410227825Stheraven 411227825Stheraven// shared_ptr comparisons: 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; 418227825Stheraventemplate<class T, class U> 419227825Stheraven bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 420227825Stheraventemplate<class T, class U> 421227825Stheraven bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 422227825Stheraventemplate<class T, class U> 423227825Stheraven bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 424227825Stheraven 425227825Stheraventemplate <class T> 426227825Stheraven bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept; 427227825Stheraventemplate <class T> 428227825Stheraven bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept; 429227825Stheraventemplate <class T> 430227825Stheraven bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept; 431227825Stheraventemplate <class T> 432227825Stheraven bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept; 433227825Stheraventemplate <class T> 434227825Stheraven bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept; 435227825Stheraventemplate <class T> 436227825Stheravenbool operator<(nullptr_t, const shared_ptr<T>& y) noexcept; 437227825Stheraventemplate <class T> 438227825Stheraven bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept; 439227825Stheraventemplate <class T> 440227825Stheraven bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept; 441227825Stheraventemplate <class T> 442227825Stheraven bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept; 443227825Stheraventemplate <class T> 444227825Stheraven bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept; 445227825Stheraventemplate <class T> 446227825Stheraven bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept; 447227825Stheraventemplate <class T> 448227825Stheraven bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept; 449227825Stheraven 450227825Stheraven// shared_ptr specialized algorithms: 451227825Stheraventemplate<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept; 452227825Stheraven 453227825Stheraven// shared_ptr casts: 454227825Stheraventemplate<class T, class U> 455227825Stheraven shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept; 456227825Stheraventemplate<class T, class U> 457227825Stheraven shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept; 458227825Stheraventemplate<class T, class U> 459227825Stheraven shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept; 460227825Stheraven 461227825Stheraven// shared_ptr I/O: 462227825Stheraventemplate<class E, class T, class Y> 463227825Stheraven basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p); 464227825Stheraven 465227825Stheraven// shared_ptr get_deleter: 466227825Stheraventemplate<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept; 467227825Stheraven 468227825Stheraventemplate<class T, class... Args> 469227825Stheraven shared_ptr<T> make_shared(Args&&... args); 470227825Stheraventemplate<class T, class A, class... Args> 471227825Stheraven shared_ptr<T> allocate_shared(const A& a, Args&&... args); 472227825Stheraven 473227825Stheraventemplate<class T> 474227825Stheravenclass weak_ptr 475227825Stheraven{ 476227825Stheravenpublic: 477227825Stheraven typedef T element_type; 478227825Stheraven 479227825Stheraven // constructors 480227825Stheraven constexpr weak_ptr() noexcept; 481227825Stheraven template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept; 482227825Stheraven weak_ptr(weak_ptr const& r) noexcept; 483227825Stheraven template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept; 484276792Sdim weak_ptr(weak_ptr&& r) noexcept; // C++14 485276792Sdim template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14 486227825Stheraven 487227825Stheraven // destructor 488227825Stheraven ~weak_ptr(); 489227825Stheraven 490227825Stheraven // assignment 491227825Stheraven weak_ptr& operator=(weak_ptr const& r) noexcept; 492227825Stheraven template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept; 493227825Stheraven template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept; 494276792Sdim weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 495276792Sdim template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14 496227825Stheraven 497227825Stheraven // modifiers 498227825Stheraven void swap(weak_ptr& r) noexcept; 499227825Stheraven void reset() noexcept; 500227825Stheraven 501227825Stheraven // observers 502227825Stheraven long use_count() const noexcept; 503227825Stheraven bool expired() const noexcept; 504227825Stheraven shared_ptr<T> lock() const noexcept; 505261272Sdim template<class U> bool owner_before(shared_ptr<U> const& b) const; 506261272Sdim template<class U> bool owner_before(weak_ptr<U> const& b) const; 507227825Stheraven}; 508227825Stheraven 509227825Stheraven// weak_ptr specialized algorithms: 510227825Stheraventemplate<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept; 511227825Stheraven 512227825Stheraven// class owner_less: 513227825Stheraventemplate<class T> struct owner_less; 514227825Stheraven 515227825Stheraventemplate<class T> 516227825Stheravenstruct owner_less<shared_ptr<T>> 517227825Stheraven : binary_function<shared_ptr<T>, shared_ptr<T>, bool> 518227825Stheraven{ 519227825Stheraven typedef bool result_type; 520227825Stheraven bool operator()(shared_ptr<T> const&, shared_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> 526227825Stheravenstruct owner_less<weak_ptr<T>> 527227825Stheraven : binary_function<weak_ptr<T>, weak_ptr<T>, bool> 528227825Stheraven{ 529227825Stheraven typedef bool result_type; 530227825Stheraven bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; 531227825Stheraven bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; 532227825Stheraven bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; 533227825Stheraven}; 534227825Stheraven 535227825Stheraventemplate<class T> 536227825Stheravenclass enable_shared_from_this 537227825Stheraven{ 538227825Stheravenprotected: 539227825Stheraven constexpr enable_shared_from_this() noexcept; 540227825Stheraven enable_shared_from_this(enable_shared_from_this const&) noexcept; 541227825Stheraven enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; 542227825Stheraven ~enable_shared_from_this(); 543227825Stheravenpublic: 544227825Stheraven shared_ptr<T> shared_from_this(); 545227825Stheraven shared_ptr<T const> shared_from_this() const; 546227825Stheraven}; 547227825Stheraven 548227825Stheraventemplate<class T> 549227825Stheraven bool atomic_is_lock_free(const shared_ptr<T>* p); 550227825Stheraventemplate<class T> 551227825Stheraven shared_ptr<T> atomic_load(const shared_ptr<T>* p); 552227825Stheraventemplate<class T> 553227825Stheraven shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo); 554227825Stheraventemplate<class T> 555227825Stheraven void atomic_store(shared_ptr<T>* p, shared_ptr<T> r); 556227825Stheraventemplate<class T> 557227825Stheraven void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); 558227825Stheraventemplate<class T> 559227825Stheraven shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r); 560227825Stheraventemplate<class T> 561227825Stheraven shared_ptr<T> 562227825Stheraven atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); 563227825Stheraventemplate<class T> 564227825Stheraven bool 565227825Stheraven atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); 566227825Stheraventemplate<class T> 567227825Stheraven bool 568227825Stheraven atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); 569227825Stheraventemplate<class T> 570227825Stheraven bool 571227825Stheraven atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, 572227825Stheraven shared_ptr<T> w, memory_order success, 573227825Stheraven memory_order failure); 574227825Stheraventemplate<class T> 575227825Stheraven bool 576227825Stheraven atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, 577227825Stheraven shared_ptr<T> w, memory_order success, 578227825Stheraven memory_order failure); 579227825Stheraven// Hash support 580227825Stheraventemplate <class T> struct hash; 581227825Stheraventemplate <class T, class D> struct hash<unique_ptr<T, D> >; 582227825Stheraventemplate <class T> struct hash<shared_ptr<T> >; 583227825Stheraven 584227825Stheraven// Pointer safety 585227825Stheravenenum class pointer_safety { relaxed, preferred, strict }; 586227825Stheravenvoid declare_reachable(void *p); 587227825Stheraventemplate <class T> T *undeclare_reachable(T *p); 588227825Stheravenvoid declare_no_pointers(char *p, size_t n); 589227825Stheravenvoid undeclare_no_pointers(char *p, size_t n); 590227825Stheravenpointer_safety get_pointer_safety() noexcept; 591227825Stheraven 592227825Stheravenvoid* align(size_t alignment, size_t size, void*& ptr, size_t& space); 593227825Stheraven 594227825Stheraven} // std 595227825Stheraven 596227825Stheraven*/ 597227825Stheraven 598227825Stheraven#include <__config> 599227825Stheraven#include <type_traits> 600227825Stheraven#include <typeinfo> 601227825Stheraven#include <cstddef> 602227825Stheraven#include <cstdint> 603227825Stheraven#include <new> 604227825Stheraven#include <utility> 605227825Stheraven#include <limits> 606227825Stheraven#include <iterator> 607227825Stheraven#include <__functional_base> 608227825Stheraven#include <iosfwd> 609232924Stheraven#include <tuple> 610232924Stheraven#include <cstring> 611227825Stheraven#if defined(_LIBCPP_NO_EXCEPTIONS) 612227825Stheraven #include <cassert> 613227825Stheraven#endif 614227825Stheraven 615276792Sdim#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) 616241900Sdim# include <atomic> 617241900Sdim#endif 618241900Sdim 619232924Stheraven#include <__undef_min_max> 620288943Sdim#include <__undef___deallocate> 621232924Stheraven 622227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 623227825Stheraven#pragma GCC system_header 624227825Stheraven#endif 625227825Stheraven 626227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 627227825Stheraven 628288943Sdimtemplate <class _ValueType> 629288943Sdiminline _LIBCPP_ALWAYS_INLINE 630288943Sdim_ValueType __libcpp_relaxed_load(_ValueType const* __value) { 631288943Sdim#if !defined(_LIBCPP_HAS_NO_THREADS) && \ 632288943Sdim defined(__ATOMIC_RELAXED) && \ 633288943Sdim (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407) 634288943Sdim return __atomic_load_n(__value, __ATOMIC_RELAXED); 635288943Sdim#else 636288943Sdim return *__value; 637288943Sdim#endif 638288943Sdim} 639288943Sdim 640261272Sdim// addressof moved to <__functional_base> 641227825Stheraven 642227825Stheraventemplate <class _Tp> class allocator; 643227825Stheraven 644227825Stheraventemplate <> 645261272Sdimclass _LIBCPP_TYPE_VIS_ONLY allocator<void> 646227825Stheraven{ 647227825Stheravenpublic: 648227825Stheraven typedef void* pointer; 649227825Stheraven typedef const void* const_pointer; 650227825Stheraven typedef void value_type; 651227825Stheraven 652227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 653227825Stheraven}; 654227825Stheraven 655232924Stheraventemplate <> 656261272Sdimclass _LIBCPP_TYPE_VIS_ONLY allocator<const void> 657232924Stheraven{ 658232924Stheravenpublic: 659232924Stheraven typedef const void* pointer; 660232924Stheraven typedef const void* const_pointer; 661232924Stheraven typedef const void value_type; 662232924Stheraven 663232924Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 664232924Stheraven}; 665232924Stheraven 666227825Stheraven// pointer_traits 667227825Stheraven 668227825Stheraventemplate <class _Tp> 669227825Stheravenstruct __has_element_type 670227825Stheraven{ 671227825Stheravenprivate: 672242939Stheraven struct __two {char __lx; char __lxx;}; 673227825Stheraven template <class _Up> static __two __test(...); 674227825Stheraven template <class _Up> static char __test(typename _Up::element_type* = 0); 675227825Stheravenpublic: 676227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 677227825Stheraven}; 678227825Stheraven 679227825Stheraventemplate <class _Ptr, bool = __has_element_type<_Ptr>::value> 680227825Stheravenstruct __pointer_traits_element_type; 681227825Stheraven 682227825Stheraventemplate <class _Ptr> 683227825Stheravenstruct __pointer_traits_element_type<_Ptr, true> 684227825Stheraven{ 685227825Stheraven typedef typename _Ptr::element_type type; 686227825Stheraven}; 687227825Stheraven 688227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 689227825Stheraven 690227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 691227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> 692227825Stheraven{ 693227825Stheraven typedef typename _Sp<_Tp, _Args...>::element_type type; 694227825Stheraven}; 695227825Stheraven 696227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 697227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> 698227825Stheraven{ 699227825Stheraven typedef _Tp type; 700227825Stheraven}; 701227825Stheraven 702227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 703227825Stheraven 704227825Stheraventemplate <template <class> class _Sp, class _Tp> 705227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp>, true> 706227825Stheraven{ 707227825Stheraven typedef typename _Sp<_Tp>::element_type type; 708227825Stheraven}; 709227825Stheraven 710227825Stheraventemplate <template <class> class _Sp, class _Tp> 711227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp>, false> 712227825Stheraven{ 713227825Stheraven typedef _Tp type; 714227825Stheraven}; 715227825Stheraven 716227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0> 717227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, true> 718227825Stheraven{ 719227825Stheraven typedef typename _Sp<_Tp, _A0>::element_type type; 720227825Stheraven}; 721227825Stheraven 722227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0> 723227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, false> 724227825Stheraven{ 725227825Stheraven typedef _Tp type; 726227825Stheraven}; 727227825Stheraven 728227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 729227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true> 730227825Stheraven{ 731227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::element_type type; 732227825Stheraven}; 733227825Stheraven 734227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 735227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false> 736227825Stheraven{ 737227825Stheraven typedef _Tp type; 738227825Stheraven}; 739227825Stheraven 740227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 741227825Stheraven class _A1, class _A2> 742227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true> 743227825Stheraven{ 744227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type; 745227825Stheraven}; 746227825Stheraven 747227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 748227825Stheraven class _A1, class _A2> 749227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false> 750227825Stheraven{ 751227825Stheraven typedef _Tp type; 752227825Stheraven}; 753227825Stheraven 754227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 755227825Stheraven 756227825Stheraventemplate <class _Tp> 757227825Stheravenstruct __has_difference_type 758227825Stheraven{ 759227825Stheravenprivate: 760242939Stheraven struct __two {char __lx; char __lxx;}; 761227825Stheraven template <class _Up> static __two __test(...); 762227825Stheraven template <class _Up> static char __test(typename _Up::difference_type* = 0); 763227825Stheravenpublic: 764227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 765227825Stheraven}; 766227825Stheraven 767227825Stheraventemplate <class _Ptr, bool = __has_difference_type<_Ptr>::value> 768227825Stheravenstruct __pointer_traits_difference_type 769227825Stheraven{ 770227825Stheraven typedef ptrdiff_t type; 771227825Stheraven}; 772227825Stheraven 773227825Stheraventemplate <class _Ptr> 774227825Stheravenstruct __pointer_traits_difference_type<_Ptr, true> 775227825Stheraven{ 776227825Stheraven typedef typename _Ptr::difference_type type; 777227825Stheraven}; 778227825Stheraven 779227825Stheraventemplate <class _Tp, class _Up> 780227825Stheravenstruct __has_rebind 781227825Stheraven{ 782227825Stheravenprivate: 783242939Stheraven struct __two {char __lx; char __lxx;}; 784227825Stheraven template <class _Xp> static __two __test(...); 785227825Stheraven template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); 786227825Stheravenpublic: 787227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 788227825Stheraven}; 789227825Stheraven 790227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 791227825Stheravenstruct __pointer_traits_rebind 792227825Stheraven{ 793227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 794227825Stheraven typedef typename _Tp::template rebind<_Up> type; 795227825Stheraven#else 796227825Stheraven typedef typename _Tp::template rebind<_Up>::other type; 797227825Stheraven#endif 798227825Stheraven}; 799227825Stheraven 800227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 801227825Stheraven 802227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 803227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> 804227825Stheraven{ 805227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 806227825Stheraven typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; 807227825Stheraven#else 808227825Stheraven typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; 809227825Stheraven#endif 810227825Stheraven}; 811227825Stheraven 812227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 813227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> 814227825Stheraven{ 815227825Stheraven typedef _Sp<_Up, _Args...> type; 816227825Stheraven}; 817227825Stheraven 818227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 819227825Stheraven 820227825Stheraventemplate <template <class> class _Sp, class _Tp, class _Up> 821227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> 822227825Stheraven{ 823227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 824227825Stheraven typedef typename _Sp<_Tp>::template rebind<_Up> type; 825227825Stheraven#else 826227825Stheraven typedef typename _Sp<_Tp>::template rebind<_Up>::other type; 827227825Stheraven#endif 828227825Stheraven}; 829227825Stheraven 830227825Stheraventemplate <template <class> class _Sp, class _Tp, class _Up> 831227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, false> 832227825Stheraven{ 833227825Stheraven typedef _Sp<_Up> type; 834227825Stheraven}; 835227825Stheraven 836227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 837227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> 838227825Stheraven{ 839227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 840227825Stheraven typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; 841227825Stheraven#else 842227825Stheraven typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; 843227825Stheraven#endif 844227825Stheraven}; 845227825Stheraven 846227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 847227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false> 848227825Stheraven{ 849227825Stheraven typedef _Sp<_Up, _A0> type; 850227825Stheraven}; 851227825Stheraven 852227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 853227825Stheraven class _A1, class _Up> 854227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> 855227825Stheraven{ 856227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 857227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; 858227825Stheraven#else 859227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; 860227825Stheraven#endif 861227825Stheraven}; 862227825Stheraven 863227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 864227825Stheraven class _A1, class _Up> 865227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false> 866227825Stheraven{ 867227825Stheraven typedef _Sp<_Up, _A0, _A1> type; 868227825Stheraven}; 869227825Stheraven 870227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 871227825Stheraven class _A1, class _A2, class _Up> 872227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> 873227825Stheraven{ 874227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 875227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; 876227825Stheraven#else 877227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 878227825Stheraven#endif 879227825Stheraven}; 880227825Stheraven 881227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 882227825Stheraven class _A1, class _A2, class _Up> 883227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> 884227825Stheraven{ 885227825Stheraven typedef _Sp<_Up, _A0, _A1, _A2> type; 886227825Stheraven}; 887227825Stheraven 888227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 889227825Stheraven 890227825Stheraventemplate <class _Ptr> 891261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY pointer_traits 892227825Stheraven{ 893227825Stheraven typedef _Ptr pointer; 894227825Stheraven typedef typename __pointer_traits_element_type<pointer>::type element_type; 895227825Stheraven typedef typename __pointer_traits_difference_type<pointer>::type difference_type; 896227825Stheraven 897227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 898227825Stheraven template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; 899227825Stheraven#else 900227825Stheraven template <class _Up> struct rebind 901227825Stheraven {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; 902227825Stheraven#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 903227825Stheraven 904227825Stheravenprivate: 905227825Stheraven struct __nat {}; 906227825Stheravenpublic: 907227825Stheraven _LIBCPP_INLINE_VISIBILITY 908227825Stheraven static pointer pointer_to(typename conditional<is_void<element_type>::value, 909227825Stheraven __nat, element_type>::type& __r) 910227825Stheraven {return pointer::pointer_to(__r);} 911227825Stheraven}; 912227825Stheraven 913227825Stheraventemplate <class _Tp> 914261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*> 915227825Stheraven{ 916227825Stheraven typedef _Tp* pointer; 917227825Stheraven typedef _Tp element_type; 918227825Stheraven typedef ptrdiff_t difference_type; 919227825Stheraven 920227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 921227825Stheraven template <class _Up> using rebind = _Up*; 922227825Stheraven#else 923227825Stheraven template <class _Up> struct rebind {typedef _Up* other;}; 924227825Stheraven#endif 925227825Stheraven 926227825Stheravenprivate: 927227825Stheraven struct __nat {}; 928227825Stheravenpublic: 929227825Stheraven _LIBCPP_INLINE_VISIBILITY 930227825Stheraven static pointer pointer_to(typename conditional<is_void<element_type>::value, 931227825Stheraven __nat, element_type>::type& __r) _NOEXCEPT 932227825Stheraven {return _VSTD::addressof(__r);} 933227825Stheraven}; 934227825Stheraven 935227825Stheraven// allocator_traits 936227825Stheraven 937227825Stheravennamespace __has_pointer_type_imp 938227825Stheraven{ 939261272Sdim template <class _Up> static __two __test(...); 940261272Sdim template <class _Up> static char __test(typename _Up::pointer* = 0); 941227825Stheraven} 942227825Stheraven 943227825Stheraventemplate <class _Tp> 944227825Stheravenstruct __has_pointer_type 945261272Sdim : public integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1> 946227825Stheraven{ 947227825Stheraven}; 948227825Stheraven 949227825Stheravennamespace __pointer_type_imp 950227825Stheraven{ 951227825Stheraven 952227825Stheraventemplate <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value> 953227825Stheravenstruct __pointer_type 954227825Stheraven{ 955227825Stheraven typedef typename _Dp::pointer type; 956227825Stheraven}; 957227825Stheraven 958227825Stheraventemplate <class _Tp, class _Dp> 959227825Stheravenstruct __pointer_type<_Tp, _Dp, false> 960227825Stheraven{ 961227825Stheraven typedef _Tp* type; 962227825Stheraven}; 963227825Stheraven 964227825Stheraven} // __pointer_type_imp 965227825Stheraven 966227825Stheraventemplate <class _Tp, class _Dp> 967227825Stheravenstruct __pointer_type 968227825Stheraven{ 969227825Stheraven typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type; 970227825Stheraven}; 971227825Stheraven 972227825Stheraventemplate <class _Tp> 973227825Stheravenstruct __has_const_pointer 974227825Stheraven{ 975227825Stheravenprivate: 976242939Stheraven struct __two {char __lx; char __lxx;}; 977227825Stheraven template <class _Up> static __two __test(...); 978227825Stheraven template <class _Up> static char __test(typename _Up::const_pointer* = 0); 979227825Stheravenpublic: 980227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 981227825Stheraven}; 982227825Stheraven 983227825Stheraventemplate <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value> 984227825Stheravenstruct __const_pointer 985227825Stheraven{ 986227825Stheraven typedef typename _Alloc::const_pointer type; 987227825Stheraven}; 988227825Stheraven 989227825Stheraventemplate <class _Tp, class _Ptr, class _Alloc> 990227825Stheravenstruct __const_pointer<_Tp, _Ptr, _Alloc, false> 991227825Stheraven{ 992227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 993227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; 994227825Stheraven#else 995227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; 996227825Stheraven#endif 997227825Stheraven}; 998227825Stheraven 999227825Stheraventemplate <class _Tp> 1000227825Stheravenstruct __has_void_pointer 1001227825Stheraven{ 1002227825Stheravenprivate: 1003242939Stheraven struct __two {char __lx; char __lxx;}; 1004227825Stheraven template <class _Up> static __two __test(...); 1005227825Stheraven template <class _Up> static char __test(typename _Up::void_pointer* = 0); 1006227825Stheravenpublic: 1007227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1008227825Stheraven}; 1009227825Stheraven 1010227825Stheraventemplate <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value> 1011227825Stheravenstruct __void_pointer 1012227825Stheraven{ 1013227825Stheraven typedef typename _Alloc::void_pointer type; 1014227825Stheraven}; 1015227825Stheraven 1016227825Stheraventemplate <class _Ptr, class _Alloc> 1017227825Stheravenstruct __void_pointer<_Ptr, _Alloc, false> 1018227825Stheraven{ 1019227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1020227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<void> type; 1021227825Stheraven#else 1022227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; 1023227825Stheraven#endif 1024227825Stheraven}; 1025227825Stheraven 1026227825Stheraventemplate <class _Tp> 1027227825Stheravenstruct __has_const_void_pointer 1028227825Stheraven{ 1029227825Stheravenprivate: 1030242939Stheraven struct __two {char __lx; char __lxx;}; 1031227825Stheraven template <class _Up> static __two __test(...); 1032227825Stheraven template <class _Up> static char __test(typename _Up::const_void_pointer* = 0); 1033227825Stheravenpublic: 1034227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1035227825Stheraven}; 1036227825Stheraven 1037227825Stheraventemplate <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value> 1038227825Stheravenstruct __const_void_pointer 1039227825Stheraven{ 1040227825Stheraven typedef typename _Alloc::const_void_pointer type; 1041227825Stheraven}; 1042227825Stheraven 1043227825Stheraventemplate <class _Ptr, class _Alloc> 1044227825Stheravenstruct __const_void_pointer<_Ptr, _Alloc, false> 1045227825Stheraven{ 1046227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1047227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const void> type; 1048227825Stheraven#else 1049227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; 1050227825Stheraven#endif 1051227825Stheraven}; 1052227825Stheraven 1053232924Stheraventemplate <class _Tp> 1054227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1055232924Stheraven_Tp* 1056232924Stheraven__to_raw_pointer(_Tp* __p) _NOEXCEPT 1057227825Stheraven{ 1058227825Stheraven return __p; 1059227825Stheraven} 1060227825Stheraven 1061227825Stheraventemplate <class _Pointer> 1062227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1063227825Stheraventypename pointer_traits<_Pointer>::element_type* 1064227825Stheraven__to_raw_pointer(_Pointer __p) _NOEXCEPT 1065227825Stheraven{ 1066227825Stheraven return _VSTD::__to_raw_pointer(__p.operator->()); 1067227825Stheraven} 1068227825Stheraven 1069227825Stheraventemplate <class _Tp> 1070227825Stheravenstruct __has_size_type 1071227825Stheraven{ 1072227825Stheravenprivate: 1073242939Stheraven struct __two {char __lx; char __lxx;}; 1074227825Stheraven template <class _Up> static __two __test(...); 1075227825Stheraven template <class _Up> static char __test(typename _Up::size_type* = 0); 1076227825Stheravenpublic: 1077227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1078227825Stheraven}; 1079227825Stheraven 1080227825Stheraventemplate <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> 1081227825Stheravenstruct __size_type 1082227825Stheraven{ 1083227825Stheraven typedef typename make_unsigned<_DiffType>::type type; 1084227825Stheraven}; 1085227825Stheraven 1086227825Stheraventemplate <class _Alloc, class _DiffType> 1087227825Stheravenstruct __size_type<_Alloc, _DiffType, true> 1088227825Stheraven{ 1089227825Stheraven typedef typename _Alloc::size_type type; 1090227825Stheraven}; 1091227825Stheraven 1092227825Stheraventemplate <class _Tp> 1093227825Stheravenstruct __has_propagate_on_container_copy_assignment 1094227825Stheraven{ 1095227825Stheravenprivate: 1096242939Stheraven struct __two {char __lx; char __lxx;}; 1097227825Stheraven template <class _Up> static __two __test(...); 1098227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0); 1099227825Stheravenpublic: 1100227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1101227825Stheraven}; 1102227825Stheraven 1103227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value> 1104227825Stheravenstruct __propagate_on_container_copy_assignment 1105227825Stheraven{ 1106227825Stheraven typedef false_type type; 1107227825Stheraven}; 1108227825Stheraven 1109227825Stheraventemplate <class _Alloc> 1110227825Stheravenstruct __propagate_on_container_copy_assignment<_Alloc, true> 1111227825Stheraven{ 1112227825Stheraven typedef typename _Alloc::propagate_on_container_copy_assignment type; 1113227825Stheraven}; 1114227825Stheraven 1115227825Stheraventemplate <class _Tp> 1116227825Stheravenstruct __has_propagate_on_container_move_assignment 1117227825Stheraven{ 1118227825Stheravenprivate: 1119242939Stheraven struct __two {char __lx; char __lxx;}; 1120227825Stheraven template <class _Up> static __two __test(...); 1121227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0); 1122227825Stheravenpublic: 1123227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1124227825Stheraven}; 1125227825Stheraven 1126227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value> 1127227825Stheravenstruct __propagate_on_container_move_assignment 1128227825Stheraven{ 1129227825Stheraven typedef false_type type; 1130227825Stheraven}; 1131227825Stheraven 1132227825Stheraventemplate <class _Alloc> 1133227825Stheravenstruct __propagate_on_container_move_assignment<_Alloc, true> 1134227825Stheraven{ 1135227825Stheraven typedef typename _Alloc::propagate_on_container_move_assignment type; 1136227825Stheraven}; 1137227825Stheraven 1138227825Stheraventemplate <class _Tp> 1139227825Stheravenstruct __has_propagate_on_container_swap 1140227825Stheraven{ 1141227825Stheravenprivate: 1142242939Stheraven struct __two {char __lx; char __lxx;}; 1143227825Stheraven template <class _Up> static __two __test(...); 1144227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0); 1145227825Stheravenpublic: 1146227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1147227825Stheraven}; 1148227825Stheraven 1149227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> 1150227825Stheravenstruct __propagate_on_container_swap 1151227825Stheraven{ 1152227825Stheraven typedef false_type type; 1153227825Stheraven}; 1154227825Stheraven 1155227825Stheraventemplate <class _Alloc> 1156227825Stheravenstruct __propagate_on_container_swap<_Alloc, true> 1157227825Stheraven{ 1158227825Stheraven typedef typename _Alloc::propagate_on_container_swap type; 1159227825Stheraven}; 1160227825Stheraven 1161288943Sdimtemplate <class _Tp> 1162288943Sdimstruct __has_is_always_equal 1163288943Sdim{ 1164288943Sdimprivate: 1165288943Sdim struct __two {char __lx; char __lxx;}; 1166288943Sdim template <class _Up> static __two __test(...); 1167288943Sdim template <class _Up> static char __test(typename _Up::is_always_equal* = 0); 1168288943Sdimpublic: 1169288943Sdim static const bool value = sizeof(__test<_Tp>(0)) == 1; 1170288943Sdim}; 1171288943Sdim 1172288943Sdimtemplate <class _Alloc, bool = __has_is_always_equal<_Alloc>::value> 1173288943Sdimstruct __is_always_equal 1174288943Sdim{ 1175288943Sdim typedef typename _VSTD::is_empty<_Alloc>::type type; 1176288943Sdim}; 1177288943Sdim 1178288943Sdimtemplate <class _Alloc> 1179288943Sdimstruct __is_always_equal<_Alloc, true> 1180288943Sdim{ 1181288943Sdim typedef typename _Alloc::is_always_equal type; 1182288943Sdim}; 1183288943Sdim 1184227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 1185227825Stheravenstruct __has_rebind_other 1186227825Stheraven{ 1187227825Stheravenprivate: 1188242939Stheraven struct __two {char __lx; char __lxx;}; 1189227825Stheraven template <class _Xp> static __two __test(...); 1190227825Stheraven template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); 1191227825Stheravenpublic: 1192227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1193227825Stheraven}; 1194227825Stheraven 1195227825Stheraventemplate <class _Tp, class _Up> 1196227825Stheravenstruct __has_rebind_other<_Tp, _Up, false> 1197227825Stheraven{ 1198227825Stheraven static const bool value = false; 1199227825Stheraven}; 1200227825Stheraven 1201227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> 1202227825Stheravenstruct __allocator_traits_rebind 1203227825Stheraven{ 1204227825Stheraven typedef typename _Tp::template rebind<_Up>::other type; 1205227825Stheraven}; 1206227825Stheraven 1207227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1208227825Stheraven 1209227825Stheraventemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 1210227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> 1211227825Stheraven{ 1212227825Stheraven typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; 1213227825Stheraven}; 1214227825Stheraven 1215227825Stheraventemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 1216227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> 1217227825Stheraven{ 1218227825Stheraven typedef _Alloc<_Up, _Args...> type; 1219227825Stheraven}; 1220227825Stheraven 1221227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1222227825Stheraven 1223227825Stheraventemplate <template <class> class _Alloc, class _Tp, class _Up> 1224227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true> 1225227825Stheraven{ 1226227825Stheraven typedef typename _Alloc<_Tp>::template rebind<_Up>::other type; 1227227825Stheraven}; 1228227825Stheraven 1229227825Stheraventemplate <template <class> class _Alloc, class _Tp, class _Up> 1230227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false> 1231227825Stheraven{ 1232227825Stheraven typedef _Alloc<_Up> type; 1233227825Stheraven}; 1234227825Stheraven 1235227825Stheraventemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 1236227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true> 1237227825Stheraven{ 1238227825Stheraven typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type; 1239227825Stheraven}; 1240227825Stheraven 1241227825Stheraventemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 1242227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false> 1243227825Stheraven{ 1244227825Stheraven typedef _Alloc<_Up, _A0> type; 1245227825Stheraven}; 1246227825Stheraven 1247227825Stheraventemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 1248227825Stheraven class _A1, class _Up> 1249227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true> 1250227825Stheraven{ 1251227825Stheraven typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type; 1252227825Stheraven}; 1253227825Stheraven 1254227825Stheraventemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 1255227825Stheraven class _A1, class _Up> 1256227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false> 1257227825Stheraven{ 1258227825Stheraven typedef _Alloc<_Up, _A0, _A1> type; 1259227825Stheraven}; 1260227825Stheraven 1261227825Stheraventemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 1262227825Stheraven class _A1, class _A2, class _Up> 1263227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true> 1264227825Stheraven{ 1265227825Stheraven typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 1266227825Stheraven}; 1267227825Stheraven 1268227825Stheraventemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 1269227825Stheraven class _A1, class _A2, class _Up> 1270227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> 1271227825Stheraven{ 1272227825Stheraven typedef _Alloc<_Up, _A0, _A1, _A2> type; 1273227825Stheraven}; 1274227825Stheraven 1275227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1276227825Stheraven 1277227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 1278227825Stheraven 1279227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1280227825Stheravenauto 1281227825Stheraven__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 1282227825Stheraven -> decltype(__a.allocate(__sz, __p), true_type()); 1283227825Stheraven 1284227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1285227825Stheravenauto 1286227825Stheraven__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 1287227825Stheraven -> false_type; 1288227825Stheraven 1289227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1290227825Stheravenstruct __has_allocate_hint 1291227825Stheraven : integral_constant<bool, 1292227825Stheraven is_same< 1293227825Stheraven decltype(__has_allocate_hint_test(declval<_Alloc>(), 1294227825Stheraven declval<_SizeType>(), 1295227825Stheraven declval<_ConstVoidPtr>())), 1296227825Stheraven true_type>::value> 1297227825Stheraven{ 1298227825Stheraven}; 1299227825Stheraven 1300227825Stheraven#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1301227825Stheraven 1302227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1303227825Stheravenstruct __has_allocate_hint 1304227825Stheraven : true_type 1305227825Stheraven{ 1306227825Stheraven}; 1307227825Stheraven 1308227825Stheraven#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1309227825Stheraven 1310227825Stheraven#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1311227825Stheraven 1312227825Stheraventemplate <class _Alloc, class _Tp, class ..._Args> 1313227825Stheravendecltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), 1314227825Stheraven _VSTD::declval<_Args>()...), 1315227825Stheraven true_type()) 1316227825Stheraven__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args); 1317227825Stheraven 1318227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1319227825Stheravenfalse_type 1320227825Stheraven__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args); 1321227825Stheraven 1322227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1323227825Stheravenstruct __has_construct 1324227825Stheraven : integral_constant<bool, 1325227825Stheraven is_same< 1326227825Stheraven decltype(__has_construct_test(declval<_Alloc>(), 1327227825Stheraven declval<_Pointer>(), 1328227825Stheraven declval<_Args>()...)), 1329227825Stheraven true_type>::value> 1330227825Stheraven{ 1331227825Stheraven}; 1332227825Stheraven 1333227825Stheraventemplate <class _Alloc, class _Pointer> 1334227825Stheravenauto 1335227825Stheraven__has_destroy_test(_Alloc&& __a, _Pointer&& __p) 1336227825Stheraven -> decltype(__a.destroy(__p), true_type()); 1337227825Stheraven 1338227825Stheraventemplate <class _Alloc, class _Pointer> 1339227825Stheravenauto 1340227825Stheraven__has_destroy_test(const _Alloc& __a, _Pointer&& __p) 1341227825Stheraven -> false_type; 1342227825Stheraven 1343227825Stheraventemplate <class _Alloc, class _Pointer> 1344227825Stheravenstruct __has_destroy 1345227825Stheraven : integral_constant<bool, 1346227825Stheraven is_same< 1347227825Stheraven decltype(__has_destroy_test(declval<_Alloc>(), 1348227825Stheraven declval<_Pointer>())), 1349227825Stheraven true_type>::value> 1350227825Stheraven{ 1351227825Stheraven}; 1352227825Stheraven 1353227825Stheraventemplate <class _Alloc> 1354227825Stheravenauto 1355227825Stheraven__has_max_size_test(_Alloc&& __a) 1356227825Stheraven -> decltype(__a.max_size(), true_type()); 1357227825Stheraven 1358227825Stheraventemplate <class _Alloc> 1359227825Stheravenauto 1360227825Stheraven__has_max_size_test(const volatile _Alloc& __a) 1361227825Stheraven -> false_type; 1362227825Stheraven 1363227825Stheraventemplate <class _Alloc> 1364227825Stheravenstruct __has_max_size 1365227825Stheraven : integral_constant<bool, 1366227825Stheraven is_same< 1367227825Stheraven decltype(__has_max_size_test(declval<_Alloc&>())), 1368227825Stheraven true_type>::value> 1369227825Stheraven{ 1370227825Stheraven}; 1371227825Stheraven 1372227825Stheraventemplate <class _Alloc> 1373227825Stheravenauto 1374227825Stheraven__has_select_on_container_copy_construction_test(_Alloc&& __a) 1375227825Stheraven -> decltype(__a.select_on_container_copy_construction(), true_type()); 1376227825Stheraven 1377227825Stheraventemplate <class _Alloc> 1378227825Stheravenauto 1379227825Stheraven__has_select_on_container_copy_construction_test(const volatile _Alloc& __a) 1380227825Stheraven -> false_type; 1381227825Stheraven 1382227825Stheraventemplate <class _Alloc> 1383227825Stheravenstruct __has_select_on_container_copy_construction 1384227825Stheraven : integral_constant<bool, 1385227825Stheraven is_same< 1386227825Stheraven decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())), 1387227825Stheraven true_type>::value> 1388227825Stheraven{ 1389227825Stheraven}; 1390227825Stheraven 1391227825Stheraven#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1392227825Stheraven 1393227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1394227825Stheraven 1395227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1396227825Stheravenstruct __has_construct 1397227825Stheraven : false_type 1398227825Stheraven{ 1399227825Stheraven}; 1400227825Stheraven 1401232924Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1402232924Stheraven 1403232924Stheraventemplate <class _Alloc, class _Pointer, class _Args> 1404232924Stheravenstruct __has_construct 1405232924Stheraven : false_type 1406232924Stheraven{ 1407232924Stheraven}; 1408232924Stheraven 1409227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1410227825Stheraven 1411227825Stheraventemplate <class _Alloc, class _Pointer> 1412227825Stheravenstruct __has_destroy 1413227825Stheraven : false_type 1414227825Stheraven{ 1415227825Stheraven}; 1416227825Stheraven 1417227825Stheraventemplate <class _Alloc> 1418227825Stheravenstruct __has_max_size 1419227825Stheraven : true_type 1420227825Stheraven{ 1421227825Stheraven}; 1422227825Stheraven 1423227825Stheraventemplate <class _Alloc> 1424227825Stheravenstruct __has_select_on_container_copy_construction 1425227825Stheraven : false_type 1426227825Stheraven{ 1427227825Stheraven}; 1428227825Stheraven 1429227825Stheraven#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1430227825Stheraven 1431227825Stheraventemplate <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> 1432227825Stheravenstruct __alloc_traits_difference_type 1433227825Stheraven{ 1434227825Stheraven typedef typename pointer_traits<_Ptr>::difference_type type; 1435227825Stheraven}; 1436227825Stheraven 1437227825Stheraventemplate <class _Alloc, class _Ptr> 1438227825Stheravenstruct __alloc_traits_difference_type<_Alloc, _Ptr, true> 1439227825Stheraven{ 1440227825Stheraven typedef typename _Alloc::difference_type type; 1441227825Stheraven}; 1442227825Stheraven 1443227825Stheraventemplate <class _Alloc> 1444261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY allocator_traits 1445227825Stheraven{ 1446227825Stheraven typedef _Alloc allocator_type; 1447227825Stheraven typedef typename allocator_type::value_type value_type; 1448227825Stheraven 1449227825Stheraven typedef typename __pointer_type<value_type, allocator_type>::type pointer; 1450227825Stheraven typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer; 1451227825Stheraven typedef typename __void_pointer<pointer, allocator_type>::type void_pointer; 1452227825Stheraven typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer; 1453227825Stheraven 1454227825Stheraven typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type; 1455227825Stheraven typedef typename __size_type<allocator_type, difference_type>::type size_type; 1456227825Stheraven 1457227825Stheraven typedef typename __propagate_on_container_copy_assignment<allocator_type>::type 1458227825Stheraven propagate_on_container_copy_assignment; 1459227825Stheraven typedef typename __propagate_on_container_move_assignment<allocator_type>::type 1460227825Stheraven propagate_on_container_move_assignment; 1461227825Stheraven typedef typename __propagate_on_container_swap<allocator_type>::type 1462227825Stheraven propagate_on_container_swap; 1463288943Sdim typedef typename __is_always_equal<allocator_type>::type 1464288943Sdim is_always_equal; 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) 1493276792Sdim {__construct(__has_construct<allocator_type, _Tp*, _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 1530261272Sdim static size_type max_size(const allocator_type& __a) _NOEXCEPT 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 1540232924Stheraven template <class _Ptr> 1541232924Stheraven _LIBCPP_INLINE_VISIBILITY 1542232924Stheraven static 1543232924Stheraven void 1544232924Stheraven __construct_forward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) 1545232924Stheraven { 1546232924Stheraven for (; __begin1 != __end1; ++__begin1, ++__begin2) 1547232924Stheraven construct(__a, _VSTD::__to_raw_pointer(__begin2), _VSTD::move_if_noexcept(*__begin1)); 1548232924Stheraven } 1549232924Stheraven 1550232924Stheraven template <class _Tp> 1551232924Stheraven _LIBCPP_INLINE_VISIBILITY 1552232924Stheraven static 1553232924Stheraven typename enable_if 1554232924Stheraven < 1555232924Stheraven (is_same<allocator_type, allocator<_Tp> >::value 1556232924Stheraven || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 1557232924Stheraven is_trivially_move_constructible<_Tp>::value, 1558232924Stheraven void 1559232924Stheraven >::type 1560232924Stheraven __construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) 1561232924Stheraven { 1562232924Stheraven ptrdiff_t _Np = __end1 - __begin1; 1563288943Sdim if (_Np > 0) 1564288943Sdim { 1565288943Sdim _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); 1566288943Sdim __begin2 += _Np; 1567288943Sdim } 1568232924Stheraven } 1569232924Stheraven 1570288943Sdim template <class _Iter, class _Ptr> 1571288943Sdim _LIBCPP_INLINE_VISIBILITY 1572288943Sdim static 1573288943Sdim void 1574288943Sdim __construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) 1575288943Sdim { 1576288943Sdim for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) 1577288943Sdim construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1); 1578288943Sdim } 1579288943Sdim 1580288943Sdim template <class _Tp> 1581288943Sdim _LIBCPP_INLINE_VISIBILITY 1582288943Sdim static 1583288943Sdim typename enable_if 1584288943Sdim < 1585288943Sdim (is_same<allocator_type, allocator<_Tp> >::value 1586288943Sdim || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 1587288943Sdim is_trivially_move_constructible<_Tp>::value, 1588288943Sdim void 1589288943Sdim >::type 1590288943Sdim __construct_range_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) 1591288943Sdim { 1592288943Sdim typedef typename remove_const<_Tp>::type _Vp; 1593288943Sdim ptrdiff_t _Np = __end1 - __begin1; 1594288943Sdim if (_Np > 0) 1595288943Sdim { 1596288943Sdim _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp)); 1597288943Sdim __begin2 += _Np; 1598288943Sdim } 1599288943Sdim } 1600288943Sdim 1601232924Stheraven template <class _Ptr> 1602232924Stheraven _LIBCPP_INLINE_VISIBILITY 1603232924Stheraven static 1604232924Stheraven void 1605232924Stheraven __construct_backward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) 1606232924Stheraven { 1607232924Stheraven while (__end1 != __begin1) 1608246468Stheraven { 1609246468Stheraven construct(__a, _VSTD::__to_raw_pointer(__end2-1), _VSTD::move_if_noexcept(*--__end1)); 1610246468Stheraven --__end2; 1611246468Stheraven } 1612232924Stheraven } 1613232924Stheraven 1614232924Stheraven template <class _Tp> 1615232924Stheraven _LIBCPP_INLINE_VISIBILITY 1616232924Stheraven static 1617232924Stheraven typename enable_if 1618232924Stheraven < 1619232924Stheraven (is_same<allocator_type, allocator<_Tp> >::value 1620232924Stheraven || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 1621232924Stheraven is_trivially_move_constructible<_Tp>::value, 1622232924Stheraven void 1623232924Stheraven >::type 1624232924Stheraven __construct_backward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) 1625232924Stheraven { 1626232924Stheraven ptrdiff_t _Np = __end1 - __begin1; 1627232924Stheraven __end2 -= _Np; 1628288943Sdim if (_Np > 0) 1629288943Sdim _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp)); 1630232924Stheraven } 1631232924Stheraven 1632227825Stheravenprivate: 1633227825Stheraven 1634227825Stheraven _LIBCPP_INLINE_VISIBILITY 1635227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, 1636227825Stheraven const_void_pointer __hint, true_type) 1637227825Stheraven {return __a.allocate(__n, __hint);} 1638227825Stheraven _LIBCPP_INLINE_VISIBILITY 1639227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, 1640232924Stheraven const_void_pointer, false_type) 1641227825Stheraven {return __a.allocate(__n);} 1642227825Stheraven 1643227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1644227825Stheraven template <class _Tp, class... _Args> 1645227825Stheraven _LIBCPP_INLINE_VISIBILITY 1646227825Stheraven static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) 1647227825Stheraven {__a.construct(__p, _VSTD::forward<_Args>(__args)...);} 1648227825Stheraven template <class _Tp, class... _Args> 1649227825Stheraven _LIBCPP_INLINE_VISIBILITY 1650227825Stheraven static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) 1651227825Stheraven { 1652227825Stheraven ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); 1653227825Stheraven } 1654227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1655227825Stheraven 1656227825Stheraven template <class _Tp> 1657227825Stheraven _LIBCPP_INLINE_VISIBILITY 1658227825Stheraven static void __destroy(true_type, allocator_type& __a, _Tp* __p) 1659227825Stheraven {__a.destroy(__p);} 1660227825Stheraven template <class _Tp> 1661227825Stheraven _LIBCPP_INLINE_VISIBILITY 1662227825Stheraven static void __destroy(false_type, allocator_type&, _Tp* __p) 1663227825Stheraven { 1664227825Stheraven __p->~_Tp(); 1665227825Stheraven } 1666227825Stheraven 1667227825Stheraven _LIBCPP_INLINE_VISIBILITY 1668227825Stheraven static size_type __max_size(true_type, const allocator_type& __a) 1669227825Stheraven {return __a.max_size();} 1670227825Stheraven _LIBCPP_INLINE_VISIBILITY 1671227825Stheraven static size_type __max_size(false_type, const allocator_type&) 1672227825Stheraven {return numeric_limits<size_type>::max();} 1673227825Stheraven 1674227825Stheraven _LIBCPP_INLINE_VISIBILITY 1675227825Stheraven static allocator_type 1676227825Stheraven select_on_container_copy_construction(true_type, const allocator_type& __a) 1677227825Stheraven {return __a.select_on_container_copy_construction();} 1678227825Stheraven _LIBCPP_INLINE_VISIBILITY 1679227825Stheraven static allocator_type 1680227825Stheraven select_on_container_copy_construction(false_type, const allocator_type& __a) 1681227825Stheraven {return __a;} 1682227825Stheraven}; 1683227825Stheraven 1684288943Sdimtemplate <class _Traits, class _Tp> 1685288943Sdimstruct __rebind_alloc_helper 1686288943Sdim{ 1687288943Sdim#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1688288943Sdim typedef typename _Traits::template rebind_alloc<_Tp> type; 1689288943Sdim#else 1690288943Sdim typedef typename _Traits::template rebind_alloc<_Tp>::other type; 1691288943Sdim#endif 1692288943Sdim}; 1693288943Sdim 1694232924Stheraven// allocator 1695227825Stheraven 1696227825Stheraventemplate <class _Tp> 1697261272Sdimclass _LIBCPP_TYPE_VIS_ONLY allocator 1698227825Stheraven{ 1699227825Stheravenpublic: 1700232924Stheraven typedef size_t size_type; 1701232924Stheraven typedef ptrdiff_t difference_type; 1702232924Stheraven typedef _Tp* pointer; 1703232924Stheraven typedef const _Tp* const_pointer; 1704232924Stheraven typedef _Tp& reference; 1705232924Stheraven typedef const _Tp& const_reference; 1706232924Stheraven typedef _Tp value_type; 1707227825Stheraven 1708232924Stheraven typedef true_type propagate_on_container_move_assignment; 1709288943Sdim typedef true_type is_always_equal; 1710227825Stheraven 1711232924Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 1712227825Stheraven 1713232924Stheraven _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 1714232924Stheraven template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 1715232924Stheraven _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT 1716232924Stheraven {return _VSTD::addressof(__x);} 1717232924Stheraven _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 1718232924Stheraven {return _VSTD::addressof(__x);} 1719232924Stheraven _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1720276792Sdim {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));} 1721232924Stheraven _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1722276792Sdim {_VSTD::__deallocate((void*)__p);} 1723232924Stheraven _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 1724232924Stheraven {return size_type(~0) / sizeof(_Tp);} 1725232924Stheraven#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1726232924Stheraven template <class _Up, class... _Args> 1727232924Stheraven _LIBCPP_INLINE_VISIBILITY 1728232924Stheraven void 1729232924Stheraven construct(_Up* __p, _Args&&... __args) 1730232924Stheraven { 1731232924Stheraven ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 1732232924Stheraven } 1733232924Stheraven#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1734232924Stheraven _LIBCPP_INLINE_VISIBILITY 1735232924Stheraven void 1736232924Stheraven construct(pointer __p) 1737232924Stheraven { 1738232924Stheraven ::new((void*)__p) _Tp(); 1739232924Stheraven } 1740232924Stheraven# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1741234959Stheraven 1742232924Stheraven template <class _A0> 1743232924Stheraven _LIBCPP_INLINE_VISIBILITY 1744234959Stheraven void 1745232924Stheraven construct(pointer __p, _A0& __a0) 1746232924Stheraven { 1747232924Stheraven ::new((void*)__p) _Tp(__a0); 1748232924Stheraven } 1749232924Stheraven template <class _A0> 1750232924Stheraven _LIBCPP_INLINE_VISIBILITY 1751234959Stheraven void 1752232924Stheraven construct(pointer __p, const _A0& __a0) 1753232924Stheraven { 1754232924Stheraven ::new((void*)__p) _Tp(__a0); 1755232924Stheraven } 1756232924Stheraven# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1757232924Stheraven template <class _A0, class _A1> 1758232924Stheraven _LIBCPP_INLINE_VISIBILITY 1759232924Stheraven void 1760232924Stheraven construct(pointer __p, _A0& __a0, _A1& __a1) 1761232924Stheraven { 1762232924Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1763232924Stheraven } 1764232924Stheraven template <class _A0, class _A1> 1765232924Stheraven _LIBCPP_INLINE_VISIBILITY 1766232924Stheraven void 1767232924Stheraven construct(pointer __p, const _A0& __a0, _A1& __a1) 1768232924Stheraven { 1769232924Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1770232924Stheraven } 1771232924Stheraven template <class _A0, class _A1> 1772232924Stheraven _LIBCPP_INLINE_VISIBILITY 1773232924Stheraven void 1774232924Stheraven construct(pointer __p, _A0& __a0, const _A1& __a1) 1775232924Stheraven { 1776232924Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1777232924Stheraven } 1778232924Stheraven template <class _A0, class _A1> 1779232924Stheraven _LIBCPP_INLINE_VISIBILITY 1780232924Stheraven void 1781232924Stheraven construct(pointer __p, const _A0& __a0, const _A1& __a1) 1782232924Stheraven { 1783232924Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1784232924Stheraven } 1785232924Stheraven#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1786232924Stheraven _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 1787227825Stheraven}; 1788227825Stheraven 1789227825Stheraventemplate <class _Tp> 1790261272Sdimclass _LIBCPP_TYPE_VIS_ONLY allocator<const _Tp> 1791227825Stheraven{ 1792227825Stheravenpublic: 1793227825Stheraven typedef size_t size_type; 1794227825Stheraven typedef ptrdiff_t difference_type; 1795232924Stheraven typedef const _Tp* pointer; 1796227825Stheraven typedef const _Tp* const_pointer; 1797232924Stheraven typedef const _Tp& reference; 1798227825Stheraven typedef const _Tp& const_reference; 1799253146Stheraven typedef const _Tp value_type; 1800227825Stheraven 1801227825Stheraven typedef true_type propagate_on_container_move_assignment; 1802288943Sdim typedef true_type is_always_equal; 1803227825Stheraven 1804227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 1805227825Stheraven 1806227825Stheraven _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 1807227825Stheraven template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 1808227825Stheraven _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 1809227825Stheraven {return _VSTD::addressof(__x);} 1810227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1811276792Sdim {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));} 1812227825Stheraven _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1813276792Sdim {_VSTD::__deallocate((void*)__p);} 1814227825Stheraven _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 1815227825Stheraven {return size_type(~0) / sizeof(_Tp);} 1816227825Stheraven#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1817227825Stheraven template <class _Up, class... _Args> 1818227825Stheraven _LIBCPP_INLINE_VISIBILITY 1819227825Stheraven void 1820227825Stheraven construct(_Up* __p, _Args&&... __args) 1821227825Stheraven { 1822227825Stheraven ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 1823227825Stheraven } 1824227825Stheraven#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1825227825Stheraven _LIBCPP_INLINE_VISIBILITY 1826227825Stheraven void 1827227825Stheraven construct(pointer __p) 1828227825Stheraven { 1829227825Stheraven ::new((void*)__p) _Tp(); 1830227825Stheraven } 1831227825Stheraven# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1832234959Stheraven 1833227825Stheraven template <class _A0> 1834227825Stheraven _LIBCPP_INLINE_VISIBILITY 1835234959Stheraven void 1836227825Stheraven construct(pointer __p, _A0& __a0) 1837227825Stheraven { 1838227825Stheraven ::new((void*)__p) _Tp(__a0); 1839227825Stheraven } 1840227825Stheraven template <class _A0> 1841227825Stheraven _LIBCPP_INLINE_VISIBILITY 1842234959Stheraven void 1843227825Stheraven construct(pointer __p, const _A0& __a0) 1844227825Stheraven { 1845227825Stheraven ::new((void*)__p) _Tp(__a0); 1846227825Stheraven } 1847227825Stheraven# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1848227825Stheraven template <class _A0, class _A1> 1849227825Stheraven _LIBCPP_INLINE_VISIBILITY 1850227825Stheraven void 1851227825Stheraven construct(pointer __p, _A0& __a0, _A1& __a1) 1852227825Stheraven { 1853227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1854227825Stheraven } 1855227825Stheraven template <class _A0, class _A1> 1856227825Stheraven _LIBCPP_INLINE_VISIBILITY 1857227825Stheraven void 1858227825Stheraven construct(pointer __p, const _A0& __a0, _A1& __a1) 1859227825Stheraven { 1860227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1861227825Stheraven } 1862227825Stheraven template <class _A0, class _A1> 1863227825Stheraven _LIBCPP_INLINE_VISIBILITY 1864227825Stheraven void 1865227825Stheraven construct(pointer __p, _A0& __a0, const _A1& __a1) 1866227825Stheraven { 1867227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1868227825Stheraven } 1869227825Stheraven template <class _A0, class _A1> 1870227825Stheraven _LIBCPP_INLINE_VISIBILITY 1871227825Stheraven void 1872227825Stheraven construct(pointer __p, const _A0& __a0, const _A1& __a1) 1873227825Stheraven { 1874227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1875227825Stheraven } 1876227825Stheraven#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1877227825Stheraven _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 1878227825Stheraven}; 1879227825Stheraven 1880227825Stheraventemplate <class _Tp, class _Up> 1881227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1882227825Stheravenbool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} 1883227825Stheraven 1884227825Stheraventemplate <class _Tp, class _Up> 1885227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1886227825Stheravenbool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} 1887227825Stheraven 1888227825Stheraventemplate <class _OutputIterator, class _Tp> 1889261272Sdimclass _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator 1890227825Stheraven : public iterator<output_iterator_tag, 1891227825Stheraven _Tp, // purposefully not C++03 1892227825Stheraven ptrdiff_t, // purposefully not C++03 1893227825Stheraven _Tp*, // purposefully not C++03 1894227825Stheraven raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03 1895227825Stheraven{ 1896227825Stheravenprivate: 1897227825Stheraven _OutputIterator __x_; 1898227825Stheravenpublic: 1899227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} 1900227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} 1901227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) 1902227825Stheraven {::new(&*__x_) _Tp(__element); return *this;} 1903227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} 1904227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) 1905227825Stheraven {raw_storage_iterator __t(*this); ++__x_; return __t;} 1906288943Sdim#if _LIBCPP_STD_VER >= 14 1907288943Sdim _LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; } 1908288943Sdim#endif 1909227825Stheraven}; 1910227825Stheraven 1911227825Stheraventemplate <class _Tp> 1912227825Stheravenpair<_Tp*, ptrdiff_t> 1913227825Stheravenget_temporary_buffer(ptrdiff_t __n) _NOEXCEPT 1914227825Stheraven{ 1915227825Stheraven pair<_Tp*, ptrdiff_t> __r(0, 0); 1916227825Stheraven const ptrdiff_t __m = (~ptrdiff_t(0) ^ 1917227825Stheraven ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) 1918227825Stheraven / sizeof(_Tp); 1919227825Stheraven if (__n > __m) 1920227825Stheraven __n = __m; 1921227825Stheraven while (__n > 0) 1922227825Stheraven { 1923227825Stheraven __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); 1924227825Stheraven if (__r.first) 1925227825Stheraven { 1926227825Stheraven __r.second = __n; 1927227825Stheraven break; 1928227825Stheraven } 1929227825Stheraven __n /= 2; 1930227825Stheraven } 1931227825Stheraven return __r; 1932227825Stheraven} 1933227825Stheraven 1934227825Stheraventemplate <class _Tp> 1935227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1936227825Stheravenvoid return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);} 1937227825Stheraven 1938227825Stheraventemplate <class _Tp> 1939227825Stheravenstruct auto_ptr_ref 1940227825Stheraven{ 1941227825Stheraven _Tp* __ptr_; 1942227825Stheraven}; 1943227825Stheraven 1944227825Stheraventemplate<class _Tp> 1945261272Sdimclass _LIBCPP_TYPE_VIS_ONLY auto_ptr 1946227825Stheraven{ 1947227825Stheravenprivate: 1948227825Stheraven _Tp* __ptr_; 1949227825Stheravenpublic: 1950227825Stheraven typedef _Tp element_type; 1951227825Stheraven 1952227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} 1953227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} 1954227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() 1955227825Stheraven : __ptr_(__p.release()) {} 1956227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() 1957227825Stheraven {reset(__p.release()); return *this;} 1958227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() 1959227825Stheraven {reset(__p.release()); return *this;} 1960227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() 1961227825Stheraven {reset(__p.__ptr_); return *this;} 1962227825Stheraven _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} 1963227825Stheraven 1964227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() 1965227825Stheraven {return *__ptr_;} 1966227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} 1967227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} 1968227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() 1969227825Stheraven { 1970227825Stheraven _Tp* __t = __ptr_; 1971227825Stheraven __ptr_ = 0; 1972227825Stheraven return __t; 1973227825Stheraven } 1974227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() 1975227825Stheraven { 1976227825Stheraven if (__ptr_ != __p) 1977227825Stheraven delete __ptr_; 1978227825Stheraven __ptr_ = __p; 1979227825Stheraven } 1980227825Stheraven 1981227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} 1982227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() 1983227825Stheraven {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} 1984227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() 1985227825Stheraven {return auto_ptr<_Up>(release());} 1986227825Stheraven}; 1987227825Stheraven 1988227825Stheraventemplate <> 1989261272Sdimclass _LIBCPP_TYPE_VIS_ONLY auto_ptr<void> 1990227825Stheraven{ 1991227825Stheravenpublic: 1992227825Stheraven typedef void element_type; 1993227825Stheraven}; 1994227825Stheraven 1995227825Stheraventemplate <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, 1996227825Stheraven typename remove_cv<_T2>::type>::value, 1997232924Stheraven bool = is_empty<_T1>::value 1998288943Sdim && !__libcpp_is_final<_T1>::value, 1999232924Stheraven bool = is_empty<_T2>::value 2000288943Sdim && !__libcpp_is_final<_T2>::value 2001232924Stheraven > 2002227825Stheravenstruct __libcpp_compressed_pair_switch; 2003227825Stheraven 2004227825Stheraventemplate <class _T1, class _T2, bool IsSame> 2005227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};}; 2006227825Stheraven 2007227825Stheraventemplate <class _T1, class _T2, bool IsSame> 2008227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false> {enum {value = 1};}; 2009227825Stheraven 2010227825Stheraventemplate <class _T1, class _T2, bool IsSame> 2011227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true> {enum {value = 2};}; 2012227825Stheraven 2013227825Stheraventemplate <class _T1, class _T2> 2014227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true> {enum {value = 3};}; 2015227825Stheraven 2016227825Stheraventemplate <class _T1, class _T2> 2017227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true> {enum {value = 1};}; 2018227825Stheraven 2019227825Stheraventemplate <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value> 2020227825Stheravenclass __libcpp_compressed_pair_imp; 2021227825Stheraven 2022227825Stheraventemplate <class _T1, class _T2> 2023227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 0> 2024227825Stheraven{ 2025227825Stheravenprivate: 2026227825Stheraven _T1 __first_; 2027227825Stheraven _T2 __second_; 2028227825Stheravenpublic: 2029227825Stheraven typedef _T1 _T1_param; 2030227825Stheraven typedef _T2 _T2_param; 2031227825Stheraven 2032227825Stheraven typedef typename remove_reference<_T1>::type& _T1_reference; 2033227825Stheraven typedef typename remove_reference<_T2>::type& _T2_reference; 2034227825Stheraven 2035227825Stheraven typedef const typename remove_reference<_T1>::type& _T1_const_reference; 2036227825Stheraven typedef const typename remove_reference<_T2>::type& _T2_const_reference; 2037227825Stheraven 2038288943Sdim _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_(), __second_() {} 2039232924Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2040288943Sdim : __first_(_VSTD::forward<_T1_param>(__t1)), __second_() {} 2041232924Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2042288943Sdim : __first_(), __second_(_VSTD::forward<_T2_param>(__t2)) {} 2043227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2044227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 2045227825Stheraven 2046261272Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2047227825Stheraven 2048227825Stheraven _LIBCPP_INLINE_VISIBILITY 2049227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2050227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2051227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2052227825Stheraven : __first_(__p.first()), 2053227825Stheraven __second_(__p.second()) {} 2054227825Stheraven 2055227825Stheraven _LIBCPP_INLINE_VISIBILITY 2056227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2057227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2058227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2059227825Stheraven { 2060227825Stheraven __first_ = __p.first(); 2061227825Stheraven __second_ = __p.second(); 2062227825Stheraven return *this; 2063227825Stheraven } 2064227825Stheraven 2065227825Stheraven _LIBCPP_INLINE_VISIBILITY 2066227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2067227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2068227825Stheraven is_nothrow_move_constructible<_T2>::value) 2069227825Stheraven : __first_(_VSTD::forward<_T1>(__p.first())), 2070227825Stheraven __second_(_VSTD::forward<_T2>(__p.second())) {} 2071227825Stheraven 2072227825Stheraven _LIBCPP_INLINE_VISIBILITY 2073227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2074227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2075227825Stheraven is_nothrow_move_assignable<_T2>::value) 2076227825Stheraven { 2077227825Stheraven __first_ = _VSTD::forward<_T1>(__p.first()); 2078227825Stheraven __second_ = _VSTD::forward<_T2>(__p.second()); 2079227825Stheraven return *this; 2080227825Stheraven } 2081227825Stheraven 2082261272Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2083253146Stheraven 2084232924Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2085232924Stheraven 2086232924Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2087232924Stheraven _LIBCPP_INLINE_VISIBILITY 2088232924Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2089232924Stheraven tuple<_Args1...> __first_args, 2090232924Stheraven tuple<_Args2...> __second_args, 2091232924Stheraven __tuple_indices<_I1...>, 2092232924Stheraven __tuple_indices<_I2...>) 2093276792Sdim : __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), 2094276792Sdim __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) 2095232924Stheraven {} 2096232924Stheraven 2097232924Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2098232924Stheraven 2099227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 2100227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 2101227825Stheraven 2102227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 2103227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 2104227825Stheraven 2105227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2106227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2107276792Sdim __is_nothrow_swappable<_T2>::value) 2108227825Stheraven { 2109227825Stheraven using _VSTD::swap; 2110227825Stheraven swap(__first_, __x.__first_); 2111227825Stheraven swap(__second_, __x.__second_); 2112227825Stheraven } 2113227825Stheraven}; 2114227825Stheraven 2115227825Stheraventemplate <class _T1, class _T2> 2116227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 1> 2117227825Stheraven : private _T1 2118227825Stheraven{ 2119227825Stheravenprivate: 2120227825Stheraven _T2 __second_; 2121227825Stheravenpublic: 2122227825Stheraven typedef _T1 _T1_param; 2123227825Stheraven typedef _T2 _T2_param; 2124227825Stheraven 2125227825Stheraven typedef _T1& _T1_reference; 2126227825Stheraven typedef typename remove_reference<_T2>::type& _T2_reference; 2127227825Stheraven 2128227825Stheraven typedef const _T1& _T1_const_reference; 2129227825Stheraven typedef const typename remove_reference<_T2>::type& _T2_const_reference; 2130227825Stheraven 2131288943Sdim _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __second_() {} 2132232924Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2133288943Sdim : _T1(_VSTD::forward<_T1_param>(__t1)), __second_() {} 2134232924Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2135227825Stheraven : __second_(_VSTD::forward<_T2_param>(__t2)) {} 2136227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2137227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 2138227825Stheraven 2139261272Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2140227825Stheraven 2141227825Stheraven _LIBCPP_INLINE_VISIBILITY 2142227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2143227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2144227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2145227825Stheraven : _T1(__p.first()), __second_(__p.second()) {} 2146227825Stheraven 2147227825Stheraven _LIBCPP_INLINE_VISIBILITY 2148227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2149227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2150227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2151227825Stheraven { 2152227825Stheraven _T1::operator=(__p.first()); 2153227825Stheraven __second_ = __p.second(); 2154227825Stheraven return *this; 2155227825Stheraven } 2156227825Stheraven 2157227825Stheraven _LIBCPP_INLINE_VISIBILITY 2158227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2159227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2160227825Stheraven is_nothrow_move_constructible<_T2>::value) 2161227825Stheraven : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {} 2162227825Stheraven 2163227825Stheraven _LIBCPP_INLINE_VISIBILITY 2164227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2165227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2166227825Stheraven is_nothrow_move_assignable<_T2>::value) 2167227825Stheraven { 2168227825Stheraven _T1::operator=(_VSTD::move(__p.first())); 2169227825Stheraven __second_ = _VSTD::forward<_T2>(__p.second()); 2170227825Stheraven return *this; 2171227825Stheraven } 2172227825Stheraven 2173261272Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2174253146Stheraven 2175232924Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2176232924Stheraven 2177232924Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2178232924Stheraven _LIBCPP_INLINE_VISIBILITY 2179232924Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2180232924Stheraven tuple<_Args1...> __first_args, 2181232924Stheraven tuple<_Args2...> __second_args, 2182232924Stheraven __tuple_indices<_I1...>, 2183232924Stheraven __tuple_indices<_I2...>) 2184276792Sdim : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), 2185276792Sdim __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) 2186232924Stheraven {} 2187232924Stheraven 2188232924Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2189232924Stheraven 2190227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 2191227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 2192227825Stheraven 2193227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 2194227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 2195227825Stheraven 2196227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2197227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2198276792Sdim __is_nothrow_swappable<_T2>::value) 2199227825Stheraven { 2200227825Stheraven using _VSTD::swap; 2201227825Stheraven swap(__second_, __x.__second_); 2202227825Stheraven } 2203227825Stheraven}; 2204227825Stheraven 2205227825Stheraventemplate <class _T1, class _T2> 2206227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 2> 2207227825Stheraven : private _T2 2208227825Stheraven{ 2209227825Stheravenprivate: 2210227825Stheraven _T1 __first_; 2211227825Stheravenpublic: 2212227825Stheraven typedef _T1 _T1_param; 2213227825Stheraven typedef _T2 _T2_param; 2214227825Stheraven 2215227825Stheraven typedef typename remove_reference<_T1>::type& _T1_reference; 2216227825Stheraven typedef _T2& _T2_reference; 2217227825Stheraven 2218227825Stheraven typedef const typename remove_reference<_T1>::type& _T1_const_reference; 2219227825Stheraven typedef const _T2& _T2_const_reference; 2220227825Stheraven 2221288943Sdim _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_() {} 2222227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2223227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)) {} 2224227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2225288943Sdim : _T2(_VSTD::forward<_T2_param>(__t2)), __first_() {} 2226227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2227227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2228227825Stheraven is_nothrow_move_constructible<_T2>::value) 2229227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} 2230227825Stheraven 2231261272Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2232227825Stheraven 2233227825Stheraven _LIBCPP_INLINE_VISIBILITY 2234227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2235227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2236227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2237227825Stheraven : _T2(__p.second()), __first_(__p.first()) {} 2238227825Stheraven 2239227825Stheraven _LIBCPP_INLINE_VISIBILITY 2240227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2241227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2242227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2243227825Stheraven { 2244227825Stheraven _T2::operator=(__p.second()); 2245227825Stheraven __first_ = __p.first(); 2246227825Stheraven return *this; 2247227825Stheraven } 2248227825Stheraven 2249227825Stheraven _LIBCPP_INLINE_VISIBILITY 2250227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2251227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2252227825Stheraven is_nothrow_move_constructible<_T2>::value) 2253227825Stheraven : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {} 2254227825Stheraven 2255227825Stheraven _LIBCPP_INLINE_VISIBILITY 2256227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2257227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2258227825Stheraven is_nothrow_move_assignable<_T2>::value) 2259227825Stheraven { 2260227825Stheraven _T2::operator=(_VSTD::forward<_T2>(__p.second())); 2261227825Stheraven __first_ = _VSTD::move(__p.first()); 2262227825Stheraven return *this; 2263227825Stheraven } 2264227825Stheraven 2265261272Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2266253146Stheraven 2267232924Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2268232924Stheraven 2269232924Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2270232924Stheraven _LIBCPP_INLINE_VISIBILITY 2271232924Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2272232924Stheraven tuple<_Args1...> __first_args, 2273232924Stheraven tuple<_Args2...> __second_args, 2274232924Stheraven __tuple_indices<_I1...>, 2275232924Stheraven __tuple_indices<_I2...>) 2276276792Sdim : _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...), 2277276792Sdim __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...) 2278232924Stheraven 2279232924Stheraven {} 2280232924Stheraven 2281232924Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2282232924Stheraven 2283227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 2284227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 2285227825Stheraven 2286227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 2287227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 2288227825Stheraven 2289227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2290227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2291276792Sdim __is_nothrow_swappable<_T2>::value) 2292227825Stheraven { 2293227825Stheraven using _VSTD::swap; 2294227825Stheraven swap(__first_, __x.__first_); 2295227825Stheraven } 2296227825Stheraven}; 2297227825Stheraven 2298227825Stheraventemplate <class _T1, class _T2> 2299227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 3> 2300227825Stheraven : private _T1, 2301227825Stheraven private _T2 2302227825Stheraven{ 2303227825Stheravenpublic: 2304227825Stheraven typedef _T1 _T1_param; 2305227825Stheraven typedef _T2 _T2_param; 2306227825Stheraven 2307227825Stheraven typedef _T1& _T1_reference; 2308227825Stheraven typedef _T2& _T2_reference; 2309227825Stheraven 2310227825Stheraven typedef const _T1& _T1_const_reference; 2311227825Stheraven typedef const _T2& _T2_const_reference; 2312227825Stheraven 2313227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2314227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2315227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)) {} 2316227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2317227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)) {} 2318227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2319227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} 2320227825Stheraven 2321261272Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2322227825Stheraven 2323227825Stheraven _LIBCPP_INLINE_VISIBILITY 2324227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2325227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2326227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2327227825Stheraven : _T1(__p.first()), _T2(__p.second()) {} 2328227825Stheraven 2329227825Stheraven _LIBCPP_INLINE_VISIBILITY 2330227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2331227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2332227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2333227825Stheraven { 2334227825Stheraven _T1::operator=(__p.first()); 2335227825Stheraven _T2::operator=(__p.second()); 2336227825Stheraven return *this; 2337227825Stheraven } 2338227825Stheraven 2339227825Stheraven _LIBCPP_INLINE_VISIBILITY 2340227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2341227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2342227825Stheraven is_nothrow_move_constructible<_T2>::value) 2343227825Stheraven : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {} 2344227825Stheraven 2345227825Stheraven _LIBCPP_INLINE_VISIBILITY 2346227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2347227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2348227825Stheraven is_nothrow_move_assignable<_T2>::value) 2349227825Stheraven { 2350227825Stheraven _T1::operator=(_VSTD::move(__p.first())); 2351227825Stheraven _T2::operator=(_VSTD::move(__p.second())); 2352227825Stheraven return *this; 2353227825Stheraven } 2354227825Stheraven 2355261272Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2356253146Stheraven 2357232924Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2358232924Stheraven 2359232924Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2360232924Stheraven _LIBCPP_INLINE_VISIBILITY 2361232924Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2362232924Stheraven tuple<_Args1...> __first_args, 2363232924Stheraven tuple<_Args2...> __second_args, 2364232924Stheraven __tuple_indices<_I1...>, 2365232924Stheraven __tuple_indices<_I2...>) 2366276792Sdim : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), 2367276792Sdim _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) 2368232924Stheraven {} 2369232924Stheraven 2370232924Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2371232924Stheraven 2372227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 2373227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 2374227825Stheraven 2375227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 2376227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 2377227825Stheraven 2378232924Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&) 2379227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2380276792Sdim __is_nothrow_swappable<_T2>::value) 2381227825Stheraven { 2382227825Stheraven } 2383227825Stheraven}; 2384227825Stheraven 2385227825Stheraventemplate <class _T1, class _T2> 2386227825Stheravenclass __compressed_pair 2387227825Stheraven : private __libcpp_compressed_pair_imp<_T1, _T2> 2388227825Stheraven{ 2389227825Stheraven typedef __libcpp_compressed_pair_imp<_T1, _T2> base; 2390227825Stheravenpublic: 2391227825Stheraven typedef typename base::_T1_param _T1_param; 2392227825Stheraven typedef typename base::_T2_param _T2_param; 2393227825Stheraven 2394227825Stheraven typedef typename base::_T1_reference _T1_reference; 2395227825Stheraven typedef typename base::_T2_reference _T2_reference; 2396227825Stheraven 2397227825Stheraven typedef typename base::_T1_const_reference _T1_const_reference; 2398227825Stheraven typedef typename base::_T2_const_reference _T2_const_reference; 2399227825Stheraven 2400227825Stheraven _LIBCPP_INLINE_VISIBILITY __compressed_pair() {} 2401232924Stheraven _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1) 2402227825Stheraven : base(_VSTD::forward<_T1_param>(__t1)) {} 2403232924Stheraven _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2) 2404227825Stheraven : base(_VSTD::forward<_T2_param>(__t2)) {} 2405227825Stheraven _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) 2406227825Stheraven : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} 2407227825Stheraven 2408261272Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2409227825Stheraven 2410227825Stheraven _LIBCPP_INLINE_VISIBILITY 2411227825Stheraven __compressed_pair(const __compressed_pair& __p) 2412227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2413227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2414227825Stheraven : base(__p) {} 2415227825Stheraven 2416227825Stheraven _LIBCPP_INLINE_VISIBILITY 2417227825Stheraven __compressed_pair& operator=(const __compressed_pair& __p) 2418227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2419227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2420227825Stheraven { 2421227825Stheraven base::operator=(__p); 2422227825Stheraven return *this; 2423227825Stheraven } 2424227825Stheraven 2425227825Stheraven _LIBCPP_INLINE_VISIBILITY 2426227825Stheraven __compressed_pair(__compressed_pair&& __p) 2427227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2428227825Stheraven is_nothrow_move_constructible<_T2>::value) 2429227825Stheraven : base(_VSTD::move(__p)) {} 2430227825Stheraven 2431227825Stheraven _LIBCPP_INLINE_VISIBILITY 2432227825Stheraven __compressed_pair& operator=(__compressed_pair&& __p) 2433227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2434227825Stheraven is_nothrow_move_assignable<_T2>::value) 2435227825Stheraven { 2436227825Stheraven base::operator=(_VSTD::move(__p)); 2437227825Stheraven return *this; 2438227825Stheraven } 2439232924Stheraven 2440261272Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2441253146Stheraven 2442232924Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2443232924Stheraven 2444232924Stheraven template <class... _Args1, class... _Args2> 2445232924Stheraven _LIBCPP_INLINE_VISIBILITY 2446232924Stheraven __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, 2447232924Stheraven tuple<_Args2...> __second_args) 2448232924Stheraven : base(__pc, _VSTD::move(__first_args), _VSTD::move(__second_args), 2449232924Stheraven typename __make_tuple_indices<sizeof...(_Args1)>::type(), 2450232924Stheraven typename __make_tuple_indices<sizeof...(_Args2) >::type()) 2451232924Stheraven {} 2452232924Stheraven 2453232924Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2454232924Stheraven 2455227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return base::first();} 2456227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();} 2457227825Stheraven 2458227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return base::second();} 2459227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();} 2460227825Stheraven 2461227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) 2462227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2463276792Sdim __is_nothrow_swappable<_T2>::value) 2464227825Stheraven {base::swap(__x);} 2465227825Stheraven}; 2466227825Stheraven 2467227825Stheraventemplate <class _T1, class _T2> 2468227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2469227825Stheravenvoid 2470227825Stheravenswap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) 2471227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2472276792Sdim __is_nothrow_swappable<_T2>::value) 2473227825Stheraven {__x.swap(__y);} 2474227825Stheraven 2475232924Stheraven// __same_or_less_cv_qualified 2476232924Stheraven 2477232924Stheraventemplate <class _Ptr1, class _Ptr2, 2478232924Stheraven bool = is_same<typename remove_cv<typename pointer_traits<_Ptr1>::element_type>::type, 2479232924Stheraven typename remove_cv<typename pointer_traits<_Ptr2>::element_type>::type 2480232924Stheraven >::value 2481232924Stheraven > 2482232924Stheravenstruct __same_or_less_cv_qualified_imp 2483232924Stheraven : is_convertible<_Ptr1, _Ptr2> {}; 2484232924Stheraven 2485232924Stheraventemplate <class _Ptr1, class _Ptr2> 2486232924Stheravenstruct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false> 2487232924Stheraven : false_type {}; 2488232924Stheraven 2489276792Sdimtemplate <class _Ptr1, class _Ptr2, bool = is_pointer<_Ptr1>::value || 2490276792Sdim is_same<_Ptr1, _Ptr2>::value || 2491276792Sdim __has_element_type<_Ptr1>::value> 2492232924Stheravenstruct __same_or_less_cv_qualified 2493232924Stheraven : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {}; 2494232924Stheraven 2495232924Stheraventemplate <class _Ptr1, class _Ptr2> 2496276792Sdimstruct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false> 2497232924Stheraven : false_type {}; 2498232924Stheraven 2499232924Stheraven// default_delete 2500232924Stheraven 2501227825Stheraventemplate <class _Tp> 2502261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY default_delete 2503227825Stheraven{ 2504241900Sdim#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2505241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; 2506241900Sdim#else 2507241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} 2508241900Sdim#endif 2509227825Stheraven template <class _Up> 2510227825Stheraven _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, 2511227825Stheraven typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 2512227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT 2513227825Stheraven { 2514227825Stheraven static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 2515249989Sdim static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); 2516227825Stheraven delete __ptr; 2517227825Stheraven } 2518227825Stheraven}; 2519227825Stheraven 2520227825Stheraventemplate <class _Tp> 2521261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]> 2522227825Stheraven{ 2523232924Stheravenpublic: 2524241900Sdim#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2525241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; 2526241900Sdim#else 2527241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} 2528241900Sdim#endif 2529232924Stheraven template <class _Up> 2530232924Stheraven _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&, 2531232924Stheraven typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 2532232924Stheraven template <class _Up> 2533232924Stheraven _LIBCPP_INLINE_VISIBILITY 2534232924Stheraven void operator() (_Up* __ptr, 2535232924Stheraven typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT 2536227825Stheraven { 2537227825Stheraven static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 2538249989Sdim static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); 2539227825Stheraven delete [] __ptr; 2540227825Stheraven } 2541227825Stheraven}; 2542227825Stheraven 2543227825Stheraventemplate <class _Tp, class _Dp = default_delete<_Tp> > 2544261272Sdimclass _LIBCPP_TYPE_VIS_ONLY unique_ptr 2545227825Stheraven{ 2546227825Stheravenpublic: 2547227825Stheraven typedef _Tp element_type; 2548227825Stheraven typedef _Dp deleter_type; 2549227825Stheraven typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 2550227825Stheravenprivate: 2551227825Stheraven __compressed_pair<pointer, deleter_type> __ptr_; 2552227825Stheraven 2553232924Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2554227825Stheraven unique_ptr(unique_ptr&); 2555227825Stheraven template <class _Up, class _Ep> 2556227825Stheraven unique_ptr(unique_ptr<_Up, _Ep>&); 2557227825Stheraven unique_ptr& operator=(unique_ptr&); 2558227825Stheraven template <class _Up, class _Ep> 2559227825Stheraven unique_ptr& operator=(unique_ptr<_Up, _Ep>&); 2560227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2561227825Stheraven 2562227825Stheraven struct __nat {int __for_bool_;}; 2563227825Stheraven 2564227825Stheraven typedef typename remove_reference<deleter_type>::type& _Dp_reference; 2565227825Stheraven typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 2566227825Stheravenpublic: 2567241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT 2568227825Stheraven : __ptr_(pointer()) 2569227825Stheraven { 2570227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2571227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2572227825Stheraven } 2573241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT 2574227825Stheraven : __ptr_(pointer()) 2575227825Stheraven { 2576227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2577227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2578227825Stheraven } 2579227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT 2580227825Stheraven : __ptr_(_VSTD::move(__p)) 2581227825Stheraven { 2582227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2583227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2584227825Stheraven } 2585227825Stheraven 2586227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2587227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional< 2588227825Stheraven is_reference<deleter_type>::value, 2589227825Stheraven deleter_type, 2590227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2591227825Stheraven _NOEXCEPT 2592227825Stheraven : __ptr_(__p, __d) {} 2593227825Stheraven 2594227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d) 2595227825Stheraven _NOEXCEPT 2596227825Stheraven : __ptr_(__p, _VSTD::move(__d)) 2597227825Stheraven { 2598227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2599227825Stheraven } 2600227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 2601227825Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2602227825Stheraven template <class _Up, class _Ep> 2603227825Stheraven _LIBCPP_INLINE_VISIBILITY 2604227825Stheraven unique_ptr(unique_ptr<_Up, _Ep>&& __u, 2605227825Stheraven typename enable_if 2606227825Stheraven < 2607227825Stheraven !is_array<_Up>::value && 2608227825Stheraven is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2609227825Stheraven is_convertible<_Ep, deleter_type>::value && 2610227825Stheraven ( 2611227825Stheraven !is_reference<deleter_type>::value || 2612227825Stheraven is_same<deleter_type, _Ep>::value 2613227825Stheraven ), 2614227825Stheraven __nat 2615227825Stheraven >::type = __nat()) _NOEXCEPT 2616227825Stheraven : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} 2617227825Stheraven 2618227825Stheraven template <class _Up> 2619227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, 2620227825Stheraven typename enable_if< 2621227825Stheraven is_convertible<_Up*, _Tp*>::value && 2622227825Stheraven is_same<_Dp, default_delete<_Tp> >::value, 2623227825Stheraven __nat 2624227825Stheraven >::type = __nat()) _NOEXCEPT 2625227825Stheraven : __ptr_(__p.release()) 2626227825Stheraven { 2627227825Stheraven } 2628227825Stheraven 2629227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 2630227825Stheraven { 2631227825Stheraven reset(__u.release()); 2632227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2633227825Stheraven return *this; 2634227825Stheraven } 2635227825Stheraven 2636227825Stheraven template <class _Up, class _Ep> 2637227825Stheraven _LIBCPP_INLINE_VISIBILITY 2638227825Stheraven typename enable_if 2639227825Stheraven < 2640232924Stheraven !is_array<_Up>::value && 2641232924Stheraven is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2642232924Stheraven is_assignable<deleter_type&, _Ep&&>::value, 2643227825Stheraven unique_ptr& 2644227825Stheraven >::type 2645227825Stheraven operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 2646227825Stheraven { 2647227825Stheraven reset(__u.release()); 2648227825Stheraven __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 2649227825Stheraven return *this; 2650227825Stheraven } 2651227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2652227825Stheraven 2653227825Stheraven _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 2654227825Stheraven { 2655227825Stheraven return __rv<unique_ptr>(*this); 2656227825Stheraven } 2657227825Stheraven 2658227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 2659227825Stheraven : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 2660227825Stheraven 2661227825Stheraven template <class _Up, class _Ep> 2662227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) 2663227825Stheraven { 2664227825Stheraven reset(__u.release()); 2665227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2666227825Stheraven return *this; 2667227825Stheraven } 2668227825Stheraven 2669227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 2670227825Stheraven : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {} 2671227825Stheraven 2672227825Stheraven template <class _Up> 2673227825Stheraven _LIBCPP_INLINE_VISIBILITY 2674227825Stheraven typename enable_if< 2675227825Stheraven is_convertible<_Up*, _Tp*>::value && 2676227825Stheraven is_same<_Dp, default_delete<_Tp> >::value, 2677227825Stheraven unique_ptr& 2678227825Stheraven >::type 2679227825Stheraven operator=(auto_ptr<_Up> __p) 2680227825Stheraven {reset(__p.release()); return *this;} 2681227825Stheraven 2682227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2683227825Stheraven _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 2684227825Stheraven 2685227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 2686227825Stheraven { 2687227825Stheraven reset(); 2688227825Stheraven return *this; 2689227825Stheraven } 2690227825Stheraven 2691227825Stheraven _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const 2692227825Stheraven {return *__ptr_.first();} 2693227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();} 2694227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 2695227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 2696227825Stheraven {return __ptr_.second();} 2697227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 2698227825Stheraven {return __ptr_.second();} 2699232924Stheraven _LIBCPP_INLINE_VISIBILITY 2700232924Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT 2701232924Stheraven {return __ptr_.first() != nullptr;} 2702227825Stheraven 2703227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 2704227825Stheraven { 2705227825Stheraven pointer __t = __ptr_.first(); 2706227825Stheraven __ptr_.first() = pointer(); 2707227825Stheraven return __t; 2708227825Stheraven } 2709227825Stheraven 2710227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT 2711227825Stheraven { 2712227825Stheraven pointer __tmp = __ptr_.first(); 2713227825Stheraven __ptr_.first() = __p; 2714227825Stheraven if (__tmp) 2715227825Stheraven __ptr_.second()(__tmp); 2716227825Stheraven } 2717227825Stheraven 2718227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT 2719227825Stheraven {__ptr_.swap(__u.__ptr_);} 2720227825Stheraven}; 2721227825Stheraven 2722227825Stheraventemplate <class _Tp, class _Dp> 2723261272Sdimclass _LIBCPP_TYPE_VIS_ONLY unique_ptr<_Tp[], _Dp> 2724227825Stheraven{ 2725227825Stheravenpublic: 2726227825Stheraven typedef _Tp element_type; 2727227825Stheraven typedef _Dp deleter_type; 2728227825Stheraven typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 2729227825Stheravenprivate: 2730227825Stheraven __compressed_pair<pointer, deleter_type> __ptr_; 2731227825Stheraven 2732232924Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2733227825Stheraven unique_ptr(unique_ptr&); 2734227825Stheraven template <class _Up> 2735227825Stheraven unique_ptr(unique_ptr<_Up>&); 2736227825Stheraven unique_ptr& operator=(unique_ptr&); 2737227825Stheraven template <class _Up> 2738227825Stheraven unique_ptr& operator=(unique_ptr<_Up>&); 2739227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2740227825Stheraven 2741227825Stheraven struct __nat {int __for_bool_;}; 2742227825Stheraven 2743227825Stheraven typedef typename remove_reference<deleter_type>::type& _Dp_reference; 2744227825Stheraven typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 2745227825Stheravenpublic: 2746241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT 2747227825Stheraven : __ptr_(pointer()) 2748227825Stheraven { 2749227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2750227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2751227825Stheraven } 2752241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT 2753227825Stheraven : __ptr_(pointer()) 2754227825Stheraven { 2755227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2756227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2757227825Stheraven } 2758227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2759276792Sdim template <class _Pp> 2760276792Sdim _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p, 2761276792Sdim typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT 2762227825Stheraven : __ptr_(__p) 2763227825Stheraven { 2764227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2765227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2766227825Stheraven } 2767227825Stheraven 2768276792Sdim template <class _Pp> 2769232924Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional< 2770227825Stheraven is_reference<deleter_type>::value, 2771227825Stheraven deleter_type, 2772276792Sdim typename add_lvalue_reference<const deleter_type>::type>::type __d, 2773276792Sdim typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) 2774227825Stheraven _NOEXCEPT 2775227825Stheraven : __ptr_(__p, __d) {} 2776227825Stheraven 2777227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional< 2778227825Stheraven is_reference<deleter_type>::value, 2779227825Stheraven deleter_type, 2780227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2781227825Stheraven _NOEXCEPT 2782227825Stheraven : __ptr_(pointer(), __d) {} 2783227825Stheraven 2784276792Sdim template <class _Pp> 2785276792Sdim _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, 2786276792Sdim typename remove_reference<deleter_type>::type&& __d, 2787276792Sdim typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) 2788227825Stheraven _NOEXCEPT 2789227825Stheraven : __ptr_(__p, _VSTD::move(__d)) 2790227825Stheraven { 2791227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2792227825Stheraven } 2793227825Stheraven 2794227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d) 2795227825Stheraven _NOEXCEPT 2796227825Stheraven : __ptr_(pointer(), _VSTD::move(__d)) 2797227825Stheraven { 2798227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2799227825Stheraven } 2800227825Stheraven 2801227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 2802227825Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2803227825Stheraven 2804227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 2805227825Stheraven { 2806227825Stheraven reset(__u.release()); 2807227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2808227825Stheraven return *this; 2809227825Stheraven } 2810232924Stheraven 2811232924Stheraven template <class _Up, class _Ep> 2812232924Stheraven _LIBCPP_INLINE_VISIBILITY 2813232924Stheraven unique_ptr(unique_ptr<_Up, _Ep>&& __u, 2814232924Stheraven typename enable_if 2815232924Stheraven < 2816232924Stheraven is_array<_Up>::value && 2817232924Stheraven __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value 2818232924Stheraven && is_convertible<_Ep, deleter_type>::value && 2819232924Stheraven ( 2820232924Stheraven !is_reference<deleter_type>::value || 2821232924Stheraven is_same<deleter_type, _Ep>::value 2822232924Stheraven ), 2823232924Stheraven __nat 2824232924Stheraven >::type = __nat() 2825232924Stheraven ) _NOEXCEPT 2826232924Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2827232924Stheraven 2828232924Stheraven 2829232924Stheraven template <class _Up, class _Ep> 2830232924Stheraven _LIBCPP_INLINE_VISIBILITY 2831232924Stheraven typename enable_if 2832232924Stheraven < 2833232924Stheraven is_array<_Up>::value && 2834232924Stheraven __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2835232924Stheraven is_assignable<deleter_type&, _Ep&&>::value, 2836232924Stheraven unique_ptr& 2837232924Stheraven >::type 2838232924Stheraven operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 2839232924Stheraven { 2840232924Stheraven reset(__u.release()); 2841232924Stheraven __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 2842232924Stheraven return *this; 2843232924Stheraven } 2844227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2845227825Stheraven 2846227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) 2847227825Stheraven : __ptr_(__p) 2848227825Stheraven { 2849227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2850227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2851227825Stheraven } 2852227825Stheraven 2853227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 2854227825Stheraven : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {} 2855227825Stheraven 2856227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d) 2857227825Stheraven : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {} 2858227825Stheraven 2859227825Stheraven _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 2860227825Stheraven { 2861227825Stheraven return __rv<unique_ptr>(*this); 2862227825Stheraven } 2863227825Stheraven 2864227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 2865227825Stheraven : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 2866227825Stheraven 2867227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u) 2868227825Stheraven { 2869227825Stheraven reset(__u->release()); 2870227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter()); 2871227825Stheraven return *this; 2872227825Stheraven } 2873227825Stheraven 2874227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2875227825Stheraven _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 2876227825Stheraven 2877227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 2878227825Stheraven { 2879227825Stheraven reset(); 2880227825Stheraven return *this; 2881227825Stheraven } 2882227825Stheraven 2883227825Stheraven _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const 2884227825Stheraven {return __ptr_.first()[__i];} 2885227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 2886227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 2887227825Stheraven {return __ptr_.second();} 2888227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 2889227825Stheraven {return __ptr_.second();} 2890232924Stheraven _LIBCPP_INLINE_VISIBILITY 2891232924Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT 2892232924Stheraven {return __ptr_.first() != nullptr;} 2893227825Stheraven 2894227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 2895227825Stheraven { 2896227825Stheraven pointer __t = __ptr_.first(); 2897227825Stheraven __ptr_.first() = pointer(); 2898227825Stheraven return __t; 2899227825Stheraven } 2900227825Stheraven 2901227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2902276792Sdim template <class _Pp> 2903276792Sdim _LIBCPP_INLINE_VISIBILITY 2904276792Sdim typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type 2905276792Sdim reset(_Pp __p) _NOEXCEPT 2906227825Stheraven { 2907227825Stheraven pointer __tmp = __ptr_.first(); 2908227825Stheraven __ptr_.first() = __p; 2909227825Stheraven if (__tmp) 2910227825Stheraven __ptr_.second()(__tmp); 2911227825Stheraven } 2912227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT 2913227825Stheraven { 2914227825Stheraven pointer __tmp = __ptr_.first(); 2915227825Stheraven __ptr_.first() = nullptr; 2916227825Stheraven if (__tmp) 2917227825Stheraven __ptr_.second()(__tmp); 2918227825Stheraven } 2919227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT 2920227825Stheraven { 2921227825Stheraven pointer __tmp = __ptr_.first(); 2922227825Stheraven __ptr_.first() = nullptr; 2923227825Stheraven if (__tmp) 2924227825Stheraven __ptr_.second()(__tmp); 2925227825Stheraven } 2926227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2927227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) 2928227825Stheraven { 2929227825Stheraven pointer __tmp = __ptr_.first(); 2930227825Stheraven __ptr_.first() = __p; 2931227825Stheraven if (__tmp) 2932227825Stheraven __ptr_.second()(__tmp); 2933227825Stheraven } 2934227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2935227825Stheraven 2936227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} 2937227825Stheravenprivate: 2938227825Stheraven 2939227825Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2940227825Stheraven template <class _Up> 2941227825Stheraven explicit unique_ptr(_Up); 2942227825Stheraven template <class _Up> 2943227825Stheraven unique_ptr(_Up __u, 2944227825Stheraven typename conditional< 2945227825Stheraven is_reference<deleter_type>::value, 2946227825Stheraven deleter_type, 2947227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type, 2948227825Stheraven typename enable_if 2949227825Stheraven < 2950227825Stheraven is_convertible<_Up, pointer>::value, 2951227825Stheraven __nat 2952227825Stheraven >::type = __nat()); 2953227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2954227825Stheraven}; 2955227825Stheraven 2956227825Stheraventemplate <class _Tp, class _Dp> 2957227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2958227825Stheravenvoid 2959227825Stheravenswap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);} 2960227825Stheraven 2961227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2962227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2963227825Stheravenbool 2964227825Stheravenoperator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();} 2965227825Stheraven 2966227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2967227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2968227825Stheravenbool 2969227825Stheravenoperator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);} 2970227825Stheraven 2971227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2972227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2973227825Stheravenbool 2974232924Stheravenoperator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) 2975232924Stheraven{ 2976232924Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 2977232924Stheraven typedef typename unique_ptr<_T2, _D2>::pointer _P2; 2978288943Sdim typedef typename common_type<_P1, _P2>::type _Vp; 2979288943Sdim return less<_Vp>()(__x.get(), __y.get()); 2980232924Stheraven} 2981227825Stheraven 2982227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2983227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2984227825Stheravenbool 2985227825Stheravenoperator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;} 2986227825Stheraven 2987227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2988227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2989227825Stheravenbool 2990227825Stheravenoperator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);} 2991227825Stheraven 2992227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2993227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2994227825Stheravenbool 2995227825Stheravenoperator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} 2996227825Stheraven 2997232924Stheraventemplate <class _T1, class _D1> 2998232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 2999232924Stheravenbool 3000241900Sdimoperator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT 3001232924Stheraven{ 3002232924Stheraven return !__x; 3003232924Stheraven} 3004232924Stheraven 3005232924Stheraventemplate <class _T1, class _D1> 3006232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3007232924Stheravenbool 3008241900Sdimoperator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT 3009232924Stheraven{ 3010232924Stheraven return !__x; 3011232924Stheraven} 3012232924Stheraven 3013232924Stheraventemplate <class _T1, class _D1> 3014232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3015232924Stheravenbool 3016241900Sdimoperator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT 3017232924Stheraven{ 3018232924Stheraven return static_cast<bool>(__x); 3019232924Stheraven} 3020232924Stheraven 3021232924Stheraventemplate <class _T1, class _D1> 3022232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3023232924Stheravenbool 3024241900Sdimoperator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT 3025232924Stheraven{ 3026232924Stheraven return static_cast<bool>(__x); 3027232924Stheraven} 3028232924Stheraven 3029232924Stheraventemplate <class _T1, class _D1> 3030232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3031232924Stheravenbool 3032232924Stheravenoperator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) 3033232924Stheraven{ 3034232924Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 3035232924Stheraven return less<_P1>()(__x.get(), nullptr); 3036232924Stheraven} 3037232924Stheraven 3038232924Stheraventemplate <class _T1, class _D1> 3039232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3040232924Stheravenbool 3041232924Stheravenoperator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3042232924Stheraven{ 3043232924Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 3044232924Stheraven return less<_P1>()(nullptr, __x.get()); 3045232924Stheraven} 3046232924Stheraven 3047232924Stheraventemplate <class _T1, class _D1> 3048232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3049232924Stheravenbool 3050232924Stheravenoperator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) 3051232924Stheraven{ 3052232924Stheraven return nullptr < __x; 3053232924Stheraven} 3054232924Stheraven 3055232924Stheraventemplate <class _T1, class _D1> 3056232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3057232924Stheravenbool 3058232924Stheravenoperator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3059232924Stheraven{ 3060232924Stheraven return __x < nullptr; 3061232924Stheraven} 3062232924Stheraven 3063232924Stheraventemplate <class _T1, class _D1> 3064232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3065232924Stheravenbool 3066232924Stheravenoperator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) 3067232924Stheraven{ 3068232924Stheraven return !(nullptr < __x); 3069232924Stheraven} 3070232924Stheraven 3071232924Stheraventemplate <class _T1, class _D1> 3072232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3073232924Stheravenbool 3074232924Stheravenoperator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3075232924Stheraven{ 3076232924Stheraven return !(__x < nullptr); 3077232924Stheraven} 3078232924Stheraven 3079232924Stheraventemplate <class _T1, class _D1> 3080232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3081232924Stheravenbool 3082232924Stheravenoperator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) 3083232924Stheraven{ 3084232924Stheraven return !(__x < nullptr); 3085232924Stheraven} 3086232924Stheraven 3087232924Stheraventemplate <class _T1, class _D1> 3088232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 3089232924Stheravenbool 3090232924Stheravenoperator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3091232924Stheraven{ 3092232924Stheraven return !(nullptr < __x); 3093232924Stheraven} 3094232924Stheraven 3095234959Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3096234959Stheraven 3097234959Stheraventemplate <class _Tp, class _Dp> 3098234959Stheraveninline _LIBCPP_INLINE_VISIBILITY 3099234959Stheravenunique_ptr<_Tp, _Dp> 3100234959Stheravenmove(unique_ptr<_Tp, _Dp>& __t) 3101234959Stheraven{ 3102234959Stheraven return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t)); 3103234959Stheraven} 3104234959Stheraven 3105234959Stheraven#endif 3106234959Stheraven 3107253146Stheraven#if _LIBCPP_STD_VER > 11 3108253146Stheraven 3109253146Stheraventemplate<class _Tp> 3110253146Stheravenstruct __unique_if 3111253146Stheraven{ 3112253146Stheraven typedef unique_ptr<_Tp> __unique_single; 3113253146Stheraven}; 3114253146Stheraven 3115253146Stheraventemplate<class _Tp> 3116253146Stheravenstruct __unique_if<_Tp[]> 3117253146Stheraven{ 3118253146Stheraven typedef unique_ptr<_Tp[]> __unique_array_unknown_bound; 3119253146Stheraven}; 3120253146Stheraven 3121253146Stheraventemplate<class _Tp, size_t _Np> 3122253146Stheravenstruct __unique_if<_Tp[_Np]> 3123253146Stheraven{ 3124253146Stheraven typedef void __unique_array_known_bound; 3125253146Stheraven}; 3126253146Stheraven 3127253146Stheraventemplate<class _Tp, class... _Args> 3128253146Stheraveninline _LIBCPP_INLINE_VISIBILITY 3129253146Stheraventypename __unique_if<_Tp>::__unique_single 3130253146Stheravenmake_unique(_Args&&... __args) 3131253146Stheraven{ 3132253146Stheraven return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...)); 3133253146Stheraven} 3134253146Stheraven 3135253146Stheraventemplate<class _Tp> 3136253146Stheraveninline _LIBCPP_INLINE_VISIBILITY 3137253146Stheraventypename __unique_if<_Tp>::__unique_array_unknown_bound 3138253146Stheravenmake_unique(size_t __n) 3139253146Stheraven{ 3140253146Stheraven typedef typename remove_extent<_Tp>::type _Up; 3141253146Stheraven return unique_ptr<_Tp>(new _Up[__n]()); 3142253146Stheraven} 3143253146Stheraven 3144253146Stheraventemplate<class _Tp, class... _Args> 3145253146Stheraven typename __unique_if<_Tp>::__unique_array_known_bound 3146253146Stheraven make_unique(_Args&&...) = delete; 3147253146Stheraven 3148253146Stheraven#endif // _LIBCPP_STD_VER > 11 3149253146Stheraven 3150227825Stheraventemplate <class _Tp> struct hash; 3151227825Stheraven 3152253146Stheraventemplate <class _Size> 3153253146Stheraveninline _LIBCPP_INLINE_VISIBILITY 3154253146Stheraven_Size 3155253146Stheraven__loadword(const void* __p) 3156253146Stheraven{ 3157253146Stheraven _Size __r; 3158253146Stheraven std::memcpy(&__r, __p, sizeof(__r)); 3159253146Stheraven return __r; 3160253146Stheraven} 3161253146Stheraven 3162232924Stheraven// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t 3163232924Stheraven// is 64 bits. This is because cityhash64 uses 64bit x 64bit 3164232924Stheraven// multiplication, which can be very slow on 32-bit systems. 3165232924Stheraventemplate <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__> 3166232924Stheravenstruct __murmur2_or_cityhash; 3167232924Stheraven 3168232924Stheraventemplate <class _Size> 3169232924Stheravenstruct __murmur2_or_cityhash<_Size, 32> 3170227825Stheraven{ 3171232924Stheraven _Size operator()(const void* __key, _Size __len); 3172232924Stheraven}; 3173232924Stheraven 3174232924Stheraven// murmur2 3175232924Stheraventemplate <class _Size> 3176232924Stheraven_Size 3177232924Stheraven__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) 3178232924Stheraven{ 3179232924Stheraven const _Size __m = 0x5bd1e995; 3180232924Stheraven const _Size __r = 24; 3181232924Stheraven _Size __h = __len; 3182232924Stheraven const unsigned char* __data = static_cast<const unsigned char*>(__key); 3183232924Stheraven for (; __len >= 4; __data += 4, __len -= 4) 3184232924Stheraven { 3185253146Stheraven _Size __k = __loadword<_Size>(__data); 3186232924Stheraven __k *= __m; 3187232924Stheraven __k ^= __k >> __r; 3188232924Stheraven __k *= __m; 3189232924Stheraven __h *= __m; 3190232924Stheraven __h ^= __k; 3191232924Stheraven } 3192232924Stheraven switch (__len) 3193232924Stheraven { 3194232924Stheraven case 3: 3195232924Stheraven __h ^= __data[2] << 16; 3196232924Stheraven case 2: 3197232924Stheraven __h ^= __data[1] << 8; 3198232924Stheraven case 1: 3199232924Stheraven __h ^= __data[0]; 3200232924Stheraven __h *= __m; 3201232924Stheraven } 3202232924Stheraven __h ^= __h >> 13; 3203232924Stheraven __h *= __m; 3204232924Stheraven __h ^= __h >> 15; 3205232924Stheraven return __h; 3206232924Stheraven} 3207232924Stheraven 3208232924Stheraventemplate <class _Size> 3209232924Stheravenstruct __murmur2_or_cityhash<_Size, 64> 3210232924Stheraven{ 3211232924Stheraven _Size operator()(const void* __key, _Size __len); 3212232924Stheraven 3213232924Stheraven private: 3214232924Stheraven // Some primes between 2^63 and 2^64. 3215232924Stheraven static const _Size __k0 = 0xc3a5c85c97cb3127ULL; 3216232924Stheraven static const _Size __k1 = 0xb492b66fbe98f273ULL; 3217232924Stheraven static const _Size __k2 = 0x9ae16a3b2f90404fULL; 3218232924Stheraven static const _Size __k3 = 0xc949d7c7509e6557ULL; 3219232924Stheraven 3220232924Stheraven static _Size __rotate(_Size __val, int __shift) { 3221232924Stheraven return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); 3222232924Stheraven } 3223232924Stheraven 3224232924Stheraven static _Size __rotate_by_at_least_1(_Size __val, int __shift) { 3225232924Stheraven return (__val >> __shift) | (__val << (64 - __shift)); 3226232924Stheraven } 3227232924Stheraven 3228232924Stheraven static _Size __shift_mix(_Size __val) { 3229232924Stheraven return __val ^ (__val >> 47); 3230232924Stheraven } 3231232924Stheraven 3232232924Stheraven static _Size __hash_len_16(_Size __u, _Size __v) { 3233232924Stheraven const _Size __mul = 0x9ddfea08eb382d69ULL; 3234232924Stheraven _Size __a = (__u ^ __v) * __mul; 3235232924Stheraven __a ^= (__a >> 47); 3236232924Stheraven _Size __b = (__v ^ __a) * __mul; 3237232924Stheraven __b ^= (__b >> 47); 3238232924Stheraven __b *= __mul; 3239232924Stheraven return __b; 3240232924Stheraven } 3241232924Stheraven 3242232924Stheraven static _Size __hash_len_0_to_16(const char* __s, _Size __len) { 3243232924Stheraven if (__len > 8) { 3244253146Stheraven const _Size __a = __loadword<_Size>(__s); 3245253146Stheraven const _Size __b = __loadword<_Size>(__s + __len - 8); 3246232924Stheraven return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; 3247232924Stheraven } 3248232924Stheraven if (__len >= 4) { 3249253146Stheraven const uint32_t __a = __loadword<uint32_t>(__s); 3250253146Stheraven const uint32_t __b = __loadword<uint32_t>(__s + __len - 4); 3251232924Stheraven return __hash_len_16(__len + (__a << 3), __b); 3252232924Stheraven } 3253232924Stheraven if (__len > 0) { 3254232924Stheraven const unsigned char __a = __s[0]; 3255232924Stheraven const unsigned char __b = __s[__len >> 1]; 3256232924Stheraven const unsigned char __c = __s[__len - 1]; 3257232924Stheraven const uint32_t __y = static_cast<uint32_t>(__a) + 3258232924Stheraven (static_cast<uint32_t>(__b) << 8); 3259232924Stheraven const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2); 3260232924Stheraven return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; 3261232924Stheraven } 3262232924Stheraven return __k2; 3263232924Stheraven } 3264232924Stheraven 3265232924Stheraven static _Size __hash_len_17_to_32(const char *__s, _Size __len) { 3266253146Stheraven const _Size __a = __loadword<_Size>(__s) * __k1; 3267253146Stheraven const _Size __b = __loadword<_Size>(__s + 8); 3268253146Stheraven const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2; 3269253146Stheraven const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0; 3270232924Stheraven return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, 3271232924Stheraven __a + __rotate(__b ^ __k3, 20) - __c + __len); 3272232924Stheraven } 3273232924Stheraven 3274232924Stheraven // Return a 16-byte hash for 48 bytes. Quick and dirty. 3275232924Stheraven // Callers do best to use "random-looking" values for a and b. 3276232924Stheraven static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 3277232924Stheraven _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) { 3278232924Stheraven __a += __w; 3279232924Stheraven __b = __rotate(__b + __a + __z, 21); 3280232924Stheraven const _Size __c = __a; 3281232924Stheraven __a += __x; 3282232924Stheraven __a += __y; 3283232924Stheraven __b += __rotate(__a, 44); 3284232924Stheraven return pair<_Size, _Size>(__a + __z, __b + __c); 3285232924Stheraven } 3286232924Stheraven 3287232924Stheraven // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. 3288232924Stheraven static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 3289232924Stheraven const char* __s, _Size __a, _Size __b) { 3290253146Stheraven return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s), 3291253146Stheraven __loadword<_Size>(__s + 8), 3292253146Stheraven __loadword<_Size>(__s + 16), 3293253146Stheraven __loadword<_Size>(__s + 24), 3294232924Stheraven __a, 3295232924Stheraven __b); 3296232924Stheraven } 3297232924Stheraven 3298232924Stheraven // Return an 8-byte hash for 33 to 64 bytes. 3299232924Stheraven static _Size __hash_len_33_to_64(const char *__s, size_t __len) { 3300253146Stheraven _Size __z = __loadword<_Size>(__s + 24); 3301253146Stheraven _Size __a = __loadword<_Size>(__s) + 3302253146Stheraven (__len + __loadword<_Size>(__s + __len - 16)) * __k0; 3303232924Stheraven _Size __b = __rotate(__a + __z, 52); 3304232924Stheraven _Size __c = __rotate(__a, 37); 3305253146Stheraven __a += __loadword<_Size>(__s + 8); 3306232924Stheraven __c += __rotate(__a, 7); 3307253146Stheraven __a += __loadword<_Size>(__s + 16); 3308232924Stheraven _Size __vf = __a + __z; 3309232924Stheraven _Size __vs = __b + __rotate(__a, 31) + __c; 3310253146Stheraven __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32); 3311253146Stheraven __z += __loadword<_Size>(__s + __len - 8); 3312232924Stheraven __b = __rotate(__a + __z, 52); 3313232924Stheraven __c = __rotate(__a, 37); 3314253146Stheraven __a += __loadword<_Size>(__s + __len - 24); 3315232924Stheraven __c += __rotate(__a, 7); 3316253146Stheraven __a += __loadword<_Size>(__s + __len - 16); 3317232924Stheraven _Size __wf = __a + __z; 3318232924Stheraven _Size __ws = __b + __rotate(__a, 31) + __c; 3319232924Stheraven _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); 3320232924Stheraven return __shift_mix(__r * __k0 + __vs) * __k2; 3321232924Stheraven } 3322232924Stheraven}; 3323232924Stheraven 3324232924Stheraven// cityhash64 3325232924Stheraventemplate <class _Size> 3326232924Stheraven_Size 3327232924Stheraven__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) 3328232924Stheraven{ 3329232924Stheraven const char* __s = static_cast<const char*>(__key); 3330232924Stheraven if (__len <= 32) { 3331232924Stheraven if (__len <= 16) { 3332232924Stheraven return __hash_len_0_to_16(__s, __len); 3333232924Stheraven } else { 3334232924Stheraven return __hash_len_17_to_32(__s, __len); 3335232924Stheraven } 3336232924Stheraven } else if (__len <= 64) { 3337232924Stheraven return __hash_len_33_to_64(__s, __len); 3338232924Stheraven } 3339232924Stheraven 3340232924Stheraven // For strings over 64 bytes we hash the end first, and then as we 3341232924Stheraven // loop we keep 56 bytes of state: v, w, x, y, and z. 3342253146Stheraven _Size __x = __loadword<_Size>(__s + __len - 40); 3343253146Stheraven _Size __y = __loadword<_Size>(__s + __len - 16) + 3344253146Stheraven __loadword<_Size>(__s + __len - 56); 3345253146Stheraven _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len, 3346253146Stheraven __loadword<_Size>(__s + __len - 24)); 3347232924Stheraven pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); 3348232924Stheraven pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); 3349253146Stheraven __x = __x * __k1 + __loadword<_Size>(__s); 3350232924Stheraven 3351232924Stheraven // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. 3352232924Stheraven __len = (__len - 1) & ~static_cast<_Size>(63); 3353232924Stheraven do { 3354253146Stheraven __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1; 3355253146Stheraven __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1; 3356232924Stheraven __x ^= __w.second; 3357253146Stheraven __y += __v.first + __loadword<_Size>(__s + 40); 3358232924Stheraven __z = __rotate(__z + __w.first, 33) * __k1; 3359232924Stheraven __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); 3360232924Stheraven __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, 3361253146Stheraven __y + __loadword<_Size>(__s + 16)); 3362232924Stheraven std::swap(__z, __x); 3363232924Stheraven __s += 64; 3364232924Stheraven __len -= 64; 3365232924Stheraven } while (__len != 0); 3366232924Stheraven return __hash_len_16( 3367232924Stheraven __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, 3368232924Stheraven __hash_len_16(__v.second, __w.second) + __x); 3369232924Stheraven} 3370232924Stheraven 3371232924Stheraventemplate <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> 3372232924Stheravenstruct __scalar_hash; 3373232924Stheraven 3374232924Stheraventemplate <class _Tp> 3375232924Stheravenstruct __scalar_hash<_Tp, 0> 3376232924Stheraven : public unary_function<_Tp, size_t> 3377232924Stheraven{ 3378227825Stheraven _LIBCPP_INLINE_VISIBILITY 3379232924Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3380227825Stheraven { 3381232924Stheraven union 3382232924Stheraven { 3383232924Stheraven _Tp __t; 3384232924Stheraven size_t __a; 3385232924Stheraven } __u; 3386232924Stheraven __u.__a = 0; 3387232924Stheraven __u.__t = __v; 3388232924Stheraven return __u.__a; 3389227825Stheraven } 3390227825Stheraven}; 3391227825Stheraven 3392232924Stheraventemplate <class _Tp> 3393232924Stheravenstruct __scalar_hash<_Tp, 1> 3394232924Stheraven : public unary_function<_Tp, size_t> 3395232924Stheraven{ 3396232924Stheraven _LIBCPP_INLINE_VISIBILITY 3397232924Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3398232924Stheraven { 3399232924Stheraven union 3400232924Stheraven { 3401232924Stheraven _Tp __t; 3402232924Stheraven size_t __a; 3403232924Stheraven } __u; 3404232924Stheraven __u.__t = __v; 3405232924Stheraven return __u.__a; 3406232924Stheraven } 3407232924Stheraven}; 3408232924Stheraven 3409232924Stheraventemplate <class _Tp> 3410232924Stheravenstruct __scalar_hash<_Tp, 2> 3411232924Stheraven : public unary_function<_Tp, size_t> 3412232924Stheraven{ 3413232924Stheraven _LIBCPP_INLINE_VISIBILITY 3414232924Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3415232924Stheraven { 3416232924Stheraven union 3417232924Stheraven { 3418232924Stheraven _Tp __t; 3419232924Stheraven struct 3420232924Stheraven { 3421232924Stheraven size_t __a; 3422232924Stheraven size_t __b; 3423232924Stheraven }; 3424232924Stheraven } __u; 3425232924Stheraven __u.__t = __v; 3426232924Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3427232924Stheraven } 3428232924Stheraven}; 3429232924Stheraven 3430232924Stheraventemplate <class _Tp> 3431232924Stheravenstruct __scalar_hash<_Tp, 3> 3432232924Stheraven : public unary_function<_Tp, size_t> 3433232924Stheraven{ 3434232924Stheraven _LIBCPP_INLINE_VISIBILITY 3435232924Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3436232924Stheraven { 3437232924Stheraven union 3438232924Stheraven { 3439232924Stheraven _Tp __t; 3440232924Stheraven struct 3441232924Stheraven { 3442232924Stheraven size_t __a; 3443232924Stheraven size_t __b; 3444232924Stheraven size_t __c; 3445232924Stheraven }; 3446232924Stheraven } __u; 3447232924Stheraven __u.__t = __v; 3448232924Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3449232924Stheraven } 3450232924Stheraven}; 3451232924Stheraven 3452232924Stheraventemplate <class _Tp> 3453232924Stheravenstruct __scalar_hash<_Tp, 4> 3454232924Stheraven : public unary_function<_Tp, size_t> 3455232924Stheraven{ 3456232924Stheraven _LIBCPP_INLINE_VISIBILITY 3457232924Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3458232924Stheraven { 3459232924Stheraven union 3460232924Stheraven { 3461232924Stheraven _Tp __t; 3462232924Stheraven struct 3463232924Stheraven { 3464232924Stheraven size_t __a; 3465232924Stheraven size_t __b; 3466232924Stheraven size_t __c; 3467232924Stheraven size_t __d; 3468232924Stheraven }; 3469232924Stheraven } __u; 3470232924Stheraven __u.__t = __v; 3471232924Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3472232924Stheraven } 3473232924Stheraven}; 3474232924Stheraven 3475232924Stheraventemplate<class _Tp> 3476261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*> 3477241900Sdim : public unary_function<_Tp*, size_t> 3478232924Stheraven{ 3479241900Sdim _LIBCPP_INLINE_VISIBILITY 3480241900Sdim size_t operator()(_Tp* __v) const _NOEXCEPT 3481241900Sdim { 3482241900Sdim union 3483241900Sdim { 3484241900Sdim _Tp* __t; 3485241900Sdim size_t __a; 3486241900Sdim } __u; 3487241900Sdim __u.__t = __v; 3488241900Sdim return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3489241900Sdim } 3490232924Stheraven}; 3491232924Stheraven 3492227825Stheraventemplate <class _Tp, class _Dp> 3493261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unique_ptr<_Tp, _Dp> > 3494227825Stheraven{ 3495227825Stheraven typedef unique_ptr<_Tp, _Dp> argument_type; 3496227825Stheraven typedef size_t result_type; 3497227825Stheraven _LIBCPP_INLINE_VISIBILITY 3498227825Stheraven result_type operator()(const argument_type& __ptr) const _NOEXCEPT 3499227825Stheraven { 3500227825Stheraven typedef typename argument_type::pointer pointer; 3501227825Stheraven return hash<pointer>()(__ptr.get()); 3502227825Stheraven } 3503227825Stheraven}; 3504227825Stheraven 3505227825Stheravenstruct __destruct_n 3506227825Stheraven{ 3507227825Stheravenprivate: 3508227825Stheraven size_t size; 3509227825Stheraven 3510227825Stheraven template <class _Tp> 3511227825Stheraven _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT 3512227825Stheraven {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} 3513227825Stheraven 3514227825Stheraven template <class _Tp> 3515227825Stheraven _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT 3516227825Stheraven {} 3517227825Stheraven 3518227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT 3519227825Stheraven {++size;} 3520227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT 3521227825Stheraven {} 3522227825Stheraven 3523227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT 3524227825Stheraven {size = __s;} 3525227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT 3526227825Stheraven {} 3527227825Stheravenpublic: 3528227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT 3529227825Stheraven : size(__s) {} 3530227825Stheraven 3531227825Stheraven template <class _Tp> 3532227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT 3533227825Stheraven {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3534227825Stheraven 3535227825Stheraven template <class _Tp> 3536227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT 3537227825Stheraven {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3538227825Stheraven 3539227825Stheraven template <class _Tp> 3540227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT 3541227825Stheraven {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3542227825Stheraven}; 3543227825Stheraven 3544227825Stheraventemplate <class _Alloc> 3545227825Stheravenclass __allocator_destructor 3546227825Stheraven{ 3547227825Stheraven typedef allocator_traits<_Alloc> __alloc_traits; 3548227825Stheravenpublic: 3549227825Stheraven typedef typename __alloc_traits::pointer pointer; 3550227825Stheraven typedef typename __alloc_traits::size_type size_type; 3551227825Stheravenprivate: 3552227825Stheraven _Alloc& __alloc_; 3553227825Stheraven size_type __s_; 3554227825Stheravenpublic: 3555227825Stheraven _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) 3556227825Stheraven _NOEXCEPT 3557227825Stheraven : __alloc_(__a), __s_(__s) {} 3558227825Stheraven _LIBCPP_INLINE_VISIBILITY 3559227825Stheraven void operator()(pointer __p) _NOEXCEPT 3560227825Stheraven {__alloc_traits::deallocate(__alloc_, __p, __s_);} 3561227825Stheraven}; 3562227825Stheraven 3563227825Stheraventemplate <class _InputIterator, class _ForwardIterator> 3564227825Stheraven_ForwardIterator 3565227825Stheravenuninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) 3566227825Stheraven{ 3567227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3568232924Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3569232924Stheraven _ForwardIterator __s = __r; 3570232924Stheraven try 3571232924Stheraven { 3572232924Stheraven#endif 3573288943Sdim for (; __f != __l; ++__f, (void) ++__r) 3574288943Sdim ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f); 3575232924Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3576232924Stheraven } 3577232924Stheraven catch (...) 3578232924Stheraven { 3579232924Stheraven for (; __s != __r; ++__s) 3580232924Stheraven __s->~value_type(); 3581232924Stheraven throw; 3582232924Stheraven } 3583232924Stheraven#endif 3584227825Stheraven return __r; 3585227825Stheraven} 3586227825Stheraven 3587227825Stheraventemplate <class _InputIterator, class _Size, class _ForwardIterator> 3588227825Stheraven_ForwardIterator 3589227825Stheravenuninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) 3590227825Stheraven{ 3591227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3592232924Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3593232924Stheraven _ForwardIterator __s = __r; 3594232924Stheraven try 3595232924Stheraven { 3596232924Stheraven#endif 3597288943Sdim for (; __n > 0; ++__f, (void) ++__r, (void) --__n) 3598288943Sdim ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f); 3599232924Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3600232924Stheraven } 3601232924Stheraven catch (...) 3602232924Stheraven { 3603232924Stheraven for (; __s != __r; ++__s) 3604232924Stheraven __s->~value_type(); 3605232924Stheraven throw; 3606232924Stheraven } 3607232924Stheraven#endif 3608227825Stheraven return __r; 3609227825Stheraven} 3610227825Stheraven 3611227825Stheraventemplate <class _ForwardIterator, class _Tp> 3612227825Stheravenvoid 3613227825Stheravenuninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) 3614227825Stheraven{ 3615227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3616232924Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3617232924Stheraven _ForwardIterator __s = __f; 3618232924Stheraven try 3619232924Stheraven { 3620232924Stheraven#endif 3621232924Stheraven for (; __f != __l; ++__f) 3622288943Sdim ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x); 3623232924Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3624232924Stheraven } 3625232924Stheraven catch (...) 3626232924Stheraven { 3627232924Stheraven for (; __s != __f; ++__s) 3628232924Stheraven __s->~value_type(); 3629232924Stheraven throw; 3630232924Stheraven } 3631232924Stheraven#endif 3632227825Stheraven} 3633227825Stheraven 3634227825Stheraventemplate <class _ForwardIterator, class _Size, class _Tp> 3635227825Stheraven_ForwardIterator 3636227825Stheravenuninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) 3637227825Stheraven{ 3638227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3639232924Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3640232924Stheraven _ForwardIterator __s = __f; 3641232924Stheraven try 3642232924Stheraven { 3643232924Stheraven#endif 3644288943Sdim for (; __n > 0; ++__f, (void) --__n) 3645288943Sdim ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x); 3646232924Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3647232924Stheraven } 3648232924Stheraven catch (...) 3649232924Stheraven { 3650232924Stheraven for (; __s != __f; ++__s) 3651232924Stheraven __s->~value_type(); 3652232924Stheraven throw; 3653232924Stheraven } 3654232924Stheraven#endif 3655227825Stheraven return __f; 3656227825Stheraven} 3657227825Stheraven 3658227825Stheravenclass _LIBCPP_EXCEPTION_ABI bad_weak_ptr 3659227825Stheraven : public std::exception 3660227825Stheraven{ 3661227825Stheravenpublic: 3662227825Stheraven virtual ~bad_weak_ptr() _NOEXCEPT; 3663227825Stheraven virtual const char* what() const _NOEXCEPT; 3664227825Stheraven}; 3665227825Stheraven 3666261272Sdimtemplate<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 3667227825Stheraven 3668261272Sdimclass _LIBCPP_TYPE_VIS __shared_count 3669227825Stheraven{ 3670227825Stheraven __shared_count(const __shared_count&); 3671227825Stheraven __shared_count& operator=(const __shared_count&); 3672227825Stheraven 3673227825Stheravenprotected: 3674227825Stheraven long __shared_owners_; 3675227825Stheraven virtual ~__shared_count(); 3676227825Stheravenprivate: 3677227825Stheraven virtual void __on_zero_shared() _NOEXCEPT = 0; 3678227825Stheraven 3679227825Stheravenpublic: 3680227825Stheraven _LIBCPP_INLINE_VISIBILITY 3681227825Stheraven explicit __shared_count(long __refs = 0) _NOEXCEPT 3682227825Stheraven : __shared_owners_(__refs) {} 3683227825Stheraven 3684227825Stheraven void __add_shared() _NOEXCEPT; 3685227825Stheraven bool __release_shared() _NOEXCEPT; 3686227825Stheraven _LIBCPP_INLINE_VISIBILITY 3687288943Sdim long use_count() const _NOEXCEPT { 3688288943Sdim return __libcpp_relaxed_load(&__shared_owners_) + 1; 3689288943Sdim } 3690227825Stheraven}; 3691227825Stheraven 3692261272Sdimclass _LIBCPP_TYPE_VIS __shared_weak_count 3693227825Stheraven : private __shared_count 3694227825Stheraven{ 3695227825Stheraven long __shared_weak_owners_; 3696227825Stheraven 3697227825Stheravenpublic: 3698227825Stheraven _LIBCPP_INLINE_VISIBILITY 3699227825Stheraven explicit __shared_weak_count(long __refs = 0) _NOEXCEPT 3700227825Stheraven : __shared_count(__refs), 3701227825Stheraven __shared_weak_owners_(__refs) {} 3702227825Stheravenprotected: 3703227825Stheraven virtual ~__shared_weak_count(); 3704227825Stheraven 3705227825Stheravenpublic: 3706227825Stheraven void __add_shared() _NOEXCEPT; 3707227825Stheraven void __add_weak() _NOEXCEPT; 3708227825Stheraven void __release_shared() _NOEXCEPT; 3709227825Stheraven void __release_weak() _NOEXCEPT; 3710227825Stheraven _LIBCPP_INLINE_VISIBILITY 3711227825Stheraven long use_count() const _NOEXCEPT {return __shared_count::use_count();} 3712227825Stheraven __shared_weak_count* lock() _NOEXCEPT; 3713227825Stheraven 3714249989Sdim // Define the function out only if we build static libc++ without RTTI. 3715249989Sdim // Otherwise we may break clients who need to compile their projects with 3716249989Sdim // -fno-rtti and yet link against a libc++.dylib compiled 3717249989Sdim // without -fno-rtti. 3718249989Sdim#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) 3719227825Stheraven virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 3720249989Sdim#endif 3721227825Stheravenprivate: 3722227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT = 0; 3723227825Stheraven}; 3724227825Stheraven 3725227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3726227825Stheravenclass __shared_ptr_pointer 3727227825Stheraven : public __shared_weak_count 3728227825Stheraven{ 3729227825Stheraven __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; 3730227825Stheravenpublic: 3731227825Stheraven _LIBCPP_INLINE_VISIBILITY 3732227825Stheraven __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) 3733227825Stheraven : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {} 3734227825Stheraven 3735227825Stheraven#ifndef _LIBCPP_NO_RTTI 3736227825Stheraven virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 3737227825Stheraven#endif 3738227825Stheraven 3739227825Stheravenprivate: 3740227825Stheraven virtual void __on_zero_shared() _NOEXCEPT; 3741227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT; 3742227825Stheraven}; 3743227825Stheraven 3744227825Stheraven#ifndef _LIBCPP_NO_RTTI 3745227825Stheraven 3746227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3747227825Stheravenconst void* 3748227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT 3749227825Stheraven{ 3750276792Sdim return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : 0; 3751227825Stheraven} 3752227825Stheraven 3753227825Stheraven#endif // _LIBCPP_NO_RTTI 3754227825Stheraven 3755227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3756227825Stheravenvoid 3757227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT 3758227825Stheraven{ 3759227825Stheraven __data_.first().second()(__data_.first().first()); 3760227825Stheraven __data_.first().second().~_Dp(); 3761227825Stheraven} 3762227825Stheraven 3763227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3764227825Stheravenvoid 3765227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 3766227825Stheraven{ 3767288943Sdim typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _Al; 3768288943Sdim typedef allocator_traits<_Al> _ATraits; 3769276792Sdim typedef pointer_traits<typename _ATraits::pointer> _PTraits; 3770276792Sdim 3771288943Sdim _Al __a(__data_.second()); 3772227825Stheraven __data_.second().~_Alloc(); 3773276792Sdim __a.deallocate(_PTraits::pointer_to(*this), 1); 3774227825Stheraven} 3775227825Stheraven 3776227825Stheraventemplate <class _Tp, class _Alloc> 3777227825Stheravenclass __shared_ptr_emplace 3778227825Stheraven : public __shared_weak_count 3779227825Stheraven{ 3780227825Stheraven __compressed_pair<_Alloc, _Tp> __data_; 3781227825Stheravenpublic: 3782227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 3783227825Stheraven 3784227825Stheraven _LIBCPP_INLINE_VISIBILITY 3785227825Stheraven __shared_ptr_emplace(_Alloc __a) 3786227825Stheraven : __data_(_VSTD::move(__a)) {} 3787227825Stheraven 3788227825Stheraven template <class ..._Args> 3789227825Stheraven _LIBCPP_INLINE_VISIBILITY 3790227825Stheraven __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) 3791232924Stheraven : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), 3792232924Stheraven _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} 3793227825Stheraven 3794227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 3795227825Stheraven 3796227825Stheraven _LIBCPP_INLINE_VISIBILITY 3797227825Stheraven __shared_ptr_emplace(_Alloc __a) 3798227825Stheraven : __data_(__a) {} 3799227825Stheraven 3800227825Stheraven template <class _A0> 3801227825Stheraven _LIBCPP_INLINE_VISIBILITY 3802227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0) 3803227825Stheraven : __data_(__a, _Tp(__a0)) {} 3804227825Stheraven 3805227825Stheraven template <class _A0, class _A1> 3806227825Stheraven _LIBCPP_INLINE_VISIBILITY 3807227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1) 3808227825Stheraven : __data_(__a, _Tp(__a0, __a1)) {} 3809227825Stheraven 3810227825Stheraven template <class _A0, class _A1, class _A2> 3811227825Stheraven _LIBCPP_INLINE_VISIBILITY 3812227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2) 3813227825Stheraven : __data_(__a, _Tp(__a0, __a1, __a2)) {} 3814227825Stheraven 3815227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 3816227825Stheraven 3817227825Stheravenprivate: 3818227825Stheraven virtual void __on_zero_shared() _NOEXCEPT; 3819227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT; 3820227825Stheravenpublic: 3821227825Stheraven _LIBCPP_INLINE_VISIBILITY 3822227825Stheraven _Tp* get() _NOEXCEPT {return &__data_.second();} 3823227825Stheraven}; 3824227825Stheraven 3825227825Stheraventemplate <class _Tp, class _Alloc> 3826227825Stheravenvoid 3827227825Stheraven__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT 3828227825Stheraven{ 3829227825Stheraven __data_.second().~_Tp(); 3830227825Stheraven} 3831227825Stheraven 3832227825Stheraventemplate <class _Tp, class _Alloc> 3833227825Stheravenvoid 3834227825Stheraven__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 3835227825Stheraven{ 3836288943Sdim typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _Al; 3837288943Sdim typedef allocator_traits<_Al> _ATraits; 3838276792Sdim typedef pointer_traits<typename _ATraits::pointer> _PTraits; 3839288943Sdim _Al __a(__data_.first()); 3840227825Stheraven __data_.first().~_Alloc(); 3841276792Sdim __a.deallocate(_PTraits::pointer_to(*this), 1); 3842227825Stheraven} 3843227825Stheraven 3844261272Sdimtemplate<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this; 3845227825Stheraven 3846227825Stheraventemplate<class _Tp> 3847261272Sdimclass _LIBCPP_TYPE_VIS_ONLY shared_ptr 3848227825Stheraven{ 3849227825Stheravenpublic: 3850227825Stheraven typedef _Tp element_type; 3851227825Stheravenprivate: 3852227825Stheraven element_type* __ptr_; 3853227825Stheraven __shared_weak_count* __cntrl_; 3854227825Stheraven 3855227825Stheraven struct __nat {int __for_bool_;}; 3856227825Stheravenpublic: 3857241900Sdim _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; 3858241900Sdim _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; 3859276792Sdim template<class _Yp> 3860276792Sdim explicit shared_ptr(_Yp* __p, 3861276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 3862276792Sdim template<class _Yp, class _Dp> 3863276792Sdim shared_ptr(_Yp* __p, _Dp __d, 3864276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 3865276792Sdim template<class _Yp, class _Dp, class _Alloc> 3866276792Sdim shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, 3867276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 3868227825Stheraven template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); 3869227825Stheraven template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); 3870227825Stheraven template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; 3871227825Stheraven shared_ptr(const shared_ptr& __r) _NOEXCEPT; 3872227825Stheraven template<class _Yp> 3873227825Stheraven shared_ptr(const shared_ptr<_Yp>& __r, 3874227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 3875227825Stheraven _NOEXCEPT; 3876227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3877227825Stheraven shared_ptr(shared_ptr&& __r) _NOEXCEPT; 3878227825Stheraven template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r, 3879227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 3880227825Stheraven _NOEXCEPT; 3881227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3882227825Stheraven template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, 3883227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); 3884227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3885276792Sdim template<class _Yp> 3886276792Sdim shared_ptr(auto_ptr<_Yp>&& __r, 3887276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 3888227825Stheraven#else 3889276792Sdim template<class _Yp> 3890276792Sdim shared_ptr(auto_ptr<_Yp> __r, 3891276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 3892227825Stheraven#endif 3893227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3894276792Sdim template <class _Yp, class _Dp> 3895276792Sdim shared_ptr(unique_ptr<_Yp, _Dp>&&, 3896276792Sdim typename enable_if 3897276792Sdim < 3898276792Sdim !is_lvalue_reference<_Dp>::value && 3899276792Sdim !is_array<_Yp>::value && 3900276792Sdim is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3901276792Sdim __nat 3902276792Sdim >::type = __nat()); 3903276792Sdim template <class _Yp, class _Dp> 3904276792Sdim shared_ptr(unique_ptr<_Yp, _Dp>&&, 3905276792Sdim typename enable_if 3906276792Sdim < 3907276792Sdim is_lvalue_reference<_Dp>::value && 3908276792Sdim !is_array<_Yp>::value && 3909276792Sdim is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3910276792Sdim __nat 3911276792Sdim >::type = __nat()); 3912227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3913276792Sdim template <class _Yp, class _Dp> 3914276792Sdim shared_ptr(unique_ptr<_Yp, _Dp>, 3915276792Sdim typename enable_if 3916276792Sdim < 3917276792Sdim !is_lvalue_reference<_Dp>::value && 3918276792Sdim !is_array<_Yp>::value && 3919276792Sdim is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3920276792Sdim __nat 3921276792Sdim >::type = __nat()); 3922276792Sdim template <class _Yp, class _Dp> 3923276792Sdim shared_ptr(unique_ptr<_Yp, _Dp>, 3924276792Sdim typename enable_if 3925276792Sdim < 3926276792Sdim is_lvalue_reference<_Dp>::value && 3927276792Sdim !is_array<_Yp>::value && 3928276792Sdim is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3929276792Sdim __nat 3930276792Sdim >::type = __nat()); 3931227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3932227825Stheraven 3933227825Stheraven ~shared_ptr(); 3934227825Stheraven 3935227825Stheraven shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; 3936232924Stheraven template<class _Yp> 3937232924Stheraven typename enable_if 3938232924Stheraven < 3939232924Stheraven is_convertible<_Yp*, element_type*>::value, 3940232924Stheraven shared_ptr& 3941232924Stheraven >::type 3942232924Stheraven operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; 3943227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3944227825Stheraven shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; 3945232924Stheraven template<class _Yp> 3946232924Stheraven typename enable_if 3947232924Stheraven < 3948232924Stheraven is_convertible<_Yp*, element_type*>::value, 3949232924Stheraven shared_ptr<_Tp>& 3950232924Stheraven >::type 3951232924Stheraven operator=(shared_ptr<_Yp>&& __r); 3952232924Stheraven template<class _Yp> 3953232924Stheraven typename enable_if 3954232924Stheraven < 3955232924Stheraven !is_array<_Yp>::value && 3956232924Stheraven is_convertible<_Yp*, element_type*>::value, 3957261272Sdim shared_ptr 3958261272Sdim >::type& 3959232924Stheraven operator=(auto_ptr<_Yp>&& __r); 3960227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3961232924Stheraven template<class _Yp> 3962232924Stheraven typename enable_if 3963232924Stheraven < 3964232924Stheraven !is_array<_Yp>::value && 3965232924Stheraven is_convertible<_Yp*, element_type*>::value, 3966232924Stheraven shared_ptr& 3967232924Stheraven >::type 3968232924Stheraven operator=(auto_ptr<_Yp> __r); 3969227825Stheraven#endif 3970232924Stheraven template <class _Yp, class _Dp> 3971232924Stheraven typename enable_if 3972232924Stheraven < 3973232924Stheraven !is_array<_Yp>::value && 3974232924Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3975232924Stheraven shared_ptr& 3976232924Stheraven >::type 3977227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3978232924Stheraven operator=(unique_ptr<_Yp, _Dp>&& __r); 3979227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3980232924Stheraven operator=(unique_ptr<_Yp, _Dp> __r); 3981227825Stheraven#endif 3982227825Stheraven 3983227825Stheraven void swap(shared_ptr& __r) _NOEXCEPT; 3984227825Stheraven void reset() _NOEXCEPT; 3985232924Stheraven template<class _Yp> 3986232924Stheraven typename enable_if 3987232924Stheraven < 3988232924Stheraven is_convertible<_Yp*, element_type*>::value, 3989232924Stheraven void 3990232924Stheraven >::type 3991232924Stheraven reset(_Yp* __p); 3992232924Stheraven template<class _Yp, class _Dp> 3993232924Stheraven typename enable_if 3994232924Stheraven < 3995232924Stheraven is_convertible<_Yp*, element_type*>::value, 3996232924Stheraven void 3997232924Stheraven >::type 3998232924Stheraven reset(_Yp* __p, _Dp __d); 3999232924Stheraven template<class _Yp, class _Dp, class _Alloc> 4000232924Stheraven typename enable_if 4001232924Stheraven < 4002232924Stheraven is_convertible<_Yp*, element_type*>::value, 4003232924Stheraven void 4004232924Stheraven >::type 4005232924Stheraven reset(_Yp* __p, _Dp __d, _Alloc __a); 4006227825Stheraven 4007227825Stheraven _LIBCPP_INLINE_VISIBILITY 4008227825Stheraven element_type* get() const _NOEXCEPT {return __ptr_;} 4009227825Stheraven _LIBCPP_INLINE_VISIBILITY 4010227825Stheraven typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT 4011227825Stheraven {return *__ptr_;} 4012227825Stheraven _LIBCPP_INLINE_VISIBILITY 4013227825Stheraven element_type* operator->() const _NOEXCEPT {return __ptr_;} 4014227825Stheraven _LIBCPP_INLINE_VISIBILITY 4015227825Stheraven long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} 4016227825Stheraven _LIBCPP_INLINE_VISIBILITY 4017227825Stheraven bool unique() const _NOEXCEPT {return use_count() == 1;} 4018227825Stheraven _LIBCPP_INLINE_VISIBILITY 4019232924Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;} 4020232924Stheraven template <class _Up> 4021227825Stheraven _LIBCPP_INLINE_VISIBILITY 4022232924Stheraven bool owner_before(shared_ptr<_Up> const& __p) const 4023227825Stheraven {return __cntrl_ < __p.__cntrl_;} 4024232924Stheraven template <class _Up> 4025227825Stheraven _LIBCPP_INLINE_VISIBILITY 4026232924Stheraven bool owner_before(weak_ptr<_Up> const& __p) const 4027227825Stheraven {return __cntrl_ < __p.__cntrl_;} 4028241900Sdim _LIBCPP_INLINE_VISIBILITY 4029241900Sdim bool 4030241900Sdim __owner_equivalent(const shared_ptr& __p) const 4031241900Sdim {return __cntrl_ == __p.__cntrl_;} 4032227825Stheraven 4033227825Stheraven#ifndef _LIBCPP_NO_RTTI 4034227825Stheraven template <class _Dp> 4035227825Stheraven _LIBCPP_INLINE_VISIBILITY 4036227825Stheraven _Dp* __get_deleter() const _NOEXCEPT 4037227825Stheraven {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} 4038227825Stheraven#endif // _LIBCPP_NO_RTTI 4039227825Stheraven 4040227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 4041227825Stheraven 4042227825Stheraven template<class ..._Args> 4043227825Stheraven static 4044227825Stheraven shared_ptr<_Tp> 4045227825Stheraven make_shared(_Args&& ...__args); 4046227825Stheraven 4047227825Stheraven template<class _Alloc, class ..._Args> 4048227825Stheraven static 4049227825Stheraven shared_ptr<_Tp> 4050227825Stheraven allocate_shared(const _Alloc& __a, _Args&& ...__args); 4051227825Stheraven 4052227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 4053227825Stheraven 4054227825Stheraven static shared_ptr<_Tp> make_shared(); 4055227825Stheraven 4056227825Stheraven template<class _A0> 4057227825Stheraven static shared_ptr<_Tp> make_shared(_A0&); 4058227825Stheraven 4059227825Stheraven template<class _A0, class _A1> 4060227825Stheraven static shared_ptr<_Tp> make_shared(_A0&, _A1&); 4061227825Stheraven 4062227825Stheraven template<class _A0, class _A1, class _A2> 4063227825Stheraven static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&); 4064227825Stheraven 4065227825Stheraven template<class _Alloc> 4066227825Stheraven static shared_ptr<_Tp> 4067227825Stheraven allocate_shared(const _Alloc& __a); 4068227825Stheraven 4069227825Stheraven template<class _Alloc, class _A0> 4070227825Stheraven static shared_ptr<_Tp> 4071227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0); 4072227825Stheraven 4073227825Stheraven template<class _Alloc, class _A0, class _A1> 4074227825Stheraven static shared_ptr<_Tp> 4075227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1); 4076227825Stheraven 4077227825Stheraven template<class _Alloc, class _A0, class _A1, class _A2> 4078227825Stheraven static shared_ptr<_Tp> 4079227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2); 4080227825Stheraven 4081227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4082227825Stheraven 4083227825Stheravenprivate: 4084227825Stheraven 4085227825Stheraven template <class _Yp> 4086227825Stheraven _LIBCPP_INLINE_VISIBILITY 4087227825Stheraven void 4088227825Stheraven __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT 4089227825Stheraven { 4090227825Stheraven if (__e) 4091288943Sdim { 4092288943Sdim __e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast<const _Yp*>(__e)); 4093288943Sdim __e->__weak_this_.__cntrl_ = __cntrl_; 4094288943Sdim __cntrl_->__add_weak(); 4095288943Sdim } 4096227825Stheraven } 4097227825Stheraven 4098227825Stheraven _LIBCPP_INLINE_VISIBILITY 4099288943Sdim void __enable_weak_this(const volatile void*) _NOEXCEPT {} 4100227825Stheraven 4101261272Sdim template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; 4102261272Sdim template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 4103227825Stheraven}; 4104227825Stheraven 4105227825Stheraventemplate<class _Tp> 4106227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4107241900Sdim_LIBCPP_CONSTEXPR 4108227825Stheravenshared_ptr<_Tp>::shared_ptr() _NOEXCEPT 4109227825Stheraven : __ptr_(0), 4110227825Stheraven __cntrl_(0) 4111227825Stheraven{ 4112227825Stheraven} 4113227825Stheraven 4114227825Stheraventemplate<class _Tp> 4115227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4116241900Sdim_LIBCPP_CONSTEXPR 4117227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT 4118227825Stheraven : __ptr_(0), 4119227825Stheraven __cntrl_(0) 4120227825Stheraven{ 4121227825Stheraven} 4122227825Stheraven 4123227825Stheraventemplate<class _Tp> 4124276792Sdimtemplate<class _Yp> 4125276792Sdimshared_ptr<_Tp>::shared_ptr(_Yp* __p, 4126276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) 4127227825Stheraven : __ptr_(__p) 4128227825Stheraven{ 4129227825Stheraven unique_ptr<_Yp> __hold(__p); 4130227825Stheraven typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 4131227825Stheraven __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); 4132227825Stheraven __hold.release(); 4133227825Stheraven __enable_weak_this(__p); 4134227825Stheraven} 4135227825Stheraven 4136227825Stheraventemplate<class _Tp> 4137276792Sdimtemplate<class _Yp, class _Dp> 4138276792Sdimshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, 4139276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) 4140227825Stheraven : __ptr_(__p) 4141227825Stheraven{ 4142227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4143227825Stheraven try 4144227825Stheraven { 4145227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4146227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 4147227825Stheraven __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); 4148227825Stheraven __enable_weak_this(__p); 4149227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4150227825Stheraven } 4151227825Stheraven catch (...) 4152227825Stheraven { 4153227825Stheraven __d(__p); 4154227825Stheraven throw; 4155227825Stheraven } 4156227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4157227825Stheraven} 4158227825Stheraven 4159227825Stheraventemplate<class _Tp> 4160227825Stheraventemplate<class _Dp> 4161227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) 4162227825Stheraven : __ptr_(0) 4163227825Stheraven{ 4164227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4165227825Stheraven try 4166227825Stheraven { 4167227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4168227825Stheraven typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; 4169227825Stheraven __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); 4170227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4171227825Stheraven } 4172227825Stheraven catch (...) 4173227825Stheraven { 4174227825Stheraven __d(__p); 4175227825Stheraven throw; 4176227825Stheraven } 4177227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4178227825Stheraven} 4179227825Stheraven 4180227825Stheraventemplate<class _Tp> 4181276792Sdimtemplate<class _Yp, class _Dp, class _Alloc> 4182276792Sdimshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, 4183276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) 4184227825Stheraven : __ptr_(__p) 4185227825Stheraven{ 4186227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4187227825Stheraven try 4188227825Stheraven { 4189227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4190227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; 4191276792Sdim typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; 4192227825Stheraven typedef __allocator_destructor<_A2> _D2; 4193227825Stheraven _A2 __a2(__a); 4194227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4195276792Sdim ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4196276792Sdim _CntrlBlk(__p, __d, __a); 4197276792Sdim __cntrl_ = _VSTD::addressof(*__hold2.release()); 4198227825Stheraven __enable_weak_this(__p); 4199227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4200227825Stheraven } 4201227825Stheraven catch (...) 4202227825Stheraven { 4203227825Stheraven __d(__p); 4204227825Stheraven throw; 4205227825Stheraven } 4206227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4207227825Stheraven} 4208227825Stheraven 4209227825Stheraventemplate<class _Tp> 4210227825Stheraventemplate<class _Dp, class _Alloc> 4211227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) 4212227825Stheraven : __ptr_(0) 4213227825Stheraven{ 4214227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4215227825Stheraven try 4216227825Stheraven { 4217227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4218227825Stheraven typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; 4219276792Sdim typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; 4220227825Stheraven typedef __allocator_destructor<_A2> _D2; 4221227825Stheraven _A2 __a2(__a); 4222227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4223276792Sdim ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4224276792Sdim _CntrlBlk(__p, __d, __a); 4225276792Sdim __cntrl_ = _VSTD::addressof(*__hold2.release()); 4226227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4227227825Stheraven } 4228227825Stheraven catch (...) 4229227825Stheraven { 4230227825Stheraven __d(__p); 4231227825Stheraven throw; 4232227825Stheraven } 4233227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4234227825Stheraven} 4235227825Stheraven 4236227825Stheraventemplate<class _Tp> 4237227825Stheraventemplate<class _Yp> 4238227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4239227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT 4240227825Stheraven : __ptr_(__p), 4241227825Stheraven __cntrl_(__r.__cntrl_) 4242227825Stheraven{ 4243227825Stheraven if (__cntrl_) 4244227825Stheraven __cntrl_->__add_shared(); 4245227825Stheraven} 4246227825Stheraven 4247227825Stheraventemplate<class _Tp> 4248227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4249227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT 4250227825Stheraven : __ptr_(__r.__ptr_), 4251227825Stheraven __cntrl_(__r.__cntrl_) 4252227825Stheraven{ 4253227825Stheraven if (__cntrl_) 4254227825Stheraven __cntrl_->__add_shared(); 4255227825Stheraven} 4256227825Stheraven 4257227825Stheraventemplate<class _Tp> 4258227825Stheraventemplate<class _Yp> 4259227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4260227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, 4261227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 4262227825Stheraven _NOEXCEPT 4263227825Stheraven : __ptr_(__r.__ptr_), 4264227825Stheraven __cntrl_(__r.__cntrl_) 4265227825Stheraven{ 4266227825Stheraven if (__cntrl_) 4267227825Stheraven __cntrl_->__add_shared(); 4268227825Stheraven} 4269227825Stheraven 4270227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4271227825Stheraven 4272227825Stheraventemplate<class _Tp> 4273227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4274227825Stheravenshared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT 4275227825Stheraven : __ptr_(__r.__ptr_), 4276227825Stheraven __cntrl_(__r.__cntrl_) 4277227825Stheraven{ 4278227825Stheraven __r.__ptr_ = 0; 4279227825Stheraven __r.__cntrl_ = 0; 4280227825Stheraven} 4281227825Stheraven 4282227825Stheraventemplate<class _Tp> 4283227825Stheraventemplate<class _Yp> 4284227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4285227825Stheravenshared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, 4286227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 4287227825Stheraven _NOEXCEPT 4288227825Stheraven : __ptr_(__r.__ptr_), 4289227825Stheraven __cntrl_(__r.__cntrl_) 4290227825Stheraven{ 4291227825Stheraven __r.__ptr_ = 0; 4292227825Stheraven __r.__cntrl_ = 0; 4293227825Stheraven} 4294227825Stheraven 4295227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4296227825Stheraven 4297227825Stheraventemplate<class _Tp> 4298276792Sdimtemplate<class _Yp> 4299227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4300276792Sdimshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r, 4301227825Stheraven#else 4302276792Sdimshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r, 4303227825Stheraven#endif 4304276792Sdim typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) 4305227825Stheraven : __ptr_(__r.get()) 4306227825Stheraven{ 4307227825Stheraven typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 4308227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); 4309227825Stheraven __enable_weak_this(__r.get()); 4310227825Stheraven __r.release(); 4311227825Stheraven} 4312227825Stheraven 4313227825Stheraventemplate<class _Tp> 4314276792Sdimtemplate <class _Yp, class _Dp> 4315227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4316227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 4317227825Stheraven#else 4318227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 4319227825Stheraven#endif 4320276792Sdim typename enable_if 4321276792Sdim < 4322276792Sdim !is_lvalue_reference<_Dp>::value && 4323276792Sdim !is_array<_Yp>::value && 4324276792Sdim is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 4325276792Sdim __nat 4326276792Sdim >::type) 4327227825Stheraven : __ptr_(__r.get()) 4328227825Stheraven{ 4329288943Sdim#if _LIBCPP_STD_VER > 11 4330288943Sdim if (__ptr_ == nullptr) 4331288943Sdim __cntrl_ = nullptr; 4332288943Sdim else 4333288943Sdim#endif 4334288943Sdim { 4335288943Sdim typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 4336288943Sdim __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); 4337288943Sdim __enable_weak_this(__r.get()); 4338288943Sdim } 4339227825Stheraven __r.release(); 4340227825Stheraven} 4341227825Stheraven 4342227825Stheraventemplate<class _Tp> 4343276792Sdimtemplate <class _Yp, class _Dp> 4344227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4345227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 4346227825Stheraven#else 4347227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 4348227825Stheraven#endif 4349276792Sdim typename enable_if 4350276792Sdim < 4351276792Sdim is_lvalue_reference<_Dp>::value && 4352276792Sdim !is_array<_Yp>::value && 4353276792Sdim is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 4354276792Sdim __nat 4355276792Sdim >::type) 4356227825Stheraven : __ptr_(__r.get()) 4357227825Stheraven{ 4358288943Sdim#if _LIBCPP_STD_VER > 11 4359288943Sdim if (__ptr_ == nullptr) 4360288943Sdim __cntrl_ = nullptr; 4361288943Sdim else 4362288943Sdim#endif 4363288943Sdim { 4364288943Sdim typedef __shared_ptr_pointer<_Yp*, 4365288943Sdim reference_wrapper<typename remove_reference<_Dp>::type>, 4366288943Sdim allocator<_Yp> > _CntrlBlk; 4367288943Sdim __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); 4368288943Sdim __enable_weak_this(__r.get()); 4369288943Sdim } 4370227825Stheraven __r.release(); 4371227825Stheraven} 4372227825Stheraven 4373227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 4374227825Stheraven 4375227825Stheraventemplate<class _Tp> 4376227825Stheraventemplate<class ..._Args> 4377227825Stheravenshared_ptr<_Tp> 4378227825Stheravenshared_ptr<_Tp>::make_shared(_Args&& ...__args) 4379227825Stheraven{ 4380227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4381227825Stheraven typedef allocator<_CntrlBlk> _A2; 4382227825Stheraven typedef __allocator_destructor<_A2> _D2; 4383227825Stheraven _A2 __a2; 4384227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4385227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); 4386227825Stheraven shared_ptr<_Tp> __r; 4387227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4388227825Stheraven __r.__cntrl_ = __hold2.release(); 4389227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4390227825Stheraven return __r; 4391227825Stheraven} 4392227825Stheraven 4393227825Stheraventemplate<class _Tp> 4394227825Stheraventemplate<class _Alloc, class ..._Args> 4395227825Stheravenshared_ptr<_Tp> 4396227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) 4397227825Stheraven{ 4398227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4399276792Sdim typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; 4400227825Stheraven typedef __allocator_destructor<_A2> _D2; 4401227825Stheraven _A2 __a2(__a); 4402227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4403276792Sdim ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4404276792Sdim _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); 4405227825Stheraven shared_ptr<_Tp> __r; 4406227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4407276792Sdim __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 4408227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4409227825Stheraven return __r; 4410227825Stheraven} 4411227825Stheraven 4412227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 4413227825Stheraven 4414227825Stheraventemplate<class _Tp> 4415227825Stheravenshared_ptr<_Tp> 4416227825Stheravenshared_ptr<_Tp>::make_shared() 4417227825Stheraven{ 4418227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4419227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4420227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4421227825Stheraven _Alloc2 __alloc2; 4422227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4423227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2); 4424227825Stheraven shared_ptr<_Tp> __r; 4425227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4426227825Stheraven __r.__cntrl_ = __hold2.release(); 4427227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4428227825Stheraven return __r; 4429227825Stheraven} 4430227825Stheraven 4431227825Stheraventemplate<class _Tp> 4432227825Stheraventemplate<class _A0> 4433227825Stheravenshared_ptr<_Tp> 4434227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0) 4435227825Stheraven{ 4436227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4437227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4438227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4439227825Stheraven _Alloc2 __alloc2; 4440227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4441227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); 4442227825Stheraven shared_ptr<_Tp> __r; 4443227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4444227825Stheraven __r.__cntrl_ = __hold2.release(); 4445227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4446227825Stheraven return __r; 4447227825Stheraven} 4448227825Stheraven 4449227825Stheraventemplate<class _Tp> 4450227825Stheraventemplate<class _A0, class _A1> 4451227825Stheravenshared_ptr<_Tp> 4452227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) 4453227825Stheraven{ 4454227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4455227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4456227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4457227825Stheraven _Alloc2 __alloc2; 4458227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4459227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); 4460227825Stheraven shared_ptr<_Tp> __r; 4461227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4462227825Stheraven __r.__cntrl_ = __hold2.release(); 4463227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4464227825Stheraven return __r; 4465227825Stheraven} 4466227825Stheraven 4467227825Stheraventemplate<class _Tp> 4468227825Stheraventemplate<class _A0, class _A1, class _A2> 4469227825Stheravenshared_ptr<_Tp> 4470227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) 4471227825Stheraven{ 4472227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4473227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4474227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4475227825Stheraven _Alloc2 __alloc2; 4476227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4477227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); 4478227825Stheraven shared_ptr<_Tp> __r; 4479227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4480227825Stheraven __r.__cntrl_ = __hold2.release(); 4481227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4482227825Stheraven return __r; 4483227825Stheraven} 4484227825Stheraven 4485227825Stheraventemplate<class _Tp> 4486227825Stheraventemplate<class _Alloc> 4487227825Stheravenshared_ptr<_Tp> 4488227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a) 4489227825Stheraven{ 4490227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4491276792Sdim typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; 4492227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4493227825Stheraven _Alloc2 __alloc2(__a); 4494227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4495276792Sdim ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4496276792Sdim _CntrlBlk(__a); 4497227825Stheraven shared_ptr<_Tp> __r; 4498227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4499276792Sdim __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 4500227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4501227825Stheraven return __r; 4502227825Stheraven} 4503227825Stheraven 4504227825Stheraventemplate<class _Tp> 4505227825Stheraventemplate<class _Alloc, class _A0> 4506227825Stheravenshared_ptr<_Tp> 4507227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) 4508227825Stheraven{ 4509227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4510276792Sdim typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; 4511227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4512227825Stheraven _Alloc2 __alloc2(__a); 4513227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4514276792Sdim ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4515276792Sdim _CntrlBlk(__a, __a0); 4516227825Stheraven shared_ptr<_Tp> __r; 4517227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4518276792Sdim __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 4519227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4520227825Stheraven return __r; 4521227825Stheraven} 4522227825Stheraven 4523227825Stheraventemplate<class _Tp> 4524227825Stheraventemplate<class _Alloc, class _A0, class _A1> 4525227825Stheravenshared_ptr<_Tp> 4526227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 4527227825Stheraven{ 4528227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4529276792Sdim typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; 4530227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4531227825Stheraven _Alloc2 __alloc2(__a); 4532227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4533276792Sdim ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4534276792Sdim _CntrlBlk(__a, __a0, __a1); 4535227825Stheraven shared_ptr<_Tp> __r; 4536227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4537276792Sdim __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 4538227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4539227825Stheraven return __r; 4540227825Stheraven} 4541227825Stheraven 4542227825Stheraventemplate<class _Tp> 4543227825Stheraventemplate<class _Alloc, class _A0, class _A1, class _A2> 4544227825Stheravenshared_ptr<_Tp> 4545227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 4546227825Stheraven{ 4547227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4548276792Sdim typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; 4549227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4550227825Stheraven _Alloc2 __alloc2(__a); 4551227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4552276792Sdim ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4553276792Sdim _CntrlBlk(__a, __a0, __a1, __a2); 4554227825Stheraven shared_ptr<_Tp> __r; 4555227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4556276792Sdim __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 4557227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4558227825Stheraven return __r; 4559227825Stheraven} 4560227825Stheraven 4561227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4562227825Stheraven 4563227825Stheraventemplate<class _Tp> 4564227825Stheravenshared_ptr<_Tp>::~shared_ptr() 4565227825Stheraven{ 4566227825Stheraven if (__cntrl_) 4567227825Stheraven __cntrl_->__release_shared(); 4568227825Stheraven} 4569227825Stheraven 4570227825Stheraventemplate<class _Tp> 4571227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4572227825Stheravenshared_ptr<_Tp>& 4573227825Stheravenshared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT 4574227825Stheraven{ 4575227825Stheraven shared_ptr(__r).swap(*this); 4576227825Stheraven return *this; 4577227825Stheraven} 4578227825Stheraven 4579227825Stheraventemplate<class _Tp> 4580227825Stheraventemplate<class _Yp> 4581227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4582232924Stheraventypename enable_if 4583232924Stheraven< 4584232924Stheraven is_convertible<_Yp*, _Tp*>::value, 4585232924Stheraven shared_ptr<_Tp>& 4586232924Stheraven>::type 4587227825Stheravenshared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT 4588227825Stheraven{ 4589227825Stheraven shared_ptr(__r).swap(*this); 4590227825Stheraven return *this; 4591227825Stheraven} 4592227825Stheraven 4593227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4594227825Stheraven 4595227825Stheraventemplate<class _Tp> 4596227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4597227825Stheravenshared_ptr<_Tp>& 4598227825Stheravenshared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT 4599227825Stheraven{ 4600227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4601227825Stheraven return *this; 4602227825Stheraven} 4603227825Stheraven 4604227825Stheraventemplate<class _Tp> 4605227825Stheraventemplate<class _Yp> 4606227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4607232924Stheraventypename enable_if 4608232924Stheraven< 4609232924Stheraven is_convertible<_Yp*, _Tp*>::value, 4610232924Stheraven shared_ptr<_Tp>& 4611232924Stheraven>::type 4612227825Stheravenshared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) 4613227825Stheraven{ 4614227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4615227825Stheraven return *this; 4616227825Stheraven} 4617227825Stheraven 4618227825Stheraventemplate<class _Tp> 4619227825Stheraventemplate<class _Yp> 4620227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4621232924Stheraventypename enable_if 4622232924Stheraven< 4623232924Stheraven !is_array<_Yp>::value && 4624232924Stheraven is_convertible<_Yp*, _Tp*>::value, 4625261272Sdim shared_ptr<_Tp> 4626261272Sdim>::type& 4627227825Stheravenshared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) 4628227825Stheraven{ 4629227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4630227825Stheraven return *this; 4631227825Stheraven} 4632227825Stheraven 4633227825Stheraventemplate<class _Tp> 4634227825Stheraventemplate <class _Yp, class _Dp> 4635227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4636232924Stheraventypename enable_if 4637232924Stheraven< 4638232924Stheraven !is_array<_Yp>::value && 4639232924Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, 4640232924Stheraven shared_ptr<_Tp>& 4641232924Stheraven>::type 4642227825Stheravenshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) 4643227825Stheraven{ 4644227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4645227825Stheraven return *this; 4646227825Stheraven} 4647227825Stheraven 4648227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4649227825Stheraven 4650227825Stheraventemplate<class _Tp> 4651227825Stheraventemplate<class _Yp> 4652227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4653232924Stheraventypename enable_if 4654232924Stheraven< 4655232924Stheraven !is_array<_Yp>::value && 4656232924Stheraven is_convertible<_Yp*, _Tp*>::value, 4657232924Stheraven shared_ptr<_Tp>& 4658232924Stheraven>::type 4659227825Stheravenshared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) 4660227825Stheraven{ 4661227825Stheraven shared_ptr(__r).swap(*this); 4662227825Stheraven return *this; 4663227825Stheraven} 4664227825Stheraven 4665227825Stheraventemplate<class _Tp> 4666227825Stheraventemplate <class _Yp, class _Dp> 4667227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4668232924Stheraventypename enable_if 4669232924Stheraven< 4670232924Stheraven !is_array<_Yp>::value && 4671232924Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, 4672232924Stheraven shared_ptr<_Tp>& 4673232924Stheraven>::type 4674227825Stheravenshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) 4675227825Stheraven{ 4676227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4677227825Stheraven return *this; 4678227825Stheraven} 4679227825Stheraven 4680227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4681227825Stheraven 4682227825Stheraventemplate<class _Tp> 4683227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4684227825Stheravenvoid 4685227825Stheravenshared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT 4686227825Stheraven{ 4687227825Stheraven _VSTD::swap(__ptr_, __r.__ptr_); 4688227825Stheraven _VSTD::swap(__cntrl_, __r.__cntrl_); 4689227825Stheraven} 4690227825Stheraven 4691227825Stheraventemplate<class _Tp> 4692227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4693227825Stheravenvoid 4694227825Stheravenshared_ptr<_Tp>::reset() _NOEXCEPT 4695227825Stheraven{ 4696227825Stheraven shared_ptr().swap(*this); 4697227825Stheraven} 4698227825Stheraven 4699227825Stheraventemplate<class _Tp> 4700227825Stheraventemplate<class _Yp> 4701227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4702232924Stheraventypename enable_if 4703232924Stheraven< 4704232924Stheraven is_convertible<_Yp*, _Tp*>::value, 4705232924Stheraven void 4706232924Stheraven>::type 4707227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p) 4708227825Stheraven{ 4709227825Stheraven shared_ptr(__p).swap(*this); 4710227825Stheraven} 4711227825Stheraven 4712227825Stheraventemplate<class _Tp> 4713227825Stheraventemplate<class _Yp, class _Dp> 4714227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4715232924Stheraventypename enable_if 4716232924Stheraven< 4717232924Stheraven is_convertible<_Yp*, _Tp*>::value, 4718232924Stheraven void 4719232924Stheraven>::type 4720227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) 4721227825Stheraven{ 4722227825Stheraven shared_ptr(__p, __d).swap(*this); 4723227825Stheraven} 4724227825Stheraven 4725227825Stheraventemplate<class _Tp> 4726227825Stheraventemplate<class _Yp, class _Dp, class _Alloc> 4727227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4728232924Stheraventypename enable_if 4729232924Stheraven< 4730232924Stheraven is_convertible<_Yp*, _Tp*>::value, 4731232924Stheraven void 4732232924Stheraven>::type 4733227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) 4734227825Stheraven{ 4735227825Stheraven shared_ptr(__p, __d, __a).swap(*this); 4736227825Stheraven} 4737227825Stheraven 4738227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 4739227825Stheraven 4740227825Stheraventemplate<class _Tp, class ..._Args> 4741227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4742232924Stheraventypename enable_if 4743232924Stheraven< 4744232924Stheraven !is_array<_Tp>::value, 4745232924Stheraven shared_ptr<_Tp> 4746232924Stheraven>::type 4747227825Stheravenmake_shared(_Args&& ...__args) 4748227825Stheraven{ 4749227825Stheraven return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...); 4750227825Stheraven} 4751227825Stheraven 4752227825Stheraventemplate<class _Tp, class _Alloc, class ..._Args> 4753227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4754232924Stheraventypename enable_if 4755232924Stheraven< 4756232924Stheraven !is_array<_Tp>::value, 4757232924Stheraven shared_ptr<_Tp> 4758232924Stheraven>::type 4759227825Stheravenallocate_shared(const _Alloc& __a, _Args&& ...__args) 4760227825Stheraven{ 4761227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...); 4762227825Stheraven} 4763227825Stheraven 4764227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 4765227825Stheraven 4766227825Stheraventemplate<class _Tp> 4767227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4768227825Stheravenshared_ptr<_Tp> 4769227825Stheravenmake_shared() 4770227825Stheraven{ 4771227825Stheraven return shared_ptr<_Tp>::make_shared(); 4772227825Stheraven} 4773227825Stheraven 4774227825Stheraventemplate<class _Tp, class _A0> 4775227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4776227825Stheravenshared_ptr<_Tp> 4777227825Stheravenmake_shared(_A0& __a0) 4778227825Stheraven{ 4779227825Stheraven return shared_ptr<_Tp>::make_shared(__a0); 4780227825Stheraven} 4781227825Stheraven 4782227825Stheraventemplate<class _Tp, class _A0, class _A1> 4783227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4784227825Stheravenshared_ptr<_Tp> 4785227825Stheravenmake_shared(_A0& __a0, _A1& __a1) 4786227825Stheraven{ 4787227825Stheraven return shared_ptr<_Tp>::make_shared(__a0, __a1); 4788227825Stheraven} 4789227825Stheraven 4790227825Stheraventemplate<class _Tp, class _A0, class _A1, class _A2> 4791227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4792227825Stheravenshared_ptr<_Tp> 4793227825Stheravenmake_shared(_A0& __a0, _A1& __a1, _A2& __a2) 4794227825Stheraven{ 4795227825Stheraven return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2); 4796227825Stheraven} 4797227825Stheraven 4798227825Stheraventemplate<class _Tp, class _Alloc> 4799227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4800227825Stheravenshared_ptr<_Tp> 4801227825Stheravenallocate_shared(const _Alloc& __a) 4802227825Stheraven{ 4803227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a); 4804227825Stheraven} 4805227825Stheraven 4806227825Stheraventemplate<class _Tp, class _Alloc, class _A0> 4807227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4808227825Stheravenshared_ptr<_Tp> 4809227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0) 4810227825Stheraven{ 4811227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0); 4812227825Stheraven} 4813227825Stheraven 4814227825Stheraventemplate<class _Tp, class _Alloc, class _A0, class _A1> 4815227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4816227825Stheravenshared_ptr<_Tp> 4817227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 4818227825Stheraven{ 4819227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1); 4820227825Stheraven} 4821227825Stheraven 4822227825Stheraventemplate<class _Tp, class _Alloc, class _A0, class _A1, class _A2> 4823227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4824227825Stheravenshared_ptr<_Tp> 4825227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 4826227825Stheraven{ 4827227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2); 4828227825Stheraven} 4829227825Stheraven 4830227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4831227825Stheraven 4832227825Stheraventemplate<class _Tp, class _Up> 4833227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4834227825Stheravenbool 4835227825Stheravenoperator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4836227825Stheraven{ 4837227825Stheraven return __x.get() == __y.get(); 4838227825Stheraven} 4839227825Stheraven 4840227825Stheraventemplate<class _Tp, class _Up> 4841227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4842227825Stheravenbool 4843227825Stheravenoperator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4844227825Stheraven{ 4845227825Stheraven return !(__x == __y); 4846227825Stheraven} 4847227825Stheraven 4848227825Stheraventemplate<class _Tp, class _Up> 4849227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4850227825Stheravenbool 4851227825Stheravenoperator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4852227825Stheraven{ 4853288943Sdim typedef typename common_type<_Tp*, _Up*>::type _Vp; 4854288943Sdim return less<_Vp>()(__x.get(), __y.get()); 4855227825Stheraven} 4856227825Stheraven 4857232924Stheraventemplate<class _Tp, class _Up> 4858232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4859232924Stheravenbool 4860232924Stheravenoperator>(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4861232924Stheraven{ 4862232924Stheraven return __y < __x; 4863232924Stheraven} 4864232924Stheraven 4865232924Stheraventemplate<class _Tp, class _Up> 4866232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4867232924Stheravenbool 4868232924Stheravenoperator<=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4869232924Stheraven{ 4870232924Stheraven return !(__y < __x); 4871232924Stheraven} 4872232924Stheraven 4873232924Stheraventemplate<class _Tp, class _Up> 4874232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4875232924Stheravenbool 4876232924Stheravenoperator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4877232924Stheraven{ 4878232924Stheraven return !(__x < __y); 4879232924Stheraven} 4880232924Stheraven 4881227825Stheraventemplate<class _Tp> 4882227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4883232924Stheravenbool 4884232924Stheravenoperator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4885232924Stheraven{ 4886232924Stheraven return !__x; 4887232924Stheraven} 4888232924Stheraven 4889232924Stheraventemplate<class _Tp> 4890232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4891232924Stheravenbool 4892232924Stheravenoperator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4893232924Stheraven{ 4894232924Stheraven return !__x; 4895232924Stheraven} 4896232924Stheraven 4897232924Stheraventemplate<class _Tp> 4898232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4899232924Stheravenbool 4900232924Stheravenoperator!=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4901232924Stheraven{ 4902232924Stheraven return static_cast<bool>(__x); 4903232924Stheraven} 4904232924Stheraven 4905232924Stheraventemplate<class _Tp> 4906232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4907232924Stheravenbool 4908232924Stheravenoperator!=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4909232924Stheraven{ 4910232924Stheraven return static_cast<bool>(__x); 4911232924Stheraven} 4912232924Stheraven 4913232924Stheraventemplate<class _Tp> 4914232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4915232924Stheravenbool 4916232924Stheravenoperator<(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4917232924Stheraven{ 4918232924Stheraven return less<_Tp*>()(__x.get(), nullptr); 4919232924Stheraven} 4920232924Stheraven 4921232924Stheraventemplate<class _Tp> 4922232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4923232924Stheravenbool 4924232924Stheravenoperator<(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4925232924Stheraven{ 4926232924Stheraven return less<_Tp*>()(nullptr, __x.get()); 4927232924Stheraven} 4928232924Stheraven 4929232924Stheraventemplate<class _Tp> 4930232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4931232924Stheravenbool 4932232924Stheravenoperator>(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4933232924Stheraven{ 4934232924Stheraven return nullptr < __x; 4935232924Stheraven} 4936232924Stheraven 4937232924Stheraventemplate<class _Tp> 4938232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4939232924Stheravenbool 4940232924Stheravenoperator>(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4941232924Stheraven{ 4942232924Stheraven return __x < nullptr; 4943232924Stheraven} 4944232924Stheraven 4945232924Stheraventemplate<class _Tp> 4946232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4947232924Stheravenbool 4948232924Stheravenoperator<=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4949232924Stheraven{ 4950232924Stheraven return !(nullptr < __x); 4951232924Stheraven} 4952232924Stheraven 4953232924Stheraventemplate<class _Tp> 4954232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4955232924Stheravenbool 4956232924Stheravenoperator<=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4957232924Stheraven{ 4958232924Stheraven return !(__x < nullptr); 4959232924Stheraven} 4960232924Stheraven 4961232924Stheraventemplate<class _Tp> 4962232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4963232924Stheravenbool 4964232924Stheravenoperator>=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4965232924Stheraven{ 4966232924Stheraven return !(__x < nullptr); 4967232924Stheraven} 4968232924Stheraven 4969232924Stheraventemplate<class _Tp> 4970232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4971232924Stheravenbool 4972232924Stheravenoperator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4973232924Stheraven{ 4974232924Stheraven return !(nullptr < __x); 4975232924Stheraven} 4976232924Stheraven 4977232924Stheraventemplate<class _Tp> 4978232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 4979227825Stheravenvoid 4980227825Stheravenswap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT 4981227825Stheraven{ 4982227825Stheraven __x.swap(__y); 4983227825Stheraven} 4984227825Stheraven 4985227825Stheraventemplate<class _Tp, class _Up> 4986227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4987232924Stheraventypename enable_if 4988232924Stheraven< 4989232924Stheraven !is_array<_Tp>::value && !is_array<_Up>::value, 4990232924Stheraven shared_ptr<_Tp> 4991232924Stheraven>::type 4992227825Stheravenstatic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 4993227825Stheraven{ 4994227825Stheraven return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); 4995227825Stheraven} 4996227825Stheraven 4997227825Stheraventemplate<class _Tp, class _Up> 4998227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4999232924Stheraventypename enable_if 5000232924Stheraven< 5001232924Stheraven !is_array<_Tp>::value && !is_array<_Up>::value, 5002232924Stheraven shared_ptr<_Tp> 5003232924Stheraven>::type 5004227825Stheravendynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 5005227825Stheraven{ 5006227825Stheraven _Tp* __p = dynamic_cast<_Tp*>(__r.get()); 5007227825Stheraven return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); 5008227825Stheraven} 5009227825Stheraven 5010227825Stheraventemplate<class _Tp, class _Up> 5011232924Stheraventypename enable_if 5012232924Stheraven< 5013232924Stheraven is_array<_Tp>::value == is_array<_Up>::value, 5014232924Stheraven shared_ptr<_Tp> 5015232924Stheraven>::type 5016227825Stheravenconst_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 5017227825Stheraven{ 5018232924Stheraven typedef typename remove_extent<_Tp>::type _RTp; 5019232924Stheraven return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); 5020227825Stheraven} 5021227825Stheraven 5022227825Stheraven#ifndef _LIBCPP_NO_RTTI 5023227825Stheraven 5024227825Stheraventemplate<class _Dp, class _Tp> 5025227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5026227825Stheraven_Dp* 5027227825Stheravenget_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT 5028227825Stheraven{ 5029227825Stheraven return __p.template __get_deleter<_Dp>(); 5030227825Stheraven} 5031227825Stheraven 5032227825Stheraven#endif // _LIBCPP_NO_RTTI 5033227825Stheraven 5034227825Stheraventemplate<class _Tp> 5035261272Sdimclass _LIBCPP_TYPE_VIS_ONLY weak_ptr 5036227825Stheraven{ 5037227825Stheravenpublic: 5038227825Stheraven typedef _Tp element_type; 5039227825Stheravenprivate: 5040227825Stheraven element_type* __ptr_; 5041227825Stheraven __shared_weak_count* __cntrl_; 5042227825Stheraven 5043227825Stheravenpublic: 5044241900Sdim _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; 5045227825Stheraven template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r, 5046227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 5047227825Stheraven _NOEXCEPT; 5048227825Stheraven weak_ptr(weak_ptr const& __r) _NOEXCEPT; 5049227825Stheraven template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r, 5050227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 5051227825Stheraven _NOEXCEPT; 5052227825Stheraven 5053232924Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5054232924Stheraven weak_ptr(weak_ptr&& __r) _NOEXCEPT; 5055232924Stheraven template<class _Yp> weak_ptr(weak_ptr<_Yp>&& __r, 5056232924Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 5057232924Stheraven _NOEXCEPT; 5058232924Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5059227825Stheraven ~weak_ptr(); 5060227825Stheraven 5061227825Stheraven weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; 5062232924Stheraven template<class _Yp> 5063232924Stheraven typename enable_if 5064232924Stheraven < 5065232924Stheraven is_convertible<_Yp*, element_type*>::value, 5066232924Stheraven weak_ptr& 5067232924Stheraven >::type 5068232924Stheraven operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; 5069227825Stheraven 5070232924Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5071232924Stheraven 5072232924Stheraven weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT; 5073232924Stheraven template<class _Yp> 5074232924Stheraven typename enable_if 5075232924Stheraven < 5076232924Stheraven is_convertible<_Yp*, element_type*>::value, 5077232924Stheraven weak_ptr& 5078232924Stheraven >::type 5079232924Stheraven operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT; 5080232924Stheraven 5081232924Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5082232924Stheraven 5083232924Stheraven template<class _Yp> 5084232924Stheraven typename enable_if 5085232924Stheraven < 5086232924Stheraven is_convertible<_Yp*, element_type*>::value, 5087232924Stheraven weak_ptr& 5088232924Stheraven >::type 5089232924Stheraven operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; 5090232924Stheraven 5091227825Stheraven void swap(weak_ptr& __r) _NOEXCEPT; 5092227825Stheraven void reset() _NOEXCEPT; 5093227825Stheraven 5094227825Stheraven _LIBCPP_INLINE_VISIBILITY 5095227825Stheraven long use_count() const _NOEXCEPT 5096227825Stheraven {return __cntrl_ ? __cntrl_->use_count() : 0;} 5097227825Stheraven _LIBCPP_INLINE_VISIBILITY 5098227825Stheraven bool expired() const _NOEXCEPT 5099227825Stheraven {return __cntrl_ == 0 || __cntrl_->use_count() == 0;} 5100227825Stheraven shared_ptr<_Tp> lock() const _NOEXCEPT; 5101227825Stheraven template<class _Up> 5102227825Stheraven _LIBCPP_INLINE_VISIBILITY 5103227825Stheraven bool owner_before(const shared_ptr<_Up>& __r) const 5104227825Stheraven {return __cntrl_ < __r.__cntrl_;} 5105227825Stheraven template<class _Up> 5106227825Stheraven _LIBCPP_INLINE_VISIBILITY 5107227825Stheraven bool owner_before(const weak_ptr<_Up>& __r) const 5108227825Stheraven {return __cntrl_ < __r.__cntrl_;} 5109227825Stheraven 5110261272Sdim template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 5111261272Sdim template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; 5112227825Stheraven}; 5113227825Stheraven 5114227825Stheraventemplate<class _Tp> 5115227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5116241900Sdim_LIBCPP_CONSTEXPR 5117227825Stheravenweak_ptr<_Tp>::weak_ptr() _NOEXCEPT 5118227825Stheraven : __ptr_(0), 5119227825Stheraven __cntrl_(0) 5120227825Stheraven{ 5121227825Stheraven} 5122227825Stheraven 5123227825Stheraventemplate<class _Tp> 5124227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5125227825Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT 5126227825Stheraven : __ptr_(__r.__ptr_), 5127227825Stheraven __cntrl_(__r.__cntrl_) 5128227825Stheraven{ 5129227825Stheraven if (__cntrl_) 5130227825Stheraven __cntrl_->__add_weak(); 5131227825Stheraven} 5132227825Stheraven 5133227825Stheraventemplate<class _Tp> 5134227825Stheraventemplate<class _Yp> 5135227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5136227825Stheravenweak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, 5137227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5138227825Stheraven _NOEXCEPT 5139227825Stheraven : __ptr_(__r.__ptr_), 5140227825Stheraven __cntrl_(__r.__cntrl_) 5141227825Stheraven{ 5142227825Stheraven if (__cntrl_) 5143227825Stheraven __cntrl_->__add_weak(); 5144227825Stheraven} 5145227825Stheraven 5146227825Stheraventemplate<class _Tp> 5147227825Stheraventemplate<class _Yp> 5148227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5149227825Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, 5150227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5151227825Stheraven _NOEXCEPT 5152227825Stheraven : __ptr_(__r.__ptr_), 5153227825Stheraven __cntrl_(__r.__cntrl_) 5154227825Stheraven{ 5155227825Stheraven if (__cntrl_) 5156227825Stheraven __cntrl_->__add_weak(); 5157227825Stheraven} 5158227825Stheraven 5159232924Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5160232924Stheraven 5161227825Stheraventemplate<class _Tp> 5162232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 5163232924Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT 5164232924Stheraven : __ptr_(__r.__ptr_), 5165232924Stheraven __cntrl_(__r.__cntrl_) 5166232924Stheraven{ 5167232924Stheraven __r.__ptr_ = 0; 5168232924Stheraven __r.__cntrl_ = 0; 5169232924Stheraven} 5170232924Stheraven 5171232924Stheraventemplate<class _Tp> 5172232924Stheraventemplate<class _Yp> 5173232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 5174232924Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, 5175232924Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5176232924Stheraven _NOEXCEPT 5177232924Stheraven : __ptr_(__r.__ptr_), 5178232924Stheraven __cntrl_(__r.__cntrl_) 5179232924Stheraven{ 5180232924Stheraven __r.__ptr_ = 0; 5181232924Stheraven __r.__cntrl_ = 0; 5182232924Stheraven} 5183232924Stheraven 5184232924Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5185232924Stheraven 5186232924Stheraventemplate<class _Tp> 5187227825Stheravenweak_ptr<_Tp>::~weak_ptr() 5188227825Stheraven{ 5189227825Stheraven if (__cntrl_) 5190227825Stheraven __cntrl_->__release_weak(); 5191227825Stheraven} 5192227825Stheraven 5193227825Stheraventemplate<class _Tp> 5194227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5195227825Stheravenweak_ptr<_Tp>& 5196227825Stheravenweak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT 5197227825Stheraven{ 5198227825Stheraven weak_ptr(__r).swap(*this); 5199227825Stheraven return *this; 5200227825Stheraven} 5201227825Stheraven 5202227825Stheraventemplate<class _Tp> 5203227825Stheraventemplate<class _Yp> 5204227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5205232924Stheraventypename enable_if 5206232924Stheraven< 5207232924Stheraven is_convertible<_Yp*, _Tp*>::value, 5208232924Stheraven weak_ptr<_Tp>& 5209232924Stheraven>::type 5210227825Stheravenweak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT 5211227825Stheraven{ 5212227825Stheraven weak_ptr(__r).swap(*this); 5213227825Stheraven return *this; 5214227825Stheraven} 5215227825Stheraven 5216232924Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5217232924Stheraven 5218227825Stheraventemplate<class _Tp> 5219232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 5220232924Stheravenweak_ptr<_Tp>& 5221232924Stheravenweak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT 5222232924Stheraven{ 5223232924Stheraven weak_ptr(_VSTD::move(__r)).swap(*this); 5224232924Stheraven return *this; 5225232924Stheraven} 5226232924Stheraven 5227232924Stheraventemplate<class _Tp> 5228227825Stheraventemplate<class _Yp> 5229227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5230232924Stheraventypename enable_if 5231232924Stheraven< 5232232924Stheraven is_convertible<_Yp*, _Tp*>::value, 5233232924Stheraven weak_ptr<_Tp>& 5234232924Stheraven>::type 5235232924Stheravenweak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT 5236232924Stheraven{ 5237232924Stheraven weak_ptr(_VSTD::move(__r)).swap(*this); 5238232924Stheraven return *this; 5239232924Stheraven} 5240232924Stheraven 5241232924Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5242232924Stheraven 5243232924Stheraventemplate<class _Tp> 5244232924Stheraventemplate<class _Yp> 5245232924Stheraveninline _LIBCPP_INLINE_VISIBILITY 5246232924Stheraventypename enable_if 5247232924Stheraven< 5248232924Stheraven is_convertible<_Yp*, _Tp*>::value, 5249232924Stheraven weak_ptr<_Tp>& 5250232924Stheraven>::type 5251227825Stheravenweak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT 5252227825Stheraven{ 5253227825Stheraven weak_ptr(__r).swap(*this); 5254227825Stheraven return *this; 5255227825Stheraven} 5256227825Stheraven 5257227825Stheraventemplate<class _Tp> 5258227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5259227825Stheravenvoid 5260227825Stheravenweak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT 5261227825Stheraven{ 5262227825Stheraven _VSTD::swap(__ptr_, __r.__ptr_); 5263227825Stheraven _VSTD::swap(__cntrl_, __r.__cntrl_); 5264227825Stheraven} 5265227825Stheraven 5266227825Stheraventemplate<class _Tp> 5267227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5268227825Stheravenvoid 5269227825Stheravenswap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT 5270227825Stheraven{ 5271227825Stheraven __x.swap(__y); 5272227825Stheraven} 5273227825Stheraven 5274227825Stheraventemplate<class _Tp> 5275227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5276227825Stheravenvoid 5277227825Stheravenweak_ptr<_Tp>::reset() _NOEXCEPT 5278227825Stheraven{ 5279227825Stheraven weak_ptr().swap(*this); 5280227825Stheraven} 5281227825Stheraven 5282227825Stheraventemplate<class _Tp> 5283227825Stheraventemplate<class _Yp> 5284227825Stheravenshared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, 5285227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 5286227825Stheraven : __ptr_(__r.__ptr_), 5287227825Stheraven __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) 5288227825Stheraven{ 5289227825Stheraven if (__cntrl_ == 0) 5290227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 5291227825Stheraven throw bad_weak_ptr(); 5292227825Stheraven#else 5293227825Stheraven assert(!"bad_weak_ptr"); 5294227825Stheraven#endif 5295227825Stheraven} 5296227825Stheraven 5297227825Stheraventemplate<class _Tp> 5298227825Stheravenshared_ptr<_Tp> 5299227825Stheravenweak_ptr<_Tp>::lock() const _NOEXCEPT 5300227825Stheraven{ 5301227825Stheraven shared_ptr<_Tp> __r; 5302227825Stheraven __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_; 5303227825Stheraven if (__r.__cntrl_) 5304227825Stheraven __r.__ptr_ = __ptr_; 5305227825Stheraven return __r; 5306227825Stheraven} 5307227825Stheraven 5308227825Stheraventemplate <class _Tp> struct owner_less; 5309227825Stheraven 5310227825Stheraventemplate <class _Tp> 5311261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> > 5312227825Stheraven : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> 5313227825Stheraven{ 5314227825Stheraven typedef bool result_type; 5315227825Stheraven _LIBCPP_INLINE_VISIBILITY 5316227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5317227825Stheraven {return __x.owner_before(__y);} 5318227825Stheraven _LIBCPP_INLINE_VISIBILITY 5319227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5320227825Stheraven {return __x.owner_before(__y);} 5321227825Stheraven _LIBCPP_INLINE_VISIBILITY 5322227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5323227825Stheraven {return __x.owner_before(__y);} 5324227825Stheraven}; 5325227825Stheraven 5326227825Stheraventemplate <class _Tp> 5327261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> > 5328227825Stheraven : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> 5329227825Stheraven{ 5330227825Stheraven typedef bool result_type; 5331227825Stheraven _LIBCPP_INLINE_VISIBILITY 5332227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5333227825Stheraven {return __x.owner_before(__y);} 5334227825Stheraven _LIBCPP_INLINE_VISIBILITY 5335227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5336227825Stheraven {return __x.owner_before(__y);} 5337227825Stheraven _LIBCPP_INLINE_VISIBILITY 5338227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5339227825Stheraven {return __x.owner_before(__y);} 5340227825Stheraven}; 5341227825Stheraven 5342227825Stheraventemplate<class _Tp> 5343261272Sdimclass _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this 5344227825Stheraven{ 5345227825Stheraven mutable weak_ptr<_Tp> __weak_this_; 5346227825Stheravenprotected: 5347241900Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 5348227825Stheraven enable_shared_from_this() _NOEXCEPT {} 5349227825Stheraven _LIBCPP_INLINE_VISIBILITY 5350227825Stheraven enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {} 5351227825Stheraven _LIBCPP_INLINE_VISIBILITY 5352227825Stheraven enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT 5353227825Stheraven {return *this;} 5354227825Stheraven _LIBCPP_INLINE_VISIBILITY 5355227825Stheraven ~enable_shared_from_this() {} 5356227825Stheravenpublic: 5357227825Stheraven _LIBCPP_INLINE_VISIBILITY 5358227825Stheraven shared_ptr<_Tp> shared_from_this() 5359227825Stheraven {return shared_ptr<_Tp>(__weak_this_);} 5360227825Stheraven _LIBCPP_INLINE_VISIBILITY 5361227825Stheraven shared_ptr<_Tp const> shared_from_this() const 5362227825Stheraven {return shared_ptr<const _Tp>(__weak_this_);} 5363227825Stheraven 5364227825Stheraven template <class _Up> friend class shared_ptr; 5365227825Stheraven}; 5366227825Stheraven 5367227825Stheraventemplate <class _Tp> 5368261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<shared_ptr<_Tp> > 5369227825Stheraven{ 5370227825Stheraven typedef shared_ptr<_Tp> argument_type; 5371227825Stheraven typedef size_t result_type; 5372227825Stheraven _LIBCPP_INLINE_VISIBILITY 5373227825Stheraven result_type operator()(const argument_type& __ptr) const _NOEXCEPT 5374227825Stheraven { 5375227825Stheraven return hash<_Tp*>()(__ptr.get()); 5376227825Stheraven } 5377227825Stheraven}; 5378227825Stheraven 5379232924Stheraventemplate<class _CharT, class _Traits, class _Yp> 5380227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5381227825Stheravenbasic_ostream<_CharT, _Traits>& 5382232924Stheravenoperator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); 5383227825Stheraven 5384276792Sdim#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) 5385241900Sdim 5386261272Sdimclass _LIBCPP_TYPE_VIS __sp_mut 5387241900Sdim{ 5388242939Stheraven void* __lx; 5389241900Sdimpublic: 5390241900Sdim void lock() _NOEXCEPT; 5391241900Sdim void unlock() _NOEXCEPT; 5392241900Sdim 5393241900Sdimprivate: 5394241900Sdim _LIBCPP_CONSTEXPR __sp_mut(void*) _NOEXCEPT; 5395241900Sdim __sp_mut(const __sp_mut&); 5396241900Sdim __sp_mut& operator=(const __sp_mut&); 5397241900Sdim 5398249989Sdim friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); 5399241900Sdim}; 5400241900Sdim 5401249989Sdim_LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); 5402241900Sdim 5403241900Sdimtemplate <class _Tp> 5404241900Sdiminline _LIBCPP_INLINE_VISIBILITY 5405241900Sdimbool 5406241900Sdimatomic_is_lock_free(const shared_ptr<_Tp>*) 5407241900Sdim{ 5408241900Sdim return false; 5409241900Sdim} 5410241900Sdim 5411241900Sdimtemplate <class _Tp> 5412241900Sdimshared_ptr<_Tp> 5413241900Sdimatomic_load(const shared_ptr<_Tp>* __p) 5414241900Sdim{ 5415241900Sdim __sp_mut& __m = __get_sp_mut(__p); 5416241900Sdim __m.lock(); 5417241900Sdim shared_ptr<_Tp> __q = *__p; 5418241900Sdim __m.unlock(); 5419241900Sdim return __q; 5420241900Sdim} 5421241900Sdim 5422241900Sdimtemplate <class _Tp> 5423241900Sdiminline _LIBCPP_INLINE_VISIBILITY 5424241900Sdimshared_ptr<_Tp> 5425241900Sdimatomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) 5426241900Sdim{ 5427241900Sdim return atomic_load(__p); 5428241900Sdim} 5429241900Sdim 5430241900Sdimtemplate <class _Tp> 5431241900Sdimvoid 5432241900Sdimatomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) 5433241900Sdim{ 5434241900Sdim __sp_mut& __m = __get_sp_mut(__p); 5435241900Sdim __m.lock(); 5436241900Sdim __p->swap(__r); 5437241900Sdim __m.unlock(); 5438241900Sdim} 5439241900Sdim 5440241900Sdimtemplate <class _Tp> 5441241900Sdiminline _LIBCPP_INLINE_VISIBILITY 5442241900Sdimvoid 5443241900Sdimatomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) 5444241900Sdim{ 5445241900Sdim atomic_store(__p, __r); 5446241900Sdim} 5447241900Sdim 5448241900Sdimtemplate <class _Tp> 5449241900Sdimshared_ptr<_Tp> 5450241900Sdimatomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) 5451241900Sdim{ 5452241900Sdim __sp_mut& __m = __get_sp_mut(__p); 5453241900Sdim __m.lock(); 5454241900Sdim __p->swap(__r); 5455241900Sdim __m.unlock(); 5456241900Sdim return __r; 5457241900Sdim} 5458241900Sdim 5459241900Sdimtemplate <class _Tp> 5460241900Sdiminline _LIBCPP_INLINE_VISIBILITY 5461241900Sdimshared_ptr<_Tp> 5462241900Sdimatomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) 5463241900Sdim{ 5464241900Sdim return atomic_exchange(__p, __r); 5465241900Sdim} 5466241900Sdim 5467241900Sdimtemplate <class _Tp> 5468241900Sdimbool 5469241900Sdimatomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) 5470241900Sdim{ 5471241900Sdim __sp_mut& __m = __get_sp_mut(__p); 5472241900Sdim __m.lock(); 5473241900Sdim if (__p->__owner_equivalent(*__v)) 5474241900Sdim { 5475241900Sdim *__p = __w; 5476241900Sdim __m.unlock(); 5477241900Sdim return true; 5478241900Sdim } 5479241900Sdim *__v = *__p; 5480241900Sdim __m.unlock(); 5481241900Sdim return false; 5482241900Sdim} 5483241900Sdim 5484241900Sdimtemplate <class _Tp> 5485241900Sdiminline _LIBCPP_INLINE_VISIBILITY 5486241900Sdimbool 5487241900Sdimatomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) 5488241900Sdim{ 5489241900Sdim return atomic_compare_exchange_strong(__p, __v, __w); 5490241900Sdim} 5491241900Sdim 5492241900Sdimtemplate <class _Tp> 5493241900Sdiminline _LIBCPP_INLINE_VISIBILITY 5494241900Sdimbool 5495241900Sdimatomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, 5496241900Sdim shared_ptr<_Tp> __w, memory_order, memory_order) 5497241900Sdim{ 5498241900Sdim return atomic_compare_exchange_strong(__p, __v, __w); 5499241900Sdim} 5500241900Sdim 5501241900Sdimtemplate <class _Tp> 5502241900Sdiminline _LIBCPP_INLINE_VISIBILITY 5503241900Sdimbool 5504241900Sdimatomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, 5505241900Sdim shared_ptr<_Tp> __w, memory_order, memory_order) 5506241900Sdim{ 5507241900Sdim return atomic_compare_exchange_weak(__p, __v, __w); 5508241900Sdim} 5509241900Sdim 5510276792Sdim#endif // __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) 5511241900Sdim 5512227825Stheraven//enum class 5513249989Sdimstruct _LIBCPP_TYPE_VIS pointer_safety 5514227825Stheraven{ 5515242939Stheraven enum __lx 5516227825Stheraven { 5517227825Stheraven relaxed, 5518227825Stheraven preferred, 5519227825Stheraven strict 5520227825Stheraven }; 5521227825Stheraven 5522242939Stheraven __lx __v_; 5523227825Stheraven 5524227825Stheraven _LIBCPP_INLINE_VISIBILITY 5525242939Stheraven pointer_safety(__lx __v) : __v_(__v) {} 5526227825Stheraven _LIBCPP_INLINE_VISIBILITY 5527227825Stheraven operator int() const {return __v_;} 5528227825Stheraven}; 5529227825Stheraven 5530261272Sdim_LIBCPP_FUNC_VIS void declare_reachable(void* __p); 5531261272Sdim_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n); 5532261272Sdim_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n); 5533261272Sdim_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT; 5534261272Sdim_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p); 5535227825Stheraven 5536227825Stheraventemplate <class _Tp> 5537227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5538227825Stheraven_Tp* 5539227825Stheravenundeclare_reachable(_Tp* __p) 5540227825Stheraven{ 5541227825Stheraven return static_cast<_Tp*>(__undeclare_reachable(__p)); 5542227825Stheraven} 5543227825Stheraven 5544261272Sdim_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); 5545227825Stheraven 5546288943Sdim// --- Helper for container swap -- 5547288943Sdimtemplate <typename _Alloc> 5548288943Sdim_LIBCPP_INLINE_VISIBILITY 5549288943Sdimvoid __swap_allocator(_Alloc & __a1, _Alloc & __a2) 5550288943Sdim#if _LIBCPP_STD_VER >= 14 5551288943Sdim _NOEXCEPT 5552288943Sdim#else 5553288943Sdim _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) 5554288943Sdim#endif 5555288943Sdim{ 5556288943Sdim __swap_allocator(__a1, __a2, 5557288943Sdim integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>()); 5558288943Sdim} 5559288943Sdim 5560288943Sdimtemplate <typename _Alloc> 5561288943Sdim_LIBCPP_INLINE_VISIBILITY 5562288943Sdimvoid __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type) 5563288943Sdim#if _LIBCPP_STD_VER >= 14 5564288943Sdim _NOEXCEPT 5565288943Sdim#else 5566288943Sdim _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) 5567288943Sdim#endif 5568288943Sdim{ 5569288943Sdim using _VSTD::swap; 5570288943Sdim swap(__a1, __a2); 5571288943Sdim} 5572288943Sdim 5573288943Sdimtemplate <typename _Alloc> 5574288943Sdim_LIBCPP_INLINE_VISIBILITY 5575288943Sdimvoid __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} 5576288943Sdim 5577288943Sdim 5578227825Stheraven_LIBCPP_END_NAMESPACE_STD 5579227825Stheraven 5580227825Stheraven#endif // _LIBCPP_MEMORY 5581