memory revision 262801
1227825Stheraven// -*- C++ -*- 2227825Stheraven//===-------------------------- memory ------------------------------------===// 3227825Stheraven// 4227825Stheraven// The LLVM Compiler Infrastructure 5227825Stheraven// 6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open 7227825Stheraven// Source Licenses. See LICENSE.TXT for details. 8227825Stheraven// 9227825Stheraven//===----------------------------------------------------------------------===// 10227825Stheraven 11227825Stheraven#ifndef _LIBCPP_MEMORY 12227825Stheraven#define _LIBCPP_MEMORY 13227825Stheraven 14227825Stheraven/* 15227825Stheraven memory synopsis 16227825Stheraven 17227825Stheravennamespace std 18227825Stheraven{ 19227825Stheraven 20227825Stheravenstruct allocator_arg_t { }; 21227825Stheravenconstexpr allocator_arg_t allocator_arg = allocator_arg_t(); 22227825Stheraven 23227825Stheraventemplate <class T, class Alloc> struct uses_allocator; 24227825Stheraven 25227825Stheraventemplate <class Ptr> 26227825Stheravenstruct pointer_traits 27227825Stheraven{ 28227825Stheraven typedef Ptr pointer; 29227825Stheraven typedef <details> element_type; 30227825Stheraven typedef <details> difference_type; 31227825Stheraven 32227825Stheraven template <class U> using rebind = <details>; 33227825Stheraven 34227825Stheraven static pointer pointer_to(<details>); 35227825Stheraven}; 36227825Stheraven 37227825Stheraventemplate <class T> 38227825Stheravenstruct pointer_traits<T*> 39227825Stheraven{ 40227825Stheraven typedef T* pointer; 41227825Stheraven typedef T element_type; 42227825Stheraven typedef ptrdiff_t difference_type; 43227825Stheraven 44227825Stheraven template <class U> using rebind = U*; 45227825Stheraven 46227825Stheraven static pointer pointer_to(<details>) noexcept; 47227825Stheraven}; 48227825Stheraven 49227825Stheraventemplate <class Alloc> 50227825Stheravenstruct allocator_traits 51227825Stheraven{ 52227825Stheraven typedef Alloc allocator_type; 53227825Stheraven typedef typename allocator_type::value_type 54227825Stheraven value_type; 55227825Stheraven 56227825Stheraven typedef Alloc::pointer | value_type* pointer; 57227825Stheraven typedef Alloc::const_pointer 58227825Stheraven | pointer_traits<pointer>::rebind<const value_type> 59227825Stheraven const_pointer; 60227825Stheraven typedef Alloc::void_pointer 61227825Stheraven | pointer_traits<pointer>::rebind<void> 62227825Stheraven void_pointer; 63227825Stheraven typedef Alloc::const_void_pointer 64227825Stheraven | pointer_traits<pointer>::rebind<const void> 65227825Stheraven const_void_pointer; 66227825Stheraven typedef Alloc::difference_type 67227825Stheraven | pointer_traits<pointer>::difference_type 68227825Stheraven difference_type; 69227825Stheraven typedef Alloc::size_type 70227825Stheraven | make_unsigned<difference_type>::type 71227825Stheraven size_type; 72227825Stheraven typedef Alloc::propagate_on_container_copy_assignment 73227825Stheraven | false_type propagate_on_container_copy_assignment; 74227825Stheraven typedef Alloc::propagate_on_container_move_assignment 75227825Stheraven | false_type propagate_on_container_move_assignment; 76227825Stheraven typedef Alloc::propagate_on_container_swap 77227825Stheraven | false_type propagate_on_container_swap; 78227825Stheraven 79227825Stheraven template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>; 80227825Stheraven template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; 81227825Stheraven 82227825Stheraven static pointer allocate(allocator_type& a, size_type n); 83227825Stheraven static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); 84227825Stheraven 85227825Stheraven static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; 86227825Stheraven 87227825Stheraven template <class T, class... Args> 88227825Stheraven static void construct(allocator_type& a, T* p, Args&&... args); 89227825Stheraven 90227825Stheraven template <class T> 91227825Stheraven static void destroy(allocator_type& a, T* p); 92227825Stheraven 93262801Sdim static size_type max_size(const allocator_type& a); // noexcept in C++14 94227825Stheraven 95227825Stheraven static allocator_type 96227825Stheraven select_on_container_copy_construction(const allocator_type& a); 97227825Stheraven}; 98227825Stheraven 99227825Stheraventemplate <> 100227825Stheravenclass allocator<void> 101227825Stheraven{ 102227825Stheravenpublic: 103227825Stheraven typedef void* pointer; 104227825Stheraven typedef const void* const_pointer; 105227825Stheraven typedef void value_type; 106227825Stheraven 107227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 108227825Stheraven}; 109227825Stheraven 110227825Stheraventemplate <class T> 111227825Stheravenclass allocator 112227825Stheraven{ 113227825Stheravenpublic: 114227825Stheraven typedef size_t size_type; 115227825Stheraven typedef ptrdiff_t difference_type; 116227825Stheraven typedef T* pointer; 117227825Stheraven typedef const T* const_pointer; 118227825Stheraven typedef typename add_lvalue_reference<T>::type reference; 119227825Stheraven typedef typename add_lvalue_reference<const T>::type const_reference; 120227825Stheraven typedef T value_type; 121227825Stheraven 122227825Stheraven template <class U> struct rebind {typedef allocator<U> other;}; 123227825Stheraven 124227825Stheraven allocator() noexcept; 125227825Stheraven allocator(const allocator&) noexcept; 126227825Stheraven template <class U> allocator(const allocator<U>&) noexcept; 127227825Stheraven ~allocator(); 128227825Stheraven pointer address(reference x) const noexcept; 129227825Stheraven const_pointer address(const_reference x) const noexcept; 130227825Stheraven pointer allocate(size_type, allocator<void>::const_pointer hint = 0); 131227825Stheraven void deallocate(pointer p, size_type n) noexcept; 132227825Stheraven size_type max_size() const noexcept; 133227825Stheraven template<class U, class... Args> 134227825Stheraven void construct(U* p, Args&&... args); 135227825Stheraven template <class U> 136227825Stheraven void destroy(U* p); 137227825Stheraven}; 138227825Stheraven 139227825Stheraventemplate <class T, class U> 140227825Stheravenbool operator==(const allocator<T>&, const allocator<U>&) noexcept; 141227825Stheraven 142227825Stheraventemplate <class T, class U> 143227825Stheravenbool operator!=(const allocator<T>&, const allocator<U>&) noexcept; 144227825Stheraven 145227825Stheraventemplate <class OutputIterator, class T> 146227825Stheravenclass raw_storage_iterator 147227825Stheraven : public iterator<output_iterator_tag, 148227825Stheraven T, // purposefully not C++03 149227825Stheraven ptrdiff_t, // purposefully not C++03 150227825Stheraven T*, // purposefully not C++03 151227825Stheraven raw_storage_iterator&> // purposefully not C++03 152227825Stheraven{ 153227825Stheravenpublic: 154227825Stheraven explicit raw_storage_iterator(OutputIterator x); 155227825Stheraven raw_storage_iterator& operator*(); 156227825Stheraven raw_storage_iterator& operator=(const T& element); 157227825Stheraven raw_storage_iterator& operator++(); 158227825Stheraven raw_storage_iterator operator++(int); 159227825Stheraven}; 160227825Stheraven 161227825Stheraventemplate <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; 162227825Stheraventemplate <class T> void return_temporary_buffer(T* p) noexcept; 163227825Stheraven 164227825Stheraventemplate <class T> T* addressof(T& r) noexcept; 165227825Stheraven 166227825Stheraventemplate <class InputIterator, class ForwardIterator> 167227825StheravenForwardIterator 168227825Stheravenuninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); 169227825Stheraven 170227825Stheraventemplate <class InputIterator, class Size, class ForwardIterator> 171227825StheravenForwardIterator 172227825Stheravenuninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); 173227825Stheraven 174227825Stheraventemplate <class ForwardIterator, class T> 175227825Stheravenvoid uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); 176227825Stheraven 177227825Stheraventemplate <class ForwardIterator, class Size, class T> 178227825StheravenForwardIterator 179227825Stheravenuninitialized_fill_n(ForwardIterator first, Size n, const T& x); 180227825Stheraven 181227825Stheraventemplate <class Y> struct auto_ptr_ref {}; 182227825Stheraven 183227825Stheraventemplate<class X> 184227825Stheravenclass auto_ptr 185227825Stheraven{ 186227825Stheravenpublic: 187227825Stheraven typedef X element_type; 188227825Stheraven 189227825Stheraven explicit auto_ptr(X* p =0) throw(); 190227825Stheraven auto_ptr(auto_ptr&) throw(); 191227825Stheraven template<class Y> auto_ptr(auto_ptr<Y>&) throw(); 192227825Stheraven auto_ptr& operator=(auto_ptr&) throw(); 193227825Stheraven template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw(); 194227825Stheraven auto_ptr& operator=(auto_ptr_ref<X> r) throw(); 195227825Stheraven ~auto_ptr() throw(); 196227825Stheraven 197227825Stheraven typename add_lvalue_reference<X>::type operator*() const throw(); 198227825Stheraven X* operator->() const throw(); 199227825Stheraven X* get() const throw(); 200227825Stheraven X* release() throw(); 201227825Stheraven void reset(X* p =0) throw(); 202227825Stheraven 203227825Stheraven auto_ptr(auto_ptr_ref<X>) throw(); 204227825Stheraven template<class Y> operator auto_ptr_ref<Y>() throw(); 205227825Stheraven template<class Y> operator auto_ptr<Y>() throw(); 206227825Stheraven}; 207227825Stheraven 208227825Stheraventemplate <class T> 209227825Stheravenstruct default_delete 210227825Stheraven{ 211227825Stheraven constexpr default_delete() noexcept = default; 212227825Stheraven template <class U> default_delete(const default_delete<U>&) noexcept; 213227825Stheraven 214227825Stheraven void operator()(T*) const noexcept; 215227825Stheraven}; 216227825Stheraven 217227825Stheraventemplate <class T> 218227825Stheravenstruct default_delete<T[]> 219227825Stheraven{ 220227825Stheraven constexpr default_delete() noexcept = default; 221227825Stheraven void operator()(T*) const noexcept; 222227825Stheraven template <class U> void operator()(U*) const = delete; 223227825Stheraven}; 224227825Stheraven 225227825Stheraventemplate <class T, class D = default_delete<T>> 226227825Stheravenclass unique_ptr 227227825Stheraven{ 228227825Stheravenpublic: 229227825Stheraven typedef see below pointer; 230227825Stheraven typedef T element_type; 231227825Stheraven typedef D deleter_type; 232227825Stheraven 233227825Stheraven // constructors 234227825Stheraven constexpr unique_ptr() noexcept; 235227825Stheraven explicit unique_ptr(pointer p) noexcept; 236227825Stheraven unique_ptr(pointer p, see below d1) noexcept; 237227825Stheraven unique_ptr(pointer p, see below d2) noexcept; 238227825Stheraven unique_ptr(unique_ptr&& u) noexcept; 239227825Stheraven unique_ptr(nullptr_t) noexcept : unique_ptr() { } 240227825Stheraven template <class U, class E> 241227825Stheraven unique_ptr(unique_ptr<U, E>&& u) noexcept; 242227825Stheraven template <class U> 243227825Stheraven unique_ptr(auto_ptr<U>&& u) noexcept; 244227825Stheraven 245227825Stheraven // destructor 246227825Stheraven ~unique_ptr(); 247227825Stheraven 248227825Stheraven // assignment 249227825Stheraven unique_ptr& operator=(unique_ptr&& u) noexcept; 250227825Stheraven template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept; 251227825Stheraven unique_ptr& operator=(nullptr_t) noexcept; 252227825Stheraven 253227825Stheraven // observers 254227825Stheraven typename add_lvalue_reference<T>::type operator*() const; 255227825Stheraven pointer operator->() const noexcept; 256227825Stheraven pointer get() const noexcept; 257227825Stheraven deleter_type& get_deleter() noexcept; 258227825Stheraven const deleter_type& get_deleter() const noexcept; 259227825Stheraven explicit operator bool() const noexcept; 260227825Stheraven 261227825Stheraven // modifiers 262227825Stheraven pointer release() noexcept; 263227825Stheraven void reset(pointer p = pointer()) noexcept; 264227825Stheraven void swap(unique_ptr& u) noexcept; 265227825Stheraven}; 266227825Stheraven 267227825Stheraventemplate <class T, class D> 268227825Stheravenclass unique_ptr<T[], D> 269227825Stheraven{ 270227825Stheravenpublic: 271227825Stheraven typedef implementation-defined pointer; 272227825Stheraven typedef T element_type; 273227825Stheraven typedef D deleter_type; 274227825Stheraven 275227825Stheraven // constructors 276227825Stheraven constexpr unique_ptr() noexcept; 277227825Stheraven explicit unique_ptr(pointer p) noexcept; 278227825Stheraven unique_ptr(pointer p, see below d) noexcept; 279227825Stheraven unique_ptr(pointer p, see below d) noexcept; 280227825Stheraven unique_ptr(unique_ptr&& u) noexcept; 281227825Stheraven unique_ptr(nullptr_t) noexcept : unique_ptr() { } 282227825Stheraven 283227825Stheraven // destructor 284227825Stheraven ~unique_ptr(); 285227825Stheraven 286227825Stheraven // assignment 287227825Stheraven unique_ptr& operator=(unique_ptr&& u) noexcept; 288227825Stheraven unique_ptr& operator=(nullptr_t) noexcept; 289227825Stheraven 290227825Stheraven // observers 291227825Stheraven T& operator[](size_t i) const; 292227825Stheraven pointer get() const noexcept; 293227825Stheraven deleter_type& get_deleter() noexcept; 294227825Stheraven const deleter_type& get_deleter() const noexcept; 295227825Stheraven explicit operator bool() const noexcept; 296227825Stheraven 297227825Stheraven // modifiers 298227825Stheraven pointer release() noexcept; 299227825Stheraven void reset(pointer p = pointer()) noexcept; 300227825Stheraven void reset(nullptr_t) noexcept; 301227825Stheraven template <class U> void reset(U) = delete; 302227825Stheraven void swap(unique_ptr& u) noexcept; 303227825Stheraven}; 304227825Stheraven 305227825Stheraventemplate <class T, class D> 306227825Stheraven void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept; 307227825Stheraven 308227825Stheraventemplate <class T1, class D1, class T2, class D2> 309227825Stheraven bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 310227825Stheraventemplate <class T1, class D1, class T2, class D2> 311227825Stheraven bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 312227825Stheraventemplate <class T1, class D1, class T2, class D2> 313227825Stheraven bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 314227825Stheraventemplate <class T1, class D1, class T2, class D2> 315227825Stheraven bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 316227825Stheraventemplate <class T1, class D1, class T2, class D2> 317227825Stheraven bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 318227825Stheraventemplate <class T1, class D1, class T2, class D2> 319227825Stheraven bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 320227825Stheraven 321227825Stheraventemplate <class T, class D> 322227825Stheraven bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; 323227825Stheraventemplate <class T, class D> 324227825Stheraven bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; 325227825Stheraventemplate <class T, class D> 326227825Stheraven bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; 327227825Stheraventemplate <class T, class D> 328227825Stheraven bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; 329227825Stheraven 330227825Stheraventemplate <class T, class D> 331227825Stheraven bool operator<(const unique_ptr<T, D>& x, nullptr_t); 332227825Stheraventemplate <class T, class D> 333227825Stheraven bool operator<(nullptr_t, const unique_ptr<T, D>& y); 334227825Stheraventemplate <class T, class D> 335227825Stheraven bool operator<=(const unique_ptr<T, D>& x, nullptr_t); 336227825Stheraventemplate <class T, class D> 337227825Stheraven bool operator<=(nullptr_t, const unique_ptr<T, D>& y); 338227825Stheraventemplate <class T, class D> 339227825Stheraven bool operator>(const unique_ptr<T, D>& x, nullptr_t); 340227825Stheraventemplate <class T, class D> 341227825Stheraven bool operator>(nullptr_t, const unique_ptr<T, D>& y); 342227825Stheraventemplate <class T, class D> 343227825Stheraven bool operator>=(const unique_ptr<T, D>& x, nullptr_t); 344227825Stheraventemplate <class T, class D> 345227825Stheraven bool operator>=(nullptr_t, const unique_ptr<T, D>& y); 346227825Stheraven 347227825Stheravenclass bad_weak_ptr 348227825Stheraven : public std::exception 349227825Stheraven{ 350227825Stheraven bad_weak_ptr() noexcept; 351227825Stheraven}; 352227825Stheraven 353253159Stheraventemplate<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // C++14 354253159Stheraventemplate<class T> unique_ptr<T> make_unique(size_t n); // C++14 355253159Stheraventemplate<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N] 356253159Stheraven 357227825Stheraventemplate<class T> 358227825Stheravenclass shared_ptr 359227825Stheraven{ 360227825Stheravenpublic: 361227825Stheraven typedef T element_type; 362227825Stheraven 363227825Stheraven // constructors: 364227825Stheraven constexpr shared_ptr() noexcept; 365227825Stheraven template<class Y> explicit shared_ptr(Y* p); 366227825Stheraven template<class Y, class D> shared_ptr(Y* p, D d); 367227825Stheraven template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); 368227825Stheraven template <class D> shared_ptr(nullptr_t p, D d); 369227825Stheraven template <class D, class A> shared_ptr(nullptr_t p, D d, A a); 370227825Stheraven template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept; 371227825Stheraven shared_ptr(const shared_ptr& r) noexcept; 372227825Stheraven template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept; 373227825Stheraven shared_ptr(shared_ptr&& r) noexcept; 374227825Stheraven template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept; 375227825Stheraven template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); 376227825Stheraven template<class Y> shared_ptr(auto_ptr<Y>&& r); 377227825Stheraven template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r); 378227825Stheraven shared_ptr(nullptr_t) : shared_ptr() { } 379227825Stheraven 380227825Stheraven // destructor: 381227825Stheraven ~shared_ptr(); 382227825Stheraven 383227825Stheraven // assignment: 384227825Stheraven shared_ptr& operator=(const shared_ptr& r) noexcept; 385227825Stheraven template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept; 386227825Stheraven shared_ptr& operator=(shared_ptr&& r) noexcept; 387227825Stheraven template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r); 388227825Stheraven template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); 389227825Stheraven template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); 390227825Stheraven 391227825Stheraven // modifiers: 392227825Stheraven void swap(shared_ptr& r) noexcept; 393227825Stheraven void reset() noexcept; 394227825Stheraven template<class Y> void reset(Y* p); 395227825Stheraven template<class Y, class D> void reset(Y* p, D d); 396227825Stheraven template<class Y, class D, class A> void reset(Y* p, D d, A a); 397227825Stheraven 398227825Stheraven // observers: 399227825Stheraven T* get() const noexcept; 400227825Stheraven T& operator*() const noexcept; 401227825Stheraven T* operator->() const noexcept; 402227825Stheraven long use_count() const noexcept; 403227825Stheraven bool unique() const noexcept; 404227825Stheraven explicit operator bool() const noexcept; 405227825Stheraven template<class U> bool owner_before(shared_ptr<U> const& b) const; 406227825Stheraven template<class U> bool owner_before(weak_ptr<U> const& b) const; 407227825Stheraven}; 408227825Stheraven 409227825Stheraven// shared_ptr comparisons: 410227825Stheraventemplate<class T, class U> 411227825Stheraven bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 412227825Stheraventemplate<class T, class U> 413227825Stheraven bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 414227825Stheraventemplate<class T, class U> 415227825Stheraven bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 416227825Stheraventemplate<class T, class U> 417227825Stheraven bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 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; 422227825Stheraven 423227825Stheraventemplate <class T> 424227825Stheraven bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept; 425227825Stheraventemplate <class T> 426227825Stheraven bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept; 427227825Stheraventemplate <class T> 428227825Stheraven bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept; 429227825Stheraventemplate <class T> 430227825Stheraven bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept; 431227825Stheraventemplate <class T> 432227825Stheraven bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept; 433227825Stheraventemplate <class T> 434227825Stheravenbool operator<(nullptr_t, const shared_ptr<T>& y) noexcept; 435227825Stheraventemplate <class T> 436227825Stheraven bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept; 437227825Stheraventemplate <class T> 438227825Stheraven bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept; 439227825Stheraventemplate <class T> 440227825Stheraven bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept; 441227825Stheraventemplate <class T> 442227825Stheraven bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept; 443227825Stheraventemplate <class T> 444227825Stheraven bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept; 445227825Stheraventemplate <class T> 446227825Stheraven bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept; 447227825Stheraven 448227825Stheraven// shared_ptr specialized algorithms: 449227825Stheraventemplate<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept; 450227825Stheraven 451227825Stheraven// shared_ptr casts: 452227825Stheraventemplate<class T, class U> 453227825Stheraven shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept; 454227825Stheraventemplate<class T, class U> 455227825Stheraven shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept; 456227825Stheraventemplate<class T, class U> 457227825Stheraven shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept; 458227825Stheraven 459227825Stheraven// shared_ptr I/O: 460227825Stheraventemplate<class E, class T, class Y> 461227825Stheraven basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p); 462227825Stheraven 463227825Stheraven// shared_ptr get_deleter: 464227825Stheraventemplate<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept; 465227825Stheraven 466227825Stheraventemplate<class T, class... Args> 467227825Stheraven shared_ptr<T> make_shared(Args&&... args); 468227825Stheraventemplate<class T, class A, class... Args> 469227825Stheraven shared_ptr<T> allocate_shared(const A& a, Args&&... args); 470227825Stheraven 471227825Stheraventemplate<class T> 472227825Stheravenclass weak_ptr 473227825Stheraven{ 474227825Stheravenpublic: 475227825Stheraven typedef T element_type; 476227825Stheraven 477227825Stheraven // constructors 478227825Stheraven constexpr weak_ptr() noexcept; 479227825Stheraven template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept; 480227825Stheraven weak_ptr(weak_ptr const& r) noexcept; 481227825Stheraven template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept; 482227825Stheraven 483227825Stheraven // destructor 484227825Stheraven ~weak_ptr(); 485227825Stheraven 486227825Stheraven // assignment 487227825Stheraven weak_ptr& operator=(weak_ptr const& r) noexcept; 488227825Stheraven template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept; 489227825Stheraven template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept; 490227825Stheraven 491227825Stheraven // modifiers 492227825Stheraven void swap(weak_ptr& r) noexcept; 493227825Stheraven void reset() noexcept; 494227825Stheraven 495227825Stheraven // observers 496227825Stheraven long use_count() const noexcept; 497227825Stheraven bool expired() const noexcept; 498227825Stheraven shared_ptr<T> lock() const noexcept; 499262801Sdim template<class U> bool owner_before(shared_ptr<U> const& b) const; 500262801Sdim template<class U> bool owner_before(weak_ptr<U> const& b) const; 501227825Stheraven}; 502227825Stheraven 503227825Stheraven// weak_ptr specialized algorithms: 504227825Stheraventemplate<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept; 505227825Stheraven 506227825Stheraven// class owner_less: 507227825Stheraventemplate<class T> struct owner_less; 508227825Stheraven 509227825Stheraventemplate<class T> 510227825Stheravenstruct owner_less<shared_ptr<T>> 511227825Stheraven : binary_function<shared_ptr<T>, shared_ptr<T>, bool> 512227825Stheraven{ 513227825Stheraven typedef bool result_type; 514227825Stheraven bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const; 515227825Stheraven bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; 516227825Stheraven bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; 517227825Stheraven}; 518227825Stheraven 519227825Stheraventemplate<class T> 520227825Stheravenstruct owner_less<weak_ptr<T>> 521227825Stheraven : binary_function<weak_ptr<T>, weak_ptr<T>, bool> 522227825Stheraven{ 523227825Stheraven typedef bool result_type; 524227825Stheraven bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; 525227825Stheraven bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; 526227825Stheraven bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; 527227825Stheraven}; 528227825Stheraven 529227825Stheraventemplate<class T> 530227825Stheravenclass enable_shared_from_this 531227825Stheraven{ 532227825Stheravenprotected: 533227825Stheraven constexpr enable_shared_from_this() noexcept; 534227825Stheraven enable_shared_from_this(enable_shared_from_this const&) noexcept; 535227825Stheraven enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; 536227825Stheraven ~enable_shared_from_this(); 537227825Stheravenpublic: 538227825Stheraven shared_ptr<T> shared_from_this(); 539227825Stheraven shared_ptr<T const> shared_from_this() const; 540227825Stheraven}; 541227825Stheraven 542227825Stheraventemplate<class T> 543227825Stheraven bool atomic_is_lock_free(const shared_ptr<T>* p); 544227825Stheraventemplate<class T> 545227825Stheraven shared_ptr<T> atomic_load(const shared_ptr<T>* p); 546227825Stheraventemplate<class T> 547227825Stheraven shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo); 548227825Stheraventemplate<class T> 549227825Stheraven void atomic_store(shared_ptr<T>* p, shared_ptr<T> r); 550227825Stheraventemplate<class T> 551227825Stheraven void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); 552227825Stheraventemplate<class T> 553227825Stheraven shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r); 554227825Stheraventemplate<class T> 555227825Stheraven shared_ptr<T> 556227825Stheraven atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); 557227825Stheraventemplate<class T> 558227825Stheraven bool 559227825Stheraven atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); 560227825Stheraventemplate<class T> 561227825Stheraven bool 562227825Stheraven atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); 563227825Stheraventemplate<class T> 564227825Stheraven bool 565227825Stheraven atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, 566227825Stheraven shared_ptr<T> w, memory_order success, 567227825Stheraven memory_order failure); 568227825Stheraventemplate<class T> 569227825Stheraven bool 570227825Stheraven atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, 571227825Stheraven shared_ptr<T> w, memory_order success, 572227825Stheraven memory_order failure); 573227825Stheraven// Hash support 574227825Stheraventemplate <class T> struct hash; 575227825Stheraventemplate <class T, class D> struct hash<unique_ptr<T, D> >; 576227825Stheraventemplate <class T> struct hash<shared_ptr<T> >; 577227825Stheraven 578227825Stheraven// Pointer safety 579227825Stheravenenum class pointer_safety { relaxed, preferred, strict }; 580227825Stheravenvoid declare_reachable(void *p); 581227825Stheraventemplate <class T> T *undeclare_reachable(T *p); 582227825Stheravenvoid declare_no_pointers(char *p, size_t n); 583227825Stheravenvoid undeclare_no_pointers(char *p, size_t n); 584227825Stheravenpointer_safety get_pointer_safety() noexcept; 585227825Stheraven 586227825Stheravenvoid* align(size_t alignment, size_t size, void*& ptr, size_t& space); 587227825Stheraven 588227825Stheraven} // std 589227825Stheraven 590227825Stheraven*/ 591227825Stheraven 592227825Stheraven#include <__config> 593227825Stheraven#include <type_traits> 594227825Stheraven#include <typeinfo> 595227825Stheraven#include <cstddef> 596227825Stheraven#include <cstdint> 597227825Stheraven#include <new> 598227825Stheraven#include <utility> 599227825Stheraven#include <limits> 600227825Stheraven#include <iterator> 601227825Stheraven#include <__functional_base> 602227825Stheraven#include <iosfwd> 603232950Stheraven#include <tuple> 604232950Stheraven#include <cstring> 605227825Stheraven#if defined(_LIBCPP_NO_EXCEPTIONS) 606227825Stheraven #include <cassert> 607227825Stheraven#endif 608227825Stheraven 609241903Sdim#if __has_feature(cxx_atomic) 610241903Sdim# include <atomic> 611241903Sdim#endif 612241903Sdim 613232950Stheraven#include <__undef_min_max> 614232950Stheraven 615227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 616227825Stheraven#pragma GCC system_header 617227825Stheraven#endif 618227825Stheraven 619227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 620227825Stheraven 621262801Sdim// addressof moved to <__functional_base> 622227825Stheraven 623227825Stheraventemplate <class _Tp> class allocator; 624227825Stheraven 625227825Stheraventemplate <> 626262801Sdimclass _LIBCPP_TYPE_VIS_ONLY allocator<void> 627227825Stheraven{ 628227825Stheravenpublic: 629227825Stheraven typedef void* pointer; 630227825Stheraven typedef const void* const_pointer; 631227825Stheraven typedef void value_type; 632227825Stheraven 633227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 634227825Stheraven}; 635227825Stheraven 636232950Stheraventemplate <> 637262801Sdimclass _LIBCPP_TYPE_VIS_ONLY allocator<const void> 638232950Stheraven{ 639232950Stheravenpublic: 640232950Stheraven typedef const void* pointer; 641232950Stheraven typedef const void* const_pointer; 642232950Stheraven typedef const void value_type; 643232950Stheraven 644232950Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 645232950Stheraven}; 646232950Stheraven 647227825Stheraven// pointer_traits 648227825Stheraven 649227825Stheraventemplate <class _Tp> 650227825Stheravenstruct __has_element_type 651227825Stheraven{ 652227825Stheravenprivate: 653242945Stheraven struct __two {char __lx; char __lxx;}; 654227825Stheraven template <class _Up> static __two __test(...); 655227825Stheraven template <class _Up> static char __test(typename _Up::element_type* = 0); 656227825Stheravenpublic: 657227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 658227825Stheraven}; 659227825Stheraven 660227825Stheraventemplate <class _Ptr, bool = __has_element_type<_Ptr>::value> 661227825Stheravenstruct __pointer_traits_element_type; 662227825Stheraven 663227825Stheraventemplate <class _Ptr> 664227825Stheravenstruct __pointer_traits_element_type<_Ptr, true> 665227825Stheraven{ 666227825Stheraven typedef typename _Ptr::element_type type; 667227825Stheraven}; 668227825Stheraven 669227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 670227825Stheraven 671227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 672227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> 673227825Stheraven{ 674227825Stheraven typedef typename _Sp<_Tp, _Args...>::element_type type; 675227825Stheraven}; 676227825Stheraven 677227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 678227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> 679227825Stheraven{ 680227825Stheraven typedef _Tp type; 681227825Stheraven}; 682227825Stheraven 683227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 684227825Stheraven 685227825Stheraventemplate <template <class> class _Sp, class _Tp> 686227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp>, true> 687227825Stheraven{ 688227825Stheraven typedef typename _Sp<_Tp>::element_type type; 689227825Stheraven}; 690227825Stheraven 691227825Stheraventemplate <template <class> class _Sp, class _Tp> 692227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp>, false> 693227825Stheraven{ 694227825Stheraven typedef _Tp type; 695227825Stheraven}; 696227825Stheraven 697227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0> 698227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, true> 699227825Stheraven{ 700227825Stheraven typedef typename _Sp<_Tp, _A0>::element_type type; 701227825Stheraven}; 702227825Stheraven 703227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0> 704227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, false> 705227825Stheraven{ 706227825Stheraven typedef _Tp type; 707227825Stheraven}; 708227825Stheraven 709227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 710227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true> 711227825Stheraven{ 712227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::element_type type; 713227825Stheraven}; 714227825Stheraven 715227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 716227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false> 717227825Stheraven{ 718227825Stheraven typedef _Tp type; 719227825Stheraven}; 720227825Stheraven 721227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 722227825Stheraven class _A1, class _A2> 723227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true> 724227825Stheraven{ 725227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type; 726227825Stheraven}; 727227825Stheraven 728227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 729227825Stheraven class _A1, class _A2> 730227825Stheravenstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false> 731227825Stheraven{ 732227825Stheraven typedef _Tp type; 733227825Stheraven}; 734227825Stheraven 735227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 736227825Stheraven 737227825Stheraventemplate <class _Tp> 738227825Stheravenstruct __has_difference_type 739227825Stheraven{ 740227825Stheravenprivate: 741242945Stheraven struct __two {char __lx; char __lxx;}; 742227825Stheraven template <class _Up> static __two __test(...); 743227825Stheraven template <class _Up> static char __test(typename _Up::difference_type* = 0); 744227825Stheravenpublic: 745227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 746227825Stheraven}; 747227825Stheraven 748227825Stheraventemplate <class _Ptr, bool = __has_difference_type<_Ptr>::value> 749227825Stheravenstruct __pointer_traits_difference_type 750227825Stheraven{ 751227825Stheraven typedef ptrdiff_t type; 752227825Stheraven}; 753227825Stheraven 754227825Stheraventemplate <class _Ptr> 755227825Stheravenstruct __pointer_traits_difference_type<_Ptr, true> 756227825Stheraven{ 757227825Stheraven typedef typename _Ptr::difference_type type; 758227825Stheraven}; 759227825Stheraven 760227825Stheraventemplate <class _Tp, class _Up> 761227825Stheravenstruct __has_rebind 762227825Stheraven{ 763227825Stheravenprivate: 764242945Stheraven struct __two {char __lx; char __lxx;}; 765227825Stheraven template <class _Xp> static __two __test(...); 766227825Stheraven template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); 767227825Stheravenpublic: 768227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 769227825Stheraven}; 770227825Stheraven 771227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 772227825Stheravenstruct __pointer_traits_rebind 773227825Stheraven{ 774227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 775227825Stheraven typedef typename _Tp::template rebind<_Up> type; 776227825Stheraven#else 777227825Stheraven typedef typename _Tp::template rebind<_Up>::other type; 778227825Stheraven#endif 779227825Stheraven}; 780227825Stheraven 781227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 782227825Stheraven 783227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 784227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> 785227825Stheraven{ 786227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 787227825Stheraven typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; 788227825Stheraven#else 789227825Stheraven typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; 790227825Stheraven#endif 791227825Stheraven}; 792227825Stheraven 793227825Stheraventemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 794227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> 795227825Stheraven{ 796227825Stheraven typedef _Sp<_Up, _Args...> type; 797227825Stheraven}; 798227825Stheraven 799227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 800227825Stheraven 801227825Stheraventemplate <template <class> class _Sp, class _Tp, class _Up> 802227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> 803227825Stheraven{ 804227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 805227825Stheraven typedef typename _Sp<_Tp>::template rebind<_Up> type; 806227825Stheraven#else 807227825Stheraven typedef typename _Sp<_Tp>::template rebind<_Up>::other type; 808227825Stheraven#endif 809227825Stheraven}; 810227825Stheraven 811227825Stheraventemplate <template <class> class _Sp, class _Tp, class _Up> 812227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, false> 813227825Stheraven{ 814227825Stheraven typedef _Sp<_Up> type; 815227825Stheraven}; 816227825Stheraven 817227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 818227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> 819227825Stheraven{ 820227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 821227825Stheraven typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; 822227825Stheraven#else 823227825Stheraven typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; 824227825Stheraven#endif 825227825Stheraven}; 826227825Stheraven 827227825Stheraventemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 828227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false> 829227825Stheraven{ 830227825Stheraven typedef _Sp<_Up, _A0> type; 831227825Stheraven}; 832227825Stheraven 833227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 834227825Stheraven class _A1, class _Up> 835227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> 836227825Stheraven{ 837227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 838227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; 839227825Stheraven#else 840227825Stheraven typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; 841227825Stheraven#endif 842227825Stheraven}; 843227825Stheraven 844227825Stheraventemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 845227825Stheraven class _A1, class _Up> 846227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false> 847227825Stheraven{ 848227825Stheraven typedef _Sp<_Up, _A0, _A1> type; 849227825Stheraven}; 850227825Stheraven 851227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 852227825Stheraven class _A1, class _A2, class _Up> 853227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> 854227825Stheraven{ 855227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 856227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; 857227825Stheraven#else 858227825Stheraven typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 859227825Stheraven#endif 860227825Stheraven}; 861227825Stheraven 862227825Stheraventemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 863227825Stheraven class _A1, class _A2, class _Up> 864227825Stheravenstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> 865227825Stheraven{ 866227825Stheraven typedef _Sp<_Up, _A0, _A1, _A2> type; 867227825Stheraven}; 868227825Stheraven 869227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 870227825Stheraven 871227825Stheraventemplate <class _Ptr> 872262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY pointer_traits 873227825Stheraven{ 874227825Stheraven typedef _Ptr pointer; 875227825Stheraven typedef typename __pointer_traits_element_type<pointer>::type element_type; 876227825Stheraven typedef typename __pointer_traits_difference_type<pointer>::type difference_type; 877227825Stheraven 878227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 879227825Stheraven template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; 880227825Stheraven#else 881227825Stheraven template <class _Up> struct rebind 882227825Stheraven {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; 883227825Stheraven#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 884227825Stheraven 885227825Stheravenprivate: 886227825Stheraven struct __nat {}; 887227825Stheravenpublic: 888227825Stheraven _LIBCPP_INLINE_VISIBILITY 889227825Stheraven static pointer pointer_to(typename conditional<is_void<element_type>::value, 890227825Stheraven __nat, element_type>::type& __r) 891227825Stheraven {return pointer::pointer_to(__r);} 892227825Stheraven}; 893227825Stheraven 894227825Stheraventemplate <class _Tp> 895262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*> 896227825Stheraven{ 897227825Stheraven typedef _Tp* pointer; 898227825Stheraven typedef _Tp element_type; 899227825Stheraven typedef ptrdiff_t difference_type; 900227825Stheraven 901227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 902227825Stheraven template <class _Up> using rebind = _Up*; 903227825Stheraven#else 904227825Stheraven template <class _Up> struct rebind {typedef _Up* other;}; 905227825Stheraven#endif 906227825Stheraven 907227825Stheravenprivate: 908227825Stheraven struct __nat {}; 909227825Stheravenpublic: 910227825Stheraven _LIBCPP_INLINE_VISIBILITY 911227825Stheraven static pointer pointer_to(typename conditional<is_void<element_type>::value, 912227825Stheraven __nat, element_type>::type& __r) _NOEXCEPT 913227825Stheraven {return _VSTD::addressof(__r);} 914227825Stheraven}; 915227825Stheraven 916227825Stheraven// allocator_traits 917227825Stheraven 918227825Stheravennamespace __has_pointer_type_imp 919227825Stheraven{ 920256082Sdecke template <class _Up> static __two __test(...); 921256082Sdecke template <class _Up> static char __test(typename _Up::pointer* = 0); 922227825Stheraven} 923227825Stheraven 924227825Stheraventemplate <class _Tp> 925227825Stheravenstruct __has_pointer_type 926256082Sdecke : public integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1> 927227825Stheraven{ 928227825Stheraven}; 929227825Stheraven 930227825Stheravennamespace __pointer_type_imp 931227825Stheraven{ 932227825Stheraven 933227825Stheraventemplate <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value> 934227825Stheravenstruct __pointer_type 935227825Stheraven{ 936227825Stheraven typedef typename _Dp::pointer type; 937227825Stheraven}; 938227825Stheraven 939227825Stheraventemplate <class _Tp, class _Dp> 940227825Stheravenstruct __pointer_type<_Tp, _Dp, false> 941227825Stheraven{ 942227825Stheraven typedef _Tp* type; 943227825Stheraven}; 944227825Stheraven 945227825Stheraven} // __pointer_type_imp 946227825Stheraven 947227825Stheraventemplate <class _Tp, class _Dp> 948227825Stheravenstruct __pointer_type 949227825Stheraven{ 950227825Stheraven typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type; 951227825Stheraven}; 952227825Stheraven 953227825Stheraventemplate <class _Tp> 954227825Stheravenstruct __has_const_pointer 955227825Stheraven{ 956227825Stheravenprivate: 957242945Stheraven struct __two {char __lx; char __lxx;}; 958227825Stheraven template <class _Up> static __two __test(...); 959227825Stheraven template <class _Up> static char __test(typename _Up::const_pointer* = 0); 960227825Stheravenpublic: 961227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 962227825Stheraven}; 963227825Stheraven 964227825Stheraventemplate <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value> 965227825Stheravenstruct __const_pointer 966227825Stheraven{ 967227825Stheraven typedef typename _Alloc::const_pointer type; 968227825Stheraven}; 969227825Stheraven 970227825Stheraventemplate <class _Tp, class _Ptr, class _Alloc> 971227825Stheravenstruct __const_pointer<_Tp, _Ptr, _Alloc, false> 972227825Stheraven{ 973227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 974227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; 975227825Stheraven#else 976227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; 977227825Stheraven#endif 978227825Stheraven}; 979227825Stheraven 980227825Stheraventemplate <class _Tp> 981227825Stheravenstruct __has_void_pointer 982227825Stheraven{ 983227825Stheravenprivate: 984242945Stheraven struct __two {char __lx; char __lxx;}; 985227825Stheraven template <class _Up> static __two __test(...); 986227825Stheraven template <class _Up> static char __test(typename _Up::void_pointer* = 0); 987227825Stheravenpublic: 988227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 989227825Stheraven}; 990227825Stheraven 991227825Stheraventemplate <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value> 992227825Stheravenstruct __void_pointer 993227825Stheraven{ 994227825Stheraven typedef typename _Alloc::void_pointer type; 995227825Stheraven}; 996227825Stheraven 997227825Stheraventemplate <class _Ptr, class _Alloc> 998227825Stheravenstruct __void_pointer<_Ptr, _Alloc, false> 999227825Stheraven{ 1000227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1001227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<void> type; 1002227825Stheraven#else 1003227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; 1004227825Stheraven#endif 1005227825Stheraven}; 1006227825Stheraven 1007227825Stheraventemplate <class _Tp> 1008227825Stheravenstruct __has_const_void_pointer 1009227825Stheraven{ 1010227825Stheravenprivate: 1011242945Stheraven struct __two {char __lx; char __lxx;}; 1012227825Stheraven template <class _Up> static __two __test(...); 1013227825Stheraven template <class _Up> static char __test(typename _Up::const_void_pointer* = 0); 1014227825Stheravenpublic: 1015227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1016227825Stheraven}; 1017227825Stheraven 1018227825Stheraventemplate <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value> 1019227825Stheravenstruct __const_void_pointer 1020227825Stheraven{ 1021227825Stheraven typedef typename _Alloc::const_void_pointer type; 1022227825Stheraven}; 1023227825Stheraven 1024227825Stheraventemplate <class _Ptr, class _Alloc> 1025227825Stheravenstruct __const_void_pointer<_Ptr, _Alloc, false> 1026227825Stheraven{ 1027227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1028227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const void> type; 1029227825Stheraven#else 1030227825Stheraven typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; 1031227825Stheraven#endif 1032227825Stheraven}; 1033227825Stheraven 1034232950Stheraventemplate <class _Tp> 1035227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1036232950Stheraven_Tp* 1037232950Stheraven__to_raw_pointer(_Tp* __p) _NOEXCEPT 1038227825Stheraven{ 1039227825Stheraven return __p; 1040227825Stheraven} 1041227825Stheraven 1042227825Stheraventemplate <class _Pointer> 1043227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1044227825Stheraventypename pointer_traits<_Pointer>::element_type* 1045227825Stheraven__to_raw_pointer(_Pointer __p) _NOEXCEPT 1046227825Stheraven{ 1047227825Stheraven return _VSTD::__to_raw_pointer(__p.operator->()); 1048227825Stheraven} 1049227825Stheraven 1050227825Stheraventemplate <class _Tp> 1051227825Stheravenstruct __has_size_type 1052227825Stheraven{ 1053227825Stheravenprivate: 1054242945Stheraven struct __two {char __lx; char __lxx;}; 1055227825Stheraven template <class _Up> static __two __test(...); 1056227825Stheraven template <class _Up> static char __test(typename _Up::size_type* = 0); 1057227825Stheravenpublic: 1058227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1059227825Stheraven}; 1060227825Stheraven 1061227825Stheraventemplate <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> 1062227825Stheravenstruct __size_type 1063227825Stheraven{ 1064227825Stheraven typedef typename make_unsigned<_DiffType>::type type; 1065227825Stheraven}; 1066227825Stheraven 1067227825Stheraventemplate <class _Alloc, class _DiffType> 1068227825Stheravenstruct __size_type<_Alloc, _DiffType, true> 1069227825Stheraven{ 1070227825Stheraven typedef typename _Alloc::size_type type; 1071227825Stheraven}; 1072227825Stheraven 1073227825Stheraventemplate <class _Tp> 1074227825Stheravenstruct __has_propagate_on_container_copy_assignment 1075227825Stheraven{ 1076227825Stheravenprivate: 1077242945Stheraven struct __two {char __lx; char __lxx;}; 1078227825Stheraven template <class _Up> static __two __test(...); 1079227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0); 1080227825Stheravenpublic: 1081227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1082227825Stheraven}; 1083227825Stheraven 1084227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value> 1085227825Stheravenstruct __propagate_on_container_copy_assignment 1086227825Stheraven{ 1087227825Stheraven typedef false_type type; 1088227825Stheraven}; 1089227825Stheraven 1090227825Stheraventemplate <class _Alloc> 1091227825Stheravenstruct __propagate_on_container_copy_assignment<_Alloc, true> 1092227825Stheraven{ 1093227825Stheraven typedef typename _Alloc::propagate_on_container_copy_assignment type; 1094227825Stheraven}; 1095227825Stheraven 1096227825Stheraventemplate <class _Tp> 1097227825Stheravenstruct __has_propagate_on_container_move_assignment 1098227825Stheraven{ 1099227825Stheravenprivate: 1100242945Stheraven struct __two {char __lx; char __lxx;}; 1101227825Stheraven template <class _Up> static __two __test(...); 1102227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0); 1103227825Stheravenpublic: 1104227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1105227825Stheraven}; 1106227825Stheraven 1107227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value> 1108227825Stheravenstruct __propagate_on_container_move_assignment 1109227825Stheraven{ 1110227825Stheraven typedef false_type type; 1111227825Stheraven}; 1112227825Stheraven 1113227825Stheraventemplate <class _Alloc> 1114227825Stheravenstruct __propagate_on_container_move_assignment<_Alloc, true> 1115227825Stheraven{ 1116227825Stheraven typedef typename _Alloc::propagate_on_container_move_assignment type; 1117227825Stheraven}; 1118227825Stheraven 1119227825Stheraventemplate <class _Tp> 1120227825Stheravenstruct __has_propagate_on_container_swap 1121227825Stheraven{ 1122227825Stheravenprivate: 1123242945Stheraven struct __two {char __lx; char __lxx;}; 1124227825Stheraven template <class _Up> static __two __test(...); 1125227825Stheraven template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0); 1126227825Stheravenpublic: 1127227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1128227825Stheraven}; 1129227825Stheraven 1130227825Stheraventemplate <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> 1131227825Stheravenstruct __propagate_on_container_swap 1132227825Stheraven{ 1133227825Stheraven typedef false_type type; 1134227825Stheraven}; 1135227825Stheraven 1136227825Stheraventemplate <class _Alloc> 1137227825Stheravenstruct __propagate_on_container_swap<_Alloc, true> 1138227825Stheraven{ 1139227825Stheraven typedef typename _Alloc::propagate_on_container_swap type; 1140227825Stheraven}; 1141227825Stheraven 1142227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 1143227825Stheravenstruct __has_rebind_other 1144227825Stheraven{ 1145227825Stheravenprivate: 1146242945Stheraven struct __two {char __lx; char __lxx;}; 1147227825Stheraven template <class _Xp> static __two __test(...); 1148227825Stheraven template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); 1149227825Stheravenpublic: 1150227825Stheraven static const bool value = sizeof(__test<_Tp>(0)) == 1; 1151227825Stheraven}; 1152227825Stheraven 1153227825Stheraventemplate <class _Tp, class _Up> 1154227825Stheravenstruct __has_rebind_other<_Tp, _Up, false> 1155227825Stheraven{ 1156227825Stheraven static const bool value = false; 1157227825Stheraven}; 1158227825Stheraven 1159227825Stheraventemplate <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> 1160227825Stheravenstruct __allocator_traits_rebind 1161227825Stheraven{ 1162227825Stheraven typedef typename _Tp::template rebind<_Up>::other type; 1163227825Stheraven}; 1164227825Stheraven 1165227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1166227825Stheraven 1167227825Stheraventemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 1168227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> 1169227825Stheraven{ 1170227825Stheraven typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; 1171227825Stheraven}; 1172227825Stheraven 1173227825Stheraventemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 1174227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> 1175227825Stheraven{ 1176227825Stheraven typedef _Alloc<_Up, _Args...> type; 1177227825Stheraven}; 1178227825Stheraven 1179227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1180227825Stheraven 1181227825Stheraventemplate <template <class> class _Alloc, class _Tp, class _Up> 1182227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true> 1183227825Stheraven{ 1184227825Stheraven typedef typename _Alloc<_Tp>::template rebind<_Up>::other type; 1185227825Stheraven}; 1186227825Stheraven 1187227825Stheraventemplate <template <class> class _Alloc, class _Tp, class _Up> 1188227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false> 1189227825Stheraven{ 1190227825Stheraven typedef _Alloc<_Up> type; 1191227825Stheraven}; 1192227825Stheraven 1193227825Stheraventemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 1194227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true> 1195227825Stheraven{ 1196227825Stheraven typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type; 1197227825Stheraven}; 1198227825Stheraven 1199227825Stheraventemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 1200227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false> 1201227825Stheraven{ 1202227825Stheraven typedef _Alloc<_Up, _A0> type; 1203227825Stheraven}; 1204227825Stheraven 1205227825Stheraventemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 1206227825Stheraven class _A1, class _Up> 1207227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true> 1208227825Stheraven{ 1209227825Stheraven typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type; 1210227825Stheraven}; 1211227825Stheraven 1212227825Stheraventemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 1213227825Stheraven class _A1, class _Up> 1214227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false> 1215227825Stheraven{ 1216227825Stheraven typedef _Alloc<_Up, _A0, _A1> type; 1217227825Stheraven}; 1218227825Stheraven 1219227825Stheraventemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 1220227825Stheraven class _A1, class _A2, class _Up> 1221227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true> 1222227825Stheraven{ 1223227825Stheraven typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 1224227825Stheraven}; 1225227825Stheraven 1226227825Stheraventemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 1227227825Stheraven class _A1, class _A2, class _Up> 1228227825Stheravenstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> 1229227825Stheraven{ 1230227825Stheraven typedef _Alloc<_Up, _A0, _A1, _A2> type; 1231227825Stheraven}; 1232227825Stheraven 1233227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1234227825Stheraven 1235227825Stheraven#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 1236227825Stheraven 1237227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1238227825Stheravenauto 1239227825Stheraven__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 1240227825Stheraven -> decltype(__a.allocate(__sz, __p), true_type()); 1241227825Stheraven 1242227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1243227825Stheravenauto 1244227825Stheraven__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 1245227825Stheraven -> false_type; 1246227825Stheraven 1247227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1248227825Stheravenstruct __has_allocate_hint 1249227825Stheraven : integral_constant<bool, 1250227825Stheraven is_same< 1251227825Stheraven decltype(__has_allocate_hint_test(declval<_Alloc>(), 1252227825Stheraven declval<_SizeType>(), 1253227825Stheraven declval<_ConstVoidPtr>())), 1254227825Stheraven true_type>::value> 1255227825Stheraven{ 1256227825Stheraven}; 1257227825Stheraven 1258227825Stheraven#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1259227825Stheraven 1260227825Stheraventemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 1261227825Stheravenstruct __has_allocate_hint 1262227825Stheraven : true_type 1263227825Stheraven{ 1264227825Stheraven}; 1265227825Stheraven 1266227825Stheraven#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1267227825Stheraven 1268227825Stheraven#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1269227825Stheraven 1270227825Stheraventemplate <class _Alloc, class _Tp, class ..._Args> 1271227825Stheravendecltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), 1272227825Stheraven _VSTD::declval<_Args>()...), 1273227825Stheraven true_type()) 1274227825Stheraven__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args); 1275227825Stheraven 1276227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1277227825Stheravenfalse_type 1278227825Stheraven__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args); 1279227825Stheraven 1280227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1281227825Stheravenstruct __has_construct 1282227825Stheraven : integral_constant<bool, 1283227825Stheraven is_same< 1284227825Stheraven decltype(__has_construct_test(declval<_Alloc>(), 1285227825Stheraven declval<_Pointer>(), 1286227825Stheraven declval<_Args>()...)), 1287227825Stheraven true_type>::value> 1288227825Stheraven{ 1289227825Stheraven}; 1290227825Stheraven 1291227825Stheraventemplate <class _Alloc, class _Pointer> 1292227825Stheravenauto 1293227825Stheraven__has_destroy_test(_Alloc&& __a, _Pointer&& __p) 1294227825Stheraven -> decltype(__a.destroy(__p), true_type()); 1295227825Stheraven 1296227825Stheraventemplate <class _Alloc, class _Pointer> 1297227825Stheravenauto 1298227825Stheraven__has_destroy_test(const _Alloc& __a, _Pointer&& __p) 1299227825Stheraven -> false_type; 1300227825Stheraven 1301227825Stheraventemplate <class _Alloc, class _Pointer> 1302227825Stheravenstruct __has_destroy 1303227825Stheraven : integral_constant<bool, 1304227825Stheraven is_same< 1305227825Stheraven decltype(__has_destroy_test(declval<_Alloc>(), 1306227825Stheraven declval<_Pointer>())), 1307227825Stheraven true_type>::value> 1308227825Stheraven{ 1309227825Stheraven}; 1310227825Stheraven 1311227825Stheraventemplate <class _Alloc> 1312227825Stheravenauto 1313227825Stheraven__has_max_size_test(_Alloc&& __a) 1314227825Stheraven -> decltype(__a.max_size(), true_type()); 1315227825Stheraven 1316227825Stheraventemplate <class _Alloc> 1317227825Stheravenauto 1318227825Stheraven__has_max_size_test(const volatile _Alloc& __a) 1319227825Stheraven -> false_type; 1320227825Stheraven 1321227825Stheraventemplate <class _Alloc> 1322227825Stheravenstruct __has_max_size 1323227825Stheraven : integral_constant<bool, 1324227825Stheraven is_same< 1325227825Stheraven decltype(__has_max_size_test(declval<_Alloc&>())), 1326227825Stheraven true_type>::value> 1327227825Stheraven{ 1328227825Stheraven}; 1329227825Stheraven 1330227825Stheraventemplate <class _Alloc> 1331227825Stheravenauto 1332227825Stheraven__has_select_on_container_copy_construction_test(_Alloc&& __a) 1333227825Stheraven -> decltype(__a.select_on_container_copy_construction(), true_type()); 1334227825Stheraven 1335227825Stheraventemplate <class _Alloc> 1336227825Stheravenauto 1337227825Stheraven__has_select_on_container_copy_construction_test(const volatile _Alloc& __a) 1338227825Stheraven -> false_type; 1339227825Stheraven 1340227825Stheraventemplate <class _Alloc> 1341227825Stheravenstruct __has_select_on_container_copy_construction 1342227825Stheraven : integral_constant<bool, 1343227825Stheraven is_same< 1344227825Stheraven decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())), 1345227825Stheraven true_type>::value> 1346227825Stheraven{ 1347227825Stheraven}; 1348227825Stheraven 1349227825Stheraven#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1350227825Stheraven 1351227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1352227825Stheraven 1353227825Stheraventemplate <class _Alloc, class _Pointer, class ..._Args> 1354227825Stheravenstruct __has_construct 1355227825Stheraven : false_type 1356227825Stheraven{ 1357227825Stheraven}; 1358227825Stheraven 1359232950Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1360232950Stheraven 1361232950Stheraventemplate <class _Alloc, class _Pointer, class _Args> 1362232950Stheravenstruct __has_construct 1363232950Stheraven : false_type 1364232950Stheraven{ 1365232950Stheraven}; 1366232950Stheraven 1367227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1368227825Stheraven 1369227825Stheraventemplate <class _Alloc, class _Pointer> 1370227825Stheravenstruct __has_destroy 1371227825Stheraven : false_type 1372227825Stheraven{ 1373227825Stheraven}; 1374227825Stheraven 1375227825Stheraventemplate <class _Alloc> 1376227825Stheravenstruct __has_max_size 1377227825Stheraven : true_type 1378227825Stheraven{ 1379227825Stheraven}; 1380227825Stheraven 1381227825Stheraventemplate <class _Alloc> 1382227825Stheravenstruct __has_select_on_container_copy_construction 1383227825Stheraven : false_type 1384227825Stheraven{ 1385227825Stheraven}; 1386227825Stheraven 1387227825Stheraven#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 1388227825Stheraven 1389227825Stheraventemplate <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> 1390227825Stheravenstruct __alloc_traits_difference_type 1391227825Stheraven{ 1392227825Stheraven typedef typename pointer_traits<_Ptr>::difference_type type; 1393227825Stheraven}; 1394227825Stheraven 1395227825Stheraventemplate <class _Alloc, class _Ptr> 1396227825Stheravenstruct __alloc_traits_difference_type<_Alloc, _Ptr, true> 1397227825Stheraven{ 1398227825Stheraven typedef typename _Alloc::difference_type type; 1399227825Stheraven}; 1400227825Stheraven 1401227825Stheraventemplate <class _Alloc> 1402262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY allocator_traits 1403227825Stheraven{ 1404227825Stheraven typedef _Alloc allocator_type; 1405227825Stheraven typedef typename allocator_type::value_type value_type; 1406227825Stheraven 1407227825Stheraven typedef typename __pointer_type<value_type, allocator_type>::type pointer; 1408227825Stheraven typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer; 1409227825Stheraven typedef typename __void_pointer<pointer, allocator_type>::type void_pointer; 1410227825Stheraven typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer; 1411227825Stheraven 1412227825Stheraven typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type; 1413227825Stheraven typedef typename __size_type<allocator_type, difference_type>::type size_type; 1414227825Stheraven 1415227825Stheraven typedef typename __propagate_on_container_copy_assignment<allocator_type>::type 1416227825Stheraven propagate_on_container_copy_assignment; 1417227825Stheraven typedef typename __propagate_on_container_move_assignment<allocator_type>::type 1418227825Stheraven propagate_on_container_move_assignment; 1419227825Stheraven typedef typename __propagate_on_container_swap<allocator_type>::type 1420227825Stheraven propagate_on_container_swap; 1421227825Stheraven 1422227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1423227825Stheraven template <class _Tp> using rebind_alloc = 1424227825Stheraven typename __allocator_traits_rebind<allocator_type, _Tp>::type; 1425227825Stheraven template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; 1426227825Stheraven#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1427227825Stheraven template <class _Tp> struct rebind_alloc 1428227825Stheraven {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;}; 1429227825Stheraven template <class _Tp> struct rebind_traits 1430227825Stheraven {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;}; 1431227825Stheraven#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1432227825Stheraven 1433227825Stheraven _LIBCPP_INLINE_VISIBILITY 1434227825Stheraven static pointer allocate(allocator_type& __a, size_type __n) 1435227825Stheraven {return __a.allocate(__n);} 1436227825Stheraven _LIBCPP_INLINE_VISIBILITY 1437227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) 1438227825Stheraven {return allocate(__a, __n, __hint, 1439227825Stheraven __has_allocate_hint<allocator_type, size_type, const_void_pointer>());} 1440227825Stheraven 1441227825Stheraven _LIBCPP_INLINE_VISIBILITY 1442227825Stheraven static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT 1443227825Stheraven {__a.deallocate(__p, __n);} 1444227825Stheraven 1445227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1446227825Stheraven template <class _Tp, class... _Args> 1447227825Stheraven _LIBCPP_INLINE_VISIBILITY 1448227825Stheraven static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) 1449227825Stheraven {__construct(__has_construct<allocator_type, pointer, _Args...>(), 1450227825Stheraven __a, __p, _VSTD::forward<_Args>(__args)...);} 1451227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1452227825Stheraven template <class _Tp> 1453227825Stheraven _LIBCPP_INLINE_VISIBILITY 1454227825Stheraven static void construct(allocator_type& __a, _Tp* __p) 1455227825Stheraven { 1456227825Stheraven ::new ((void*)__p) _Tp(); 1457227825Stheraven } 1458227825Stheraven template <class _Tp, class _A0> 1459227825Stheraven _LIBCPP_INLINE_VISIBILITY 1460227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0) 1461227825Stheraven { 1462227825Stheraven ::new ((void*)__p) _Tp(__a0); 1463227825Stheraven } 1464227825Stheraven template <class _Tp, class _A0, class _A1> 1465227825Stheraven _LIBCPP_INLINE_VISIBILITY 1466227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, 1467227825Stheraven const _A1& __a1) 1468227825Stheraven { 1469227825Stheraven ::new ((void*)__p) _Tp(__a0, __a1); 1470227825Stheraven } 1471227825Stheraven template <class _Tp, class _A0, class _A1, class _A2> 1472227825Stheraven _LIBCPP_INLINE_VISIBILITY 1473227825Stheraven static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, 1474227825Stheraven const _A1& __a1, const _A2& __a2) 1475227825Stheraven { 1476227825Stheraven ::new ((void*)__p) _Tp(__a0, __a1, __a2); 1477227825Stheraven } 1478227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1479227825Stheraven 1480227825Stheraven template <class _Tp> 1481227825Stheraven _LIBCPP_INLINE_VISIBILITY 1482227825Stheraven static void destroy(allocator_type& __a, _Tp* __p) 1483227825Stheraven {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} 1484227825Stheraven 1485227825Stheraven _LIBCPP_INLINE_VISIBILITY 1486262801Sdim static size_type max_size(const allocator_type& __a) _NOEXCEPT 1487227825Stheraven {return __max_size(__has_max_size<const allocator_type>(), __a);} 1488227825Stheraven 1489227825Stheraven _LIBCPP_INLINE_VISIBILITY 1490227825Stheraven static allocator_type 1491227825Stheraven select_on_container_copy_construction(const allocator_type& __a) 1492227825Stheraven {return select_on_container_copy_construction( 1493227825Stheraven __has_select_on_container_copy_construction<const allocator_type>(), 1494227825Stheraven __a);} 1495227825Stheraven 1496232950Stheraven template <class _Ptr> 1497232950Stheraven _LIBCPP_INLINE_VISIBILITY 1498232950Stheraven static 1499232950Stheraven void 1500232950Stheraven __construct_forward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) 1501232950Stheraven { 1502232950Stheraven for (; __begin1 != __end1; ++__begin1, ++__begin2) 1503232950Stheraven construct(__a, _VSTD::__to_raw_pointer(__begin2), _VSTD::move_if_noexcept(*__begin1)); 1504232950Stheraven } 1505232950Stheraven 1506232950Stheraven template <class _Tp> 1507232950Stheraven _LIBCPP_INLINE_VISIBILITY 1508232950Stheraven static 1509232950Stheraven typename enable_if 1510232950Stheraven < 1511232950Stheraven (is_same<allocator_type, allocator<_Tp> >::value 1512232950Stheraven || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 1513232950Stheraven is_trivially_move_constructible<_Tp>::value, 1514232950Stheraven void 1515232950Stheraven >::type 1516232950Stheraven __construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) 1517232950Stheraven { 1518232950Stheraven ptrdiff_t _Np = __end1 - __begin1; 1519232950Stheraven _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); 1520232950Stheraven __begin2 += _Np; 1521232950Stheraven } 1522232950Stheraven 1523232950Stheraven template <class _Ptr> 1524232950Stheraven _LIBCPP_INLINE_VISIBILITY 1525232950Stheraven static 1526232950Stheraven void 1527232950Stheraven __construct_backward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) 1528232950Stheraven { 1529232950Stheraven while (__end1 != __begin1) 1530246487Stheraven { 1531246487Stheraven construct(__a, _VSTD::__to_raw_pointer(__end2-1), _VSTD::move_if_noexcept(*--__end1)); 1532246487Stheraven --__end2; 1533246487Stheraven } 1534232950Stheraven } 1535232950Stheraven 1536232950Stheraven template <class _Tp> 1537232950Stheraven _LIBCPP_INLINE_VISIBILITY 1538232950Stheraven static 1539232950Stheraven typename enable_if 1540232950Stheraven < 1541232950Stheraven (is_same<allocator_type, allocator<_Tp> >::value 1542232950Stheraven || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 1543232950Stheraven is_trivially_move_constructible<_Tp>::value, 1544232950Stheraven void 1545232950Stheraven >::type 1546232950Stheraven __construct_backward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) 1547232950Stheraven { 1548232950Stheraven ptrdiff_t _Np = __end1 - __begin1; 1549232950Stheraven __end2 -= _Np; 1550232950Stheraven _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp)); 1551232950Stheraven } 1552232950Stheraven 1553227825Stheravenprivate: 1554227825Stheraven 1555227825Stheraven _LIBCPP_INLINE_VISIBILITY 1556227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, 1557227825Stheraven const_void_pointer __hint, true_type) 1558227825Stheraven {return __a.allocate(__n, __hint);} 1559227825Stheraven _LIBCPP_INLINE_VISIBILITY 1560227825Stheraven static pointer allocate(allocator_type& __a, size_type __n, 1561232950Stheraven const_void_pointer, false_type) 1562227825Stheraven {return __a.allocate(__n);} 1563227825Stheraven 1564227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1565227825Stheraven template <class _Tp, class... _Args> 1566227825Stheraven _LIBCPP_INLINE_VISIBILITY 1567227825Stheraven static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) 1568227825Stheraven {__a.construct(__p, _VSTD::forward<_Args>(__args)...);} 1569227825Stheraven template <class _Tp, class... _Args> 1570227825Stheraven _LIBCPP_INLINE_VISIBILITY 1571227825Stheraven static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) 1572227825Stheraven { 1573227825Stheraven ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); 1574227825Stheraven } 1575227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1576227825Stheraven 1577227825Stheraven template <class _Tp> 1578227825Stheraven _LIBCPP_INLINE_VISIBILITY 1579227825Stheraven static void __destroy(true_type, allocator_type& __a, _Tp* __p) 1580227825Stheraven {__a.destroy(__p);} 1581227825Stheraven template <class _Tp> 1582227825Stheraven _LIBCPP_INLINE_VISIBILITY 1583227825Stheraven static void __destroy(false_type, allocator_type&, _Tp* __p) 1584227825Stheraven { 1585227825Stheraven __p->~_Tp(); 1586227825Stheraven } 1587227825Stheraven 1588227825Stheraven _LIBCPP_INLINE_VISIBILITY 1589227825Stheraven static size_type __max_size(true_type, const allocator_type& __a) 1590227825Stheraven {return __a.max_size();} 1591227825Stheraven _LIBCPP_INLINE_VISIBILITY 1592227825Stheraven static size_type __max_size(false_type, const allocator_type&) 1593227825Stheraven {return numeric_limits<size_type>::max();} 1594227825Stheraven 1595227825Stheraven _LIBCPP_INLINE_VISIBILITY 1596227825Stheraven static allocator_type 1597227825Stheraven select_on_container_copy_construction(true_type, const allocator_type& __a) 1598227825Stheraven {return __a.select_on_container_copy_construction();} 1599227825Stheraven _LIBCPP_INLINE_VISIBILITY 1600227825Stheraven static allocator_type 1601227825Stheraven select_on_container_copy_construction(false_type, const allocator_type& __a) 1602227825Stheraven {return __a;} 1603227825Stheraven}; 1604227825Stheraven 1605232950Stheraven// allocator 1606227825Stheraven 1607227825Stheraventemplate <class _Tp> 1608262801Sdimclass _LIBCPP_TYPE_VIS_ONLY allocator 1609227825Stheraven{ 1610227825Stheravenpublic: 1611232950Stheraven typedef size_t size_type; 1612232950Stheraven typedef ptrdiff_t difference_type; 1613232950Stheraven typedef _Tp* pointer; 1614232950Stheraven typedef const _Tp* const_pointer; 1615232950Stheraven typedef _Tp& reference; 1616232950Stheraven typedef const _Tp& const_reference; 1617232950Stheraven typedef _Tp value_type; 1618227825Stheraven 1619232950Stheraven typedef true_type propagate_on_container_move_assignment; 1620227825Stheraven 1621232950Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 1622227825Stheraven 1623232950Stheraven _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 1624232950Stheraven template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 1625232950Stheraven _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT 1626232950Stheraven {return _VSTD::addressof(__x);} 1627232950Stheraven _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 1628232950Stheraven {return _VSTD::addressof(__x);} 1629232950Stheraven _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1630232950Stheraven {return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));} 1631232950Stheraven _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1632232950Stheraven {::operator delete((void*)__p);} 1633232950Stheraven _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 1634232950Stheraven {return size_type(~0) / sizeof(_Tp);} 1635232950Stheraven#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1636232950Stheraven template <class _Up, class... _Args> 1637232950Stheraven _LIBCPP_INLINE_VISIBILITY 1638232950Stheraven void 1639232950Stheraven construct(_Up* __p, _Args&&... __args) 1640232950Stheraven { 1641232950Stheraven ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 1642232950Stheraven } 1643232950Stheraven#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1644232950Stheraven _LIBCPP_INLINE_VISIBILITY 1645232950Stheraven void 1646232950Stheraven construct(pointer __p) 1647232950Stheraven { 1648232950Stheraven ::new((void*)__p) _Tp(); 1649232950Stheraven } 1650232950Stheraven# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1651234976Stheraven 1652232950Stheraven template <class _A0> 1653232950Stheraven _LIBCPP_INLINE_VISIBILITY 1654234976Stheraven void 1655232950Stheraven construct(pointer __p, _A0& __a0) 1656232950Stheraven { 1657232950Stheraven ::new((void*)__p) _Tp(__a0); 1658232950Stheraven } 1659232950Stheraven template <class _A0> 1660232950Stheraven _LIBCPP_INLINE_VISIBILITY 1661234976Stheraven void 1662232950Stheraven construct(pointer __p, const _A0& __a0) 1663232950Stheraven { 1664232950Stheraven ::new((void*)__p) _Tp(__a0); 1665232950Stheraven } 1666232950Stheraven# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1667232950Stheraven template <class _A0, class _A1> 1668232950Stheraven _LIBCPP_INLINE_VISIBILITY 1669232950Stheraven void 1670232950Stheraven construct(pointer __p, _A0& __a0, _A1& __a1) 1671232950Stheraven { 1672232950Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1673232950Stheraven } 1674232950Stheraven template <class _A0, class _A1> 1675232950Stheraven _LIBCPP_INLINE_VISIBILITY 1676232950Stheraven void 1677232950Stheraven construct(pointer __p, const _A0& __a0, _A1& __a1) 1678232950Stheraven { 1679232950Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1680232950Stheraven } 1681232950Stheraven template <class _A0, class _A1> 1682232950Stheraven _LIBCPP_INLINE_VISIBILITY 1683232950Stheraven void 1684232950Stheraven construct(pointer __p, _A0& __a0, const _A1& __a1) 1685232950Stheraven { 1686232950Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1687232950Stheraven } 1688232950Stheraven template <class _A0, class _A1> 1689232950Stheraven _LIBCPP_INLINE_VISIBILITY 1690232950Stheraven void 1691232950Stheraven construct(pointer __p, const _A0& __a0, const _A1& __a1) 1692232950Stheraven { 1693232950Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1694232950Stheraven } 1695232950Stheraven#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1696232950Stheraven _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 1697227825Stheraven}; 1698227825Stheraven 1699227825Stheraventemplate <class _Tp> 1700262801Sdimclass _LIBCPP_TYPE_VIS_ONLY allocator<const _Tp> 1701227825Stheraven{ 1702227825Stheravenpublic: 1703227825Stheraven typedef size_t size_type; 1704227825Stheraven typedef ptrdiff_t difference_type; 1705232950Stheraven typedef const _Tp* pointer; 1706227825Stheraven typedef const _Tp* const_pointer; 1707232950Stheraven typedef const _Tp& reference; 1708227825Stheraven typedef const _Tp& const_reference; 1709253159Stheraven typedef const _Tp value_type; 1710227825Stheraven 1711227825Stheraven typedef true_type propagate_on_container_move_assignment; 1712227825Stheraven 1713227825Stheraven template <class _Up> struct rebind {typedef allocator<_Up> other;}; 1714227825Stheraven 1715227825Stheraven _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 1716227825Stheraven template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 1717227825Stheraven _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 1718227825Stheraven {return _VSTD::addressof(__x);} 1719227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1720227825Stheraven {return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));} 1721227825Stheraven _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1722227825Stheraven {::operator delete((void*)__p);} 1723227825Stheraven _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 1724227825Stheraven {return size_type(~0) / sizeof(_Tp);} 1725227825Stheraven#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1726227825Stheraven template <class _Up, class... _Args> 1727227825Stheraven _LIBCPP_INLINE_VISIBILITY 1728227825Stheraven void 1729227825Stheraven construct(_Up* __p, _Args&&... __args) 1730227825Stheraven { 1731227825Stheraven ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 1732227825Stheraven } 1733227825Stheraven#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1734227825Stheraven _LIBCPP_INLINE_VISIBILITY 1735227825Stheraven void 1736227825Stheraven construct(pointer __p) 1737227825Stheraven { 1738227825Stheraven ::new((void*)__p) _Tp(); 1739227825Stheraven } 1740227825Stheraven# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1741234976Stheraven 1742227825Stheraven template <class _A0> 1743227825Stheraven _LIBCPP_INLINE_VISIBILITY 1744234976Stheraven void 1745227825Stheraven construct(pointer __p, _A0& __a0) 1746227825Stheraven { 1747227825Stheraven ::new((void*)__p) _Tp(__a0); 1748227825Stheraven } 1749227825Stheraven template <class _A0> 1750227825Stheraven _LIBCPP_INLINE_VISIBILITY 1751234976Stheraven void 1752227825Stheraven construct(pointer __p, const _A0& __a0) 1753227825Stheraven { 1754227825Stheraven ::new((void*)__p) _Tp(__a0); 1755227825Stheraven } 1756227825Stheraven# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1757227825Stheraven template <class _A0, class _A1> 1758227825Stheraven _LIBCPP_INLINE_VISIBILITY 1759227825Stheraven void 1760227825Stheraven construct(pointer __p, _A0& __a0, _A1& __a1) 1761227825Stheraven { 1762227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1763227825Stheraven } 1764227825Stheraven template <class _A0, class _A1> 1765227825Stheraven _LIBCPP_INLINE_VISIBILITY 1766227825Stheraven void 1767227825Stheraven construct(pointer __p, const _A0& __a0, _A1& __a1) 1768227825Stheraven { 1769227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1770227825Stheraven } 1771227825Stheraven template <class _A0, class _A1> 1772227825Stheraven _LIBCPP_INLINE_VISIBILITY 1773227825Stheraven void 1774227825Stheraven construct(pointer __p, _A0& __a0, const _A1& __a1) 1775227825Stheraven { 1776227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1777227825Stheraven } 1778227825Stheraven template <class _A0, class _A1> 1779227825Stheraven _LIBCPP_INLINE_VISIBILITY 1780227825Stheraven void 1781227825Stheraven construct(pointer __p, const _A0& __a0, const _A1& __a1) 1782227825Stheraven { 1783227825Stheraven ::new((void*)__p) _Tp(__a0, __a1); 1784227825Stheraven } 1785227825Stheraven#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 1786227825Stheraven _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 1787227825Stheraven}; 1788227825Stheraven 1789227825Stheraventemplate <class _Tp, class _Up> 1790227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1791227825Stheravenbool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} 1792227825Stheraven 1793227825Stheraventemplate <class _Tp, class _Up> 1794227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1795227825Stheravenbool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} 1796227825Stheraven 1797227825Stheraventemplate <class _OutputIterator, class _Tp> 1798262801Sdimclass _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator 1799227825Stheraven : public iterator<output_iterator_tag, 1800227825Stheraven _Tp, // purposefully not C++03 1801227825Stheraven ptrdiff_t, // purposefully not C++03 1802227825Stheraven _Tp*, // purposefully not C++03 1803227825Stheraven raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03 1804227825Stheraven{ 1805227825Stheravenprivate: 1806227825Stheraven _OutputIterator __x_; 1807227825Stheravenpublic: 1808227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} 1809227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} 1810227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) 1811227825Stheraven {::new(&*__x_) _Tp(__element); return *this;} 1812227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} 1813227825Stheraven _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) 1814227825Stheraven {raw_storage_iterator __t(*this); ++__x_; return __t;} 1815227825Stheraven}; 1816227825Stheraven 1817227825Stheraventemplate <class _Tp> 1818227825Stheravenpair<_Tp*, ptrdiff_t> 1819227825Stheravenget_temporary_buffer(ptrdiff_t __n) _NOEXCEPT 1820227825Stheraven{ 1821227825Stheraven pair<_Tp*, ptrdiff_t> __r(0, 0); 1822227825Stheraven const ptrdiff_t __m = (~ptrdiff_t(0) ^ 1823227825Stheraven ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) 1824227825Stheraven / sizeof(_Tp); 1825227825Stheraven if (__n > __m) 1826227825Stheraven __n = __m; 1827227825Stheraven while (__n > 0) 1828227825Stheraven { 1829227825Stheraven __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); 1830227825Stheraven if (__r.first) 1831227825Stheraven { 1832227825Stheraven __r.second = __n; 1833227825Stheraven break; 1834227825Stheraven } 1835227825Stheraven __n /= 2; 1836227825Stheraven } 1837227825Stheraven return __r; 1838227825Stheraven} 1839227825Stheraven 1840227825Stheraventemplate <class _Tp> 1841227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1842227825Stheravenvoid return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);} 1843227825Stheraven 1844227825Stheraventemplate <class _Tp> 1845227825Stheravenstruct auto_ptr_ref 1846227825Stheraven{ 1847227825Stheraven _Tp* __ptr_; 1848227825Stheraven}; 1849227825Stheraven 1850227825Stheraventemplate<class _Tp> 1851262801Sdimclass _LIBCPP_TYPE_VIS_ONLY auto_ptr 1852227825Stheraven{ 1853227825Stheravenprivate: 1854227825Stheraven _Tp* __ptr_; 1855227825Stheravenpublic: 1856227825Stheraven typedef _Tp element_type; 1857227825Stheraven 1858227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} 1859227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} 1860227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() 1861227825Stheraven : __ptr_(__p.release()) {} 1862227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() 1863227825Stheraven {reset(__p.release()); return *this;} 1864227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() 1865227825Stheraven {reset(__p.release()); return *this;} 1866227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() 1867227825Stheraven {reset(__p.__ptr_); return *this;} 1868227825Stheraven _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} 1869227825Stheraven 1870227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() 1871227825Stheraven {return *__ptr_;} 1872227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} 1873227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} 1874227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() 1875227825Stheraven { 1876227825Stheraven _Tp* __t = __ptr_; 1877227825Stheraven __ptr_ = 0; 1878227825Stheraven return __t; 1879227825Stheraven } 1880227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() 1881227825Stheraven { 1882227825Stheraven if (__ptr_ != __p) 1883227825Stheraven delete __ptr_; 1884227825Stheraven __ptr_ = __p; 1885227825Stheraven } 1886227825Stheraven 1887227825Stheraven _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} 1888227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() 1889227825Stheraven {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} 1890227825Stheraven template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() 1891227825Stheraven {return auto_ptr<_Up>(release());} 1892227825Stheraven}; 1893227825Stheraven 1894227825Stheraventemplate <> 1895262801Sdimclass _LIBCPP_TYPE_VIS_ONLY auto_ptr<void> 1896227825Stheraven{ 1897227825Stheravenpublic: 1898227825Stheraven typedef void element_type; 1899227825Stheraven}; 1900227825Stheraven 1901227825Stheraventemplate <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, 1902227825Stheraven typename remove_cv<_T2>::type>::value, 1903232950Stheraven bool = is_empty<_T1>::value 1904232950Stheraven#if __has_feature(is_final) 1905232950Stheraven && !__is_final(_T1) 1906232950Stheraven#endif 1907232950Stheraven , 1908232950Stheraven bool = is_empty<_T2>::value 1909232950Stheraven#if __has_feature(is_final) 1910232950Stheraven && !__is_final(_T2) 1911232950Stheraven#endif 1912232950Stheraven > 1913227825Stheravenstruct __libcpp_compressed_pair_switch; 1914227825Stheraven 1915227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1916227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};}; 1917227825Stheraven 1918227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1919227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false> {enum {value = 1};}; 1920227825Stheraven 1921227825Stheraventemplate <class _T1, class _T2, bool IsSame> 1922227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true> {enum {value = 2};}; 1923227825Stheraven 1924227825Stheraventemplate <class _T1, class _T2> 1925227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true> {enum {value = 3};}; 1926227825Stheraven 1927227825Stheraventemplate <class _T1, class _T2> 1928227825Stheravenstruct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true> {enum {value = 1};}; 1929227825Stheraven 1930227825Stheraventemplate <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value> 1931227825Stheravenclass __libcpp_compressed_pair_imp; 1932227825Stheraven 1933227825Stheraventemplate <class _T1, class _T2> 1934227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 0> 1935227825Stheraven{ 1936227825Stheravenprivate: 1937227825Stheraven _T1 __first_; 1938227825Stheraven _T2 __second_; 1939227825Stheravenpublic: 1940227825Stheraven typedef _T1 _T1_param; 1941227825Stheraven typedef _T2 _T2_param; 1942227825Stheraven 1943227825Stheraven typedef typename remove_reference<_T1>::type& _T1_reference; 1944227825Stheraven typedef typename remove_reference<_T2>::type& _T2_reference; 1945227825Stheraven 1946227825Stheraven typedef const typename remove_reference<_T1>::type& _T1_const_reference; 1947227825Stheraven typedef const typename remove_reference<_T2>::type& _T2_const_reference; 1948227825Stheraven 1949227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 1950232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 1951227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)) {} 1952232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 1953227825Stheraven : __second_(_VSTD::forward<_T2_param>(__t2)) {} 1954227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 1955227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 1956227825Stheraven 1957262801Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1958227825Stheraven 1959227825Stheraven _LIBCPP_INLINE_VISIBILITY 1960227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 1961227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 1962227825Stheraven is_nothrow_copy_constructible<_T2>::value) 1963227825Stheraven : __first_(__p.first()), 1964227825Stheraven __second_(__p.second()) {} 1965227825Stheraven 1966227825Stheraven _LIBCPP_INLINE_VISIBILITY 1967227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 1968227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 1969227825Stheraven is_nothrow_copy_assignable<_T2>::value) 1970227825Stheraven { 1971227825Stheraven __first_ = __p.first(); 1972227825Stheraven __second_ = __p.second(); 1973227825Stheraven return *this; 1974227825Stheraven } 1975227825Stheraven 1976227825Stheraven _LIBCPP_INLINE_VISIBILITY 1977227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 1978227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 1979227825Stheraven is_nothrow_move_constructible<_T2>::value) 1980227825Stheraven : __first_(_VSTD::forward<_T1>(__p.first())), 1981227825Stheraven __second_(_VSTD::forward<_T2>(__p.second())) {} 1982227825Stheraven 1983227825Stheraven _LIBCPP_INLINE_VISIBILITY 1984227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 1985227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 1986227825Stheraven is_nothrow_move_assignable<_T2>::value) 1987227825Stheraven { 1988227825Stheraven __first_ = _VSTD::forward<_T1>(__p.first()); 1989227825Stheraven __second_ = _VSTD::forward<_T2>(__p.second()); 1990227825Stheraven return *this; 1991227825Stheraven } 1992227825Stheraven 1993262801Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 1994253159Stheraven 1995232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 1996232950Stheraven 1997232950Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 1998232950Stheraven _LIBCPP_INLINE_VISIBILITY 1999232950Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2000232950Stheraven tuple<_Args1...> __first_args, 2001232950Stheraven tuple<_Args2...> __second_args, 2002232950Stheraven __tuple_indices<_I1...>, 2003232950Stheraven __tuple_indices<_I2...>) 2004232950Stheraven : __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), 2005232950Stheraven __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) 2006232950Stheraven {} 2007232950Stheraven 2008232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2009232950Stheraven 2010227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 2011227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 2012227825Stheraven 2013227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 2014227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 2015227825Stheraven 2016227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2017227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2018227825Stheraven __is_nothrow_swappable<_T1>::value) 2019227825Stheraven { 2020227825Stheraven using _VSTD::swap; 2021227825Stheraven swap(__first_, __x.__first_); 2022227825Stheraven swap(__second_, __x.__second_); 2023227825Stheraven } 2024227825Stheraven}; 2025227825Stheraven 2026227825Stheraventemplate <class _T1, class _T2> 2027227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 1> 2028227825Stheraven : private _T1 2029227825Stheraven{ 2030227825Stheravenprivate: 2031227825Stheraven _T2 __second_; 2032227825Stheravenpublic: 2033227825Stheraven typedef _T1 _T1_param; 2034227825Stheraven typedef _T2 _T2_param; 2035227825Stheraven 2036227825Stheraven typedef _T1& _T1_reference; 2037227825Stheraven typedef typename remove_reference<_T2>::type& _T2_reference; 2038227825Stheraven 2039227825Stheraven typedef const _T1& _T1_const_reference; 2040227825Stheraven typedef const typename remove_reference<_T2>::type& _T2_const_reference; 2041227825Stheraven 2042227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2043232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2044227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)) {} 2045232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2046227825Stheraven : __second_(_VSTD::forward<_T2_param>(__t2)) {} 2047227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2048227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 2049227825Stheraven 2050262801Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2051227825Stheraven 2052227825Stheraven _LIBCPP_INLINE_VISIBILITY 2053227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2054227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2055227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2056227825Stheraven : _T1(__p.first()), __second_(__p.second()) {} 2057227825Stheraven 2058227825Stheraven _LIBCPP_INLINE_VISIBILITY 2059227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2060227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2061227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2062227825Stheraven { 2063227825Stheraven _T1::operator=(__p.first()); 2064227825Stheraven __second_ = __p.second(); 2065227825Stheraven return *this; 2066227825Stheraven } 2067227825Stheraven 2068227825Stheraven _LIBCPP_INLINE_VISIBILITY 2069227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2070227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2071227825Stheraven is_nothrow_move_constructible<_T2>::value) 2072227825Stheraven : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {} 2073227825Stheraven 2074227825Stheraven _LIBCPP_INLINE_VISIBILITY 2075227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2076227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2077227825Stheraven is_nothrow_move_assignable<_T2>::value) 2078227825Stheraven { 2079227825Stheraven _T1::operator=(_VSTD::move(__p.first())); 2080227825Stheraven __second_ = _VSTD::forward<_T2>(__p.second()); 2081227825Stheraven return *this; 2082227825Stheraven } 2083227825Stheraven 2084262801Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2085253159Stheraven 2086232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2087232950Stheraven 2088232950Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2089232950Stheraven _LIBCPP_INLINE_VISIBILITY 2090232950Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2091232950Stheraven tuple<_Args1...> __first_args, 2092232950Stheraven tuple<_Args2...> __second_args, 2093232950Stheraven __tuple_indices<_I1...>, 2094232950Stheraven __tuple_indices<_I2...>) 2095232950Stheraven : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), 2096232950Stheraven __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) 2097232950Stheraven {} 2098232950Stheraven 2099232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2100232950Stheraven 2101227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 2102227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 2103227825Stheraven 2104227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 2105227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 2106227825Stheraven 2107227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2108227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2109227825Stheraven __is_nothrow_swappable<_T1>::value) 2110227825Stheraven { 2111227825Stheraven using _VSTD::swap; 2112227825Stheraven swap(__second_, __x.__second_); 2113227825Stheraven } 2114227825Stheraven}; 2115227825Stheraven 2116227825Stheraventemplate <class _T1, class _T2> 2117227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 2> 2118227825Stheraven : private _T2 2119227825Stheraven{ 2120227825Stheravenprivate: 2121227825Stheraven _T1 __first_; 2122227825Stheravenpublic: 2123227825Stheraven typedef _T1 _T1_param; 2124227825Stheraven typedef _T2 _T2_param; 2125227825Stheraven 2126227825Stheraven typedef typename remove_reference<_T1>::type& _T1_reference; 2127227825Stheraven typedef _T2& _T2_reference; 2128227825Stheraven 2129227825Stheraven typedef const typename remove_reference<_T1>::type& _T1_const_reference; 2130227825Stheraven typedef const _T2& _T2_const_reference; 2131227825Stheraven 2132227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2133227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2134227825Stheraven : __first_(_VSTD::forward<_T1_param>(__t1)) {} 2135227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2136227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)) {} 2137227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2138227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2139227825Stheraven is_nothrow_move_constructible<_T2>::value) 2140227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} 2141227825Stheraven 2142262801Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2143227825Stheraven 2144227825Stheraven _LIBCPP_INLINE_VISIBILITY 2145227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2146227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2147227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2148227825Stheraven : _T2(__p.second()), __first_(__p.first()) {} 2149227825Stheraven 2150227825Stheraven _LIBCPP_INLINE_VISIBILITY 2151227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2152227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2153227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2154227825Stheraven { 2155227825Stheraven _T2::operator=(__p.second()); 2156227825Stheraven __first_ = __p.first(); 2157227825Stheraven return *this; 2158227825Stheraven } 2159227825Stheraven 2160227825Stheraven _LIBCPP_INLINE_VISIBILITY 2161227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2162227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2163227825Stheraven is_nothrow_move_constructible<_T2>::value) 2164227825Stheraven : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {} 2165227825Stheraven 2166227825Stheraven _LIBCPP_INLINE_VISIBILITY 2167227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2168227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2169227825Stheraven is_nothrow_move_assignable<_T2>::value) 2170227825Stheraven { 2171227825Stheraven _T2::operator=(_VSTD::forward<_T2>(__p.second())); 2172227825Stheraven __first_ = _VSTD::move(__p.first()); 2173227825Stheraven return *this; 2174227825Stheraven } 2175227825Stheraven 2176262801Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2177253159Stheraven 2178232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2179232950Stheraven 2180232950Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2181232950Stheraven _LIBCPP_INLINE_VISIBILITY 2182232950Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2183232950Stheraven tuple<_Args1...> __first_args, 2184232950Stheraven tuple<_Args2...> __second_args, 2185232950Stheraven __tuple_indices<_I1...>, 2186232950Stheraven __tuple_indices<_I2...>) 2187232950Stheraven : _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...), 2188232950Stheraven __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...) 2189232950Stheraven 2190232950Stheraven {} 2191232950Stheraven 2192232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2193232950Stheraven 2194227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 2195227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 2196227825Stheraven 2197227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 2198227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 2199227825Stheraven 2200227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 2201227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2202227825Stheraven __is_nothrow_swappable<_T1>::value) 2203227825Stheraven { 2204227825Stheraven using _VSTD::swap; 2205227825Stheraven swap(__first_, __x.__first_); 2206227825Stheraven } 2207227825Stheraven}; 2208227825Stheraven 2209227825Stheraventemplate <class _T1, class _T2> 2210227825Stheravenclass __libcpp_compressed_pair_imp<_T1, _T2, 3> 2211227825Stheraven : private _T1, 2212227825Stheraven private _T2 2213227825Stheraven{ 2214227825Stheravenpublic: 2215227825Stheraven typedef _T1 _T1_param; 2216227825Stheraven typedef _T2 _T2_param; 2217227825Stheraven 2218227825Stheraven typedef _T1& _T1_reference; 2219227825Stheraven typedef _T2& _T2_reference; 2220227825Stheraven 2221227825Stheraven typedef const _T1& _T1_const_reference; 2222227825Stheraven typedef const _T2& _T2_const_reference; 2223227825Stheraven 2224227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 2225227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2226227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)) {} 2227227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2228227825Stheraven : _T2(_VSTD::forward<_T2_param>(__t2)) {} 2229227825Stheraven _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 2230227825Stheraven : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} 2231227825Stheraven 2232262801Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2233227825Stheraven 2234227825Stheraven _LIBCPP_INLINE_VISIBILITY 2235227825Stheraven __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 2236227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2237227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2238227825Stheraven : _T1(__p.first()), _T2(__p.second()) {} 2239227825Stheraven 2240227825Stheraven _LIBCPP_INLINE_VISIBILITY 2241227825Stheraven __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 2242227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2243227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2244227825Stheraven { 2245227825Stheraven _T1::operator=(__p.first()); 2246227825Stheraven _T2::operator=(__p.second()); 2247227825Stheraven return *this; 2248227825Stheraven } 2249227825Stheraven 2250227825Stheraven _LIBCPP_INLINE_VISIBILITY 2251227825Stheraven __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 2252227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2253227825Stheraven is_nothrow_move_constructible<_T2>::value) 2254227825Stheraven : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {} 2255227825Stheraven 2256227825Stheraven _LIBCPP_INLINE_VISIBILITY 2257227825Stheraven __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 2258227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2259227825Stheraven is_nothrow_move_assignable<_T2>::value) 2260227825Stheraven { 2261227825Stheraven _T1::operator=(_VSTD::move(__p.first())); 2262227825Stheraven _T2::operator=(_VSTD::move(__p.second())); 2263227825Stheraven return *this; 2264227825Stheraven } 2265227825Stheraven 2266262801Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2267253159Stheraven 2268232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2269232950Stheraven 2270232950Stheraven template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 2271232950Stheraven _LIBCPP_INLINE_VISIBILITY 2272232950Stheraven __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 2273232950Stheraven tuple<_Args1...> __first_args, 2274232950Stheraven tuple<_Args2...> __second_args, 2275232950Stheraven __tuple_indices<_I1...>, 2276232950Stheraven __tuple_indices<_I2...>) 2277232950Stheraven : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), 2278232950Stheraven _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) 2279232950Stheraven {} 2280232950Stheraven 2281232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2282232950Stheraven 2283227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 2284227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 2285227825Stheraven 2286227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 2287227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 2288227825Stheraven 2289232950Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&) 2290227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2291227825Stheraven __is_nothrow_swappable<_T1>::value) 2292227825Stheraven { 2293227825Stheraven } 2294227825Stheraven}; 2295227825Stheraven 2296227825Stheraventemplate <class _T1, class _T2> 2297227825Stheravenclass __compressed_pair 2298227825Stheraven : private __libcpp_compressed_pair_imp<_T1, _T2> 2299227825Stheraven{ 2300227825Stheraven typedef __libcpp_compressed_pair_imp<_T1, _T2> base; 2301227825Stheravenpublic: 2302227825Stheraven typedef typename base::_T1_param _T1_param; 2303227825Stheraven typedef typename base::_T2_param _T2_param; 2304227825Stheraven 2305227825Stheraven typedef typename base::_T1_reference _T1_reference; 2306227825Stheraven typedef typename base::_T2_reference _T2_reference; 2307227825Stheraven 2308227825Stheraven typedef typename base::_T1_const_reference _T1_const_reference; 2309227825Stheraven typedef typename base::_T2_const_reference _T2_const_reference; 2310227825Stheraven 2311227825Stheraven _LIBCPP_INLINE_VISIBILITY __compressed_pair() {} 2312232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1) 2313227825Stheraven : base(_VSTD::forward<_T1_param>(__t1)) {} 2314232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2) 2315227825Stheraven : base(_VSTD::forward<_T2_param>(__t2)) {} 2316227825Stheraven _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) 2317227825Stheraven : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} 2318227825Stheraven 2319262801Sdim#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2320227825Stheraven 2321227825Stheraven _LIBCPP_INLINE_VISIBILITY 2322227825Stheraven __compressed_pair(const __compressed_pair& __p) 2323227825Stheraven _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 2324227825Stheraven is_nothrow_copy_constructible<_T2>::value) 2325227825Stheraven : base(__p) {} 2326227825Stheraven 2327227825Stheraven _LIBCPP_INLINE_VISIBILITY 2328227825Stheraven __compressed_pair& operator=(const __compressed_pair& __p) 2329227825Stheraven _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 2330227825Stheraven is_nothrow_copy_assignable<_T2>::value) 2331227825Stheraven { 2332227825Stheraven base::operator=(__p); 2333227825Stheraven return *this; 2334227825Stheraven } 2335227825Stheraven 2336227825Stheraven _LIBCPP_INLINE_VISIBILITY 2337227825Stheraven __compressed_pair(__compressed_pair&& __p) 2338227825Stheraven _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 2339227825Stheraven is_nothrow_move_constructible<_T2>::value) 2340227825Stheraven : base(_VSTD::move(__p)) {} 2341227825Stheraven 2342227825Stheraven _LIBCPP_INLINE_VISIBILITY 2343227825Stheraven __compressed_pair& operator=(__compressed_pair&& __p) 2344227825Stheraven _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 2345227825Stheraven is_nothrow_move_assignable<_T2>::value) 2346227825Stheraven { 2347227825Stheraven base::operator=(_VSTD::move(__p)); 2348227825Stheraven return *this; 2349227825Stheraven } 2350232950Stheraven 2351262801Sdim#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 2352253159Stheraven 2353232950Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 2354232950Stheraven 2355232950Stheraven template <class... _Args1, class... _Args2> 2356232950Stheraven _LIBCPP_INLINE_VISIBILITY 2357232950Stheraven __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, 2358232950Stheraven tuple<_Args2...> __second_args) 2359232950Stheraven : base(__pc, _VSTD::move(__first_args), _VSTD::move(__second_args), 2360232950Stheraven typename __make_tuple_indices<sizeof...(_Args1)>::type(), 2361232950Stheraven typename __make_tuple_indices<sizeof...(_Args2) >::type()) 2362232950Stheraven {} 2363232950Stheraven 2364232950Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2365232950Stheraven 2366227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return base::first();} 2367227825Stheraven _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();} 2368227825Stheraven 2369227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return base::second();} 2370227825Stheraven _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();} 2371227825Stheraven 2372227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) 2373227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2374227825Stheraven __is_nothrow_swappable<_T1>::value) 2375227825Stheraven {base::swap(__x);} 2376227825Stheraven}; 2377227825Stheraven 2378227825Stheraventemplate <class _T1, class _T2> 2379227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2380227825Stheravenvoid 2381227825Stheravenswap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) 2382227825Stheraven _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2383227825Stheraven __is_nothrow_swappable<_T1>::value) 2384227825Stheraven {__x.swap(__y);} 2385227825Stheraven 2386232950Stheraven// __same_or_less_cv_qualified 2387232950Stheraven 2388232950Stheraventemplate <class _Ptr1, class _Ptr2, 2389232950Stheraven bool = is_same<typename remove_cv<typename pointer_traits<_Ptr1>::element_type>::type, 2390232950Stheraven typename remove_cv<typename pointer_traits<_Ptr2>::element_type>::type 2391232950Stheraven >::value 2392232950Stheraven > 2393232950Stheravenstruct __same_or_less_cv_qualified_imp 2394232950Stheraven : is_convertible<_Ptr1, _Ptr2> {}; 2395232950Stheraven 2396232950Stheraventemplate <class _Ptr1, class _Ptr2> 2397232950Stheravenstruct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false> 2398232950Stheraven : false_type {}; 2399232950Stheraven 2400232950Stheraventemplate <class _Ptr1, class _Ptr2, bool = is_scalar<_Ptr1>::value && 2401232950Stheraven !is_pointer<_Ptr1>::value> 2402232950Stheravenstruct __same_or_less_cv_qualified 2403232950Stheraven : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {}; 2404232950Stheraven 2405232950Stheraventemplate <class _Ptr1, class _Ptr2> 2406232950Stheravenstruct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true> 2407232950Stheraven : false_type {}; 2408232950Stheraven 2409232950Stheraven// default_delete 2410232950Stheraven 2411227825Stheraventemplate <class _Tp> 2412262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY default_delete 2413227825Stheraven{ 2414241903Sdim#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2415241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; 2416241903Sdim#else 2417241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} 2418241903Sdim#endif 2419227825Stheraven template <class _Up> 2420227825Stheraven _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, 2421227825Stheraven typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 2422227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT 2423227825Stheraven { 2424227825Stheraven static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 2425249998Sdim static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); 2426227825Stheraven delete __ptr; 2427227825Stheraven } 2428227825Stheraven}; 2429227825Stheraven 2430227825Stheraventemplate <class _Tp> 2431262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]> 2432227825Stheraven{ 2433232950Stheravenpublic: 2434241903Sdim#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2435241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; 2436241903Sdim#else 2437241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} 2438241903Sdim#endif 2439232950Stheraven template <class _Up> 2440232950Stheraven _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&, 2441232950Stheraven typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 2442232950Stheraven template <class _Up> 2443232950Stheraven _LIBCPP_INLINE_VISIBILITY 2444232950Stheraven void operator() (_Up* __ptr, 2445232950Stheraven typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT 2446227825Stheraven { 2447227825Stheraven static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 2448249998Sdim static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); 2449227825Stheraven delete [] __ptr; 2450227825Stheraven } 2451227825Stheraven}; 2452227825Stheraven 2453227825Stheraventemplate <class _Tp, class _Dp = default_delete<_Tp> > 2454262801Sdimclass _LIBCPP_TYPE_VIS_ONLY unique_ptr 2455227825Stheraven{ 2456227825Stheravenpublic: 2457227825Stheraven typedef _Tp element_type; 2458227825Stheraven typedef _Dp deleter_type; 2459227825Stheraven typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 2460227825Stheravenprivate: 2461227825Stheraven __compressed_pair<pointer, deleter_type> __ptr_; 2462227825Stheraven 2463232950Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2464227825Stheraven unique_ptr(unique_ptr&); 2465227825Stheraven template <class _Up, class _Ep> 2466227825Stheraven unique_ptr(unique_ptr<_Up, _Ep>&); 2467227825Stheraven unique_ptr& operator=(unique_ptr&); 2468227825Stheraven template <class _Up, class _Ep> 2469227825Stheraven unique_ptr& operator=(unique_ptr<_Up, _Ep>&); 2470227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2471227825Stheraven 2472227825Stheraven struct __nat {int __for_bool_;}; 2473227825Stheraven 2474227825Stheraven typedef typename remove_reference<deleter_type>::type& _Dp_reference; 2475227825Stheraven typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 2476227825Stheravenpublic: 2477241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT 2478227825Stheraven : __ptr_(pointer()) 2479227825Stheraven { 2480227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2481227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2482227825Stheraven } 2483241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT 2484227825Stheraven : __ptr_(pointer()) 2485227825Stheraven { 2486227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2487227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2488227825Stheraven } 2489227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT 2490227825Stheraven : __ptr_(_VSTD::move(__p)) 2491227825Stheraven { 2492227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2493227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2494227825Stheraven } 2495227825Stheraven 2496227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2497227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional< 2498227825Stheraven is_reference<deleter_type>::value, 2499227825Stheraven deleter_type, 2500227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2501227825Stheraven _NOEXCEPT 2502227825Stheraven : __ptr_(__p, __d) {} 2503227825Stheraven 2504227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d) 2505227825Stheraven _NOEXCEPT 2506227825Stheraven : __ptr_(__p, _VSTD::move(__d)) 2507227825Stheraven { 2508227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2509227825Stheraven } 2510227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 2511227825Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2512227825Stheraven template <class _Up, class _Ep> 2513227825Stheraven _LIBCPP_INLINE_VISIBILITY 2514227825Stheraven unique_ptr(unique_ptr<_Up, _Ep>&& __u, 2515227825Stheraven typename enable_if 2516227825Stheraven < 2517227825Stheraven !is_array<_Up>::value && 2518227825Stheraven is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2519227825Stheraven is_convertible<_Ep, deleter_type>::value && 2520227825Stheraven ( 2521227825Stheraven !is_reference<deleter_type>::value || 2522227825Stheraven is_same<deleter_type, _Ep>::value 2523227825Stheraven ), 2524227825Stheraven __nat 2525227825Stheraven >::type = __nat()) _NOEXCEPT 2526227825Stheraven : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} 2527227825Stheraven 2528227825Stheraven template <class _Up> 2529227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, 2530227825Stheraven typename enable_if< 2531227825Stheraven is_convertible<_Up*, _Tp*>::value && 2532227825Stheraven is_same<_Dp, default_delete<_Tp> >::value, 2533227825Stheraven __nat 2534227825Stheraven >::type = __nat()) _NOEXCEPT 2535227825Stheraven : __ptr_(__p.release()) 2536227825Stheraven { 2537227825Stheraven } 2538227825Stheraven 2539227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 2540227825Stheraven { 2541227825Stheraven reset(__u.release()); 2542227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2543227825Stheraven return *this; 2544227825Stheraven } 2545227825Stheraven 2546227825Stheraven template <class _Up, class _Ep> 2547227825Stheraven _LIBCPP_INLINE_VISIBILITY 2548227825Stheraven typename enable_if 2549227825Stheraven < 2550232950Stheraven !is_array<_Up>::value && 2551232950Stheraven is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2552232950Stheraven is_assignable<deleter_type&, _Ep&&>::value, 2553227825Stheraven unique_ptr& 2554227825Stheraven >::type 2555227825Stheraven operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 2556227825Stheraven { 2557227825Stheraven reset(__u.release()); 2558227825Stheraven __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 2559227825Stheraven return *this; 2560227825Stheraven } 2561227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2562227825Stheraven 2563227825Stheraven _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 2564227825Stheraven { 2565227825Stheraven return __rv<unique_ptr>(*this); 2566227825Stheraven } 2567227825Stheraven 2568227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 2569227825Stheraven : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 2570227825Stheraven 2571227825Stheraven template <class _Up, class _Ep> 2572227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) 2573227825Stheraven { 2574227825Stheraven reset(__u.release()); 2575227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2576227825Stheraven return *this; 2577227825Stheraven } 2578227825Stheraven 2579227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 2580227825Stheraven : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {} 2581227825Stheraven 2582227825Stheraven template <class _Up> 2583227825Stheraven _LIBCPP_INLINE_VISIBILITY 2584227825Stheraven typename enable_if< 2585227825Stheraven is_convertible<_Up*, _Tp*>::value && 2586227825Stheraven is_same<_Dp, default_delete<_Tp> >::value, 2587227825Stheraven unique_ptr& 2588227825Stheraven >::type 2589227825Stheraven operator=(auto_ptr<_Up> __p) 2590227825Stheraven {reset(__p.release()); return *this;} 2591227825Stheraven 2592227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2593227825Stheraven _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 2594227825Stheraven 2595227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 2596227825Stheraven { 2597227825Stheraven reset(); 2598227825Stheraven return *this; 2599227825Stheraven } 2600227825Stheraven 2601227825Stheraven _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const 2602227825Stheraven {return *__ptr_.first();} 2603227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();} 2604227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 2605227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 2606227825Stheraven {return __ptr_.second();} 2607227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 2608227825Stheraven {return __ptr_.second();} 2609232950Stheraven _LIBCPP_INLINE_VISIBILITY 2610232950Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT 2611232950Stheraven {return __ptr_.first() != nullptr;} 2612227825Stheraven 2613227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 2614227825Stheraven { 2615227825Stheraven pointer __t = __ptr_.first(); 2616227825Stheraven __ptr_.first() = pointer(); 2617227825Stheraven return __t; 2618227825Stheraven } 2619227825Stheraven 2620227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT 2621227825Stheraven { 2622227825Stheraven pointer __tmp = __ptr_.first(); 2623227825Stheraven __ptr_.first() = __p; 2624227825Stheraven if (__tmp) 2625227825Stheraven __ptr_.second()(__tmp); 2626227825Stheraven } 2627227825Stheraven 2628227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT 2629227825Stheraven {__ptr_.swap(__u.__ptr_);} 2630227825Stheraven}; 2631227825Stheraven 2632227825Stheraventemplate <class _Tp, class _Dp> 2633262801Sdimclass _LIBCPP_TYPE_VIS_ONLY unique_ptr<_Tp[], _Dp> 2634227825Stheraven{ 2635227825Stheravenpublic: 2636227825Stheraven typedef _Tp element_type; 2637227825Stheraven typedef _Dp deleter_type; 2638227825Stheraven typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 2639227825Stheravenprivate: 2640227825Stheraven __compressed_pair<pointer, deleter_type> __ptr_; 2641227825Stheraven 2642232950Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2643227825Stheraven unique_ptr(unique_ptr&); 2644227825Stheraven template <class _Up> 2645227825Stheraven unique_ptr(unique_ptr<_Up>&); 2646227825Stheraven unique_ptr& operator=(unique_ptr&); 2647227825Stheraven template <class _Up> 2648227825Stheraven unique_ptr& operator=(unique_ptr<_Up>&); 2649227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2650227825Stheraven 2651227825Stheraven struct __nat {int __for_bool_;}; 2652227825Stheraven 2653227825Stheraven typedef typename remove_reference<deleter_type>::type& _Dp_reference; 2654227825Stheraven typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 2655227825Stheravenpublic: 2656241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT 2657227825Stheraven : __ptr_(pointer()) 2658227825Stheraven { 2659227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2660227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2661227825Stheraven } 2662241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT 2663227825Stheraven : __ptr_(pointer()) 2664227825Stheraven { 2665227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2666227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2667227825Stheraven } 2668227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2669232950Stheraven template <class _Pp, 2670232950Stheraven class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type 2671227825Stheraven > 2672232950Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT 2673227825Stheraven : __ptr_(__p) 2674227825Stheraven { 2675227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2676227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2677227825Stheraven } 2678227825Stheraven 2679232950Stheraven template <class _Pp, 2680232950Stheraven class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type 2681227825Stheraven > 2682232950Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional< 2683227825Stheraven is_reference<deleter_type>::value, 2684227825Stheraven deleter_type, 2685227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2686227825Stheraven _NOEXCEPT 2687227825Stheraven : __ptr_(__p, __d) {} 2688227825Stheraven 2689227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional< 2690227825Stheraven is_reference<deleter_type>::value, 2691227825Stheraven deleter_type, 2692227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type __d) 2693227825Stheraven _NOEXCEPT 2694227825Stheraven : __ptr_(pointer(), __d) {} 2695227825Stheraven 2696232950Stheraven template <class _Pp, 2697232950Stheraven class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type 2698227825Stheraven > 2699232950Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename remove_reference<deleter_type>::type&& __d) 2700227825Stheraven _NOEXCEPT 2701227825Stheraven : __ptr_(__p, _VSTD::move(__d)) 2702227825Stheraven { 2703227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2704227825Stheraven } 2705227825Stheraven 2706227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d) 2707227825Stheraven _NOEXCEPT 2708227825Stheraven : __ptr_(pointer(), _VSTD::move(__d)) 2709227825Stheraven { 2710227825Stheraven static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 2711227825Stheraven } 2712227825Stheraven 2713227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 2714227825Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2715227825Stheraven 2716227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 2717227825Stheraven { 2718227825Stheraven reset(__u.release()); 2719227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 2720227825Stheraven return *this; 2721227825Stheraven } 2722232950Stheraven 2723232950Stheraven template <class _Up, class _Ep> 2724232950Stheraven _LIBCPP_INLINE_VISIBILITY 2725232950Stheraven unique_ptr(unique_ptr<_Up, _Ep>&& __u, 2726232950Stheraven typename enable_if 2727232950Stheraven < 2728232950Stheraven is_array<_Up>::value && 2729232950Stheraven __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value 2730232950Stheraven && is_convertible<_Ep, deleter_type>::value && 2731232950Stheraven ( 2732232950Stheraven !is_reference<deleter_type>::value || 2733232950Stheraven is_same<deleter_type, _Ep>::value 2734232950Stheraven ), 2735232950Stheraven __nat 2736232950Stheraven >::type = __nat() 2737232950Stheraven ) _NOEXCEPT 2738232950Stheraven : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 2739232950Stheraven 2740232950Stheraven 2741232950Stheraven template <class _Up, class _Ep> 2742232950Stheraven _LIBCPP_INLINE_VISIBILITY 2743232950Stheraven typename enable_if 2744232950Stheraven < 2745232950Stheraven is_array<_Up>::value && 2746232950Stheraven __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 2747232950Stheraven is_assignable<deleter_type&, _Ep&&>::value, 2748232950Stheraven unique_ptr& 2749232950Stheraven >::type 2750232950Stheraven operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 2751232950Stheraven { 2752232950Stheraven reset(__u.release()); 2753232950Stheraven __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 2754232950Stheraven return *this; 2755232950Stheraven } 2756227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2757227825Stheraven 2758227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) 2759227825Stheraven : __ptr_(__p) 2760227825Stheraven { 2761227825Stheraven static_assert(!is_pointer<deleter_type>::value, 2762227825Stheraven "unique_ptr constructed with null function pointer deleter"); 2763227825Stheraven } 2764227825Stheraven 2765227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 2766227825Stheraven : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {} 2767227825Stheraven 2768227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d) 2769227825Stheraven : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {} 2770227825Stheraven 2771227825Stheraven _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 2772227825Stheraven { 2773227825Stheraven return __rv<unique_ptr>(*this); 2774227825Stheraven } 2775227825Stheraven 2776227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 2777227825Stheraven : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 2778227825Stheraven 2779227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u) 2780227825Stheraven { 2781227825Stheraven reset(__u->release()); 2782227825Stheraven __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter()); 2783227825Stheraven return *this; 2784227825Stheraven } 2785227825Stheraven 2786227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2787227825Stheraven _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 2788227825Stheraven 2789227825Stheraven _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 2790227825Stheraven { 2791227825Stheraven reset(); 2792227825Stheraven return *this; 2793227825Stheraven } 2794227825Stheraven 2795227825Stheraven _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const 2796227825Stheraven {return __ptr_.first()[__i];} 2797227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 2798227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 2799227825Stheraven {return __ptr_.second();} 2800227825Stheraven _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 2801227825Stheraven {return __ptr_.second();} 2802232950Stheraven _LIBCPP_INLINE_VISIBILITY 2803232950Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT 2804232950Stheraven {return __ptr_.first() != nullptr;} 2805227825Stheraven 2806227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 2807227825Stheraven { 2808227825Stheraven pointer __t = __ptr_.first(); 2809227825Stheraven __ptr_.first() = pointer(); 2810227825Stheraven return __t; 2811227825Stheraven } 2812227825Stheraven 2813227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2814232950Stheraven template <class _Pp, 2815232950Stheraven class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type 2816227825Stheraven > 2817232950Stheraven _LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT 2818227825Stheraven { 2819227825Stheraven pointer __tmp = __ptr_.first(); 2820227825Stheraven __ptr_.first() = __p; 2821227825Stheraven if (__tmp) 2822227825Stheraven __ptr_.second()(__tmp); 2823227825Stheraven } 2824227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT 2825227825Stheraven { 2826227825Stheraven pointer __tmp = __ptr_.first(); 2827227825Stheraven __ptr_.first() = nullptr; 2828227825Stheraven if (__tmp) 2829227825Stheraven __ptr_.second()(__tmp); 2830227825Stheraven } 2831227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT 2832227825Stheraven { 2833227825Stheraven pointer __tmp = __ptr_.first(); 2834227825Stheraven __ptr_.first() = nullptr; 2835227825Stheraven if (__tmp) 2836227825Stheraven __ptr_.second()(__tmp); 2837227825Stheraven } 2838227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2839227825Stheraven _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) 2840227825Stheraven { 2841227825Stheraven pointer __tmp = __ptr_.first(); 2842227825Stheraven __ptr_.first() = __p; 2843227825Stheraven if (__tmp) 2844227825Stheraven __ptr_.second()(__tmp); 2845227825Stheraven } 2846227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2847227825Stheraven 2848227825Stheraven _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} 2849227825Stheravenprivate: 2850227825Stheraven 2851227825Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2852227825Stheraven template <class _Up> 2853227825Stheraven explicit unique_ptr(_Up); 2854227825Stheraven template <class _Up> 2855227825Stheraven unique_ptr(_Up __u, 2856227825Stheraven typename conditional< 2857227825Stheraven is_reference<deleter_type>::value, 2858227825Stheraven deleter_type, 2859227825Stheraven typename add_lvalue_reference<const deleter_type>::type>::type, 2860227825Stheraven typename enable_if 2861227825Stheraven < 2862227825Stheraven is_convertible<_Up, pointer>::value, 2863227825Stheraven __nat 2864227825Stheraven >::type = __nat()); 2865227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2866227825Stheraven}; 2867227825Stheraven 2868227825Stheraventemplate <class _Tp, class _Dp> 2869227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2870227825Stheravenvoid 2871227825Stheravenswap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);} 2872227825Stheraven 2873227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2874227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2875227825Stheravenbool 2876227825Stheravenoperator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();} 2877227825Stheraven 2878227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2879227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2880227825Stheravenbool 2881227825Stheravenoperator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);} 2882227825Stheraven 2883227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2884227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2885227825Stheravenbool 2886232950Stheravenoperator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) 2887232950Stheraven{ 2888232950Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 2889232950Stheraven typedef typename unique_ptr<_T2, _D2>::pointer _P2; 2890232950Stheraven typedef typename common_type<_P1, _P2>::type _V; 2891232950Stheraven return less<_V>()(__x.get(), __y.get()); 2892232950Stheraven} 2893227825Stheraven 2894227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2895227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2896227825Stheravenbool 2897227825Stheravenoperator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;} 2898227825Stheraven 2899227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2900227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2901227825Stheravenbool 2902227825Stheravenoperator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);} 2903227825Stheraven 2904227825Stheraventemplate <class _T1, class _D1, class _T2, class _D2> 2905227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2906227825Stheravenbool 2907227825Stheravenoperator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} 2908227825Stheraven 2909232950Stheraventemplate <class _T1, class _D1> 2910232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2911232950Stheravenbool 2912241903Sdimoperator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT 2913232950Stheraven{ 2914232950Stheraven return !__x; 2915232950Stheraven} 2916232950Stheraven 2917232950Stheraventemplate <class _T1, class _D1> 2918232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2919232950Stheravenbool 2920241903Sdimoperator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT 2921232950Stheraven{ 2922232950Stheraven return !__x; 2923232950Stheraven} 2924232950Stheraven 2925232950Stheraventemplate <class _T1, class _D1> 2926232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2927232950Stheravenbool 2928241903Sdimoperator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT 2929232950Stheraven{ 2930232950Stheraven return static_cast<bool>(__x); 2931232950Stheraven} 2932232950Stheraven 2933232950Stheraventemplate <class _T1, class _D1> 2934232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2935232950Stheravenbool 2936241903Sdimoperator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT 2937232950Stheraven{ 2938232950Stheraven return static_cast<bool>(__x); 2939232950Stheraven} 2940232950Stheraven 2941232950Stheraventemplate <class _T1, class _D1> 2942232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2943232950Stheravenbool 2944232950Stheravenoperator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) 2945232950Stheraven{ 2946232950Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 2947232950Stheraven return less<_P1>()(__x.get(), nullptr); 2948232950Stheraven} 2949232950Stheraven 2950232950Stheraventemplate <class _T1, class _D1> 2951232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2952232950Stheravenbool 2953232950Stheravenoperator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) 2954232950Stheraven{ 2955232950Stheraven typedef typename unique_ptr<_T1, _D1>::pointer _P1; 2956232950Stheraven return less<_P1>()(nullptr, __x.get()); 2957232950Stheraven} 2958232950Stheraven 2959232950Stheraventemplate <class _T1, class _D1> 2960232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2961232950Stheravenbool 2962232950Stheravenoperator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) 2963232950Stheraven{ 2964232950Stheraven return nullptr < __x; 2965232950Stheraven} 2966232950Stheraven 2967232950Stheraventemplate <class _T1, class _D1> 2968232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2969232950Stheravenbool 2970232950Stheravenoperator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) 2971232950Stheraven{ 2972232950Stheraven return __x < nullptr; 2973232950Stheraven} 2974232950Stheraven 2975232950Stheraventemplate <class _T1, class _D1> 2976232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2977232950Stheravenbool 2978232950Stheravenoperator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) 2979232950Stheraven{ 2980232950Stheraven return !(nullptr < __x); 2981232950Stheraven} 2982232950Stheraven 2983232950Stheraventemplate <class _T1, class _D1> 2984232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2985232950Stheravenbool 2986232950Stheravenoperator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) 2987232950Stheraven{ 2988232950Stheraven return !(__x < nullptr); 2989232950Stheraven} 2990232950Stheraven 2991232950Stheraventemplate <class _T1, class _D1> 2992232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 2993232950Stheravenbool 2994232950Stheravenoperator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) 2995232950Stheraven{ 2996232950Stheraven return !(__x < nullptr); 2997232950Stheraven} 2998232950Stheraven 2999232950Stheraventemplate <class _T1, class _D1> 3000232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 3001232950Stheravenbool 3002232950Stheravenoperator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) 3003232950Stheraven{ 3004232950Stheraven return !(nullptr < __x); 3005232950Stheraven} 3006232950Stheraven 3007234976Stheraven#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3008234976Stheraven 3009234976Stheraventemplate <class _Tp, class _Dp> 3010234976Stheraveninline _LIBCPP_INLINE_VISIBILITY 3011234976Stheravenunique_ptr<_Tp, _Dp> 3012234976Stheravenmove(unique_ptr<_Tp, _Dp>& __t) 3013234976Stheraven{ 3014234976Stheraven return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t)); 3015234976Stheraven} 3016234976Stheraven 3017234976Stheraven#endif 3018234976Stheraven 3019253159Stheraven#if _LIBCPP_STD_VER > 11 3020253159Stheraven 3021253159Stheraventemplate<class _Tp> 3022253159Stheravenstruct __unique_if 3023253159Stheraven{ 3024253159Stheraven typedef unique_ptr<_Tp> __unique_single; 3025253159Stheraven}; 3026253159Stheraven 3027253159Stheraventemplate<class _Tp> 3028253159Stheravenstruct __unique_if<_Tp[]> 3029253159Stheraven{ 3030253159Stheraven typedef unique_ptr<_Tp[]> __unique_array_unknown_bound; 3031253159Stheraven}; 3032253159Stheraven 3033253159Stheraventemplate<class _Tp, size_t _Np> 3034253159Stheravenstruct __unique_if<_Tp[_Np]> 3035253159Stheraven{ 3036253159Stheraven typedef void __unique_array_known_bound; 3037253159Stheraven}; 3038253159Stheraven 3039253159Stheraventemplate<class _Tp, class... _Args> 3040253159Stheraveninline _LIBCPP_INLINE_VISIBILITY 3041253159Stheraventypename __unique_if<_Tp>::__unique_single 3042253159Stheravenmake_unique(_Args&&... __args) 3043253159Stheraven{ 3044253159Stheraven return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...)); 3045253159Stheraven} 3046253159Stheraven 3047253159Stheraventemplate<class _Tp> 3048253159Stheraveninline _LIBCPP_INLINE_VISIBILITY 3049253159Stheraventypename __unique_if<_Tp>::__unique_array_unknown_bound 3050253159Stheravenmake_unique(size_t __n) 3051253159Stheraven{ 3052253159Stheraven typedef typename remove_extent<_Tp>::type _Up; 3053253159Stheraven return unique_ptr<_Tp>(new _Up[__n]()); 3054253159Stheraven} 3055253159Stheraven 3056253159Stheraventemplate<class _Tp, class... _Args> 3057253159Stheraven typename __unique_if<_Tp>::__unique_array_known_bound 3058253159Stheraven make_unique(_Args&&...) = delete; 3059253159Stheraven 3060253159Stheraven#endif // _LIBCPP_STD_VER > 11 3061253159Stheraven 3062227825Stheraventemplate <class _Tp> struct hash; 3063227825Stheraven 3064253159Stheraventemplate <class _Size> 3065253159Stheraveninline _LIBCPP_INLINE_VISIBILITY 3066253159Stheraven_Size 3067253159Stheraven__loadword(const void* __p) 3068253159Stheraven{ 3069253159Stheraven _Size __r; 3070253159Stheraven std::memcpy(&__r, __p, sizeof(__r)); 3071253159Stheraven return __r; 3072253159Stheraven} 3073253159Stheraven 3074232950Stheraven// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t 3075232950Stheraven// is 64 bits. This is because cityhash64 uses 64bit x 64bit 3076232950Stheraven// multiplication, which can be very slow on 32-bit systems. 3077232950Stheraventemplate <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__> 3078232950Stheravenstruct __murmur2_or_cityhash; 3079232950Stheraven 3080232950Stheraventemplate <class _Size> 3081232950Stheravenstruct __murmur2_or_cityhash<_Size, 32> 3082227825Stheraven{ 3083232950Stheraven _Size operator()(const void* __key, _Size __len); 3084232950Stheraven}; 3085232950Stheraven 3086232950Stheraven// murmur2 3087232950Stheraventemplate <class _Size> 3088232950Stheraven_Size 3089232950Stheraven__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) 3090232950Stheraven{ 3091232950Stheraven const _Size __m = 0x5bd1e995; 3092232950Stheraven const _Size __r = 24; 3093232950Stheraven _Size __h = __len; 3094232950Stheraven const unsigned char* __data = static_cast<const unsigned char*>(__key); 3095232950Stheraven for (; __len >= 4; __data += 4, __len -= 4) 3096232950Stheraven { 3097253159Stheraven _Size __k = __loadword<_Size>(__data); 3098232950Stheraven __k *= __m; 3099232950Stheraven __k ^= __k >> __r; 3100232950Stheraven __k *= __m; 3101232950Stheraven __h *= __m; 3102232950Stheraven __h ^= __k; 3103232950Stheraven } 3104232950Stheraven switch (__len) 3105232950Stheraven { 3106232950Stheraven case 3: 3107232950Stheraven __h ^= __data[2] << 16; 3108232950Stheraven case 2: 3109232950Stheraven __h ^= __data[1] << 8; 3110232950Stheraven case 1: 3111232950Stheraven __h ^= __data[0]; 3112232950Stheraven __h *= __m; 3113232950Stheraven } 3114232950Stheraven __h ^= __h >> 13; 3115232950Stheraven __h *= __m; 3116232950Stheraven __h ^= __h >> 15; 3117232950Stheraven return __h; 3118232950Stheraven} 3119232950Stheraven 3120232950Stheraventemplate <class _Size> 3121232950Stheravenstruct __murmur2_or_cityhash<_Size, 64> 3122232950Stheraven{ 3123232950Stheraven _Size operator()(const void* __key, _Size __len); 3124232950Stheraven 3125232950Stheraven private: 3126232950Stheraven // Some primes between 2^63 and 2^64. 3127232950Stheraven static const _Size __k0 = 0xc3a5c85c97cb3127ULL; 3128232950Stheraven static const _Size __k1 = 0xb492b66fbe98f273ULL; 3129232950Stheraven static const _Size __k2 = 0x9ae16a3b2f90404fULL; 3130232950Stheraven static const _Size __k3 = 0xc949d7c7509e6557ULL; 3131232950Stheraven 3132232950Stheraven static _Size __rotate(_Size __val, int __shift) { 3133232950Stheraven return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); 3134232950Stheraven } 3135232950Stheraven 3136232950Stheraven static _Size __rotate_by_at_least_1(_Size __val, int __shift) { 3137232950Stheraven return (__val >> __shift) | (__val << (64 - __shift)); 3138232950Stheraven } 3139232950Stheraven 3140232950Stheraven static _Size __shift_mix(_Size __val) { 3141232950Stheraven return __val ^ (__val >> 47); 3142232950Stheraven } 3143232950Stheraven 3144232950Stheraven static _Size __hash_len_16(_Size __u, _Size __v) { 3145232950Stheraven const _Size __mul = 0x9ddfea08eb382d69ULL; 3146232950Stheraven _Size __a = (__u ^ __v) * __mul; 3147232950Stheraven __a ^= (__a >> 47); 3148232950Stheraven _Size __b = (__v ^ __a) * __mul; 3149232950Stheraven __b ^= (__b >> 47); 3150232950Stheraven __b *= __mul; 3151232950Stheraven return __b; 3152232950Stheraven } 3153232950Stheraven 3154232950Stheraven static _Size __hash_len_0_to_16(const char* __s, _Size __len) { 3155232950Stheraven if (__len > 8) { 3156253159Stheraven const _Size __a = __loadword<_Size>(__s); 3157253159Stheraven const _Size __b = __loadword<_Size>(__s + __len - 8); 3158232950Stheraven return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; 3159232950Stheraven } 3160232950Stheraven if (__len >= 4) { 3161253159Stheraven const uint32_t __a = __loadword<uint32_t>(__s); 3162253159Stheraven const uint32_t __b = __loadword<uint32_t>(__s + __len - 4); 3163232950Stheraven return __hash_len_16(__len + (__a << 3), __b); 3164232950Stheraven } 3165232950Stheraven if (__len > 0) { 3166232950Stheraven const unsigned char __a = __s[0]; 3167232950Stheraven const unsigned char __b = __s[__len >> 1]; 3168232950Stheraven const unsigned char __c = __s[__len - 1]; 3169232950Stheraven const uint32_t __y = static_cast<uint32_t>(__a) + 3170232950Stheraven (static_cast<uint32_t>(__b) << 8); 3171232950Stheraven const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2); 3172232950Stheraven return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; 3173232950Stheraven } 3174232950Stheraven return __k2; 3175232950Stheraven } 3176232950Stheraven 3177232950Stheraven static _Size __hash_len_17_to_32(const char *__s, _Size __len) { 3178253159Stheraven const _Size __a = __loadword<_Size>(__s) * __k1; 3179253159Stheraven const _Size __b = __loadword<_Size>(__s + 8); 3180253159Stheraven const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2; 3181253159Stheraven const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0; 3182232950Stheraven return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, 3183232950Stheraven __a + __rotate(__b ^ __k3, 20) - __c + __len); 3184232950Stheraven } 3185232950Stheraven 3186232950Stheraven // Return a 16-byte hash for 48 bytes. Quick and dirty. 3187232950Stheraven // Callers do best to use "random-looking" values for a and b. 3188232950Stheraven static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 3189232950Stheraven _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) { 3190232950Stheraven __a += __w; 3191232950Stheraven __b = __rotate(__b + __a + __z, 21); 3192232950Stheraven const _Size __c = __a; 3193232950Stheraven __a += __x; 3194232950Stheraven __a += __y; 3195232950Stheraven __b += __rotate(__a, 44); 3196232950Stheraven return pair<_Size, _Size>(__a + __z, __b + __c); 3197232950Stheraven } 3198232950Stheraven 3199232950Stheraven // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. 3200232950Stheraven static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 3201232950Stheraven const char* __s, _Size __a, _Size __b) { 3202253159Stheraven return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s), 3203253159Stheraven __loadword<_Size>(__s + 8), 3204253159Stheraven __loadword<_Size>(__s + 16), 3205253159Stheraven __loadword<_Size>(__s + 24), 3206232950Stheraven __a, 3207232950Stheraven __b); 3208232950Stheraven } 3209232950Stheraven 3210232950Stheraven // Return an 8-byte hash for 33 to 64 bytes. 3211232950Stheraven static _Size __hash_len_33_to_64(const char *__s, size_t __len) { 3212253159Stheraven _Size __z = __loadword<_Size>(__s + 24); 3213253159Stheraven _Size __a = __loadword<_Size>(__s) + 3214253159Stheraven (__len + __loadword<_Size>(__s + __len - 16)) * __k0; 3215232950Stheraven _Size __b = __rotate(__a + __z, 52); 3216232950Stheraven _Size __c = __rotate(__a, 37); 3217253159Stheraven __a += __loadword<_Size>(__s + 8); 3218232950Stheraven __c += __rotate(__a, 7); 3219253159Stheraven __a += __loadword<_Size>(__s + 16); 3220232950Stheraven _Size __vf = __a + __z; 3221232950Stheraven _Size __vs = __b + __rotate(__a, 31) + __c; 3222253159Stheraven __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32); 3223253159Stheraven __z += __loadword<_Size>(__s + __len - 8); 3224232950Stheraven __b = __rotate(__a + __z, 52); 3225232950Stheraven __c = __rotate(__a, 37); 3226253159Stheraven __a += __loadword<_Size>(__s + __len - 24); 3227232950Stheraven __c += __rotate(__a, 7); 3228253159Stheraven __a += __loadword<_Size>(__s + __len - 16); 3229232950Stheraven _Size __wf = __a + __z; 3230232950Stheraven _Size __ws = __b + __rotate(__a, 31) + __c; 3231232950Stheraven _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); 3232232950Stheraven return __shift_mix(__r * __k0 + __vs) * __k2; 3233232950Stheraven } 3234232950Stheraven}; 3235232950Stheraven 3236232950Stheraven// cityhash64 3237232950Stheraventemplate <class _Size> 3238232950Stheraven_Size 3239232950Stheraven__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) 3240232950Stheraven{ 3241232950Stheraven const char* __s = static_cast<const char*>(__key); 3242232950Stheraven if (__len <= 32) { 3243232950Stheraven if (__len <= 16) { 3244232950Stheraven return __hash_len_0_to_16(__s, __len); 3245232950Stheraven } else { 3246232950Stheraven return __hash_len_17_to_32(__s, __len); 3247232950Stheraven } 3248232950Stheraven } else if (__len <= 64) { 3249232950Stheraven return __hash_len_33_to_64(__s, __len); 3250232950Stheraven } 3251232950Stheraven 3252232950Stheraven // For strings over 64 bytes we hash the end first, and then as we 3253232950Stheraven // loop we keep 56 bytes of state: v, w, x, y, and z. 3254253159Stheraven _Size __x = __loadword<_Size>(__s + __len - 40); 3255253159Stheraven _Size __y = __loadword<_Size>(__s + __len - 16) + 3256253159Stheraven __loadword<_Size>(__s + __len - 56); 3257253159Stheraven _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len, 3258253159Stheraven __loadword<_Size>(__s + __len - 24)); 3259232950Stheraven pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); 3260232950Stheraven pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); 3261253159Stheraven __x = __x * __k1 + __loadword<_Size>(__s); 3262232950Stheraven 3263232950Stheraven // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. 3264232950Stheraven __len = (__len - 1) & ~static_cast<_Size>(63); 3265232950Stheraven do { 3266253159Stheraven __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1; 3267253159Stheraven __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1; 3268232950Stheraven __x ^= __w.second; 3269253159Stheraven __y += __v.first + __loadword<_Size>(__s + 40); 3270232950Stheraven __z = __rotate(__z + __w.first, 33) * __k1; 3271232950Stheraven __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); 3272232950Stheraven __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, 3273253159Stheraven __y + __loadword<_Size>(__s + 16)); 3274232950Stheraven std::swap(__z, __x); 3275232950Stheraven __s += 64; 3276232950Stheraven __len -= 64; 3277232950Stheraven } while (__len != 0); 3278232950Stheraven return __hash_len_16( 3279232950Stheraven __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, 3280232950Stheraven __hash_len_16(__v.second, __w.second) + __x); 3281232950Stheraven} 3282232950Stheraven 3283232950Stheraventemplate <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> 3284232950Stheravenstruct __scalar_hash; 3285232950Stheraven 3286232950Stheraventemplate <class _Tp> 3287232950Stheravenstruct __scalar_hash<_Tp, 0> 3288232950Stheraven : public unary_function<_Tp, size_t> 3289232950Stheraven{ 3290227825Stheraven _LIBCPP_INLINE_VISIBILITY 3291232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3292227825Stheraven { 3293232950Stheraven union 3294232950Stheraven { 3295232950Stheraven _Tp __t; 3296232950Stheraven size_t __a; 3297232950Stheraven } __u; 3298232950Stheraven __u.__a = 0; 3299232950Stheraven __u.__t = __v; 3300232950Stheraven return __u.__a; 3301227825Stheraven } 3302227825Stheraven}; 3303227825Stheraven 3304232950Stheraventemplate <class _Tp> 3305232950Stheravenstruct __scalar_hash<_Tp, 1> 3306232950Stheraven : public unary_function<_Tp, size_t> 3307232950Stheraven{ 3308232950Stheraven _LIBCPP_INLINE_VISIBILITY 3309232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3310232950Stheraven { 3311232950Stheraven union 3312232950Stheraven { 3313232950Stheraven _Tp __t; 3314232950Stheraven size_t __a; 3315232950Stheraven } __u; 3316232950Stheraven __u.__t = __v; 3317232950Stheraven return __u.__a; 3318232950Stheraven } 3319232950Stheraven}; 3320232950Stheraven 3321232950Stheraventemplate <class _Tp> 3322232950Stheravenstruct __scalar_hash<_Tp, 2> 3323232950Stheraven : public unary_function<_Tp, size_t> 3324232950Stheraven{ 3325232950Stheraven _LIBCPP_INLINE_VISIBILITY 3326232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3327232950Stheraven { 3328232950Stheraven union 3329232950Stheraven { 3330232950Stheraven _Tp __t; 3331232950Stheraven struct 3332232950Stheraven { 3333232950Stheraven size_t __a; 3334232950Stheraven size_t __b; 3335232950Stheraven }; 3336232950Stheraven } __u; 3337232950Stheraven __u.__t = __v; 3338232950Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3339232950Stheraven } 3340232950Stheraven}; 3341232950Stheraven 3342232950Stheraventemplate <class _Tp> 3343232950Stheravenstruct __scalar_hash<_Tp, 3> 3344232950Stheraven : public unary_function<_Tp, size_t> 3345232950Stheraven{ 3346232950Stheraven _LIBCPP_INLINE_VISIBILITY 3347232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3348232950Stheraven { 3349232950Stheraven union 3350232950Stheraven { 3351232950Stheraven _Tp __t; 3352232950Stheraven struct 3353232950Stheraven { 3354232950Stheraven size_t __a; 3355232950Stheraven size_t __b; 3356232950Stheraven size_t __c; 3357232950Stheraven }; 3358232950Stheraven } __u; 3359232950Stheraven __u.__t = __v; 3360232950Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3361232950Stheraven } 3362232950Stheraven}; 3363232950Stheraven 3364232950Stheraventemplate <class _Tp> 3365232950Stheravenstruct __scalar_hash<_Tp, 4> 3366232950Stheraven : public unary_function<_Tp, size_t> 3367232950Stheraven{ 3368232950Stheraven _LIBCPP_INLINE_VISIBILITY 3369232950Stheraven size_t operator()(_Tp __v) const _NOEXCEPT 3370232950Stheraven { 3371232950Stheraven union 3372232950Stheraven { 3373232950Stheraven _Tp __t; 3374232950Stheraven struct 3375232950Stheraven { 3376232950Stheraven size_t __a; 3377232950Stheraven size_t __b; 3378232950Stheraven size_t __c; 3379232950Stheraven size_t __d; 3380232950Stheraven }; 3381232950Stheraven } __u; 3382232950Stheraven __u.__t = __v; 3383232950Stheraven return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3384232950Stheraven } 3385232950Stheraven}; 3386232950Stheraven 3387232950Stheraventemplate<class _Tp> 3388262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*> 3389241903Sdim : public unary_function<_Tp*, size_t> 3390232950Stheraven{ 3391241903Sdim _LIBCPP_INLINE_VISIBILITY 3392241903Sdim size_t operator()(_Tp* __v) const _NOEXCEPT 3393241903Sdim { 3394241903Sdim union 3395241903Sdim { 3396241903Sdim _Tp* __t; 3397241903Sdim size_t __a; 3398241903Sdim } __u; 3399241903Sdim __u.__t = __v; 3400241903Sdim return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 3401241903Sdim } 3402232950Stheraven}; 3403232950Stheraven 3404227825Stheraventemplate <class _Tp, class _Dp> 3405262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unique_ptr<_Tp, _Dp> > 3406227825Stheraven{ 3407227825Stheraven typedef unique_ptr<_Tp, _Dp> argument_type; 3408227825Stheraven typedef size_t result_type; 3409227825Stheraven _LIBCPP_INLINE_VISIBILITY 3410227825Stheraven result_type operator()(const argument_type& __ptr) const _NOEXCEPT 3411227825Stheraven { 3412227825Stheraven typedef typename argument_type::pointer pointer; 3413227825Stheraven return hash<pointer>()(__ptr.get()); 3414227825Stheraven } 3415227825Stheraven}; 3416227825Stheraven 3417227825Stheravenstruct __destruct_n 3418227825Stheraven{ 3419227825Stheravenprivate: 3420227825Stheraven size_t size; 3421227825Stheraven 3422227825Stheraven template <class _Tp> 3423227825Stheraven _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT 3424227825Stheraven {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} 3425227825Stheraven 3426227825Stheraven template <class _Tp> 3427227825Stheraven _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT 3428227825Stheraven {} 3429227825Stheraven 3430227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT 3431227825Stheraven {++size;} 3432227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT 3433227825Stheraven {} 3434227825Stheraven 3435227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT 3436227825Stheraven {size = __s;} 3437227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT 3438227825Stheraven {} 3439227825Stheravenpublic: 3440227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT 3441227825Stheraven : size(__s) {} 3442227825Stheraven 3443227825Stheraven template <class _Tp> 3444227825Stheraven _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT 3445227825Stheraven {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3446227825Stheraven 3447227825Stheraven template <class _Tp> 3448227825Stheraven _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT 3449227825Stheraven {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3450227825Stheraven 3451227825Stheraven template <class _Tp> 3452227825Stheraven _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT 3453227825Stheraven {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 3454227825Stheraven}; 3455227825Stheraven 3456227825Stheraventemplate <class _Alloc> 3457227825Stheravenclass __allocator_destructor 3458227825Stheraven{ 3459227825Stheraven typedef allocator_traits<_Alloc> __alloc_traits; 3460227825Stheravenpublic: 3461227825Stheraven typedef typename __alloc_traits::pointer pointer; 3462227825Stheraven typedef typename __alloc_traits::size_type size_type; 3463227825Stheravenprivate: 3464227825Stheraven _Alloc& __alloc_; 3465227825Stheraven size_type __s_; 3466227825Stheravenpublic: 3467227825Stheraven _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) 3468227825Stheraven _NOEXCEPT 3469227825Stheraven : __alloc_(__a), __s_(__s) {} 3470227825Stheraven _LIBCPP_INLINE_VISIBILITY 3471227825Stheraven void operator()(pointer __p) _NOEXCEPT 3472227825Stheraven {__alloc_traits::deallocate(__alloc_, __p, __s_);} 3473227825Stheraven}; 3474227825Stheraven 3475227825Stheraventemplate <class _InputIterator, class _ForwardIterator> 3476227825Stheraven_ForwardIterator 3477227825Stheravenuninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) 3478227825Stheraven{ 3479227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3480232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3481232950Stheraven _ForwardIterator __s = __r; 3482232950Stheraven try 3483232950Stheraven { 3484232950Stheraven#endif 3485232950Stheraven for (; __f != __l; ++__f, ++__r) 3486232950Stheraven ::new(&*__r) value_type(*__f); 3487232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3488232950Stheraven } 3489232950Stheraven catch (...) 3490232950Stheraven { 3491232950Stheraven for (; __s != __r; ++__s) 3492232950Stheraven __s->~value_type(); 3493232950Stheraven throw; 3494232950Stheraven } 3495232950Stheraven#endif 3496227825Stheraven return __r; 3497227825Stheraven} 3498227825Stheraven 3499227825Stheraventemplate <class _InputIterator, class _Size, class _ForwardIterator> 3500227825Stheraven_ForwardIterator 3501227825Stheravenuninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) 3502227825Stheraven{ 3503227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3504232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3505232950Stheraven _ForwardIterator __s = __r; 3506232950Stheraven try 3507232950Stheraven { 3508232950Stheraven#endif 3509232950Stheraven for (; __n > 0; ++__f, ++__r, --__n) 3510232950Stheraven ::new(&*__r) value_type(*__f); 3511232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3512232950Stheraven } 3513232950Stheraven catch (...) 3514232950Stheraven { 3515232950Stheraven for (; __s != __r; ++__s) 3516232950Stheraven __s->~value_type(); 3517232950Stheraven throw; 3518232950Stheraven } 3519232950Stheraven#endif 3520227825Stheraven return __r; 3521227825Stheraven} 3522227825Stheraven 3523227825Stheraventemplate <class _ForwardIterator, class _Tp> 3524227825Stheravenvoid 3525227825Stheravenuninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) 3526227825Stheraven{ 3527227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3528232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3529232950Stheraven _ForwardIterator __s = __f; 3530232950Stheraven try 3531232950Stheraven { 3532232950Stheraven#endif 3533232950Stheraven for (; __f != __l; ++__f) 3534232950Stheraven ::new(&*__f) value_type(__x); 3535232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3536232950Stheraven } 3537232950Stheraven catch (...) 3538232950Stheraven { 3539232950Stheraven for (; __s != __f; ++__s) 3540232950Stheraven __s->~value_type(); 3541232950Stheraven throw; 3542232950Stheraven } 3543232950Stheraven#endif 3544227825Stheraven} 3545227825Stheraven 3546227825Stheraventemplate <class _ForwardIterator, class _Size, class _Tp> 3547227825Stheraven_ForwardIterator 3548227825Stheravenuninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) 3549227825Stheraven{ 3550227825Stheraven typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 3551232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3552232950Stheraven _ForwardIterator __s = __f; 3553232950Stheraven try 3554232950Stheraven { 3555232950Stheraven#endif 3556232950Stheraven for (; __n > 0; ++__f, --__n) 3557232950Stheraven ::new(&*__f) value_type(__x); 3558232950Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 3559232950Stheraven } 3560232950Stheraven catch (...) 3561232950Stheraven { 3562232950Stheraven for (; __s != __f; ++__s) 3563232950Stheraven __s->~value_type(); 3564232950Stheraven throw; 3565232950Stheraven } 3566232950Stheraven#endif 3567227825Stheraven return __f; 3568227825Stheraven} 3569227825Stheraven 3570227825Stheravenclass _LIBCPP_EXCEPTION_ABI bad_weak_ptr 3571227825Stheraven : public std::exception 3572227825Stheraven{ 3573227825Stheravenpublic: 3574227825Stheraven virtual ~bad_weak_ptr() _NOEXCEPT; 3575227825Stheraven virtual const char* what() const _NOEXCEPT; 3576227825Stheraven}; 3577227825Stheraven 3578262801Sdimtemplate<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 3579227825Stheraven 3580262801Sdimclass _LIBCPP_TYPE_VIS __shared_count 3581227825Stheraven{ 3582227825Stheraven __shared_count(const __shared_count&); 3583227825Stheraven __shared_count& operator=(const __shared_count&); 3584227825Stheraven 3585227825Stheravenprotected: 3586227825Stheraven long __shared_owners_; 3587227825Stheraven virtual ~__shared_count(); 3588227825Stheravenprivate: 3589227825Stheraven virtual void __on_zero_shared() _NOEXCEPT = 0; 3590227825Stheraven 3591227825Stheravenpublic: 3592227825Stheraven _LIBCPP_INLINE_VISIBILITY 3593227825Stheraven explicit __shared_count(long __refs = 0) _NOEXCEPT 3594227825Stheraven : __shared_owners_(__refs) {} 3595227825Stheraven 3596227825Stheraven void __add_shared() _NOEXCEPT; 3597227825Stheraven bool __release_shared() _NOEXCEPT; 3598227825Stheraven _LIBCPP_INLINE_VISIBILITY 3599227825Stheraven long use_count() const _NOEXCEPT {return __shared_owners_ + 1;} 3600227825Stheraven}; 3601227825Stheraven 3602262801Sdimclass _LIBCPP_TYPE_VIS __shared_weak_count 3603227825Stheraven : private __shared_count 3604227825Stheraven{ 3605227825Stheraven long __shared_weak_owners_; 3606227825Stheraven 3607227825Stheravenpublic: 3608227825Stheraven _LIBCPP_INLINE_VISIBILITY 3609227825Stheraven explicit __shared_weak_count(long __refs = 0) _NOEXCEPT 3610227825Stheraven : __shared_count(__refs), 3611227825Stheraven __shared_weak_owners_(__refs) {} 3612227825Stheravenprotected: 3613227825Stheraven virtual ~__shared_weak_count(); 3614227825Stheraven 3615227825Stheravenpublic: 3616227825Stheraven void __add_shared() _NOEXCEPT; 3617227825Stheraven void __add_weak() _NOEXCEPT; 3618227825Stheraven void __release_shared() _NOEXCEPT; 3619227825Stheraven void __release_weak() _NOEXCEPT; 3620227825Stheraven _LIBCPP_INLINE_VISIBILITY 3621227825Stheraven long use_count() const _NOEXCEPT {return __shared_count::use_count();} 3622227825Stheraven __shared_weak_count* lock() _NOEXCEPT; 3623227825Stheraven 3624249998Sdim // Define the function out only if we build static libc++ without RTTI. 3625249998Sdim // Otherwise we may break clients who need to compile their projects with 3626249998Sdim // -fno-rtti and yet link against a libc++.dylib compiled 3627249998Sdim // without -fno-rtti. 3628249998Sdim#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) 3629227825Stheraven virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 3630249998Sdim#endif 3631227825Stheravenprivate: 3632227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT = 0; 3633227825Stheraven}; 3634227825Stheraven 3635227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3636227825Stheravenclass __shared_ptr_pointer 3637227825Stheraven : public __shared_weak_count 3638227825Stheraven{ 3639227825Stheraven __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; 3640227825Stheravenpublic: 3641227825Stheraven _LIBCPP_INLINE_VISIBILITY 3642227825Stheraven __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) 3643227825Stheraven : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {} 3644227825Stheraven 3645227825Stheraven#ifndef _LIBCPP_NO_RTTI 3646227825Stheraven virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 3647227825Stheraven#endif 3648227825Stheraven 3649227825Stheravenprivate: 3650227825Stheraven virtual void __on_zero_shared() _NOEXCEPT; 3651227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT; 3652227825Stheraven}; 3653227825Stheraven 3654227825Stheraven#ifndef _LIBCPP_NO_RTTI 3655227825Stheraven 3656227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3657227825Stheravenconst void* 3658227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT 3659227825Stheraven{ 3660227825Stheraven return __t == typeid(_Dp) ? &__data_.first().second() : 0; 3661227825Stheraven} 3662227825Stheraven 3663227825Stheraven#endif // _LIBCPP_NO_RTTI 3664227825Stheraven 3665227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3666227825Stheravenvoid 3667227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT 3668227825Stheraven{ 3669227825Stheraven __data_.first().second()(__data_.first().first()); 3670227825Stheraven __data_.first().second().~_Dp(); 3671227825Stheraven} 3672227825Stheraven 3673227825Stheraventemplate <class _Tp, class _Dp, class _Alloc> 3674227825Stheravenvoid 3675227825Stheraven__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 3676227825Stheraven{ 3677227825Stheraven typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second()); 3678227825Stheraven __data_.second().~_Alloc(); 3679227825Stheraven __a.deallocate(this, 1); 3680227825Stheraven} 3681227825Stheraven 3682227825Stheraventemplate <class _Tp, class _Alloc> 3683227825Stheravenclass __shared_ptr_emplace 3684227825Stheraven : public __shared_weak_count 3685227825Stheraven{ 3686227825Stheraven __compressed_pair<_Alloc, _Tp> __data_; 3687227825Stheravenpublic: 3688227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 3689227825Stheraven 3690227825Stheraven _LIBCPP_INLINE_VISIBILITY 3691227825Stheraven __shared_ptr_emplace(_Alloc __a) 3692227825Stheraven : __data_(_VSTD::move(__a)) {} 3693227825Stheraven 3694227825Stheraven template <class ..._Args> 3695227825Stheraven _LIBCPP_INLINE_VISIBILITY 3696227825Stheraven __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) 3697232950Stheraven : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), 3698232950Stheraven _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} 3699227825Stheraven 3700227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 3701227825Stheraven 3702227825Stheraven _LIBCPP_INLINE_VISIBILITY 3703227825Stheraven __shared_ptr_emplace(_Alloc __a) 3704227825Stheraven : __data_(__a) {} 3705227825Stheraven 3706227825Stheraven template <class _A0> 3707227825Stheraven _LIBCPP_INLINE_VISIBILITY 3708227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0) 3709227825Stheraven : __data_(__a, _Tp(__a0)) {} 3710227825Stheraven 3711227825Stheraven template <class _A0, class _A1> 3712227825Stheraven _LIBCPP_INLINE_VISIBILITY 3713227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1) 3714227825Stheraven : __data_(__a, _Tp(__a0, __a1)) {} 3715227825Stheraven 3716227825Stheraven template <class _A0, class _A1, class _A2> 3717227825Stheraven _LIBCPP_INLINE_VISIBILITY 3718227825Stheraven __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2) 3719227825Stheraven : __data_(__a, _Tp(__a0, __a1, __a2)) {} 3720227825Stheraven 3721227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 3722227825Stheraven 3723227825Stheravenprivate: 3724227825Stheraven virtual void __on_zero_shared() _NOEXCEPT; 3725227825Stheraven virtual void __on_zero_shared_weak() _NOEXCEPT; 3726227825Stheravenpublic: 3727227825Stheraven _LIBCPP_INLINE_VISIBILITY 3728227825Stheraven _Tp* get() _NOEXCEPT {return &__data_.second();} 3729227825Stheraven}; 3730227825Stheraven 3731227825Stheraventemplate <class _Tp, class _Alloc> 3732227825Stheravenvoid 3733227825Stheraven__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT 3734227825Stheraven{ 3735227825Stheraven __data_.second().~_Tp(); 3736227825Stheraven} 3737227825Stheraven 3738227825Stheraventemplate <class _Tp, class _Alloc> 3739227825Stheravenvoid 3740227825Stheraven__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 3741227825Stheraven{ 3742227825Stheraven typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first()); 3743227825Stheraven __data_.first().~_Alloc(); 3744227825Stheraven __a.deallocate(this, 1); 3745227825Stheraven} 3746227825Stheraven 3747262801Sdimtemplate<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this; 3748227825Stheraven 3749227825Stheraventemplate<class _Tp> 3750262801Sdimclass _LIBCPP_TYPE_VIS_ONLY shared_ptr 3751227825Stheraven{ 3752227825Stheravenpublic: 3753227825Stheraven typedef _Tp element_type; 3754227825Stheravenprivate: 3755227825Stheraven element_type* __ptr_; 3756227825Stheraven __shared_weak_count* __cntrl_; 3757227825Stheraven 3758227825Stheraven struct __nat {int __for_bool_;}; 3759227825Stheravenpublic: 3760241903Sdim _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; 3761241903Sdim _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; 3762232950Stheraven template<class _Yp, 3763232950Stheraven class = typename enable_if 3764232950Stheraven < 3765232950Stheraven is_convertible<_Yp*, element_type*>::value 3766232950Stheraven >::type 3767232950Stheraven > 3768232950Stheraven explicit shared_ptr(_Yp* __p); 3769232950Stheraven template<class _Yp, class _Dp, 3770232950Stheraven class = typename enable_if 3771232950Stheraven < 3772232950Stheraven is_convertible<_Yp*, element_type*>::value 3773232950Stheraven >::type 3774232950Stheraven > 3775232950Stheraven shared_ptr(_Yp* __p, _Dp __d); 3776232950Stheraven template<class _Yp, class _Dp, class _Alloc, 3777232950Stheraven class = typename enable_if 3778232950Stheraven < 3779232950Stheraven is_convertible<_Yp*, element_type*>::value 3780232950Stheraven >::type 3781232950Stheraven > 3782232950Stheraven shared_ptr(_Yp* __p, _Dp __d, _Alloc __a); 3783227825Stheraven template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); 3784227825Stheraven template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); 3785227825Stheraven template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; 3786227825Stheraven shared_ptr(const shared_ptr& __r) _NOEXCEPT; 3787227825Stheraven template<class _Yp> 3788227825Stheraven shared_ptr(const shared_ptr<_Yp>& __r, 3789227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 3790227825Stheraven _NOEXCEPT; 3791227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3792227825Stheraven shared_ptr(shared_ptr&& __r) _NOEXCEPT; 3793227825Stheraven template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r, 3794227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 3795227825Stheraven _NOEXCEPT; 3796227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3797227825Stheraven template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, 3798227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); 3799227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3800232950Stheraven template<class _Yp, 3801232950Stheraven class = typename enable_if 3802232950Stheraven < 3803232950Stheraven is_convertible<_Yp*, element_type*>::value 3804232950Stheraven >::type 3805232950Stheraven > 3806232950Stheraven shared_ptr(auto_ptr<_Yp>&& __r); 3807227825Stheraven#else 3808232950Stheraven template<class _Yp, 3809232950Stheraven class = typename enable_if 3810232950Stheraven < 3811232950Stheraven is_convertible<_Yp*, element_type*>::value 3812232950Stheraven >::type 3813232950Stheraven > 3814232950Stheraven shared_ptr(auto_ptr<_Yp> __r); 3815227825Stheraven#endif 3816227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3817232950Stheraven template <class _Yp, class _Dp, 3818232950Stheraven class = typename enable_if 3819232950Stheraven < 3820232950Stheraven !is_array<_Yp>::value && 3821232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value 3822232950Stheraven >::type 3823232950Stheraven > 3824232950Stheraven shared_ptr(unique_ptr<_Yp, _Dp>&&, 3825227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3826232950Stheraven template <class _Yp, class _Dp, 3827232950Stheraven class = typename enable_if 3828232950Stheraven < 3829232950Stheraven !is_array<_Yp>::value && 3830232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value 3831232950Stheraven >::type 3832232950Stheraven > 3833232950Stheraven shared_ptr(unique_ptr<_Yp, _Dp>&&, 3834227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3835227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3836232950Stheraven template <class _Yp, class _Dp, 3837232950Stheraven class = typename enable_if 3838232950Stheraven < 3839232950Stheraven !is_array<_Yp>::value && 3840232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value 3841232950Stheraven >::type 3842232950Stheraven > shared_ptr(unique_ptr<_Yp, _Dp>, 3843227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3844232950Stheraven template <class _Yp, class _Dp, 3845232950Stheraven class = typename enable_if 3846232950Stheraven < 3847232950Stheraven !is_array<_Yp>::value && 3848232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value 3849232950Stheraven >::type 3850232950Stheraven > 3851232950Stheraven shared_ptr(unique_ptr<_Yp, _Dp>, 3852227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); 3853227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3854227825Stheraven 3855227825Stheraven ~shared_ptr(); 3856227825Stheraven 3857227825Stheraven shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; 3858232950Stheraven template<class _Yp> 3859232950Stheraven typename enable_if 3860232950Stheraven < 3861232950Stheraven is_convertible<_Yp*, element_type*>::value, 3862232950Stheraven shared_ptr& 3863232950Stheraven >::type 3864232950Stheraven operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; 3865227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3866227825Stheraven shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; 3867232950Stheraven template<class _Yp> 3868232950Stheraven typename enable_if 3869232950Stheraven < 3870232950Stheraven is_convertible<_Yp*, element_type*>::value, 3871232950Stheraven shared_ptr<_Tp>& 3872232950Stheraven >::type 3873232950Stheraven operator=(shared_ptr<_Yp>&& __r); 3874232950Stheraven template<class _Yp> 3875232950Stheraven typename enable_if 3876232950Stheraven < 3877232950Stheraven !is_array<_Yp>::value && 3878232950Stheraven is_convertible<_Yp*, element_type*>::value, 3879262801Sdim shared_ptr 3880262801Sdim >::type& 3881232950Stheraven operator=(auto_ptr<_Yp>&& __r); 3882227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3883232950Stheraven template<class _Yp> 3884232950Stheraven typename enable_if 3885232950Stheraven < 3886232950Stheraven !is_array<_Yp>::value && 3887232950Stheraven is_convertible<_Yp*, element_type*>::value, 3888232950Stheraven shared_ptr& 3889232950Stheraven >::type 3890232950Stheraven operator=(auto_ptr<_Yp> __r); 3891227825Stheraven#endif 3892232950Stheraven template <class _Yp, class _Dp> 3893232950Stheraven typename enable_if 3894232950Stheraven < 3895232950Stheraven !is_array<_Yp>::value && 3896232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3897232950Stheraven shared_ptr& 3898232950Stheraven >::type 3899227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3900232950Stheraven operator=(unique_ptr<_Yp, _Dp>&& __r); 3901227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3902232950Stheraven operator=(unique_ptr<_Yp, _Dp> __r); 3903227825Stheraven#endif 3904227825Stheraven 3905227825Stheraven void swap(shared_ptr& __r) _NOEXCEPT; 3906227825Stheraven void reset() _NOEXCEPT; 3907232950Stheraven template<class _Yp> 3908232950Stheraven typename enable_if 3909232950Stheraven < 3910232950Stheraven is_convertible<_Yp*, element_type*>::value, 3911232950Stheraven void 3912232950Stheraven >::type 3913232950Stheraven reset(_Yp* __p); 3914232950Stheraven template<class _Yp, class _Dp> 3915232950Stheraven typename enable_if 3916232950Stheraven < 3917232950Stheraven is_convertible<_Yp*, element_type*>::value, 3918232950Stheraven void 3919232950Stheraven >::type 3920232950Stheraven reset(_Yp* __p, _Dp __d); 3921232950Stheraven template<class _Yp, class _Dp, class _Alloc> 3922232950Stheraven typename enable_if 3923232950Stheraven < 3924232950Stheraven is_convertible<_Yp*, element_type*>::value, 3925232950Stheraven void 3926232950Stheraven >::type 3927232950Stheraven reset(_Yp* __p, _Dp __d, _Alloc __a); 3928227825Stheraven 3929227825Stheraven _LIBCPP_INLINE_VISIBILITY 3930227825Stheraven element_type* get() const _NOEXCEPT {return __ptr_;} 3931227825Stheraven _LIBCPP_INLINE_VISIBILITY 3932227825Stheraven typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT 3933227825Stheraven {return *__ptr_;} 3934227825Stheraven _LIBCPP_INLINE_VISIBILITY 3935227825Stheraven element_type* operator->() const _NOEXCEPT {return __ptr_;} 3936227825Stheraven _LIBCPP_INLINE_VISIBILITY 3937227825Stheraven long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} 3938227825Stheraven _LIBCPP_INLINE_VISIBILITY 3939227825Stheraven bool unique() const _NOEXCEPT {return use_count() == 1;} 3940227825Stheraven _LIBCPP_INLINE_VISIBILITY 3941232950Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;} 3942232950Stheraven template <class _Up> 3943227825Stheraven _LIBCPP_INLINE_VISIBILITY 3944232950Stheraven bool owner_before(shared_ptr<_Up> const& __p) const 3945227825Stheraven {return __cntrl_ < __p.__cntrl_;} 3946232950Stheraven template <class _Up> 3947227825Stheraven _LIBCPP_INLINE_VISIBILITY 3948232950Stheraven bool owner_before(weak_ptr<_Up> const& __p) const 3949227825Stheraven {return __cntrl_ < __p.__cntrl_;} 3950241903Sdim _LIBCPP_INLINE_VISIBILITY 3951241903Sdim bool 3952241903Sdim __owner_equivalent(const shared_ptr& __p) const 3953241903Sdim {return __cntrl_ == __p.__cntrl_;} 3954227825Stheraven 3955227825Stheraven#ifndef _LIBCPP_NO_RTTI 3956227825Stheraven template <class _Dp> 3957227825Stheraven _LIBCPP_INLINE_VISIBILITY 3958227825Stheraven _Dp* __get_deleter() const _NOEXCEPT 3959227825Stheraven {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} 3960227825Stheraven#endif // _LIBCPP_NO_RTTI 3961227825Stheraven 3962227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 3963227825Stheraven 3964227825Stheraven template<class ..._Args> 3965227825Stheraven static 3966227825Stheraven shared_ptr<_Tp> 3967227825Stheraven make_shared(_Args&& ...__args); 3968227825Stheraven 3969227825Stheraven template<class _Alloc, class ..._Args> 3970227825Stheraven static 3971227825Stheraven shared_ptr<_Tp> 3972227825Stheraven allocate_shared(const _Alloc& __a, _Args&& ...__args); 3973227825Stheraven 3974227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 3975227825Stheraven 3976227825Stheraven static shared_ptr<_Tp> make_shared(); 3977227825Stheraven 3978227825Stheraven template<class _A0> 3979227825Stheraven static shared_ptr<_Tp> make_shared(_A0&); 3980227825Stheraven 3981227825Stheraven template<class _A0, class _A1> 3982227825Stheraven static shared_ptr<_Tp> make_shared(_A0&, _A1&); 3983227825Stheraven 3984227825Stheraven template<class _A0, class _A1, class _A2> 3985227825Stheraven static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&); 3986227825Stheraven 3987227825Stheraven template<class _Alloc> 3988227825Stheraven static shared_ptr<_Tp> 3989227825Stheraven allocate_shared(const _Alloc& __a); 3990227825Stheraven 3991227825Stheraven template<class _Alloc, class _A0> 3992227825Stheraven static shared_ptr<_Tp> 3993227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0); 3994227825Stheraven 3995227825Stheraven template<class _Alloc, class _A0, class _A1> 3996227825Stheraven static shared_ptr<_Tp> 3997227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1); 3998227825Stheraven 3999227825Stheraven template<class _Alloc, class _A0, class _A1, class _A2> 4000227825Stheraven static shared_ptr<_Tp> 4001227825Stheraven allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2); 4002227825Stheraven 4003227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4004227825Stheraven 4005227825Stheravenprivate: 4006227825Stheraven 4007227825Stheraven template <class _Yp> 4008227825Stheraven _LIBCPP_INLINE_VISIBILITY 4009227825Stheraven void 4010227825Stheraven __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT 4011227825Stheraven { 4012227825Stheraven if (__e) 4013227825Stheraven __e->__weak_this_ = *this; 4014227825Stheraven } 4015227825Stheraven 4016227825Stheraven _LIBCPP_INLINE_VISIBILITY 4017227825Stheraven void __enable_weak_this(const void*) _NOEXCEPT {} 4018227825Stheraven 4019262801Sdim template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; 4020262801Sdim template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 4021227825Stheraven}; 4022227825Stheraven 4023227825Stheraventemplate<class _Tp> 4024227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4025241903Sdim_LIBCPP_CONSTEXPR 4026227825Stheravenshared_ptr<_Tp>::shared_ptr() _NOEXCEPT 4027227825Stheraven : __ptr_(0), 4028227825Stheraven __cntrl_(0) 4029227825Stheraven{ 4030227825Stheraven} 4031227825Stheraven 4032227825Stheraventemplate<class _Tp> 4033227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4034241903Sdim_LIBCPP_CONSTEXPR 4035227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT 4036227825Stheraven : __ptr_(0), 4037227825Stheraven __cntrl_(0) 4038227825Stheraven{ 4039227825Stheraven} 4040227825Stheraven 4041227825Stheraventemplate<class _Tp> 4042232950Stheraventemplate<class _Yp, class> 4043227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p) 4044227825Stheraven : __ptr_(__p) 4045227825Stheraven{ 4046227825Stheraven unique_ptr<_Yp> __hold(__p); 4047227825Stheraven typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 4048227825Stheraven __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); 4049227825Stheraven __hold.release(); 4050227825Stheraven __enable_weak_this(__p); 4051227825Stheraven} 4052227825Stheraven 4053227825Stheraventemplate<class _Tp> 4054232950Stheraventemplate<class _Yp, class _Dp, class> 4055227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d) 4056227825Stheraven : __ptr_(__p) 4057227825Stheraven{ 4058227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4059227825Stheraven try 4060227825Stheraven { 4061227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4062227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 4063227825Stheraven __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); 4064227825Stheraven __enable_weak_this(__p); 4065227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4066227825Stheraven } 4067227825Stheraven catch (...) 4068227825Stheraven { 4069227825Stheraven __d(__p); 4070227825Stheraven throw; 4071227825Stheraven } 4072227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4073227825Stheraven} 4074227825Stheraven 4075227825Stheraventemplate<class _Tp> 4076227825Stheraventemplate<class _Dp> 4077227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) 4078227825Stheraven : __ptr_(0) 4079227825Stheraven{ 4080227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4081227825Stheraven try 4082227825Stheraven { 4083227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4084227825Stheraven typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; 4085227825Stheraven __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); 4086227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4087227825Stheraven } 4088227825Stheraven catch (...) 4089227825Stheraven { 4090227825Stheraven __d(__p); 4091227825Stheraven throw; 4092227825Stheraven } 4093227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4094227825Stheraven} 4095227825Stheraven 4096227825Stheraventemplate<class _Tp> 4097232950Stheraventemplate<class _Yp, class _Dp, class _Alloc, class> 4098227825Stheravenshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) 4099227825Stheraven : __ptr_(__p) 4100227825Stheraven{ 4101227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4102227825Stheraven try 4103227825Stheraven { 4104227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4105227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; 4106227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 4107227825Stheraven typedef __allocator_destructor<_A2> _D2; 4108227825Stheraven _A2 __a2(__a); 4109227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4110227825Stheraven ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); 4111227825Stheraven __cntrl_ = __hold2.release(); 4112227825Stheraven __enable_weak_this(__p); 4113227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4114227825Stheraven } 4115227825Stheraven catch (...) 4116227825Stheraven { 4117227825Stheraven __d(__p); 4118227825Stheraven throw; 4119227825Stheraven } 4120227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4121227825Stheraven} 4122227825Stheraven 4123227825Stheraventemplate<class _Tp> 4124227825Stheraventemplate<class _Dp, class _Alloc> 4125227825Stheravenshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) 4126227825Stheraven : __ptr_(0) 4127227825Stheraven{ 4128227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4129227825Stheraven try 4130227825Stheraven { 4131227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4132227825Stheraven typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; 4133227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 4134227825Stheraven typedef __allocator_destructor<_A2> _D2; 4135227825Stheraven _A2 __a2(__a); 4136227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4137227825Stheraven ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); 4138227825Stheraven __cntrl_ = __hold2.release(); 4139227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 4140227825Stheraven } 4141227825Stheraven catch (...) 4142227825Stheraven { 4143227825Stheraven __d(__p); 4144227825Stheraven throw; 4145227825Stheraven } 4146227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 4147227825Stheraven} 4148227825Stheraven 4149227825Stheraventemplate<class _Tp> 4150227825Stheraventemplate<class _Yp> 4151227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4152227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT 4153227825Stheraven : __ptr_(__p), 4154227825Stheraven __cntrl_(__r.__cntrl_) 4155227825Stheraven{ 4156227825Stheraven if (__cntrl_) 4157227825Stheraven __cntrl_->__add_shared(); 4158227825Stheraven} 4159227825Stheraven 4160227825Stheraventemplate<class _Tp> 4161227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4162227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT 4163227825Stheraven : __ptr_(__r.__ptr_), 4164227825Stheraven __cntrl_(__r.__cntrl_) 4165227825Stheraven{ 4166227825Stheraven if (__cntrl_) 4167227825Stheraven __cntrl_->__add_shared(); 4168227825Stheraven} 4169227825Stheraven 4170227825Stheraventemplate<class _Tp> 4171227825Stheraventemplate<class _Yp> 4172227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4173227825Stheravenshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, 4174227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 4175227825Stheraven _NOEXCEPT 4176227825Stheraven : __ptr_(__r.__ptr_), 4177227825Stheraven __cntrl_(__r.__cntrl_) 4178227825Stheraven{ 4179227825Stheraven if (__cntrl_) 4180227825Stheraven __cntrl_->__add_shared(); 4181227825Stheraven} 4182227825Stheraven 4183227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4184227825Stheraven 4185227825Stheraventemplate<class _Tp> 4186227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4187227825Stheravenshared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT 4188227825Stheraven : __ptr_(__r.__ptr_), 4189227825Stheraven __cntrl_(__r.__cntrl_) 4190227825Stheraven{ 4191227825Stheraven __r.__ptr_ = 0; 4192227825Stheraven __r.__cntrl_ = 0; 4193227825Stheraven} 4194227825Stheraven 4195227825Stheraventemplate<class _Tp> 4196227825Stheraventemplate<class _Yp> 4197227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4198227825Stheravenshared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, 4199227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 4200227825Stheraven _NOEXCEPT 4201227825Stheraven : __ptr_(__r.__ptr_), 4202227825Stheraven __cntrl_(__r.__cntrl_) 4203227825Stheraven{ 4204227825Stheraven __r.__ptr_ = 0; 4205227825Stheraven __r.__cntrl_ = 0; 4206227825Stheraven} 4207227825Stheraven 4208227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4209227825Stheraven 4210227825Stheraventemplate<class _Tp> 4211232950Stheraventemplate<class _Yp, class> 4212227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4213227825Stheravenshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r) 4214227825Stheraven#else 4215227825Stheravenshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) 4216227825Stheraven#endif 4217227825Stheraven : __ptr_(__r.get()) 4218227825Stheraven{ 4219227825Stheraven typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 4220227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); 4221227825Stheraven __enable_weak_this(__r.get()); 4222227825Stheraven __r.release(); 4223227825Stheraven} 4224227825Stheraven 4225227825Stheraventemplate<class _Tp> 4226232950Stheraventemplate <class _Yp, class _Dp, class> 4227227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4228227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 4229227825Stheraven#else 4230227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 4231227825Stheraven#endif 4232227825Stheraven typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type) 4233227825Stheraven : __ptr_(__r.get()) 4234227825Stheraven{ 4235227825Stheraven typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 4236227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); 4237227825Stheraven __enable_weak_this(__r.get()); 4238227825Stheraven __r.release(); 4239227825Stheraven} 4240227825Stheraven 4241227825Stheraventemplate<class _Tp> 4242232950Stheraventemplate <class _Yp, class _Dp, class> 4243227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4244227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 4245227825Stheraven#else 4246227825Stheravenshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 4247227825Stheraven#endif 4248227825Stheraven typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type) 4249227825Stheraven : __ptr_(__r.get()) 4250227825Stheraven{ 4251227825Stheraven typedef __shared_ptr_pointer<_Yp*, 4252227825Stheraven reference_wrapper<typename remove_reference<_Dp>::type>, 4253227825Stheraven allocator<_Yp> > _CntrlBlk; 4254227825Stheraven __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); 4255227825Stheraven __enable_weak_this(__r.get()); 4256227825Stheraven __r.release(); 4257227825Stheraven} 4258227825Stheraven 4259227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 4260227825Stheraven 4261227825Stheraventemplate<class _Tp> 4262227825Stheraventemplate<class ..._Args> 4263227825Stheravenshared_ptr<_Tp> 4264227825Stheravenshared_ptr<_Tp>::make_shared(_Args&& ...__args) 4265227825Stheraven{ 4266227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4267227825Stheraven typedef allocator<_CntrlBlk> _A2; 4268227825Stheraven typedef __allocator_destructor<_A2> _D2; 4269227825Stheraven _A2 __a2; 4270227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4271227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); 4272227825Stheraven shared_ptr<_Tp> __r; 4273227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4274227825Stheraven __r.__cntrl_ = __hold2.release(); 4275227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4276227825Stheraven return __r; 4277227825Stheraven} 4278227825Stheraven 4279227825Stheraventemplate<class _Tp> 4280227825Stheraventemplate<class _Alloc, class ..._Args> 4281227825Stheravenshared_ptr<_Tp> 4282227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) 4283227825Stheraven{ 4284227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4285227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; 4286227825Stheraven typedef __allocator_destructor<_A2> _D2; 4287227825Stheraven _A2 __a2(__a); 4288227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4289227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); 4290227825Stheraven shared_ptr<_Tp> __r; 4291227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4292227825Stheraven __r.__cntrl_ = __hold2.release(); 4293227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4294227825Stheraven return __r; 4295227825Stheraven} 4296227825Stheraven 4297227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 4298227825Stheraven 4299227825Stheraventemplate<class _Tp> 4300227825Stheravenshared_ptr<_Tp> 4301227825Stheravenshared_ptr<_Tp>::make_shared() 4302227825Stheraven{ 4303227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4304227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4305227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4306227825Stheraven _Alloc2 __alloc2; 4307227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4308227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2); 4309227825Stheraven shared_ptr<_Tp> __r; 4310227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4311227825Stheraven __r.__cntrl_ = __hold2.release(); 4312227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4313227825Stheraven return __r; 4314227825Stheraven} 4315227825Stheraven 4316227825Stheraventemplate<class _Tp> 4317227825Stheraventemplate<class _A0> 4318227825Stheravenshared_ptr<_Tp> 4319227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0) 4320227825Stheraven{ 4321227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4322227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4323227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4324227825Stheraven _Alloc2 __alloc2; 4325227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4326227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); 4327227825Stheraven shared_ptr<_Tp> __r; 4328227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4329227825Stheraven __r.__cntrl_ = __hold2.release(); 4330227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4331227825Stheraven return __r; 4332227825Stheraven} 4333227825Stheraven 4334227825Stheraventemplate<class _Tp> 4335227825Stheraventemplate<class _A0, class _A1> 4336227825Stheravenshared_ptr<_Tp> 4337227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) 4338227825Stheraven{ 4339227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4340227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4341227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4342227825Stheraven _Alloc2 __alloc2; 4343227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4344227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); 4345227825Stheraven shared_ptr<_Tp> __r; 4346227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4347227825Stheraven __r.__cntrl_ = __hold2.release(); 4348227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4349227825Stheraven return __r; 4350227825Stheraven} 4351227825Stheraven 4352227825Stheraventemplate<class _Tp> 4353227825Stheraventemplate<class _A0, class _A1, class _A2> 4354227825Stheravenshared_ptr<_Tp> 4355227825Stheravenshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) 4356227825Stheraven{ 4357227825Stheraven typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 4358227825Stheraven typedef allocator<_CntrlBlk> _Alloc2; 4359227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4360227825Stheraven _Alloc2 __alloc2; 4361227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4362227825Stheraven ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); 4363227825Stheraven shared_ptr<_Tp> __r; 4364227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4365227825Stheraven __r.__cntrl_ = __hold2.release(); 4366227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4367227825Stheraven return __r; 4368227825Stheraven} 4369227825Stheraven 4370227825Stheraventemplate<class _Tp> 4371227825Stheraventemplate<class _Alloc> 4372227825Stheravenshared_ptr<_Tp> 4373227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a) 4374227825Stheraven{ 4375227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4376227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 4377227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4378227825Stheraven _Alloc2 __alloc2(__a); 4379227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4380227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a); 4381227825Stheraven shared_ptr<_Tp> __r; 4382227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4383227825Stheraven __r.__cntrl_ = __hold2.release(); 4384227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4385227825Stheraven return __r; 4386227825Stheraven} 4387227825Stheraven 4388227825Stheraventemplate<class _Tp> 4389227825Stheraventemplate<class _Alloc, class _A0> 4390227825Stheravenshared_ptr<_Tp> 4391227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) 4392227825Stheraven{ 4393227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4394227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 4395227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4396227825Stheraven _Alloc2 __alloc2(__a); 4397227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4398227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0); 4399227825Stheraven shared_ptr<_Tp> __r; 4400227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4401227825Stheraven __r.__cntrl_ = __hold2.release(); 4402227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4403227825Stheraven return __r; 4404227825Stheraven} 4405227825Stheraven 4406227825Stheraventemplate<class _Tp> 4407227825Stheraventemplate<class _Alloc, class _A0, class _A1> 4408227825Stheravenshared_ptr<_Tp> 4409227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 4410227825Stheraven{ 4411227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4412227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 4413227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4414227825Stheraven _Alloc2 __alloc2(__a); 4415227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4416227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1); 4417227825Stheraven shared_ptr<_Tp> __r; 4418227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4419227825Stheraven __r.__cntrl_ = __hold2.release(); 4420227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4421227825Stheraven return __r; 4422227825Stheraven} 4423227825Stheraven 4424227825Stheraventemplate<class _Tp> 4425227825Stheraventemplate<class _Alloc, class _A0, class _A1, class _A2> 4426227825Stheravenshared_ptr<_Tp> 4427227825Stheravenshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 4428227825Stheraven{ 4429227825Stheraven typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4430227825Stheraven typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; 4431227825Stheraven typedef __allocator_destructor<_Alloc2> _D2; 4432227825Stheraven _Alloc2 __alloc2(__a); 4433227825Stheraven unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4434227825Stheraven ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2); 4435227825Stheraven shared_ptr<_Tp> __r; 4436227825Stheraven __r.__ptr_ = __hold2.get()->get(); 4437227825Stheraven __r.__cntrl_ = __hold2.release(); 4438227825Stheraven __r.__enable_weak_this(__r.__ptr_); 4439227825Stheraven return __r; 4440227825Stheraven} 4441227825Stheraven 4442227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4443227825Stheraven 4444227825Stheraventemplate<class _Tp> 4445227825Stheravenshared_ptr<_Tp>::~shared_ptr() 4446227825Stheraven{ 4447227825Stheraven if (__cntrl_) 4448227825Stheraven __cntrl_->__release_shared(); 4449227825Stheraven} 4450227825Stheraven 4451227825Stheraventemplate<class _Tp> 4452227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4453227825Stheravenshared_ptr<_Tp>& 4454227825Stheravenshared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT 4455227825Stheraven{ 4456227825Stheraven shared_ptr(__r).swap(*this); 4457227825Stheraven return *this; 4458227825Stheraven} 4459227825Stheraven 4460227825Stheraventemplate<class _Tp> 4461227825Stheraventemplate<class _Yp> 4462227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4463232950Stheraventypename enable_if 4464232950Stheraven< 4465232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4466232950Stheraven shared_ptr<_Tp>& 4467232950Stheraven>::type 4468227825Stheravenshared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT 4469227825Stheraven{ 4470227825Stheraven shared_ptr(__r).swap(*this); 4471227825Stheraven return *this; 4472227825Stheraven} 4473227825Stheraven 4474227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4475227825Stheraven 4476227825Stheraventemplate<class _Tp> 4477227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4478227825Stheravenshared_ptr<_Tp>& 4479227825Stheravenshared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT 4480227825Stheraven{ 4481227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4482227825Stheraven return *this; 4483227825Stheraven} 4484227825Stheraven 4485227825Stheraventemplate<class _Tp> 4486227825Stheraventemplate<class _Yp> 4487227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4488232950Stheraventypename enable_if 4489232950Stheraven< 4490232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4491232950Stheraven shared_ptr<_Tp>& 4492232950Stheraven>::type 4493227825Stheravenshared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) 4494227825Stheraven{ 4495227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4496227825Stheraven return *this; 4497227825Stheraven} 4498227825Stheraven 4499227825Stheraventemplate<class _Tp> 4500227825Stheraventemplate<class _Yp> 4501227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4502232950Stheraventypename enable_if 4503232950Stheraven< 4504232950Stheraven !is_array<_Yp>::value && 4505232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4506262801Sdim shared_ptr<_Tp> 4507262801Sdim>::type& 4508227825Stheravenshared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) 4509227825Stheraven{ 4510227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4511227825Stheraven return *this; 4512227825Stheraven} 4513227825Stheraven 4514227825Stheraventemplate<class _Tp> 4515227825Stheraventemplate <class _Yp, class _Dp> 4516227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4517232950Stheraventypename enable_if 4518232950Stheraven< 4519232950Stheraven !is_array<_Yp>::value && 4520232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, 4521232950Stheraven shared_ptr<_Tp>& 4522232950Stheraven>::type 4523227825Stheravenshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) 4524227825Stheraven{ 4525227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4526227825Stheraven return *this; 4527227825Stheraven} 4528227825Stheraven 4529227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4530227825Stheraven 4531227825Stheraventemplate<class _Tp> 4532227825Stheraventemplate<class _Yp> 4533227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4534232950Stheraventypename enable_if 4535232950Stheraven< 4536232950Stheraven !is_array<_Yp>::value && 4537232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4538232950Stheraven shared_ptr<_Tp>& 4539232950Stheraven>::type 4540227825Stheravenshared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) 4541227825Stheraven{ 4542227825Stheraven shared_ptr(__r).swap(*this); 4543227825Stheraven return *this; 4544227825Stheraven} 4545227825Stheraven 4546227825Stheraventemplate<class _Tp> 4547227825Stheraventemplate <class _Yp, class _Dp> 4548227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4549232950Stheraventypename enable_if 4550232950Stheraven< 4551232950Stheraven !is_array<_Yp>::value && 4552232950Stheraven is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, 4553232950Stheraven shared_ptr<_Tp>& 4554232950Stheraven>::type 4555227825Stheravenshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) 4556227825Stheraven{ 4557227825Stheraven shared_ptr(_VSTD::move(__r)).swap(*this); 4558227825Stheraven return *this; 4559227825Stheraven} 4560227825Stheraven 4561227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4562227825Stheraven 4563227825Stheraventemplate<class _Tp> 4564227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4565227825Stheravenvoid 4566227825Stheravenshared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT 4567227825Stheraven{ 4568227825Stheraven _VSTD::swap(__ptr_, __r.__ptr_); 4569227825Stheraven _VSTD::swap(__cntrl_, __r.__cntrl_); 4570227825Stheraven} 4571227825Stheraven 4572227825Stheraventemplate<class _Tp> 4573227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4574227825Stheravenvoid 4575227825Stheravenshared_ptr<_Tp>::reset() _NOEXCEPT 4576227825Stheraven{ 4577227825Stheraven shared_ptr().swap(*this); 4578227825Stheraven} 4579227825Stheraven 4580227825Stheraventemplate<class _Tp> 4581227825Stheraventemplate<class _Yp> 4582227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4583232950Stheraventypename enable_if 4584232950Stheraven< 4585232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4586232950Stheraven void 4587232950Stheraven>::type 4588227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p) 4589227825Stheraven{ 4590227825Stheraven shared_ptr(__p).swap(*this); 4591227825Stheraven} 4592227825Stheraven 4593227825Stheraventemplate<class _Tp> 4594227825Stheraventemplate<class _Yp, class _Dp> 4595227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4596232950Stheraventypename enable_if 4597232950Stheraven< 4598232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4599232950Stheraven void 4600232950Stheraven>::type 4601227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) 4602227825Stheraven{ 4603227825Stheraven shared_ptr(__p, __d).swap(*this); 4604227825Stheraven} 4605227825Stheraven 4606227825Stheraventemplate<class _Tp> 4607227825Stheraventemplate<class _Yp, class _Dp, class _Alloc> 4608227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4609232950Stheraventypename enable_if 4610232950Stheraven< 4611232950Stheraven is_convertible<_Yp*, _Tp*>::value, 4612232950Stheraven void 4613232950Stheraven>::type 4614227825Stheravenshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) 4615227825Stheraven{ 4616227825Stheraven shared_ptr(__p, __d, __a).swap(*this); 4617227825Stheraven} 4618227825Stheraven 4619227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS 4620227825Stheraven 4621227825Stheraventemplate<class _Tp, class ..._Args> 4622227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4623232950Stheraventypename enable_if 4624232950Stheraven< 4625232950Stheraven !is_array<_Tp>::value, 4626232950Stheraven shared_ptr<_Tp> 4627232950Stheraven>::type 4628227825Stheravenmake_shared(_Args&& ...__args) 4629227825Stheraven{ 4630227825Stheraven return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...); 4631227825Stheraven} 4632227825Stheraven 4633227825Stheraventemplate<class _Tp, class _Alloc, class ..._Args> 4634227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4635232950Stheraventypename enable_if 4636232950Stheraven< 4637232950Stheraven !is_array<_Tp>::value, 4638232950Stheraven shared_ptr<_Tp> 4639232950Stheraven>::type 4640227825Stheravenallocate_shared(const _Alloc& __a, _Args&& ...__args) 4641227825Stheraven{ 4642227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...); 4643227825Stheraven} 4644227825Stheraven 4645227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 4646227825Stheraven 4647227825Stheraventemplate<class _Tp> 4648227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4649227825Stheravenshared_ptr<_Tp> 4650227825Stheravenmake_shared() 4651227825Stheraven{ 4652227825Stheraven return shared_ptr<_Tp>::make_shared(); 4653227825Stheraven} 4654227825Stheraven 4655227825Stheraventemplate<class _Tp, class _A0> 4656227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4657227825Stheravenshared_ptr<_Tp> 4658227825Stheravenmake_shared(_A0& __a0) 4659227825Stheraven{ 4660227825Stheraven return shared_ptr<_Tp>::make_shared(__a0); 4661227825Stheraven} 4662227825Stheraven 4663227825Stheraventemplate<class _Tp, class _A0, class _A1> 4664227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4665227825Stheravenshared_ptr<_Tp> 4666227825Stheravenmake_shared(_A0& __a0, _A1& __a1) 4667227825Stheraven{ 4668227825Stheraven return shared_ptr<_Tp>::make_shared(__a0, __a1); 4669227825Stheraven} 4670227825Stheraven 4671227825Stheraventemplate<class _Tp, class _A0, class _A1, class _A2> 4672227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4673227825Stheravenshared_ptr<_Tp> 4674227825Stheravenmake_shared(_A0& __a0, _A1& __a1, _A2& __a2) 4675227825Stheraven{ 4676227825Stheraven return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2); 4677227825Stheraven} 4678227825Stheraven 4679227825Stheraventemplate<class _Tp, class _Alloc> 4680227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4681227825Stheravenshared_ptr<_Tp> 4682227825Stheravenallocate_shared(const _Alloc& __a) 4683227825Stheraven{ 4684227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a); 4685227825Stheraven} 4686227825Stheraven 4687227825Stheraventemplate<class _Tp, class _Alloc, class _A0> 4688227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4689227825Stheravenshared_ptr<_Tp> 4690227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0) 4691227825Stheraven{ 4692227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0); 4693227825Stheraven} 4694227825Stheraven 4695227825Stheraventemplate<class _Tp, class _Alloc, class _A0, class _A1> 4696227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4697227825Stheravenshared_ptr<_Tp> 4698227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 4699227825Stheraven{ 4700227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1); 4701227825Stheraven} 4702227825Stheraven 4703227825Stheraventemplate<class _Tp, class _Alloc, class _A0, class _A1, class _A2> 4704227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4705227825Stheravenshared_ptr<_Tp> 4706227825Stheravenallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 4707227825Stheraven{ 4708227825Stheraven return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2); 4709227825Stheraven} 4710227825Stheraven 4711227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 4712227825Stheraven 4713227825Stheraventemplate<class _Tp, class _Up> 4714227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4715227825Stheravenbool 4716227825Stheravenoperator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4717227825Stheraven{ 4718227825Stheraven return __x.get() == __y.get(); 4719227825Stheraven} 4720227825Stheraven 4721227825Stheraventemplate<class _Tp, class _Up> 4722227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4723227825Stheravenbool 4724227825Stheravenoperator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4725227825Stheraven{ 4726227825Stheraven return !(__x == __y); 4727227825Stheraven} 4728227825Stheraven 4729227825Stheraventemplate<class _Tp, class _Up> 4730227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4731227825Stheravenbool 4732227825Stheravenoperator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4733227825Stheraven{ 4734232950Stheraven typedef typename common_type<_Tp*, _Up*>::type _V; 4735232950Stheraven return less<_V>()(__x.get(), __y.get()); 4736227825Stheraven} 4737227825Stheraven 4738232950Stheraventemplate<class _Tp, class _Up> 4739232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4740232950Stheravenbool 4741232950Stheravenoperator>(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4742232950Stheraven{ 4743232950Stheraven return __y < __x; 4744232950Stheraven} 4745232950Stheraven 4746232950Stheraventemplate<class _Tp, class _Up> 4747232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4748232950Stheravenbool 4749232950Stheravenoperator<=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4750232950Stheraven{ 4751232950Stheraven return !(__y < __x); 4752232950Stheraven} 4753232950Stheraven 4754232950Stheraventemplate<class _Tp, class _Up> 4755232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4756232950Stheravenbool 4757232950Stheravenoperator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 4758232950Stheraven{ 4759232950Stheraven return !(__x < __y); 4760232950Stheraven} 4761232950Stheraven 4762227825Stheraventemplate<class _Tp> 4763227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4764232950Stheravenbool 4765232950Stheravenoperator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4766232950Stheraven{ 4767232950Stheraven return !__x; 4768232950Stheraven} 4769232950Stheraven 4770232950Stheraventemplate<class _Tp> 4771232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4772232950Stheravenbool 4773232950Stheravenoperator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4774232950Stheraven{ 4775232950Stheraven return !__x; 4776232950Stheraven} 4777232950Stheraven 4778232950Stheraventemplate<class _Tp> 4779232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4780232950Stheravenbool 4781232950Stheravenoperator!=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4782232950Stheraven{ 4783232950Stheraven return static_cast<bool>(__x); 4784232950Stheraven} 4785232950Stheraven 4786232950Stheraventemplate<class _Tp> 4787232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4788232950Stheravenbool 4789232950Stheravenoperator!=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4790232950Stheraven{ 4791232950Stheraven return static_cast<bool>(__x); 4792232950Stheraven} 4793232950Stheraven 4794232950Stheraventemplate<class _Tp> 4795232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4796232950Stheravenbool 4797232950Stheravenoperator<(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4798232950Stheraven{ 4799232950Stheraven return less<_Tp*>()(__x.get(), nullptr); 4800232950Stheraven} 4801232950Stheraven 4802232950Stheraventemplate<class _Tp> 4803232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4804232950Stheravenbool 4805232950Stheravenoperator<(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4806232950Stheraven{ 4807232950Stheraven return less<_Tp*>()(nullptr, __x.get()); 4808232950Stheraven} 4809232950Stheraven 4810232950Stheraventemplate<class _Tp> 4811232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4812232950Stheravenbool 4813232950Stheravenoperator>(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4814232950Stheraven{ 4815232950Stheraven return nullptr < __x; 4816232950Stheraven} 4817232950Stheraven 4818232950Stheraventemplate<class _Tp> 4819232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4820232950Stheravenbool 4821232950Stheravenoperator>(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4822232950Stheraven{ 4823232950Stheraven return __x < nullptr; 4824232950Stheraven} 4825232950Stheraven 4826232950Stheraventemplate<class _Tp> 4827232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4828232950Stheravenbool 4829232950Stheravenoperator<=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4830232950Stheraven{ 4831232950Stheraven return !(nullptr < __x); 4832232950Stheraven} 4833232950Stheraven 4834232950Stheraventemplate<class _Tp> 4835232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4836232950Stheravenbool 4837232950Stheravenoperator<=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4838232950Stheraven{ 4839232950Stheraven return !(__x < nullptr); 4840232950Stheraven} 4841232950Stheraven 4842232950Stheraventemplate<class _Tp> 4843232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4844232950Stheravenbool 4845232950Stheravenoperator>=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 4846232950Stheraven{ 4847232950Stheraven return !(__x < nullptr); 4848232950Stheraven} 4849232950Stheraven 4850232950Stheraventemplate<class _Tp> 4851232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4852232950Stheravenbool 4853232950Stheravenoperator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 4854232950Stheraven{ 4855232950Stheraven return !(nullptr < __x); 4856232950Stheraven} 4857232950Stheraven 4858232950Stheraventemplate<class _Tp> 4859232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 4860227825Stheravenvoid 4861227825Stheravenswap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT 4862227825Stheraven{ 4863227825Stheraven __x.swap(__y); 4864227825Stheraven} 4865227825Stheraven 4866227825Stheraventemplate<class _Tp, class _Up> 4867227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4868232950Stheraventypename enable_if 4869232950Stheraven< 4870232950Stheraven !is_array<_Tp>::value && !is_array<_Up>::value, 4871232950Stheraven shared_ptr<_Tp> 4872232950Stheraven>::type 4873227825Stheravenstatic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 4874227825Stheraven{ 4875227825Stheraven return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); 4876227825Stheraven} 4877227825Stheraven 4878227825Stheraventemplate<class _Tp, class _Up> 4879227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4880232950Stheraventypename enable_if 4881232950Stheraven< 4882232950Stheraven !is_array<_Tp>::value && !is_array<_Up>::value, 4883232950Stheraven shared_ptr<_Tp> 4884232950Stheraven>::type 4885227825Stheravendynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 4886227825Stheraven{ 4887227825Stheraven _Tp* __p = dynamic_cast<_Tp*>(__r.get()); 4888227825Stheraven return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); 4889227825Stheraven} 4890227825Stheraven 4891227825Stheraventemplate<class _Tp, class _Up> 4892232950Stheraventypename enable_if 4893232950Stheraven< 4894232950Stheraven is_array<_Tp>::value == is_array<_Up>::value, 4895232950Stheraven shared_ptr<_Tp> 4896232950Stheraven>::type 4897227825Stheravenconst_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 4898227825Stheraven{ 4899232950Stheraven typedef typename remove_extent<_Tp>::type _RTp; 4900232950Stheraven return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); 4901227825Stheraven} 4902227825Stheraven 4903227825Stheraven#ifndef _LIBCPP_NO_RTTI 4904227825Stheraven 4905227825Stheraventemplate<class _Dp, class _Tp> 4906227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4907227825Stheraven_Dp* 4908227825Stheravenget_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT 4909227825Stheraven{ 4910227825Stheraven return __p.template __get_deleter<_Dp>(); 4911227825Stheraven} 4912227825Stheraven 4913227825Stheraven#endif // _LIBCPP_NO_RTTI 4914227825Stheraven 4915227825Stheraventemplate<class _Tp> 4916262801Sdimclass _LIBCPP_TYPE_VIS_ONLY weak_ptr 4917227825Stheraven{ 4918227825Stheravenpublic: 4919227825Stheraven typedef _Tp element_type; 4920227825Stheravenprivate: 4921227825Stheraven element_type* __ptr_; 4922227825Stheraven __shared_weak_count* __cntrl_; 4923227825Stheraven 4924227825Stheravenpublic: 4925241903Sdim _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; 4926227825Stheraven template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r, 4927227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 4928227825Stheraven _NOEXCEPT; 4929227825Stheraven weak_ptr(weak_ptr const& __r) _NOEXCEPT; 4930227825Stheraven template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r, 4931227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 4932227825Stheraven _NOEXCEPT; 4933227825Stheraven 4934232950Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4935232950Stheraven weak_ptr(weak_ptr&& __r) _NOEXCEPT; 4936232950Stheraven template<class _Yp> weak_ptr(weak_ptr<_Yp>&& __r, 4937232950Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 4938232950Stheraven _NOEXCEPT; 4939232950Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4940227825Stheraven ~weak_ptr(); 4941227825Stheraven 4942227825Stheraven weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; 4943232950Stheraven template<class _Yp> 4944232950Stheraven typename enable_if 4945232950Stheraven < 4946232950Stheraven is_convertible<_Yp*, element_type*>::value, 4947232950Stheraven weak_ptr& 4948232950Stheraven >::type 4949232950Stheraven operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; 4950227825Stheraven 4951232950Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4952232950Stheraven 4953232950Stheraven weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT; 4954232950Stheraven template<class _Yp> 4955232950Stheraven typename enable_if 4956232950Stheraven < 4957232950Stheraven is_convertible<_Yp*, element_type*>::value, 4958232950Stheraven weak_ptr& 4959232950Stheraven >::type 4960232950Stheraven operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT; 4961232950Stheraven 4962232950Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 4963232950Stheraven 4964232950Stheraven template<class _Yp> 4965232950Stheraven typename enable_if 4966232950Stheraven < 4967232950Stheraven is_convertible<_Yp*, element_type*>::value, 4968232950Stheraven weak_ptr& 4969232950Stheraven >::type 4970232950Stheraven operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; 4971232950Stheraven 4972227825Stheraven void swap(weak_ptr& __r) _NOEXCEPT; 4973227825Stheraven void reset() _NOEXCEPT; 4974227825Stheraven 4975227825Stheraven _LIBCPP_INLINE_VISIBILITY 4976227825Stheraven long use_count() const _NOEXCEPT 4977227825Stheraven {return __cntrl_ ? __cntrl_->use_count() : 0;} 4978227825Stheraven _LIBCPP_INLINE_VISIBILITY 4979227825Stheraven bool expired() const _NOEXCEPT 4980227825Stheraven {return __cntrl_ == 0 || __cntrl_->use_count() == 0;} 4981227825Stheraven shared_ptr<_Tp> lock() const _NOEXCEPT; 4982227825Stheraven template<class _Up> 4983227825Stheraven _LIBCPP_INLINE_VISIBILITY 4984227825Stheraven bool owner_before(const shared_ptr<_Up>& __r) const 4985227825Stheraven {return __cntrl_ < __r.__cntrl_;} 4986227825Stheraven template<class _Up> 4987227825Stheraven _LIBCPP_INLINE_VISIBILITY 4988227825Stheraven bool owner_before(const weak_ptr<_Up>& __r) const 4989227825Stheraven {return __cntrl_ < __r.__cntrl_;} 4990227825Stheraven 4991262801Sdim template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 4992262801Sdim template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; 4993227825Stheraven}; 4994227825Stheraven 4995227825Stheraventemplate<class _Tp> 4996227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 4997241903Sdim_LIBCPP_CONSTEXPR 4998227825Stheravenweak_ptr<_Tp>::weak_ptr() _NOEXCEPT 4999227825Stheraven : __ptr_(0), 5000227825Stheraven __cntrl_(0) 5001227825Stheraven{ 5002227825Stheraven} 5003227825Stheraven 5004227825Stheraventemplate<class _Tp> 5005227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5006227825Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT 5007227825Stheraven : __ptr_(__r.__ptr_), 5008227825Stheraven __cntrl_(__r.__cntrl_) 5009227825Stheraven{ 5010227825Stheraven if (__cntrl_) 5011227825Stheraven __cntrl_->__add_weak(); 5012227825Stheraven} 5013227825Stheraven 5014227825Stheraventemplate<class _Tp> 5015227825Stheraventemplate<class _Yp> 5016227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5017227825Stheravenweak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, 5018227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5019227825Stheraven _NOEXCEPT 5020227825Stheraven : __ptr_(__r.__ptr_), 5021227825Stheraven __cntrl_(__r.__cntrl_) 5022227825Stheraven{ 5023227825Stheraven if (__cntrl_) 5024227825Stheraven __cntrl_->__add_weak(); 5025227825Stheraven} 5026227825Stheraven 5027227825Stheraventemplate<class _Tp> 5028227825Stheraventemplate<class _Yp> 5029227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5030227825Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, 5031227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5032227825Stheraven _NOEXCEPT 5033227825Stheraven : __ptr_(__r.__ptr_), 5034227825Stheraven __cntrl_(__r.__cntrl_) 5035227825Stheraven{ 5036227825Stheraven if (__cntrl_) 5037227825Stheraven __cntrl_->__add_weak(); 5038227825Stheraven} 5039227825Stheraven 5040232950Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5041232950Stheraven 5042227825Stheraventemplate<class _Tp> 5043232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 5044232950Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT 5045232950Stheraven : __ptr_(__r.__ptr_), 5046232950Stheraven __cntrl_(__r.__cntrl_) 5047232950Stheraven{ 5048232950Stheraven __r.__ptr_ = 0; 5049232950Stheraven __r.__cntrl_ = 0; 5050232950Stheraven} 5051232950Stheraven 5052232950Stheraventemplate<class _Tp> 5053232950Stheraventemplate<class _Yp> 5054232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 5055232950Stheravenweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, 5056232950Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 5057232950Stheraven _NOEXCEPT 5058232950Stheraven : __ptr_(__r.__ptr_), 5059232950Stheraven __cntrl_(__r.__cntrl_) 5060232950Stheraven{ 5061232950Stheraven __r.__ptr_ = 0; 5062232950Stheraven __r.__cntrl_ = 0; 5063232950Stheraven} 5064232950Stheraven 5065232950Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5066232950Stheraven 5067232950Stheraventemplate<class _Tp> 5068227825Stheravenweak_ptr<_Tp>::~weak_ptr() 5069227825Stheraven{ 5070227825Stheraven if (__cntrl_) 5071227825Stheraven __cntrl_->__release_weak(); 5072227825Stheraven} 5073227825Stheraven 5074227825Stheraventemplate<class _Tp> 5075227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5076227825Stheravenweak_ptr<_Tp>& 5077227825Stheravenweak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT 5078227825Stheraven{ 5079227825Stheraven weak_ptr(__r).swap(*this); 5080227825Stheraven return *this; 5081227825Stheraven} 5082227825Stheraven 5083227825Stheraventemplate<class _Tp> 5084227825Stheraventemplate<class _Yp> 5085227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5086232950Stheraventypename enable_if 5087232950Stheraven< 5088232950Stheraven is_convertible<_Yp*, _Tp*>::value, 5089232950Stheraven weak_ptr<_Tp>& 5090232950Stheraven>::type 5091227825Stheravenweak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT 5092227825Stheraven{ 5093227825Stheraven weak_ptr(__r).swap(*this); 5094227825Stheraven return *this; 5095227825Stheraven} 5096227825Stheraven 5097232950Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5098232950Stheraven 5099227825Stheraventemplate<class _Tp> 5100232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 5101232950Stheravenweak_ptr<_Tp>& 5102232950Stheravenweak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT 5103232950Stheraven{ 5104232950Stheraven weak_ptr(_VSTD::move(__r)).swap(*this); 5105232950Stheraven return *this; 5106232950Stheraven} 5107232950Stheraven 5108232950Stheraventemplate<class _Tp> 5109227825Stheraventemplate<class _Yp> 5110227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5111232950Stheraventypename enable_if 5112232950Stheraven< 5113232950Stheraven is_convertible<_Yp*, _Tp*>::value, 5114232950Stheraven weak_ptr<_Tp>& 5115232950Stheraven>::type 5116232950Stheravenweak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT 5117232950Stheraven{ 5118232950Stheraven weak_ptr(_VSTD::move(__r)).swap(*this); 5119232950Stheraven return *this; 5120232950Stheraven} 5121232950Stheraven 5122232950Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5123232950Stheraven 5124232950Stheraventemplate<class _Tp> 5125232950Stheraventemplate<class _Yp> 5126232950Stheraveninline _LIBCPP_INLINE_VISIBILITY 5127232950Stheraventypename enable_if 5128232950Stheraven< 5129232950Stheraven is_convertible<_Yp*, _Tp*>::value, 5130232950Stheraven weak_ptr<_Tp>& 5131232950Stheraven>::type 5132227825Stheravenweak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT 5133227825Stheraven{ 5134227825Stheraven weak_ptr(__r).swap(*this); 5135227825Stheraven return *this; 5136227825Stheraven} 5137227825Stheraven 5138227825Stheraventemplate<class _Tp> 5139227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5140227825Stheravenvoid 5141227825Stheravenweak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT 5142227825Stheraven{ 5143227825Stheraven _VSTD::swap(__ptr_, __r.__ptr_); 5144227825Stheraven _VSTD::swap(__cntrl_, __r.__cntrl_); 5145227825Stheraven} 5146227825Stheraven 5147227825Stheraventemplate<class _Tp> 5148227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5149227825Stheravenvoid 5150227825Stheravenswap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT 5151227825Stheraven{ 5152227825Stheraven __x.swap(__y); 5153227825Stheraven} 5154227825Stheraven 5155227825Stheraventemplate<class _Tp> 5156227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5157227825Stheravenvoid 5158227825Stheravenweak_ptr<_Tp>::reset() _NOEXCEPT 5159227825Stheraven{ 5160227825Stheraven weak_ptr().swap(*this); 5161227825Stheraven} 5162227825Stheraven 5163227825Stheraventemplate<class _Tp> 5164227825Stheraventemplate<class _Yp> 5165227825Stheravenshared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, 5166227825Stheraven typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 5167227825Stheraven : __ptr_(__r.__ptr_), 5168227825Stheraven __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) 5169227825Stheraven{ 5170227825Stheraven if (__cntrl_ == 0) 5171227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 5172227825Stheraven throw bad_weak_ptr(); 5173227825Stheraven#else 5174227825Stheraven assert(!"bad_weak_ptr"); 5175227825Stheraven#endif 5176227825Stheraven} 5177227825Stheraven 5178227825Stheraventemplate<class _Tp> 5179227825Stheravenshared_ptr<_Tp> 5180227825Stheravenweak_ptr<_Tp>::lock() const _NOEXCEPT 5181227825Stheraven{ 5182227825Stheraven shared_ptr<_Tp> __r; 5183227825Stheraven __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_; 5184227825Stheraven if (__r.__cntrl_) 5185227825Stheraven __r.__ptr_ = __ptr_; 5186227825Stheraven return __r; 5187227825Stheraven} 5188227825Stheraven 5189227825Stheraventemplate <class _Tp> struct owner_less; 5190227825Stheraven 5191227825Stheraventemplate <class _Tp> 5192262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> > 5193227825Stheraven : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> 5194227825Stheraven{ 5195227825Stheraven typedef bool result_type; 5196227825Stheraven _LIBCPP_INLINE_VISIBILITY 5197227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5198227825Stheraven {return __x.owner_before(__y);} 5199227825Stheraven _LIBCPP_INLINE_VISIBILITY 5200227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5201227825Stheraven {return __x.owner_before(__y);} 5202227825Stheraven _LIBCPP_INLINE_VISIBILITY 5203227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5204227825Stheraven {return __x.owner_before(__y);} 5205227825Stheraven}; 5206227825Stheraven 5207227825Stheraventemplate <class _Tp> 5208262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> > 5209227825Stheraven : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> 5210227825Stheraven{ 5211227825Stheraven typedef bool result_type; 5212227825Stheraven _LIBCPP_INLINE_VISIBILITY 5213227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5214227825Stheraven {return __x.owner_before(__y);} 5215227825Stheraven _LIBCPP_INLINE_VISIBILITY 5216227825Stheraven bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 5217227825Stheraven {return __x.owner_before(__y);} 5218227825Stheraven _LIBCPP_INLINE_VISIBILITY 5219227825Stheraven bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 5220227825Stheraven {return __x.owner_before(__y);} 5221227825Stheraven}; 5222227825Stheraven 5223227825Stheraventemplate<class _Tp> 5224262801Sdimclass _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this 5225227825Stheraven{ 5226227825Stheraven mutable weak_ptr<_Tp> __weak_this_; 5227227825Stheravenprotected: 5228241903Sdim _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 5229227825Stheraven enable_shared_from_this() _NOEXCEPT {} 5230227825Stheraven _LIBCPP_INLINE_VISIBILITY 5231227825Stheraven enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {} 5232227825Stheraven _LIBCPP_INLINE_VISIBILITY 5233227825Stheraven enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT 5234227825Stheraven {return *this;} 5235227825Stheraven _LIBCPP_INLINE_VISIBILITY 5236227825Stheraven ~enable_shared_from_this() {} 5237227825Stheravenpublic: 5238227825Stheraven _LIBCPP_INLINE_VISIBILITY 5239227825Stheraven shared_ptr<_Tp> shared_from_this() 5240227825Stheraven {return shared_ptr<_Tp>(__weak_this_);} 5241227825Stheraven _LIBCPP_INLINE_VISIBILITY 5242227825Stheraven shared_ptr<_Tp const> shared_from_this() const 5243227825Stheraven {return shared_ptr<const _Tp>(__weak_this_);} 5244227825Stheraven 5245227825Stheraven template <class _Up> friend class shared_ptr; 5246227825Stheraven}; 5247227825Stheraven 5248227825Stheraventemplate <class _Tp> 5249262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<shared_ptr<_Tp> > 5250227825Stheraven{ 5251227825Stheraven typedef shared_ptr<_Tp> argument_type; 5252227825Stheraven typedef size_t result_type; 5253227825Stheraven _LIBCPP_INLINE_VISIBILITY 5254227825Stheraven result_type operator()(const argument_type& __ptr) const _NOEXCEPT 5255227825Stheraven { 5256227825Stheraven return hash<_Tp*>()(__ptr.get()); 5257227825Stheraven } 5258227825Stheraven}; 5259227825Stheraven 5260232950Stheraventemplate<class _CharT, class _Traits, class _Yp> 5261227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5262227825Stheravenbasic_ostream<_CharT, _Traits>& 5263232950Stheravenoperator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); 5264227825Stheraven 5265241903Sdim#if __has_feature(cxx_atomic) 5266241903Sdim 5267262801Sdimclass _LIBCPP_TYPE_VIS __sp_mut 5268241903Sdim{ 5269242945Stheraven void* __lx; 5270241903Sdimpublic: 5271241903Sdim void lock() _NOEXCEPT; 5272241903Sdim void unlock() _NOEXCEPT; 5273241903Sdim 5274241903Sdimprivate: 5275241903Sdim _LIBCPP_CONSTEXPR __sp_mut(void*) _NOEXCEPT; 5276241903Sdim __sp_mut(const __sp_mut&); 5277241903Sdim __sp_mut& operator=(const __sp_mut&); 5278241903Sdim 5279249998Sdim friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); 5280241903Sdim}; 5281241903Sdim 5282249998Sdim_LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); 5283241903Sdim 5284241903Sdimtemplate <class _Tp> 5285241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5286241903Sdimbool 5287241903Sdimatomic_is_lock_free(const shared_ptr<_Tp>*) 5288241903Sdim{ 5289241903Sdim return false; 5290241903Sdim} 5291241903Sdim 5292241903Sdimtemplate <class _Tp> 5293241903Sdimshared_ptr<_Tp> 5294241903Sdimatomic_load(const shared_ptr<_Tp>* __p) 5295241903Sdim{ 5296241903Sdim __sp_mut& __m = __get_sp_mut(__p); 5297241903Sdim __m.lock(); 5298241903Sdim shared_ptr<_Tp> __q = *__p; 5299241903Sdim __m.unlock(); 5300241903Sdim return __q; 5301241903Sdim} 5302241903Sdim 5303241903Sdimtemplate <class _Tp> 5304241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5305241903Sdimshared_ptr<_Tp> 5306241903Sdimatomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) 5307241903Sdim{ 5308241903Sdim return atomic_load(__p); 5309241903Sdim} 5310241903Sdim 5311241903Sdimtemplate <class _Tp> 5312241903Sdimvoid 5313241903Sdimatomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) 5314241903Sdim{ 5315241903Sdim __sp_mut& __m = __get_sp_mut(__p); 5316241903Sdim __m.lock(); 5317241903Sdim __p->swap(__r); 5318241903Sdim __m.unlock(); 5319241903Sdim} 5320241903Sdim 5321241903Sdimtemplate <class _Tp> 5322241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5323241903Sdimvoid 5324241903Sdimatomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) 5325241903Sdim{ 5326241903Sdim atomic_store(__p, __r); 5327241903Sdim} 5328241903Sdim 5329241903Sdimtemplate <class _Tp> 5330241903Sdimshared_ptr<_Tp> 5331241903Sdimatomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) 5332241903Sdim{ 5333241903Sdim __sp_mut& __m = __get_sp_mut(__p); 5334241903Sdim __m.lock(); 5335241903Sdim __p->swap(__r); 5336241903Sdim __m.unlock(); 5337241903Sdim return __r; 5338241903Sdim} 5339241903Sdim 5340241903Sdimtemplate <class _Tp> 5341241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5342241903Sdimshared_ptr<_Tp> 5343241903Sdimatomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) 5344241903Sdim{ 5345241903Sdim return atomic_exchange(__p, __r); 5346241903Sdim} 5347241903Sdim 5348241903Sdimtemplate <class _Tp> 5349241903Sdimbool 5350241903Sdimatomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) 5351241903Sdim{ 5352241903Sdim __sp_mut& __m = __get_sp_mut(__p); 5353241903Sdim __m.lock(); 5354241903Sdim if (__p->__owner_equivalent(*__v)) 5355241903Sdim { 5356241903Sdim *__p = __w; 5357241903Sdim __m.unlock(); 5358241903Sdim return true; 5359241903Sdim } 5360241903Sdim *__v = *__p; 5361241903Sdim __m.unlock(); 5362241903Sdim return false; 5363241903Sdim} 5364241903Sdim 5365241903Sdimtemplate <class _Tp> 5366241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5367241903Sdimbool 5368241903Sdimatomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) 5369241903Sdim{ 5370241903Sdim return atomic_compare_exchange_strong(__p, __v, __w); 5371241903Sdim} 5372241903Sdim 5373241903Sdimtemplate <class _Tp> 5374241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5375241903Sdimbool 5376241903Sdimatomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, 5377241903Sdim shared_ptr<_Tp> __w, memory_order, memory_order) 5378241903Sdim{ 5379241903Sdim return atomic_compare_exchange_strong(__p, __v, __w); 5380241903Sdim} 5381241903Sdim 5382241903Sdimtemplate <class _Tp> 5383241903Sdiminline _LIBCPP_INLINE_VISIBILITY 5384241903Sdimbool 5385241903Sdimatomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, 5386241903Sdim shared_ptr<_Tp> __w, memory_order, memory_order) 5387241903Sdim{ 5388241903Sdim return atomic_compare_exchange_weak(__p, __v, __w); 5389241903Sdim} 5390241903Sdim 5391241903Sdim#endif // __has_feature(cxx_atomic) 5392241903Sdim 5393227825Stheraven//enum class 5394249998Sdimstruct _LIBCPP_TYPE_VIS pointer_safety 5395227825Stheraven{ 5396242945Stheraven enum __lx 5397227825Stheraven { 5398227825Stheraven relaxed, 5399227825Stheraven preferred, 5400227825Stheraven strict 5401227825Stheraven }; 5402227825Stheraven 5403242945Stheraven __lx __v_; 5404227825Stheraven 5405227825Stheraven _LIBCPP_INLINE_VISIBILITY 5406242945Stheraven pointer_safety(__lx __v) : __v_(__v) {} 5407227825Stheraven _LIBCPP_INLINE_VISIBILITY 5408227825Stheraven operator int() const {return __v_;} 5409227825Stheraven}; 5410227825Stheraven 5411262801Sdim_LIBCPP_FUNC_VIS void declare_reachable(void* __p); 5412262801Sdim_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n); 5413262801Sdim_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n); 5414262801Sdim_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT; 5415262801Sdim_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p); 5416227825Stheraven 5417227825Stheraventemplate <class _Tp> 5418227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 5419227825Stheraven_Tp* 5420227825Stheravenundeclare_reachable(_Tp* __p) 5421227825Stheraven{ 5422227825Stheraven return static_cast<_Tp*>(__undeclare_reachable(__p)); 5423227825Stheraven} 5424227825Stheraven 5425262801Sdim_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); 5426227825Stheraven 5427227825Stheraven_LIBCPP_END_NAMESPACE_STD 5428227825Stheraven 5429227825Stheraven#endif // _LIBCPP_MEMORY 5430