2 //===-------------------------- memory ------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_MEMORY
12 #define _LIBCPP_MEMORY
20 struct allocator_arg_t { };
21 constexpr allocator_arg_t allocator_arg = allocator_arg_t();
23 template <class T, class Alloc> struct uses_allocator;
29 typedef <details> element_type;
30 typedef <details> difference_type;
32 template <class U> using rebind = <details>;
34 static pointer pointer_to(<details>);
38 struct pointer_traits<T*>
41 typedef T element_type;
42 typedef ptrdiff_t difference_type;
44 template <class U> using rebind = U*;
46 static pointer pointer_to(<details>) noexcept;
49 template <class Alloc>
50 struct allocator_traits
52 typedef Alloc allocator_type;
53 typedef typename allocator_type::value_type
56 typedef Alloc::pointer | value_type* pointer;
57 typedef Alloc::const_pointer
58 | pointer_traits<pointer>::rebind<const value_type>
60 typedef Alloc::void_pointer
61 | pointer_traits<pointer>::rebind<void>
63 typedef Alloc::const_void_pointer
64 | pointer_traits<pointer>::rebind<const void>
66 typedef Alloc::difference_type
67 | pointer_traits<pointer>::difference_type
69 typedef Alloc::size_type
70 | make_unsigned<difference_type>::type
72 typedef Alloc::propagate_on_container_copy_assignment
73 | false_type propagate_on_container_copy_assignment;
74 typedef Alloc::propagate_on_container_move_assignment
75 | false_type propagate_on_container_move_assignment;
76 typedef Alloc::propagate_on_container_swap
77 | false_type propagate_on_container_swap;
79 template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>;
80 template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
82 static pointer allocate(allocator_type& a, size_type n);
83 static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
85 static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;
87 template <class T, class... Args>
88 static void construct(allocator_type& a, T* p, Args&&... args);
91 static void destroy(allocator_type& a, T* p);
93 static size_type max_size(const allocator_type& a); // noexcept in C++14
96 select_on_container_copy_construction(const allocator_type& a);
100 class allocator<void>
103 typedef void* pointer;
104 typedef const void* const_pointer;
105 typedef void value_type;
107 template <class _Up> struct rebind {typedef allocator<_Up> other;};
114 typedef size_t size_type;
115 typedef ptrdiff_t difference_type;
117 typedef const T* const_pointer;
118 typedef typename add_lvalue_reference<T>::type reference;
119 typedef typename add_lvalue_reference<const T>::type const_reference;
120 typedef T value_type;
122 template <class U> struct rebind {typedef allocator<U> other;};
124 allocator() noexcept;
125 allocator(const allocator&) noexcept;
126 template <class U> allocator(const allocator<U>&) noexcept;
128 pointer address(reference x) const noexcept;
129 const_pointer address(const_reference x) const noexcept;
130 pointer allocate(size_type, allocator<void>::const_pointer hint = 0);
131 void deallocate(pointer p, size_type n) noexcept;
132 size_type max_size() const noexcept;
133 template<class U, class... Args>
134 void construct(U* p, Args&&... args);
139 template <class T, class U>
140 bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
142 template <class T, class U>
143 bool operator!=(const allocator<T>&, const allocator<U>&) noexcept;
145 template <class OutputIterator, class T>
146 class raw_storage_iterator
147 : public iterator<output_iterator_tag,
148 T, // purposefully not C++03
149 ptrdiff_t, // purposefully not C++03
150 T*, // purposefully not C++03
151 raw_storage_iterator&> // purposefully not C++03
154 explicit raw_storage_iterator(OutputIterator x);
155 raw_storage_iterator& operator*();
156 raw_storage_iterator& operator=(const T& element);
157 raw_storage_iterator& operator++();
158 raw_storage_iterator operator++(int);
161 template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
162 template <class T> void return_temporary_buffer(T* p) noexcept;
164 template <class T> T* addressof(T& r) noexcept;
166 template <class InputIterator, class ForwardIterator>
168 uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
170 template <class InputIterator, class Size, class ForwardIterator>
172 uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
174 template <class ForwardIterator, class T>
175 void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
177 template <class ForwardIterator, class Size, class T>
179 uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
181 template <class Y> struct auto_ptr_ref {};
187 typedef X element_type;
189 explicit auto_ptr(X* p =0) throw();
190 auto_ptr(auto_ptr&) throw();
191 template<class Y> auto_ptr(auto_ptr<Y>&) throw();
192 auto_ptr& operator=(auto_ptr&) throw();
193 template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
194 auto_ptr& operator=(auto_ptr_ref<X> r) throw();
197 typename add_lvalue_reference<X>::type operator*() const throw();
198 X* operator->() const throw();
199 X* get() const throw();
200 X* release() throw();
201 void reset(X* p =0) throw();
203 auto_ptr(auto_ptr_ref<X>) throw();
204 template<class Y> operator auto_ptr_ref<Y>() throw();
205 template<class Y> operator auto_ptr<Y>() throw();
209 struct default_delete
211 constexpr default_delete() noexcept = default;
212 template <class U> default_delete(const default_delete<U>&) noexcept;
214 void operator()(T*) const noexcept;
218 struct default_delete<T[]>
220 constexpr default_delete() noexcept = default;
221 void operator()(T*) const noexcept;
222 template <class U> void operator()(U*) const = delete;
225 template <class T, class D = default_delete<T>>
229 typedef see below pointer;
230 typedef T element_type;
231 typedef D deleter_type;
234 constexpr unique_ptr() noexcept;
235 explicit unique_ptr(pointer p) noexcept;
236 unique_ptr(pointer p, see below d1) noexcept;
237 unique_ptr(pointer p, see below d2) noexcept;
238 unique_ptr(unique_ptr&& u) noexcept;
239 unique_ptr(nullptr_t) noexcept : unique_ptr() { }
240 template <class U, class E>
241 unique_ptr(unique_ptr<U, E>&& u) noexcept;
243 unique_ptr(auto_ptr<U>&& u) noexcept;
249 unique_ptr& operator=(unique_ptr&& u) noexcept;
250 template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
251 unique_ptr& operator=(nullptr_t) noexcept;
254 typename add_lvalue_reference<T>::type operator*() const;
255 pointer operator->() const noexcept;
256 pointer get() const noexcept;
257 deleter_type& get_deleter() noexcept;
258 const deleter_type& get_deleter() const noexcept;
259 explicit operator bool() const noexcept;
262 pointer release() noexcept;
263 void reset(pointer p = pointer()) noexcept;
264 void swap(unique_ptr& u) noexcept;
267 template <class T, class D>
268 class unique_ptr<T[], D>
271 typedef implementation-defined pointer;
272 typedef T element_type;
273 typedef D deleter_type;
276 constexpr unique_ptr() noexcept;
277 explicit unique_ptr(pointer p) noexcept;
278 unique_ptr(pointer p, see below d) noexcept;
279 unique_ptr(pointer p, see below d) noexcept;
280 unique_ptr(unique_ptr&& u) noexcept;
281 unique_ptr(nullptr_t) noexcept : unique_ptr() { }
287 unique_ptr& operator=(unique_ptr&& u) noexcept;
288 unique_ptr& operator=(nullptr_t) noexcept;
291 T& operator[](size_t i) const;
292 pointer get() const noexcept;
293 deleter_type& get_deleter() noexcept;
294 const deleter_type& get_deleter() const noexcept;
295 explicit operator bool() const noexcept;
298 pointer release() noexcept;
299 void reset(pointer p = pointer()) noexcept;
300 void reset(nullptr_t) noexcept;
301 template <class U> void reset(U) = delete;
302 void swap(unique_ptr& u) noexcept;
305 template <class T, class D>
306 void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
308 template <class T1, class D1, class T2, class D2>
309 bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
310 template <class T1, class D1, class T2, class D2>
311 bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
312 template <class T1, class D1, class T2, class D2>
313 bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
314 template <class T1, class D1, class T2, class D2>
315 bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
316 template <class T1, class D1, class T2, class D2>
317 bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
318 template <class T1, class D1, class T2, class D2>
319 bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
321 template <class T, class D>
322 bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
323 template <class T, class D>
324 bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
325 template <class T, class D>
326 bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
327 template <class T, class D>
328 bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
330 template <class T, class D>
331 bool operator<(const unique_ptr<T, D>& x, nullptr_t);
332 template <class T, class D>
333 bool operator<(nullptr_t, const unique_ptr<T, D>& y);
334 template <class T, class D>
335 bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
336 template <class T, class D>
337 bool operator<=(nullptr_t, const unique_ptr<T, D>& y);
338 template <class T, class D>
339 bool operator>(const unique_ptr<T, D>& x, nullptr_t);
340 template <class T, class D>
341 bool operator>(nullptr_t, const unique_ptr<T, D>& y);
342 template <class T, class D>
343 bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
344 template <class T, class D>
345 bool operator>=(nullptr_t, const unique_ptr<T, D>& y);
348 : public std::exception
350 bad_weak_ptr() noexcept;
353 template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // C++14
354 template<class T> unique_ptr<T> make_unique(size_t n); // C++14
355 template<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N]
361 typedef T element_type;
364 constexpr shared_ptr() noexcept;
365 template<class Y> explicit shared_ptr(Y* p);
366 template<class Y, class D> shared_ptr(Y* p, D d);
367 template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
368 template <class D> shared_ptr(nullptr_t p, D d);
369 template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
370 template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept;
371 shared_ptr(const shared_ptr& r) noexcept;
372 template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
373 shared_ptr(shared_ptr&& r) noexcept;
374 template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
375 template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
376 template<class Y> shared_ptr(auto_ptr<Y>&& r);
377 template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
378 shared_ptr(nullptr_t) : shared_ptr() { }
384 shared_ptr& operator=(const shared_ptr& r) noexcept;
385 template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept;
386 shared_ptr& operator=(shared_ptr&& r) noexcept;
387 template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
388 template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r);
389 template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
392 void swap(shared_ptr& r) noexcept;
393 void reset() noexcept;
394 template<class Y> void reset(Y* p);
395 template<class Y, class D> void reset(Y* p, D d);
396 template<class Y, class D, class A> void reset(Y* p, D d, A a);
399 T* get() const noexcept;
400 T& operator*() const noexcept;
401 T* operator->() const noexcept;
402 long use_count() const noexcept;
403 bool unique() const noexcept;
404 explicit operator bool() const noexcept;
405 template<class U> bool owner_before(shared_ptr<U> const& b) const;
406 template<class U> bool owner_before(weak_ptr<U> const& b) const;
409 // shared_ptr comparisons:
410 template<class T, class U>
411 bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
412 template<class T, class U>
413 bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
414 template<class T, class U>
415 bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
416 template<class T, class U>
417 bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
418 template<class T, class U>
419 bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
420 template<class T, class U>
421 bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
424 bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
426 bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
428 bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
430 bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
432 bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
434 bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
436 bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
438 bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
440 bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
442 bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
444 bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
446 bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
448 // shared_ptr specialized algorithms:
449 template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
452 template<class T, class U>
453 shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept;
454 template<class T, class U>
455 shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept;
456 template<class T, class U>
457 shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept;
460 template<class E, class T, class Y>
461 basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
463 // shared_ptr get_deleter:
464 template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
466 template<class T, class... Args>
467 shared_ptr<T> make_shared(Args&&... args);
468 template<class T, class A, class... Args>
469 shared_ptr<T> allocate_shared(const A& a, Args&&... args);
475 typedef T element_type;
478 constexpr weak_ptr() noexcept;
479 template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
480 weak_ptr(weak_ptr const& r) noexcept;
481 template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
482 weak_ptr(weak_ptr&& r) noexcept; // C++14
483 template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14
489 weak_ptr& operator=(weak_ptr const& r) noexcept;
490 template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
491 template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
492 weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14
493 template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14
496 void swap(weak_ptr& r) noexcept;
497 void reset() noexcept;
500 long use_count() const noexcept;
501 bool expired() const noexcept;
502 shared_ptr<T> lock() const noexcept;
503 template<class U> bool owner_before(shared_ptr<U> const& b) const;
504 template<class U> bool owner_before(weak_ptr<U> const& b) const;
507 // weak_ptr specialized algorithms:
508 template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
511 template<class T> struct owner_less;
514 struct owner_less<shared_ptr<T>>
515 : binary_function<shared_ptr<T>, shared_ptr<T>, bool>
517 typedef bool result_type;
518 bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const;
519 bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
520 bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
524 struct owner_less<weak_ptr<T>>
525 : binary_function<weak_ptr<T>, weak_ptr<T>, bool>
527 typedef bool result_type;
528 bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const;
529 bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
530 bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
534 class enable_shared_from_this
537 constexpr enable_shared_from_this() noexcept;
538 enable_shared_from_this(enable_shared_from_this const&) noexcept;
539 enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept;
540 ~enable_shared_from_this();
542 shared_ptr<T> shared_from_this();
543 shared_ptr<T const> shared_from_this() const;
547 bool atomic_is_lock_free(const shared_ptr<T>* p);
549 shared_ptr<T> atomic_load(const shared_ptr<T>* p);
551 shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
553 void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
555 void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
557 shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
560 atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
563 atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
566 atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
569 atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
570 shared_ptr<T> w, memory_order success,
571 memory_order failure);
574 atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
575 shared_ptr<T> w, memory_order success,
576 memory_order failure);
578 template <class T> struct hash;
579 template <class T, class D> struct hash<unique_ptr<T, D> >;
580 template <class T> struct hash<shared_ptr<T> >;
583 enum class pointer_safety { relaxed, preferred, strict };
584 void declare_reachable(void *p);
585 template <class T> T *undeclare_reachable(T *p);
586 void declare_no_pointers(char *p, size_t n);
587 void undeclare_no_pointers(char *p, size_t n);
588 pointer_safety get_pointer_safety() noexcept;
590 void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
597 #include <type_traits>
605 #include <__functional_base>
609 #if defined(_LIBCPP_NO_EXCEPTIONS)
613 #if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
617 #include <__undef_min_max>
619 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
620 #pragma GCC system_header
623 _LIBCPP_BEGIN_NAMESPACE_STD
625 // addressof moved to <__functional_base>
627 template <class _Tp> class allocator;
630 class _LIBCPP_TYPE_VIS_ONLY allocator<void>
633 typedef void* pointer;
634 typedef const void* const_pointer;
635 typedef void value_type;
637 template <class _Up> struct rebind {typedef allocator<_Up> other;};
641 class _LIBCPP_TYPE_VIS_ONLY allocator<const void>
644 typedef const void* pointer;
645 typedef const void* const_pointer;
646 typedef const void value_type;
648 template <class _Up> struct rebind {typedef allocator<_Up> other;};
654 struct __has_element_type
657 struct __two {char __lx; char __lxx;};
658 template <class _Up> static __two __test(...);
659 template <class _Up> static char __test(typename _Up::element_type* = 0);
661 static const bool value = sizeof(__test<_Tp>(0)) == 1;
664 template <class _Ptr, bool = __has_element_type<_Ptr>::value>
665 struct __pointer_traits_element_type;
667 template <class _Ptr>
668 struct __pointer_traits_element_type<_Ptr, true>
670 typedef typename _Ptr::element_type type;
673 #ifndef _LIBCPP_HAS_NO_VARIADICS
675 template <template <class, class...> class _Sp, class _Tp, class ..._Args>
676 struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
678 typedef typename _Sp<_Tp, _Args...>::element_type type;
681 template <template <class, class...> class _Sp, class _Tp, class ..._Args>
682 struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
687 #else // _LIBCPP_HAS_NO_VARIADICS
689 template <template <class> class _Sp, class _Tp>
690 struct __pointer_traits_element_type<_Sp<_Tp>, true>
692 typedef typename _Sp<_Tp>::element_type type;
695 template <template <class> class _Sp, class _Tp>
696 struct __pointer_traits_element_type<_Sp<_Tp>, false>
701 template <template <class, class> class _Sp, class _Tp, class _A0>
702 struct __pointer_traits_element_type<_Sp<_Tp, _A0>, true>
704 typedef typename _Sp<_Tp, _A0>::element_type type;
707 template <template <class, class> class _Sp, class _Tp, class _A0>
708 struct __pointer_traits_element_type<_Sp<_Tp, _A0>, false>
713 template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1>
714 struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true>
716 typedef typename _Sp<_Tp, _A0, _A1>::element_type type;
719 template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1>
720 struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false>
725 template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
726 class _A1, class _A2>
727 struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true>
729 typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type;
732 template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
733 class _A1, class _A2>
734 struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false>
739 #endif // _LIBCPP_HAS_NO_VARIADICS
742 struct __has_difference_type
745 struct __two {char __lx; char __lxx;};
746 template <class _Up> static __two __test(...);
747 template <class _Up> static char __test(typename _Up::difference_type* = 0);
749 static const bool value = sizeof(__test<_Tp>(0)) == 1;
752 template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
753 struct __pointer_traits_difference_type
755 typedef ptrdiff_t type;
758 template <class _Ptr>
759 struct __pointer_traits_difference_type<_Ptr, true>
761 typedef typename _Ptr::difference_type type;
764 template <class _Tp, class _Up>
768 struct __two {char __lx; char __lxx;};
769 template <class _Xp> static __two __test(...);
770 template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
772 static const bool value = sizeof(__test<_Tp>(0)) == 1;
775 template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
776 struct __pointer_traits_rebind
778 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
779 typedef typename _Tp::template rebind<_Up> type;
781 typedef typename _Tp::template rebind<_Up>::other type;
785 #ifndef _LIBCPP_HAS_NO_VARIADICS
787 template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
788 struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
790 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
791 typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
793 typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
797 template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
798 struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
800 typedef _Sp<_Up, _Args...> type;
803 #else // _LIBCPP_HAS_NO_VARIADICS
805 template <template <class> class _Sp, class _Tp, class _Up>
806 struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true>
808 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
809 typedef typename _Sp<_Tp>::template rebind<_Up> type;
811 typedef typename _Sp<_Tp>::template rebind<_Up>::other type;
815 template <template <class> class _Sp, class _Tp, class _Up>
816 struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false>
818 typedef _Sp<_Up> type;
821 template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
822 struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true>
824 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
825 typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type;
827 typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type;
831 template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
832 struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false>
834 typedef _Sp<_Up, _A0> type;
837 template <template <class, class, class> class _Sp, class _Tp, class _A0,
838 class _A1, class _Up>
839 struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true>
841 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
842 typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type;
844 typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type;
848 template <template <class, class, class> class _Sp, class _Tp, class _A0,
849 class _A1, class _Up>
850 struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false>
852 typedef _Sp<_Up, _A0, _A1> type;
855 template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
856 class _A1, class _A2, class _Up>
857 struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true>
859 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
860 typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type;
862 typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type;
866 template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
867 class _A1, class _A2, class _Up>
868 struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false>
870 typedef _Sp<_Up, _A0, _A1, _A2> type;
873 #endif // _LIBCPP_HAS_NO_VARIADICS
875 template <class _Ptr>
876 struct _LIBCPP_TYPE_VIS_ONLY pointer_traits
878 typedef _Ptr pointer;
879 typedef typename __pointer_traits_element_type<pointer>::type element_type;
880 typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
882 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
883 template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
885 template <class _Up> struct rebind
886 {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
887 #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
892 _LIBCPP_INLINE_VISIBILITY
893 static pointer pointer_to(typename conditional<is_void<element_type>::value,
894 __nat, element_type>::type& __r)
895 {return pointer::pointer_to(__r);}
899 struct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*>
901 typedef _Tp* pointer;
902 typedef _Tp element_type;
903 typedef ptrdiff_t difference_type;
905 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
906 template <class _Up> using rebind = _Up*;
908 template <class _Up> struct rebind {typedef _Up* other;};
914 _LIBCPP_INLINE_VISIBILITY
915 static pointer pointer_to(typename conditional<is_void<element_type>::value,
916 __nat, element_type>::type& __r) _NOEXCEPT
917 {return _VSTD::addressof(__r);}
922 namespace __has_pointer_type_imp
924 template <class _Up> static __two __test(...);
925 template <class _Up> static char __test(typename _Up::pointer* = 0);
929 struct __has_pointer_type
930 : public integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1>
934 namespace __pointer_type_imp
937 template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value>
938 struct __pointer_type
940 typedef typename _Dp::pointer type;
943 template <class _Tp, class _Dp>
944 struct __pointer_type<_Tp, _Dp, false>
949 } // __pointer_type_imp
951 template <class _Tp, class _Dp>
952 struct __pointer_type
954 typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
958 struct __has_const_pointer
961 struct __two {char __lx; char __lxx;};
962 template <class _Up> static __two __test(...);
963 template <class _Up> static char __test(typename _Up::const_pointer* = 0);
965 static const bool value = sizeof(__test<_Tp>(0)) == 1;
968 template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
969 struct __const_pointer
971 typedef typename _Alloc::const_pointer type;
974 template <class _Tp, class _Ptr, class _Alloc>
975 struct __const_pointer<_Tp, _Ptr, _Alloc, false>
977 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
978 typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
980 typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type;
985 struct __has_void_pointer
988 struct __two {char __lx; char __lxx;};
989 template <class _Up> static __two __test(...);
990 template <class _Up> static char __test(typename _Up::void_pointer* = 0);
992 static const bool value = sizeof(__test<_Tp>(0)) == 1;
995 template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>
996 struct __void_pointer
998 typedef typename _Alloc::void_pointer type;
1001 template <class _Ptr, class _Alloc>
1002 struct __void_pointer<_Ptr, _Alloc, false>
1004 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
1005 typedef typename pointer_traits<_Ptr>::template rebind<void> type;
1007 typedef typename pointer_traits<_Ptr>::template rebind<void>::other type;
1011 template <class _Tp>
1012 struct __has_const_void_pointer
1015 struct __two {char __lx; char __lxx;};
1016 template <class _Up> static __two __test(...);
1017 template <class _Up> static char __test(typename _Up::const_void_pointer* = 0);
1019 static const bool value = sizeof(__test<_Tp>(0)) == 1;
1022 template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>
1023 struct __const_void_pointer
1025 typedef typename _Alloc::const_void_pointer type;
1028 template <class _Ptr, class _Alloc>
1029 struct __const_void_pointer<_Ptr, _Alloc, false>
1031 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
1032 typedef typename pointer_traits<_Ptr>::template rebind<const void> type;
1034 typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type;
1038 template <class _Tp>
1039 inline _LIBCPP_INLINE_VISIBILITY
1041 __to_raw_pointer(_Tp* __p) _NOEXCEPT
1046 template <class _Pointer>
1047 inline _LIBCPP_INLINE_VISIBILITY
1048 typename pointer_traits<_Pointer>::element_type*
1049 __to_raw_pointer(_Pointer __p) _NOEXCEPT
1051 return _VSTD::__to_raw_pointer(__p.operator->());
1054 template <class _Tp>
1055 struct __has_size_type
1058 struct __two {char __lx; char __lxx;};
1059 template <class _Up> static __two __test(...);
1060 template <class _Up> static char __test(typename _Up::size_type* = 0);
1062 static const bool value = sizeof(__test<_Tp>(0)) == 1;
1065 template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
1068 typedef typename make_unsigned<_DiffType>::type type;
1071 template <class _Alloc, class _DiffType>
1072 struct __size_type<_Alloc, _DiffType, true>
1074 typedef typename _Alloc::size_type type;
1077 template <class _Tp>
1078 struct __has_propagate_on_container_copy_assignment
1081 struct __two {char __lx; char __lxx;};
1082 template <class _Up> static __two __test(...);
1083 template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0);
1085 static const bool value = sizeof(__test<_Tp>(0)) == 1;
1088 template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
1089 struct __propagate_on_container_copy_assignment
1091 typedef false_type type;
1094 template <class _Alloc>
1095 struct __propagate_on_container_copy_assignment<_Alloc, true>
1097 typedef typename _Alloc::propagate_on_container_copy_assignment type;
1100 template <class _Tp>
1101 struct __has_propagate_on_container_move_assignment
1104 struct __two {char __lx; char __lxx;};
1105 template <class _Up> static __two __test(...);
1106 template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0);
1108 static const bool value = sizeof(__test<_Tp>(0)) == 1;
1111 template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
1112 struct __propagate_on_container_move_assignment
1114 typedef false_type type;
1117 template <class _Alloc>
1118 struct __propagate_on_container_move_assignment<_Alloc, true>
1120 typedef typename _Alloc::propagate_on_container_move_assignment type;
1123 template <class _Tp>
1124 struct __has_propagate_on_container_swap
1127 struct __two {char __lx; char __lxx;};
1128 template <class _Up> static __two __test(...);
1129 template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0);
1131 static const bool value = sizeof(__test<_Tp>(0)) == 1;
1134 template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
1135 struct __propagate_on_container_swap
1137 typedef false_type type;
1140 template <class _Alloc>
1141 struct __propagate_on_container_swap<_Alloc, true>
1143 typedef typename _Alloc::propagate_on_container_swap type;
1146 template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
1147 struct __has_rebind_other
1150 struct __two {char __lx; char __lxx;};
1151 template <class _Xp> static __two __test(...);
1152 template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0);
1154 static const bool value = sizeof(__test<_Tp>(0)) == 1;
1157 template <class _Tp, class _Up>
1158 struct __has_rebind_other<_Tp, _Up, false>
1160 static const bool value = false;
1163 template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
1164 struct __allocator_traits_rebind
1166 typedef typename _Tp::template rebind<_Up>::other type;
1169 #ifndef _LIBCPP_HAS_NO_VARIADICS
1171 template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
1172 struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>
1174 typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
1177 template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
1178 struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
1180 typedef _Alloc<_Up, _Args...> type;
1183 #else // _LIBCPP_HAS_NO_VARIADICS
1185 template <template <class> class _Alloc, class _Tp, class _Up>
1186 struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true>
1188 typedef typename _Alloc<_Tp>::template rebind<_Up>::other type;
1191 template <template <class> class _Alloc, class _Tp, class _Up>
1192 struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false>
1194 typedef _Alloc<_Up> type;
1197 template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up>
1198 struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true>
1200 typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type;
1203 template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up>
1204 struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false>
1206 typedef _Alloc<_Up, _A0> type;
1209 template <template <class, class, class> class _Alloc, class _Tp, class _A0,
1210 class _A1, class _Up>
1211 struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true>
1213 typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type;
1216 template <template <class, class, class> class _Alloc, class _Tp, class _A0,
1217 class _A1, class _Up>
1218 struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false>
1220 typedef _Alloc<_Up, _A0, _A1> type;
1223 template <template <class, class, class, class> class _Alloc, class _Tp, class _A0,
1224 class _A1, class _A2, class _Up>
1225 struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true>
1227 typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type;
1230 template <template <class, class, class, class> class _Alloc, class _Tp, class _A0,
1231 class _A1, class _A2, class _Up>
1232 struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false>
1234 typedef _Alloc<_Up, _A0, _A1, _A2> type;
1237 #endif // _LIBCPP_HAS_NO_VARIADICS
1239 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
1241 template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1243 __has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
1244 -> decltype(__a.allocate(__sz, __p), true_type());
1246 template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1248 __has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
1251 template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1252 struct __has_allocate_hint
1253 : integral_constant<bool,
1255 decltype(__has_allocate_hint_test(declval<_Alloc>(),
1256 declval<_SizeType>(),
1257 declval<_ConstVoidPtr>())),
1262 #else // _LIBCPP_HAS_NO_ADVANCED_SFINAE
1264 template <class _Alloc, class _SizeType, class _ConstVoidPtr>
1265 struct __has_allocate_hint
1270 #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
1272 #if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1274 template <class _Alloc, class _Tp, class ..._Args>
1275 decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(),
1276 _VSTD::declval<_Args>()...),
1278 __has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args);
1280 template <class _Alloc, class _Pointer, class ..._Args>
1282 __has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args);
1284 template <class _Alloc, class _Pointer, class ..._Args>
1285 struct __has_construct
1286 : integral_constant<bool,
1288 decltype(__has_construct_test(declval<_Alloc>(),
1289 declval<_Pointer>(),
1290 declval<_Args>()...)),
1295 template <class _Alloc, class _Pointer>
1297 __has_destroy_test(_Alloc&& __a, _Pointer&& __p)
1298 -> decltype(__a.destroy(__p), true_type());
1300 template <class _Alloc, class _Pointer>
1302 __has_destroy_test(const _Alloc& __a, _Pointer&& __p)
1305 template <class _Alloc, class _Pointer>
1306 struct __has_destroy
1307 : integral_constant<bool,
1309 decltype(__has_destroy_test(declval<_Alloc>(),
1310 declval<_Pointer>())),
1315 template <class _Alloc>
1317 __has_max_size_test(_Alloc&& __a)
1318 -> decltype(__a.max_size(), true_type());
1320 template <class _Alloc>
1322 __has_max_size_test(const volatile _Alloc& __a)
1325 template <class _Alloc>
1326 struct __has_max_size
1327 : integral_constant<bool,
1329 decltype(__has_max_size_test(declval<_Alloc&>())),
1334 template <class _Alloc>
1336 __has_select_on_container_copy_construction_test(_Alloc&& __a)
1337 -> decltype(__a.select_on_container_copy_construction(), true_type());
1339 template <class _Alloc>
1341 __has_select_on_container_copy_construction_test(const volatile _Alloc& __a)
1344 template <class _Alloc>
1345 struct __has_select_on_container_copy_construction
1346 : integral_constant<bool,
1348 decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())),
1353 #else // _LIBCPP_HAS_NO_ADVANCED_SFINAE
1355 #ifndef _LIBCPP_HAS_NO_VARIADICS
1357 template <class _Alloc, class _Pointer, class ..._Args>
1358 struct __has_construct
1363 #else // _LIBCPP_HAS_NO_VARIADICS
1365 template <class _Alloc, class _Pointer, class _Args>
1366 struct __has_construct
1371 #endif // _LIBCPP_HAS_NO_VARIADICS
1373 template <class _Alloc, class _Pointer>
1374 struct __has_destroy
1379 template <class _Alloc>
1380 struct __has_max_size
1385 template <class _Alloc>
1386 struct __has_select_on_container_copy_construction
1391 #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
1393 template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
1394 struct __alloc_traits_difference_type
1396 typedef typename pointer_traits<_Ptr>::difference_type type;
1399 template <class _Alloc, class _Ptr>
1400 struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
1402 typedef typename _Alloc::difference_type type;
1405 template <class _Alloc>
1406 struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
1408 typedef _Alloc allocator_type;
1409 typedef typename allocator_type::value_type value_type;
1411 typedef typename __pointer_type<value_type, allocator_type>::type pointer;
1412 typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer;
1413 typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
1414 typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer;
1416 typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type;
1417 typedef typename __size_type<allocator_type, difference_type>::type size_type;
1419 typedef typename __propagate_on_container_copy_assignment<allocator_type>::type
1420 propagate_on_container_copy_assignment;
1421 typedef typename __propagate_on_container_move_assignment<allocator_type>::type
1422 propagate_on_container_move_assignment;
1423 typedef typename __propagate_on_container_swap<allocator_type>::type
1424 propagate_on_container_swap;
1426 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
1427 template <class _Tp> using rebind_alloc =
1428 typename __allocator_traits_rebind<allocator_type, _Tp>::type;
1429 template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
1430 #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
1431 template <class _Tp> struct rebind_alloc
1432 {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;};
1433 template <class _Tp> struct rebind_traits
1434 {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
1435 #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
1437 _LIBCPP_INLINE_VISIBILITY
1438 static pointer allocate(allocator_type& __a, size_type __n)
1439 {return __a.allocate(__n);}
1440 _LIBCPP_INLINE_VISIBILITY
1441 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
1442 {return allocate(__a, __n, __hint,
1443 __has_allocate_hint<allocator_type, size_type, const_void_pointer>());}
1445 _LIBCPP_INLINE_VISIBILITY
1446 static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT
1447 {__a.deallocate(__p, __n);}
1449 #ifndef _LIBCPP_HAS_NO_VARIADICS
1450 template <class _Tp, class... _Args>
1451 _LIBCPP_INLINE_VISIBILITY
1452 static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
1453 {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
1454 __a, __p, _VSTD::forward<_Args>(__args)...);}
1455 #else // _LIBCPP_HAS_NO_VARIADICS
1456 template <class _Tp>
1457 _LIBCPP_INLINE_VISIBILITY
1458 static void construct(allocator_type& __a, _Tp* __p)
1460 ::new ((void*)__p) _Tp();
1462 template <class _Tp, class _A0>
1463 _LIBCPP_INLINE_VISIBILITY
1464 static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0)
1466 ::new ((void*)__p) _Tp(__a0);
1468 template <class _Tp, class _A0, class _A1>
1469 _LIBCPP_INLINE_VISIBILITY
1470 static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0,
1473 ::new ((void*)__p) _Tp(__a0, __a1);
1475 template <class _Tp, class _A0, class _A1, class _A2>
1476 _LIBCPP_INLINE_VISIBILITY
1477 static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0,
1478 const _A1& __a1, const _A2& __a2)
1480 ::new ((void*)__p) _Tp(__a0, __a1, __a2);
1482 #endif // _LIBCPP_HAS_NO_VARIADICS
1484 template <class _Tp>
1485 _LIBCPP_INLINE_VISIBILITY
1486 static void destroy(allocator_type& __a, _Tp* __p)
1487 {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
1489 _LIBCPP_INLINE_VISIBILITY
1490 static size_type max_size(const allocator_type& __a) _NOEXCEPT
1491 {return __max_size(__has_max_size<const allocator_type>(), __a);}
1493 _LIBCPP_INLINE_VISIBILITY
1494 static allocator_type
1495 select_on_container_copy_construction(const allocator_type& __a)
1496 {return select_on_container_copy_construction(
1497 __has_select_on_container_copy_construction<const allocator_type>(),
1500 template <class _Ptr>
1501 _LIBCPP_INLINE_VISIBILITY
1504 __construct_forward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2)
1506 for (; __begin1 != __end1; ++__begin1, ++__begin2)
1507 construct(__a, _VSTD::__to_raw_pointer(__begin2), _VSTD::move_if_noexcept(*__begin1));
1510 template <class _Tp>
1511 _LIBCPP_INLINE_VISIBILITY
1515 (is_same<allocator_type, allocator<_Tp> >::value
1516 || !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
1517 is_trivially_move_constructible<_Tp>::value,
1520 __construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
1522 ptrdiff_t _Np = __end1 - __begin1;
1523 _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
1527 template <class _Ptr>
1528 _LIBCPP_INLINE_VISIBILITY
1531 __construct_backward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2)
1533 while (__end1 != __begin1)
1535 construct(__a, _VSTD::__to_raw_pointer(__end2-1), _VSTD::move_if_noexcept(*--__end1));
1540 template <class _Tp>
1541 _LIBCPP_INLINE_VISIBILITY
1545 (is_same<allocator_type, allocator<_Tp> >::value
1546 || !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
1547 is_trivially_move_constructible<_Tp>::value,
1550 __construct_backward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
1552 ptrdiff_t _Np = __end1 - __begin1;
1554 _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
1559 _LIBCPP_INLINE_VISIBILITY
1560 static pointer allocate(allocator_type& __a, size_type __n,
1561 const_void_pointer __hint, true_type)
1562 {return __a.allocate(__n, __hint);}
1563 _LIBCPP_INLINE_VISIBILITY
1564 static pointer allocate(allocator_type& __a, size_type __n,
1565 const_void_pointer, false_type)
1566 {return __a.allocate(__n);}
1568 #ifndef _LIBCPP_HAS_NO_VARIADICS
1569 template <class _Tp, class... _Args>
1570 _LIBCPP_INLINE_VISIBILITY
1571 static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args)
1572 {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
1573 template <class _Tp, class... _Args>
1574 _LIBCPP_INLINE_VISIBILITY
1575 static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
1577 ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
1579 #endif // _LIBCPP_HAS_NO_VARIADICS
1581 template <class _Tp>
1582 _LIBCPP_INLINE_VISIBILITY
1583 static void __destroy(true_type, allocator_type& __a, _Tp* __p)
1585 template <class _Tp>
1586 _LIBCPP_INLINE_VISIBILITY
1587 static void __destroy(false_type, allocator_type&, _Tp* __p)
1592 _LIBCPP_INLINE_VISIBILITY
1593 static size_type __max_size(true_type, const allocator_type& __a)
1594 {return __a.max_size();}
1595 _LIBCPP_INLINE_VISIBILITY
1596 static size_type __max_size(false_type, const allocator_type&)
1597 {return numeric_limits<size_type>::max();}
1599 _LIBCPP_INLINE_VISIBILITY
1600 static allocator_type
1601 select_on_container_copy_construction(true_type, const allocator_type& __a)
1602 {return __a.select_on_container_copy_construction();}
1603 _LIBCPP_INLINE_VISIBILITY
1604 static allocator_type
1605 select_on_container_copy_construction(false_type, const allocator_type& __a)
1611 template <class _Tp>
1612 class _LIBCPP_TYPE_VIS_ONLY allocator
1615 typedef size_t size_type;
1616 typedef ptrdiff_t difference_type;
1617 typedef _Tp* pointer;
1618 typedef const _Tp* const_pointer;
1619 typedef _Tp& reference;
1620 typedef const _Tp& const_reference;
1621 typedef _Tp value_type;
1623 typedef true_type propagate_on_container_move_assignment;
1625 template <class _Up> struct rebind {typedef allocator<_Up> other;};
1627 _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {}
1628 template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {}
1629 _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT
1630 {return _VSTD::addressof(__x);}
1631 _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
1632 {return _VSTD::addressof(__x);}
1633 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
1634 {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));}
1635 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
1636 {_VSTD::__deallocate((void*)__p);}
1637 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
1638 {return size_type(~0) / sizeof(_Tp);}
1639 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1640 template <class _Up, class... _Args>
1641 _LIBCPP_INLINE_VISIBILITY
1643 construct(_Up* __p, _Args&&... __args)
1645 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
1647 #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1648 _LIBCPP_INLINE_VISIBILITY
1650 construct(pointer __p)
1652 ::new((void*)__p) _Tp();
1654 # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1656 template <class _A0>
1657 _LIBCPP_INLINE_VISIBILITY
1659 construct(pointer __p, _A0& __a0)
1661 ::new((void*)__p) _Tp(__a0);
1663 template <class _A0>
1664 _LIBCPP_INLINE_VISIBILITY
1666 construct(pointer __p, const _A0& __a0)
1668 ::new((void*)__p) _Tp(__a0);
1670 # endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1671 template <class _A0, class _A1>
1672 _LIBCPP_INLINE_VISIBILITY
1674 construct(pointer __p, _A0& __a0, _A1& __a1)
1676 ::new((void*)__p) _Tp(__a0, __a1);
1678 template <class _A0, class _A1>
1679 _LIBCPP_INLINE_VISIBILITY
1681 construct(pointer __p, const _A0& __a0, _A1& __a1)
1683 ::new((void*)__p) _Tp(__a0, __a1);
1685 template <class _A0, class _A1>
1686 _LIBCPP_INLINE_VISIBILITY
1688 construct(pointer __p, _A0& __a0, const _A1& __a1)
1690 ::new((void*)__p) _Tp(__a0, __a1);
1692 template <class _A0, class _A1>
1693 _LIBCPP_INLINE_VISIBILITY
1695 construct(pointer __p, const _A0& __a0, const _A1& __a1)
1697 ::new((void*)__p) _Tp(__a0, __a1);
1699 #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1700 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
1703 template <class _Tp>
1704 class _LIBCPP_TYPE_VIS_ONLY allocator<const _Tp>
1707 typedef size_t size_type;
1708 typedef ptrdiff_t difference_type;
1709 typedef const _Tp* pointer;
1710 typedef const _Tp* const_pointer;
1711 typedef const _Tp& reference;
1712 typedef const _Tp& const_reference;
1713 typedef const _Tp value_type;
1715 typedef true_type propagate_on_container_move_assignment;
1717 template <class _Up> struct rebind {typedef allocator<_Up> other;};
1719 _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {}
1720 template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {}
1721 _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
1722 {return _VSTD::addressof(__x);}
1723 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
1724 {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));}
1725 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
1726 {_VSTD::__deallocate((void*)__p);}
1727 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
1728 {return size_type(~0) / sizeof(_Tp);}
1729 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1730 template <class _Up, class... _Args>
1731 _LIBCPP_INLINE_VISIBILITY
1733 construct(_Up* __p, _Args&&... __args)
1735 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
1737 #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1738 _LIBCPP_INLINE_VISIBILITY
1740 construct(pointer __p)
1742 ::new((void*)__p) _Tp();
1744 # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1746 template <class _A0>
1747 _LIBCPP_INLINE_VISIBILITY
1749 construct(pointer __p, _A0& __a0)
1751 ::new((void*)__p) _Tp(__a0);
1753 template <class _A0>
1754 _LIBCPP_INLINE_VISIBILITY
1756 construct(pointer __p, const _A0& __a0)
1758 ::new((void*)__p) _Tp(__a0);
1760 # endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1761 template <class _A0, class _A1>
1762 _LIBCPP_INLINE_VISIBILITY
1764 construct(pointer __p, _A0& __a0, _A1& __a1)
1766 ::new((void*)__p) _Tp(__a0, __a1);
1768 template <class _A0, class _A1>
1769 _LIBCPP_INLINE_VISIBILITY
1771 construct(pointer __p, const _A0& __a0, _A1& __a1)
1773 ::new((void*)__p) _Tp(__a0, __a1);
1775 template <class _A0, class _A1>
1776 _LIBCPP_INLINE_VISIBILITY
1778 construct(pointer __p, _A0& __a0, const _A1& __a1)
1780 ::new((void*)__p) _Tp(__a0, __a1);
1782 template <class _A0, class _A1>
1783 _LIBCPP_INLINE_VISIBILITY
1785 construct(pointer __p, const _A0& __a0, const _A1& __a1)
1787 ::new((void*)__p) _Tp(__a0, __a1);
1789 #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
1790 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
1793 template <class _Tp, class _Up>
1794 inline _LIBCPP_INLINE_VISIBILITY
1795 bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
1797 template <class _Tp, class _Up>
1798 inline _LIBCPP_INLINE_VISIBILITY
1799 bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
1801 template <class _OutputIterator, class _Tp>
1802 class _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator
1803 : public iterator<output_iterator_tag,
1804 _Tp, // purposefully not C++03
1805 ptrdiff_t, // purposefully not C++03
1806 _Tp*, // purposefully not C++03
1807 raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03
1810 _OutputIterator __x_;
1812 _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}
1813 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}
1814 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)
1815 {::new(&*__x_) _Tp(__element); return *this;}
1816 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
1817 _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int)
1818 {raw_storage_iterator __t(*this); ++__x_; return __t;}
1821 template <class _Tp>
1822 pair<_Tp*, ptrdiff_t>
1823 get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
1825 pair<_Tp*, ptrdiff_t> __r(0, 0);
1826 const ptrdiff_t __m = (~ptrdiff_t(0) ^
1827 ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1)))
1833 __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
1844 template <class _Tp>
1845 inline _LIBCPP_INLINE_VISIBILITY
1846 void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);}
1848 template <class _Tp>
1855 class _LIBCPP_TYPE_VIS_ONLY auto_ptr
1860 typedef _Tp element_type;
1862 _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {}
1863 _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {}
1864 template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw()
1865 : __ptr_(__p.release()) {}
1866 _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw()
1867 {reset(__p.release()); return *this;}
1868 template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw()
1869 {reset(__p.release()); return *this;}
1870 _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw()
1871 {reset(__p.__ptr_); return *this;}
1872 _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;}
1874 _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw()
1876 _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;}
1877 _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;}
1878 _LIBCPP_INLINE_VISIBILITY _Tp* release() throw()
1884 _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw()
1891 _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {}
1892 template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw()
1893 {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;}
1894 template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw()
1895 {return auto_ptr<_Up>(release());}
1899 class _LIBCPP_TYPE_VIS_ONLY auto_ptr<void>
1902 typedef void element_type;
1905 template <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type,
1906 typename remove_cv<_T2>::type>::value,
1907 bool = is_empty<_T1>::value
1908 #if __has_feature(is_final)
1912 bool = is_empty<_T2>::value
1913 #if __has_feature(is_final)
1917 struct __libcpp_compressed_pair_switch;
1919 template <class _T1, class _T2, bool IsSame>
1920 struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};};
1922 template <class _T1, class _T2, bool IsSame>
1923 struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false> {enum {value = 1};};
1925 template <class _T1, class _T2, bool IsSame>
1926 struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true> {enum {value = 2};};
1928 template <class _T1, class _T2>
1929 struct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true> {enum {value = 3};};
1931 template <class _T1, class _T2>
1932 struct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true> {enum {value = 1};};
1934 template <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value>
1935 class __libcpp_compressed_pair_imp;
1937 template <class _T1, class _T2>
1938 class __libcpp_compressed_pair_imp<_T1, _T2, 0>
1944 typedef _T1 _T1_param;
1945 typedef _T2 _T2_param;
1947 typedef typename remove_reference<_T1>::type& _T1_reference;
1948 typedef typename remove_reference<_T2>::type& _T2_reference;
1950 typedef const typename remove_reference<_T1>::type& _T1_const_reference;
1951 typedef const typename remove_reference<_T2>::type& _T2_const_reference;
1953 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
1954 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
1955 : __first_(_VSTD::forward<_T1_param>(__t1)) {}
1956 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
1957 : __second_(_VSTD::forward<_T2_param>(__t2)) {}
1958 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
1959 : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
1961 #if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1963 _LIBCPP_INLINE_VISIBILITY
1964 __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
1965 _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
1966 is_nothrow_copy_constructible<_T2>::value)
1967 : __first_(__p.first()),
1968 __second_(__p.second()) {}
1970 _LIBCPP_INLINE_VISIBILITY
1971 __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
1972 _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
1973 is_nothrow_copy_assignable<_T2>::value)
1975 __first_ = __p.first();
1976 __second_ = __p.second();
1980 _LIBCPP_INLINE_VISIBILITY
1981 __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
1982 _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
1983 is_nothrow_move_constructible<_T2>::value)
1984 : __first_(_VSTD::forward<_T1>(__p.first())),
1985 __second_(_VSTD::forward<_T2>(__p.second())) {}
1987 _LIBCPP_INLINE_VISIBILITY
1988 __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
1989 _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
1990 is_nothrow_move_assignable<_T2>::value)
1992 __first_ = _VSTD::forward<_T1>(__p.first());
1993 __second_ = _VSTD::forward<_T2>(__p.second());
1997 #endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
1999 #ifndef _LIBCPP_HAS_NO_VARIADICS
2001 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
2002 _LIBCPP_INLINE_VISIBILITY
2003 __libcpp_compressed_pair_imp(piecewise_construct_t __pc,
2004 tuple<_Args1...> __first_args,
2005 tuple<_Args2...> __second_args,
2006 __tuple_indices<_I1...>,
2007 __tuple_indices<_I2...>)
2008 : __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
2009 __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
2012 #endif // _LIBCPP_HAS_NO_VARIADICS
2014 _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;}
2015 _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
2017 _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;}
2018 _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;}
2020 _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
2021 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
2022 __is_nothrow_swappable<_T2>::value)
2025 swap(__first_, __x.__first_);
2026 swap(__second_, __x.__second_);
2030 template <class _T1, class _T2>
2031 class __libcpp_compressed_pair_imp<_T1, _T2, 1>
2037 typedef _T1 _T1_param;
2038 typedef _T2 _T2_param;
2040 typedef _T1& _T1_reference;
2041 typedef typename remove_reference<_T2>::type& _T2_reference;
2043 typedef const _T1& _T1_const_reference;
2044 typedef const typename remove_reference<_T2>::type& _T2_const_reference;
2046 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
2047 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
2048 : _T1(_VSTD::forward<_T1_param>(__t1)) {}
2049 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
2050 : __second_(_VSTD::forward<_T2_param>(__t2)) {}
2051 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
2052 : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
2054 #if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
2056 _LIBCPP_INLINE_VISIBILITY
2057 __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
2058 _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
2059 is_nothrow_copy_constructible<_T2>::value)
2060 : _T1(__p.first()), __second_(__p.second()) {}
2062 _LIBCPP_INLINE_VISIBILITY
2063 __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
2064 _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
2065 is_nothrow_copy_assignable<_T2>::value)
2067 _T1::operator=(__p.first());
2068 __second_ = __p.second();
2072 _LIBCPP_INLINE_VISIBILITY
2073 __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
2074 _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
2075 is_nothrow_move_constructible<_T2>::value)
2076 : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {}
2078 _LIBCPP_INLINE_VISIBILITY
2079 __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
2080 _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
2081 is_nothrow_move_assignable<_T2>::value)
2083 _T1::operator=(_VSTD::move(__p.first()));
2084 __second_ = _VSTD::forward<_T2>(__p.second());
2088 #endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
2090 #ifndef _LIBCPP_HAS_NO_VARIADICS
2092 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
2093 _LIBCPP_INLINE_VISIBILITY
2094 __libcpp_compressed_pair_imp(piecewise_construct_t __pc,
2095 tuple<_Args1...> __first_args,
2096 tuple<_Args2...> __second_args,
2097 __tuple_indices<_I1...>,
2098 __tuple_indices<_I2...>)
2099 : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
2100 __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
2103 #endif // _LIBCPP_HAS_NO_VARIADICS
2105 _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;}
2106 _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
2108 _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;}
2109 _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;}
2111 _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
2112 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
2113 __is_nothrow_swappable<_T2>::value)
2116 swap(__second_, __x.__second_);
2120 template <class _T1, class _T2>
2121 class __libcpp_compressed_pair_imp<_T1, _T2, 2>
2127 typedef _T1 _T1_param;
2128 typedef _T2 _T2_param;
2130 typedef typename remove_reference<_T1>::type& _T1_reference;
2131 typedef _T2& _T2_reference;
2133 typedef const typename remove_reference<_T1>::type& _T1_const_reference;
2134 typedef const _T2& _T2_const_reference;
2136 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
2137 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
2138 : __first_(_VSTD::forward<_T1_param>(__t1)) {}
2139 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
2140 : _T2(_VSTD::forward<_T2_param>(__t2)) {}
2141 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
2142 _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
2143 is_nothrow_move_constructible<_T2>::value)
2144 : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {}
2146 #if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
2148 _LIBCPP_INLINE_VISIBILITY
2149 __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
2150 _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
2151 is_nothrow_copy_constructible<_T2>::value)
2152 : _T2(__p.second()), __first_(__p.first()) {}
2154 _LIBCPP_INLINE_VISIBILITY
2155 __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
2156 _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
2157 is_nothrow_copy_assignable<_T2>::value)
2159 _T2::operator=(__p.second());
2160 __first_ = __p.first();
2164 _LIBCPP_INLINE_VISIBILITY
2165 __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
2166 _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
2167 is_nothrow_move_constructible<_T2>::value)
2168 : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {}
2170 _LIBCPP_INLINE_VISIBILITY
2171 __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
2172 _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
2173 is_nothrow_move_assignable<_T2>::value)
2175 _T2::operator=(_VSTD::forward<_T2>(__p.second()));
2176 __first_ = _VSTD::move(__p.first());
2180 #endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
2182 #ifndef _LIBCPP_HAS_NO_VARIADICS
2184 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
2185 _LIBCPP_INLINE_VISIBILITY
2186 __libcpp_compressed_pair_imp(piecewise_construct_t __pc,
2187 tuple<_Args1...> __first_args,
2188 tuple<_Args2...> __second_args,
2189 __tuple_indices<_I1...>,
2190 __tuple_indices<_I2...>)
2191 : _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...),
2192 __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...)
2196 #endif // _LIBCPP_HAS_NO_VARIADICS
2198 _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;}
2199 _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
2201 _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;}
2202 _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;}
2204 _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
2205 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
2206 __is_nothrow_swappable<_T2>::value)
2209 swap(__first_, __x.__first_);
2213 template <class _T1, class _T2>
2214 class __libcpp_compressed_pair_imp<_T1, _T2, 3>
2219 typedef _T1 _T1_param;
2220 typedef _T2 _T2_param;
2222 typedef _T1& _T1_reference;
2223 typedef _T2& _T2_reference;
2225 typedef const _T1& _T1_const_reference;
2226 typedef const _T2& _T2_const_reference;
2228 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
2229 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
2230 : _T1(_VSTD::forward<_T1_param>(__t1)) {}
2231 _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
2232 : _T2(_VSTD::forward<_T2_param>(__t2)) {}
2233 _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
2234 : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {}
2236 #if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
2238 _LIBCPP_INLINE_VISIBILITY
2239 __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
2240 _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
2241 is_nothrow_copy_constructible<_T2>::value)
2242 : _T1(__p.first()), _T2(__p.second()) {}
2244 _LIBCPP_INLINE_VISIBILITY
2245 __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
2246 _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
2247 is_nothrow_copy_assignable<_T2>::value)
2249 _T1::operator=(__p.first());
2250 _T2::operator=(__p.second());
2254 _LIBCPP_INLINE_VISIBILITY
2255 __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
2256 _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
2257 is_nothrow_move_constructible<_T2>::value)
2258 : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {}
2260 _LIBCPP_INLINE_VISIBILITY
2261 __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
2262 _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
2263 is_nothrow_move_assignable<_T2>::value)
2265 _T1::operator=(_VSTD::move(__p.first()));
2266 _T2::operator=(_VSTD::move(__p.second()));
2270 #endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
2272 #ifndef _LIBCPP_HAS_NO_VARIADICS
2274 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
2275 _LIBCPP_INLINE_VISIBILITY
2276 __libcpp_compressed_pair_imp(piecewise_construct_t __pc,
2277 tuple<_Args1...> __first_args,
2278 tuple<_Args2...> __second_args,
2279 __tuple_indices<_I1...>,
2280 __tuple_indices<_I2...>)
2281 : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
2282 _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
2285 #endif // _LIBCPP_HAS_NO_VARIADICS
2287 _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;}
2288 _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
2290 _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;}
2291 _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;}
2293 _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&)
2294 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
2295 __is_nothrow_swappable<_T2>::value)
2300 template <class _T1, class _T2>
2301 class __compressed_pair
2302 : private __libcpp_compressed_pair_imp<_T1, _T2>
2304 typedef __libcpp_compressed_pair_imp<_T1, _T2> base;
2306 typedef typename base::_T1_param _T1_param;
2307 typedef typename base::_T2_param _T2_param;
2309 typedef typename base::_T1_reference _T1_reference;
2310 typedef typename base::_T2_reference _T2_reference;
2312 typedef typename base::_T1_const_reference _T1_const_reference;
2313 typedef typename base::_T2_const_reference _T2_const_reference;
2315 _LIBCPP_INLINE_VISIBILITY __compressed_pair() {}
2316 _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1)
2317 : base(_VSTD::forward<_T1_param>(__t1)) {}
2318 _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2)
2319 : base(_VSTD::forward<_T2_param>(__t2)) {}
2320 _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2)
2321 : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {}
2323 #if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
2325 _LIBCPP_INLINE_VISIBILITY
2326 __compressed_pair(const __compressed_pair& __p)
2327 _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
2328 is_nothrow_copy_constructible<_T2>::value)
2331 _LIBCPP_INLINE_VISIBILITY
2332 __compressed_pair& operator=(const __compressed_pair& __p)
2333 _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
2334 is_nothrow_copy_assignable<_T2>::value)
2336 base::operator=(__p);
2340 _LIBCPP_INLINE_VISIBILITY
2341 __compressed_pair(__compressed_pair&& __p)
2342 _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
2343 is_nothrow_move_constructible<_T2>::value)
2344 : base(_VSTD::move(__p)) {}
2346 _LIBCPP_INLINE_VISIBILITY
2347 __compressed_pair& operator=(__compressed_pair&& __p)
2348 _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
2349 is_nothrow_move_assignable<_T2>::value)
2351 base::operator=(_VSTD::move(__p));
2355 #endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
2357 #ifndef _LIBCPP_HAS_NO_VARIADICS
2359 template <class... _Args1, class... _Args2>
2360 _LIBCPP_INLINE_VISIBILITY
2361 __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
2362 tuple<_Args2...> __second_args)
2363 : base(__pc, _VSTD::move(__first_args), _VSTD::move(__second_args),
2364 typename __make_tuple_indices<sizeof...(_Args1)>::type(),
2365 typename __make_tuple_indices<sizeof...(_Args2) >::type())
2368 #endif // _LIBCPP_HAS_NO_VARIADICS
2370 _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return base::first();}
2371 _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();}
2373 _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return base::second();}
2374 _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();}
2376 _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x)
2377 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
2378 __is_nothrow_swappable<_T2>::value)
2382 template <class _T1, class _T2>
2383 inline _LIBCPP_INLINE_VISIBILITY
2385 swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
2386 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
2387 __is_nothrow_swappable<_T2>::value)
2390 // __same_or_less_cv_qualified
2392 template <class _Ptr1, class _Ptr2,
2393 bool = is_same<typename remove_cv<typename pointer_traits<_Ptr1>::element_type>::type,
2394 typename remove_cv<typename pointer_traits<_Ptr2>::element_type>::type
2397 struct __same_or_less_cv_qualified_imp
2398 : is_convertible<_Ptr1, _Ptr2> {};
2400 template <class _Ptr1, class _Ptr2>
2401 struct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false>
2404 template <class _Ptr1, class _Ptr2, bool = is_pointer<_Ptr1>::value ||
2405 is_same<_Ptr1, _Ptr2>::value ||
2406 __has_element_type<_Ptr1>::value>
2407 struct __same_or_less_cv_qualified
2408 : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {};
2410 template <class _Ptr1, class _Ptr2>
2411 struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false>
2416 template <class _Tp>
2417 struct _LIBCPP_TYPE_VIS_ONLY default_delete
2419 #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2420 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
2422 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {}
2424 template <class _Up>
2425 _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&,
2426 typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
2427 _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT
2429 static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type");
2430 static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type");
2435 template <class _Tp>
2436 struct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]>
2439 #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2440 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
2442 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {}
2444 template <class _Up>
2445 _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&,
2446 typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
2447 template <class _Up>
2448 _LIBCPP_INLINE_VISIBILITY
2449 void operator() (_Up* __ptr,
2450 typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT
2452 static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type");
2453 static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type");
2458 template <class _Tp, class _Dp = default_delete<_Tp> >
2459 class _LIBCPP_TYPE_VIS_ONLY unique_ptr
2462 typedef _Tp element_type;
2463 typedef _Dp deleter_type;
2464 typedef typename __pointer_type<_Tp, deleter_type>::type pointer;
2466 __compressed_pair<pointer, deleter_type> __ptr_;
2468 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2469 unique_ptr(unique_ptr&);
2470 template <class _Up, class _Ep>
2471 unique_ptr(unique_ptr<_Up, _Ep>&);
2472 unique_ptr& operator=(unique_ptr&);
2473 template <class _Up, class _Ep>
2474 unique_ptr& operator=(unique_ptr<_Up, _Ep>&);
2475 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2477 struct __nat {int __for_bool_;};
2479 typedef typename remove_reference<deleter_type>::type& _Dp_reference;
2480 typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference;
2482 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT
2485 static_assert(!is_pointer<deleter_type>::value,
2486 "unique_ptr constructed with null function pointer deleter");
2488 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT
2491 static_assert(!is_pointer<deleter_type>::value,
2492 "unique_ptr constructed with null function pointer deleter");
2494 _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT
2495 : __ptr_(_VSTD::move(__p))
2497 static_assert(!is_pointer<deleter_type>::value,
2498 "unique_ptr constructed with null function pointer deleter");
2501 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2502 _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional<
2503 is_reference<deleter_type>::value,
2505 typename add_lvalue_reference<const deleter_type>::type>::type __d)
2507 : __ptr_(__p, __d) {}
2509 _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d)
2511 : __ptr_(__p, _VSTD::move(__d))
2513 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
2515 _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT
2516 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
2517 template <class _Up, class _Ep>
2518 _LIBCPP_INLINE_VISIBILITY
2519 unique_ptr(unique_ptr<_Up, _Ep>&& __u,
2522 !is_array<_Up>::value &&
2523 is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value &&
2524 is_convertible<_Ep, deleter_type>::value &&
2526 !is_reference<deleter_type>::value ||
2527 is_same<deleter_type, _Ep>::value
2530 >::type = __nat()) _NOEXCEPT
2531 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
2533 template <class _Up>
2534 _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p,
2536 is_convertible<_Up*, _Tp*>::value &&
2537 is_same<_Dp, default_delete<_Tp> >::value,
2539 >::type = __nat()) _NOEXCEPT
2540 : __ptr_(__p.release())
2544 _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT
2546 reset(__u.release());
2547 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
2551 template <class _Up, class _Ep>
2552 _LIBCPP_INLINE_VISIBILITY
2555 !is_array<_Up>::value &&
2556 is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value &&
2557 is_assignable<deleter_type&, _Ep&&>::value,
2560 operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
2562 reset(__u.release());
2563 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
2566 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2568 _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>()
2570 return __rv<unique_ptr>(*this);
2573 _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u)
2574 : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {}
2576 template <class _Up, class _Ep>
2577 _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u)
2579 reset(__u.release());
2580 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
2584 _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d)
2585 : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {}
2587 template <class _Up>
2588 _LIBCPP_INLINE_VISIBILITY
2590 is_convertible<_Up*, _Tp*>::value &&
2591 is_same<_Dp, default_delete<_Tp> >::value,
2594 operator=(auto_ptr<_Up> __p)
2595 {reset(__p.release()); return *this;}
2597 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2598 _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();}
2600 _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT
2606 _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const
2607 {return *__ptr_.first();}
2608 _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();}
2609 _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();}
2610 _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT
2611 {return __ptr_.second();}
2612 _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT
2613 {return __ptr_.second();}
2614 _LIBCPP_INLINE_VISIBILITY
2615 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
2616 {return __ptr_.first() != nullptr;}
2618 _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
2620 pointer __t = __ptr_.first();
2621 __ptr_.first() = pointer();
2625 _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT
2627 pointer __tmp = __ptr_.first();
2628 __ptr_.first() = __p;
2630 __ptr_.second()(__tmp);
2633 _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT
2634 {__ptr_.swap(__u.__ptr_);}
2637 template <class _Tp, class _Dp>
2638 class _LIBCPP_TYPE_VIS_ONLY unique_ptr<_Tp[], _Dp>
2641 typedef _Tp element_type;
2642 typedef _Dp deleter_type;
2643 typedef typename __pointer_type<_Tp, deleter_type>::type pointer;
2645 __compressed_pair<pointer, deleter_type> __ptr_;
2647 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2648 unique_ptr(unique_ptr&);
2649 template <class _Up>
2650 unique_ptr(unique_ptr<_Up>&);
2651 unique_ptr& operator=(unique_ptr&);
2652 template <class _Up>
2653 unique_ptr& operator=(unique_ptr<_Up>&);
2654 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2656 struct __nat {int __for_bool_;};
2658 typedef typename remove_reference<deleter_type>::type& _Dp_reference;
2659 typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference;
2661 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT
2664 static_assert(!is_pointer<deleter_type>::value,
2665 "unique_ptr constructed with null function pointer deleter");
2667 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT
2670 static_assert(!is_pointer<deleter_type>::value,
2671 "unique_ptr constructed with null function pointer deleter");
2673 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2674 template <class _Pp>
2675 _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p,
2676 typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT
2679 static_assert(!is_pointer<deleter_type>::value,
2680 "unique_ptr constructed with null function pointer deleter");
2683 template <class _Pp>
2684 _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional<
2685 is_reference<deleter_type>::value,
2687 typename add_lvalue_reference<const deleter_type>::type>::type __d,
2688 typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat())
2690 : __ptr_(__p, __d) {}
2692 _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional<
2693 is_reference<deleter_type>::value,
2695 typename add_lvalue_reference<const deleter_type>::type>::type __d)
2697 : __ptr_(pointer(), __d) {}
2699 template <class _Pp>
2700 _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p,
2701 typename remove_reference<deleter_type>::type&& __d,
2702 typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat())
2704 : __ptr_(__p, _VSTD::move(__d))
2706 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
2709 _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d)
2711 : __ptr_(pointer(), _VSTD::move(__d))
2713 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
2716 _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT
2717 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
2719 _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT
2721 reset(__u.release());
2722 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
2726 template <class _Up, class _Ep>
2727 _LIBCPP_INLINE_VISIBILITY
2728 unique_ptr(unique_ptr<_Up, _Ep>&& __u,
2731 is_array<_Up>::value &&
2732 __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value
2733 && is_convertible<_Ep, deleter_type>::value &&
2735 !is_reference<deleter_type>::value ||
2736 is_same<deleter_type, _Ep>::value
2741 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
2744 template <class _Up, class _Ep>
2745 _LIBCPP_INLINE_VISIBILITY
2748 is_array<_Up>::value &&
2749 __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value &&
2750 is_assignable<deleter_type&, _Ep&&>::value,
2753 operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
2755 reset(__u.release());
2756 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
2759 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2761 _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p)
2764 static_assert(!is_pointer<deleter_type>::value,
2765 "unique_ptr constructed with null function pointer deleter");
2768 _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d)
2769 : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {}
2771 _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d)
2772 : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {}
2774 _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>()
2776 return __rv<unique_ptr>(*this);
2779 _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u)
2780 : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {}
2782 _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u)
2784 reset(__u->release());
2785 __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter());
2789 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2790 _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();}
2792 _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT
2798 _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const
2799 {return __ptr_.first()[__i];}
2800 _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();}
2801 _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT
2802 {return __ptr_.second();}
2803 _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT
2804 {return __ptr_.second();}
2805 _LIBCPP_INLINE_VISIBILITY
2806 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
2807 {return __ptr_.first() != nullptr;}
2809 _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
2811 pointer __t = __ptr_.first();
2812 __ptr_.first() = pointer();
2816 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2817 template <class _Pp>
2818 _LIBCPP_INLINE_VISIBILITY
2819 typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type
2820 reset(_Pp __p) _NOEXCEPT
2822 pointer __tmp = __ptr_.first();
2823 __ptr_.first() = __p;
2825 __ptr_.second()(__tmp);
2827 _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT
2829 pointer __tmp = __ptr_.first();
2830 __ptr_.first() = nullptr;
2832 __ptr_.second()(__tmp);
2834 _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT
2836 pointer __tmp = __ptr_.first();
2837 __ptr_.first() = nullptr;
2839 __ptr_.second()(__tmp);
2841 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2842 _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer())
2844 pointer __tmp = __ptr_.first();
2845 __ptr_.first() = __p;
2847 __ptr_.second()(__tmp);
2849 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2851 _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);}
2854 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2855 template <class _Up>
2856 explicit unique_ptr(_Up);
2857 template <class _Up>
2859 typename conditional<
2860 is_reference<deleter_type>::value,
2862 typename add_lvalue_reference<const deleter_type>::type>::type,
2865 is_convertible<_Up, pointer>::value,
2868 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2871 template <class _Tp, class _Dp>
2872 inline _LIBCPP_INLINE_VISIBILITY
2874 swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
2876 template <class _T1, class _D1, class _T2, class _D2>
2877 inline _LIBCPP_INLINE_VISIBILITY
2879 operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();}
2881 template <class _T1, class _D1, class _T2, class _D2>
2882 inline _LIBCPP_INLINE_VISIBILITY
2884 operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);}
2886 template <class _T1, class _D1, class _T2, class _D2>
2887 inline _LIBCPP_INLINE_VISIBILITY
2889 operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y)
2891 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
2892 typedef typename unique_ptr<_T2, _D2>::pointer _P2;
2893 typedef typename common_type<_P1, _P2>::type _V;
2894 return less<_V>()(__x.get(), __y.get());
2897 template <class _T1, class _D1, class _T2, class _D2>
2898 inline _LIBCPP_INLINE_VISIBILITY
2900 operator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;}
2902 template <class _T1, class _D1, class _T2, class _D2>
2903 inline _LIBCPP_INLINE_VISIBILITY
2905 operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);}
2907 template <class _T1, class _D1, class _T2, class _D2>
2908 inline _LIBCPP_INLINE_VISIBILITY
2910 operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);}
2912 template <class _T1, class _D1>
2913 inline _LIBCPP_INLINE_VISIBILITY
2915 operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
2920 template <class _T1, class _D1>
2921 inline _LIBCPP_INLINE_VISIBILITY
2923 operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
2928 template <class _T1, class _D1>
2929 inline _LIBCPP_INLINE_VISIBILITY
2931 operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
2933 return static_cast<bool>(__x);
2936 template <class _T1, class _D1>
2937 inline _LIBCPP_INLINE_VISIBILITY
2939 operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
2941 return static_cast<bool>(__x);
2944 template <class _T1, class _D1>
2945 inline _LIBCPP_INLINE_VISIBILITY
2947 operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t)
2949 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
2950 return less<_P1>()(__x.get(), nullptr);
2953 template <class _T1, class _D1>
2954 inline _LIBCPP_INLINE_VISIBILITY
2956 operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x)
2958 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
2959 return less<_P1>()(nullptr, __x.get());
2962 template <class _T1, class _D1>
2963 inline _LIBCPP_INLINE_VISIBILITY
2965 operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t)
2967 return nullptr < __x;
2970 template <class _T1, class _D1>
2971 inline _LIBCPP_INLINE_VISIBILITY
2973 operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x)
2975 return __x < nullptr;
2978 template <class _T1, class _D1>
2979 inline _LIBCPP_INLINE_VISIBILITY
2981 operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
2983 return !(nullptr < __x);
2986 template <class _T1, class _D1>
2987 inline _LIBCPP_INLINE_VISIBILITY
2989 operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
2991 return !(__x < nullptr);
2994 template <class _T1, class _D1>
2995 inline _LIBCPP_INLINE_VISIBILITY
2997 operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
2999 return !(__x < nullptr);
3002 template <class _T1, class _D1>
3003 inline _LIBCPP_INLINE_VISIBILITY
3005 operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
3007 return !(nullptr < __x);
3010 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3012 template <class _Tp, class _Dp>
3013 inline _LIBCPP_INLINE_VISIBILITY
3014 unique_ptr<_Tp, _Dp>
3015 move(unique_ptr<_Tp, _Dp>& __t)
3017 return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t));
3022 #if _LIBCPP_STD_VER > 11
3027 typedef unique_ptr<_Tp> __unique_single;
3031 struct __unique_if<_Tp[]>
3033 typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
3036 template<class _Tp, size_t _Np>
3037 struct __unique_if<_Tp[_Np]>
3039 typedef void __unique_array_known_bound;
3042 template<class _Tp, class... _Args>
3043 inline _LIBCPP_INLINE_VISIBILITY
3044 typename __unique_if<_Tp>::__unique_single
3045 make_unique(_Args&&... __args)
3047 return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
3051 inline _LIBCPP_INLINE_VISIBILITY
3052 typename __unique_if<_Tp>::__unique_array_unknown_bound
3053 make_unique(size_t __n)
3055 typedef typename remove_extent<_Tp>::type _Up;
3056 return unique_ptr<_Tp>(new _Up[__n]());
3059 template<class _Tp, class... _Args>
3060 typename __unique_if<_Tp>::__unique_array_known_bound
3061 make_unique(_Args&&...) = delete;
3063 #endif // _LIBCPP_STD_VER > 11
3065 template <class _Tp> struct hash;
3067 template <class _Size>
3068 inline _LIBCPP_INLINE_VISIBILITY
3070 __loadword(const void* __p)
3073 std::memcpy(&__r, __p, sizeof(__r));
3077 // We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
3078 // is 64 bits. This is because cityhash64 uses 64bit x 64bit
3079 // multiplication, which can be very slow on 32-bit systems.
3080 template <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__>
3081 struct __murmur2_or_cityhash;
3083 template <class _Size>
3084 struct __murmur2_or_cityhash<_Size, 32>
3086 _Size operator()(const void* __key, _Size __len);
3090 template <class _Size>
3092 __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
3094 const _Size __m = 0x5bd1e995;
3095 const _Size __r = 24;
3097 const unsigned char* __data = static_cast<const unsigned char*>(__key);
3098 for (; __len >= 4; __data += 4, __len -= 4)
3100 _Size __k = __loadword<_Size>(__data);
3110 __h ^= __data[2] << 16;
3112 __h ^= __data[1] << 8;
3123 template <class _Size>
3124 struct __murmur2_or_cityhash<_Size, 64>
3126 _Size operator()(const void* __key, _Size __len);
3129 // Some primes between 2^63 and 2^64.
3130 static const _Size __k0 = 0xc3a5c85c97cb3127ULL;
3131 static const _Size __k1 = 0xb492b66fbe98f273ULL;
3132 static const _Size __k2 = 0x9ae16a3b2f90404fULL;
3133 static const _Size __k3 = 0xc949d7c7509e6557ULL;
3135 static _Size __rotate(_Size __val, int __shift) {
3136 return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift)));
3139 static _Size __rotate_by_at_least_1(_Size __val, int __shift) {
3140 return (__val >> __shift) | (__val << (64 - __shift));
3143 static _Size __shift_mix(_Size __val) {
3144 return __val ^ (__val >> 47);
3147 static _Size __hash_len_16(_Size __u, _Size __v) {
3148 const _Size __mul = 0x9ddfea08eb382d69ULL;
3149 _Size __a = (__u ^ __v) * __mul;
3151 _Size __b = (__v ^ __a) * __mul;
3157 static _Size __hash_len_0_to_16(const char* __s, _Size __len) {
3159 const _Size __a = __loadword<_Size>(__s);
3160 const _Size __b = __loadword<_Size>(__s + __len - 8);
3161 return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
3164 const uint32_t __a = __loadword<uint32_t>(__s);
3165 const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);
3166 return __hash_len_16(__len + (__a << 3), __b);
3169 const unsigned char __a = __s[0];
3170 const unsigned char __b = __s[__len >> 1];
3171 const unsigned char __c = __s[__len - 1];
3172 const uint32_t __y = static_cast<uint32_t>(__a) +
3173 (static_cast<uint32_t>(__b) << 8);
3174 const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2);
3175 return __shift_mix(__y * __k2 ^ __z * __k3) * __k2;
3180 static _Size __hash_len_17_to_32(const char *__s, _Size __len) {
3181 const _Size __a = __loadword<_Size>(__s) * __k1;
3182 const _Size __b = __loadword<_Size>(__s + 8);
3183 const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2;
3184 const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0;
3185 return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,
3186 __a + __rotate(__b ^ __k3, 20) - __c + __len);
3189 // Return a 16-byte hash for 48 bytes. Quick and dirty.
3190 // Callers do best to use "random-looking" values for a and b.
3191 static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
3192 _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) {
3194 __b = __rotate(__b + __a + __z, 21);
3195 const _Size __c = __a;
3198 __b += __rotate(__a, 44);
3199 return pair<_Size, _Size>(__a + __z, __b + __c);
3202 // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
3203 static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
3204 const char* __s, _Size __a, _Size __b) {
3205 return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s),
3206 __loadword<_Size>(__s + 8),
3207 __loadword<_Size>(__s + 16),
3208 __loadword<_Size>(__s + 24),
3213 // Return an 8-byte hash for 33 to 64 bytes.
3214 static _Size __hash_len_33_to_64(const char *__s, size_t __len) {
3215 _Size __z = __loadword<_Size>(__s + 24);
3216 _Size __a = __loadword<_Size>(__s) +
3217 (__len + __loadword<_Size>(__s + __len - 16)) * __k0;
3218 _Size __b = __rotate(__a + __z, 52);
3219 _Size __c = __rotate(__a, 37);
3220 __a += __loadword<_Size>(__s + 8);
3221 __c += __rotate(__a, 7);
3222 __a += __loadword<_Size>(__s + 16);
3223 _Size __vf = __a + __z;
3224 _Size __vs = __b + __rotate(__a, 31) + __c;
3225 __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32);
3226 __z += __loadword<_Size>(__s + __len - 8);
3227 __b = __rotate(__a + __z, 52);
3228 __c = __rotate(__a, 37);
3229 __a += __loadword<_Size>(__s + __len - 24);
3230 __c += __rotate(__a, 7);
3231 __a += __loadword<_Size>(__s + __len - 16);
3232 _Size __wf = __a + __z;
3233 _Size __ws = __b + __rotate(__a, 31) + __c;
3234 _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);
3235 return __shift_mix(__r * __k0 + __vs) * __k2;
3240 template <class _Size>
3242 __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
3244 const char* __s = static_cast<const char*>(__key);
3247 return __hash_len_0_to_16(__s, __len);
3249 return __hash_len_17_to_32(__s, __len);
3251 } else if (__len <= 64) {
3252 return __hash_len_33_to_64(__s, __len);
3255 // For strings over 64 bytes we hash the end first, and then as we
3256 // loop we keep 56 bytes of state: v, w, x, y, and z.
3257 _Size __x = __loadword<_Size>(__s + __len - 40);
3258 _Size __y = __loadword<_Size>(__s + __len - 16) +
3259 __loadword<_Size>(__s + __len - 56);
3260 _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len,
3261 __loadword<_Size>(__s + __len - 24));
3262 pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
3263 pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
3264 __x = __x * __k1 + __loadword<_Size>(__s);
3266 // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
3267 __len = (__len - 1) & ~static_cast<_Size>(63);
3269 __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1;
3270 __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1;
3272 __y += __v.first + __loadword<_Size>(__s + 40);
3273 __z = __rotate(__z + __w.first, 33) * __k1;
3274 __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
3275 __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
3276 __y + __loadword<_Size>(__s + 16));
3277 std::swap(__z, __x);
3280 } while (__len != 0);
3281 return __hash_len_16(
3282 __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z,
3283 __hash_len_16(__v.second, __w.second) + __x);
3286 template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
3287 struct __scalar_hash;
3289 template <class _Tp>
3290 struct __scalar_hash<_Tp, 0>
3291 : public unary_function<_Tp, size_t>
3293 _LIBCPP_INLINE_VISIBILITY
3294 size_t operator()(_Tp __v) const _NOEXCEPT
3307 template <class _Tp>
3308 struct __scalar_hash<_Tp, 1>
3309 : public unary_function<_Tp, size_t>
3311 _LIBCPP_INLINE_VISIBILITY
3312 size_t operator()(_Tp __v) const _NOEXCEPT
3324 template <class _Tp>
3325 struct __scalar_hash<_Tp, 2>
3326 : public unary_function<_Tp, size_t>
3328 _LIBCPP_INLINE_VISIBILITY
3329 size_t operator()(_Tp __v) const _NOEXCEPT
3341 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
3345 template <class _Tp>
3346 struct __scalar_hash<_Tp, 3>
3347 : public unary_function<_Tp, size_t>
3349 _LIBCPP_INLINE_VISIBILITY
3350 size_t operator()(_Tp __v) const _NOEXCEPT
3363 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
3367 template <class _Tp>
3368 struct __scalar_hash<_Tp, 4>
3369 : public unary_function<_Tp, size_t>
3371 _LIBCPP_INLINE_VISIBILITY
3372 size_t operator()(_Tp __v) const _NOEXCEPT
3386 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
3391 struct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*>
3392 : public unary_function<_Tp*, size_t>
3394 _LIBCPP_INLINE_VISIBILITY
3395 size_t operator()(_Tp* __v) const _NOEXCEPT
3403 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
3407 template <class _Tp, class _Dp>
3408 struct _LIBCPP_TYPE_VIS_ONLY hash<unique_ptr<_Tp, _Dp> >
3410 typedef unique_ptr<_Tp, _Dp> argument_type;
3411 typedef size_t result_type;
3412 _LIBCPP_INLINE_VISIBILITY
3413 result_type operator()(const argument_type& __ptr) const _NOEXCEPT
3415 typedef typename argument_type::pointer pointer;
3416 return hash<pointer>()(__ptr.get());
3425 template <class _Tp>
3426 _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT
3427 {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();}
3429 template <class _Tp>
3430 _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT
3433 _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT
3435 _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT
3438 _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT
3440 _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT
3443 _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT
3446 template <class _Tp>
3447 _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT
3448 {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
3450 template <class _Tp>
3451 _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT
3452 {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
3454 template <class _Tp>
3455 _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT
3456 {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
3459 template <class _Alloc>
3460 class __allocator_destructor
3462 typedef allocator_traits<_Alloc> __alloc_traits;
3464 typedef typename __alloc_traits::pointer pointer;
3465 typedef typename __alloc_traits::size_type size_type;
3470 _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s)
3472 : __alloc_(__a), __s_(__s) {}
3473 _LIBCPP_INLINE_VISIBILITY
3474 void operator()(pointer __p) _NOEXCEPT
3475 {__alloc_traits::deallocate(__alloc_, __p, __s_);}
3478 template <class _InputIterator, class _ForwardIterator>
3480 uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
3482 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
3483 #ifndef _LIBCPP_NO_EXCEPTIONS
3484 _ForwardIterator __s = __r;
3488 for (; __f != __l; ++__f, ++__r)
3489 ::new(&*__r) value_type(*__f);
3490 #ifndef _LIBCPP_NO_EXCEPTIONS
3494 for (; __s != __r; ++__s)
3502 template <class _InputIterator, class _Size, class _ForwardIterator>
3504 uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
3506 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
3507 #ifndef _LIBCPP_NO_EXCEPTIONS
3508 _ForwardIterator __s = __r;
3512 for (; __n > 0; ++__f, ++__r, --__n)
3513 ::new(&*__r) value_type(*__f);
3514 #ifndef _LIBCPP_NO_EXCEPTIONS
3518 for (; __s != __r; ++__s)
3526 template <class _ForwardIterator, class _Tp>
3528 uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
3530 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
3531 #ifndef _LIBCPP_NO_EXCEPTIONS
3532 _ForwardIterator __s = __f;
3536 for (; __f != __l; ++__f)
3537 ::new(&*__f) value_type(__x);
3538 #ifndef _LIBCPP_NO_EXCEPTIONS
3542 for (; __s != __f; ++__s)
3549 template <class _ForwardIterator, class _Size, class _Tp>
3551 uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
3553 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
3554 #ifndef _LIBCPP_NO_EXCEPTIONS
3555 _ForwardIterator __s = __f;
3559 for (; __n > 0; ++__f, --__n)
3560 ::new(&*__f) value_type(__x);
3561 #ifndef _LIBCPP_NO_EXCEPTIONS
3565 for (; __s != __f; ++__s)
3573 class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
3574 : public std::exception
3577 virtual ~bad_weak_ptr() _NOEXCEPT;
3578 virtual const char* what() const _NOEXCEPT;
3581 template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
3583 class _LIBCPP_TYPE_VIS __shared_count
3585 __shared_count(const __shared_count&);
3586 __shared_count& operator=(const __shared_count&);
3589 long __shared_owners_;
3590 virtual ~__shared_count();
3592 virtual void __on_zero_shared() _NOEXCEPT = 0;
3595 _LIBCPP_INLINE_VISIBILITY
3596 explicit __shared_count(long __refs = 0) _NOEXCEPT
3597 : __shared_owners_(__refs) {}
3599 void __add_shared() _NOEXCEPT;
3600 bool __release_shared() _NOEXCEPT;
3601 _LIBCPP_INLINE_VISIBILITY
3602 long use_count() const _NOEXCEPT {return __shared_owners_ + 1;}
3605 class _LIBCPP_TYPE_VIS __shared_weak_count
3606 : private __shared_count
3608 long __shared_weak_owners_;
3611 _LIBCPP_INLINE_VISIBILITY
3612 explicit __shared_weak_count(long __refs = 0) _NOEXCEPT
3613 : __shared_count(__refs),
3614 __shared_weak_owners_(__refs) {}
3616 virtual ~__shared_weak_count();
3619 void __add_shared() _NOEXCEPT;
3620 void __add_weak() _NOEXCEPT;
3621 void __release_shared() _NOEXCEPT;
3622 void __release_weak() _NOEXCEPT;
3623 _LIBCPP_INLINE_VISIBILITY
3624 long use_count() const _NOEXCEPT {return __shared_count::use_count();}
3625 __shared_weak_count* lock() _NOEXCEPT;
3627 // Define the function out only if we build static libc++ without RTTI.
3628 // Otherwise we may break clients who need to compile their projects with
3629 // -fno-rtti and yet link against a libc++.dylib compiled
3630 // without -fno-rtti.
3631 #if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
3632 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
3635 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
3638 template <class _Tp, class _Dp, class _Alloc>
3639 class __shared_ptr_pointer
3640 : public __shared_weak_count
3642 __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_;
3644 _LIBCPP_INLINE_VISIBILITY
3645 __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)
3646 : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {}
3648 #ifndef _LIBCPP_NO_RTTI
3649 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
3653 virtual void __on_zero_shared() _NOEXCEPT;
3654 virtual void __on_zero_shared_weak() _NOEXCEPT;
3657 #ifndef _LIBCPP_NO_RTTI
3659 template <class _Tp, class _Dp, class _Alloc>
3661 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT
3663 return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : 0;
3666 #endif // _LIBCPP_NO_RTTI
3668 template <class _Tp, class _Dp, class _Alloc>
3670 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT
3672 __data_.first().second()(__data_.first().first());
3673 __data_.first().second().~_Dp();
3676 template <class _Tp, class _Dp, class _Alloc>
3678 __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
3680 typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _A;
3681 typedef allocator_traits<_A> _ATraits;
3682 typedef pointer_traits<typename _ATraits::pointer> _PTraits;
3684 _A __a(__data_.second());
3685 __data_.second().~_Alloc();
3686 __a.deallocate(_PTraits::pointer_to(*this), 1);
3689 template <class _Tp, class _Alloc>
3690 class __shared_ptr_emplace
3691 : public __shared_weak_count
3693 __compressed_pair<_Alloc, _Tp> __data_;
3695 #ifndef _LIBCPP_HAS_NO_VARIADICS
3697 _LIBCPP_INLINE_VISIBILITY
3698 __shared_ptr_emplace(_Alloc __a)
3699 : __data_(_VSTD::move(__a)) {}
3701 template <class ..._Args>
3702 _LIBCPP_INLINE_VISIBILITY
3703 __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
3704 : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),
3705 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {}
3707 #else // _LIBCPP_HAS_NO_VARIADICS
3709 _LIBCPP_INLINE_VISIBILITY
3710 __shared_ptr_emplace(_Alloc __a)
3713 template <class _A0>
3714 _LIBCPP_INLINE_VISIBILITY
3715 __shared_ptr_emplace(_Alloc __a, _A0& __a0)
3716 : __data_(__a, _Tp(__a0)) {}
3718 template <class _A0, class _A1>
3719 _LIBCPP_INLINE_VISIBILITY
3720 __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1)
3721 : __data_(__a, _Tp(__a0, __a1)) {}
3723 template <class _A0, class _A1, class _A2>
3724 _LIBCPP_INLINE_VISIBILITY
3725 __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2)
3726 : __data_(__a, _Tp(__a0, __a1, __a2)) {}
3728 #endif // _LIBCPP_HAS_NO_VARIADICS
3731 virtual void __on_zero_shared() _NOEXCEPT;
3732 virtual void __on_zero_shared_weak() _NOEXCEPT;
3734 _LIBCPP_INLINE_VISIBILITY
3735 _Tp* get() _NOEXCEPT {return &__data_.second();}
3738 template <class _Tp, class _Alloc>
3740 __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT
3742 __data_.second().~_Tp();
3745 template <class _Tp, class _Alloc>
3747 __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
3749 typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _A;
3750 typedef allocator_traits<_A> _ATraits;
3751 typedef pointer_traits<typename _ATraits::pointer> _PTraits;
3752 _A __a(__data_.first());
3753 __data_.first().~_Alloc();
3754 __a.deallocate(_PTraits::pointer_to(*this), 1);
3757 template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this;
3760 class _LIBCPP_TYPE_VIS_ONLY shared_ptr
3763 typedef _Tp element_type;
3765 element_type* __ptr_;
3766 __shared_weak_count* __cntrl_;
3768 struct __nat {int __for_bool_;};
3770 _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT;
3771 _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
3773 explicit shared_ptr(_Yp* __p,
3774 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
3775 template<class _Yp, class _Dp>
3776 shared_ptr(_Yp* __p, _Dp __d,
3777 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
3778 template<class _Yp, class _Dp, class _Alloc>
3779 shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
3780 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
3781 template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d);
3782 template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a);
3783 template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT;
3784 shared_ptr(const shared_ptr& __r) _NOEXCEPT;
3786 shared_ptr(const shared_ptr<_Yp>& __r,
3787 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat())
3789 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3790 shared_ptr(shared_ptr&& __r) _NOEXCEPT;
3791 template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r,
3792 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat())
3794 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3795 template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
3796 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat());
3797 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3799 shared_ptr(auto_ptr<_Yp>&& __r,
3800 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
3803 shared_ptr(auto_ptr<_Yp> __r,
3804 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
3806 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3807 template <class _Yp, class _Dp>
3808 shared_ptr(unique_ptr<_Yp, _Dp>&&,
3811 !is_lvalue_reference<_Dp>::value &&
3812 !is_array<_Yp>::value &&
3813 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
3816 template <class _Yp, class _Dp>
3817 shared_ptr(unique_ptr<_Yp, _Dp>&&,
3820 is_lvalue_reference<_Dp>::value &&
3821 !is_array<_Yp>::value &&
3822 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
3825 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3826 template <class _Yp, class _Dp>
3827 shared_ptr(unique_ptr<_Yp, _Dp>,
3830 !is_lvalue_reference<_Dp>::value &&
3831 !is_array<_Yp>::value &&
3832 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
3835 template <class _Yp, class _Dp>
3836 shared_ptr(unique_ptr<_Yp, _Dp>,
3839 is_lvalue_reference<_Dp>::value &&
3840 !is_array<_Yp>::value &&
3841 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
3844 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3848 shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT;
3852 is_convertible<_Yp*, element_type*>::value,
3855 operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
3856 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3857 shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
3861 is_convertible<_Yp*, element_type*>::value,
3864 operator=(shared_ptr<_Yp>&& __r);
3868 !is_array<_Yp>::value &&
3869 is_convertible<_Yp*, element_type*>::value,
3872 operator=(auto_ptr<_Yp>&& __r);
3873 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3877 !is_array<_Yp>::value &&
3878 is_convertible<_Yp*, element_type*>::value,
3881 operator=(auto_ptr<_Yp> __r);
3883 template <class _Yp, class _Dp>
3886 !is_array<_Yp>::value &&
3887 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
3890 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3891 operator=(unique_ptr<_Yp, _Dp>&& __r);
3892 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3893 operator=(unique_ptr<_Yp, _Dp> __r);
3896 void swap(shared_ptr& __r) _NOEXCEPT;
3897 void reset() _NOEXCEPT;
3901 is_convertible<_Yp*, element_type*>::value,
3905 template<class _Yp, class _Dp>
3908 is_convertible<_Yp*, element_type*>::value,
3911 reset(_Yp* __p, _Dp __d);
3912 template<class _Yp, class _Dp, class _Alloc>
3915 is_convertible<_Yp*, element_type*>::value,
3918 reset(_Yp* __p, _Dp __d, _Alloc __a);
3920 _LIBCPP_INLINE_VISIBILITY
3921 element_type* get() const _NOEXCEPT {return __ptr_;}
3922 _LIBCPP_INLINE_VISIBILITY
3923 typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT
3925 _LIBCPP_INLINE_VISIBILITY
3926 element_type* operator->() const _NOEXCEPT {return __ptr_;}
3927 _LIBCPP_INLINE_VISIBILITY
3928 long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;}
3929 _LIBCPP_INLINE_VISIBILITY
3930 bool unique() const _NOEXCEPT {return use_count() == 1;}
3931 _LIBCPP_INLINE_VISIBILITY
3932 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;}
3933 template <class _Up>
3934 _LIBCPP_INLINE_VISIBILITY
3935 bool owner_before(shared_ptr<_Up> const& __p) const
3936 {return __cntrl_ < __p.__cntrl_;}
3937 template <class _Up>
3938 _LIBCPP_INLINE_VISIBILITY
3939 bool owner_before(weak_ptr<_Up> const& __p) const
3940 {return __cntrl_ < __p.__cntrl_;}
3941 _LIBCPP_INLINE_VISIBILITY
3943 __owner_equivalent(const shared_ptr& __p) const
3944 {return __cntrl_ == __p.__cntrl_;}
3946 #ifndef _LIBCPP_NO_RTTI
3947 template <class _Dp>
3948 _LIBCPP_INLINE_VISIBILITY
3949 _Dp* __get_deleter() const _NOEXCEPT
3950 {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);}
3951 #endif // _LIBCPP_NO_RTTI
3953 #ifndef _LIBCPP_HAS_NO_VARIADICS
3955 template<class ..._Args>
3958 make_shared(_Args&& ...__args);
3960 template<class _Alloc, class ..._Args>
3963 allocate_shared(const _Alloc& __a, _Args&& ...__args);
3965 #else // _LIBCPP_HAS_NO_VARIADICS
3967 static shared_ptr<_Tp> make_shared();
3970 static shared_ptr<_Tp> make_shared(_A0&);
3972 template<class _A0, class _A1>
3973 static shared_ptr<_Tp> make_shared(_A0&, _A1&);
3975 template<class _A0, class _A1, class _A2>
3976 static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&);
3978 template<class _Alloc>
3979 static shared_ptr<_Tp>
3980 allocate_shared(const _Alloc& __a);
3982 template<class _Alloc, class _A0>
3983 static shared_ptr<_Tp>
3984 allocate_shared(const _Alloc& __a, _A0& __a0);
3986 template<class _Alloc, class _A0, class _A1>
3987 static shared_ptr<_Tp>
3988 allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1);
3990 template<class _Alloc, class _A0, class _A1, class _A2>
3991 static shared_ptr<_Tp>
3992 allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2);
3994 #endif // _LIBCPP_HAS_NO_VARIADICS
3998 template <class _Yp>
3999 _LIBCPP_INLINE_VISIBILITY
4001 __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT
4004 __e->__weak_this_ = *this;
4007 _LIBCPP_INLINE_VISIBILITY
4008 void __enable_weak_this(const void*) _NOEXCEPT {}
4010 template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr;
4011 template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
4015 inline _LIBCPP_INLINE_VISIBILITY
4017 shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
4024 inline _LIBCPP_INLINE_VISIBILITY
4026 shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
4034 shared_ptr<_Tp>::shared_ptr(_Yp* __p,
4035 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
4038 unique_ptr<_Yp> __hold(__p);
4039 typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
4040 __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>());
4042 __enable_weak_this(__p);
4046 template<class _Yp, class _Dp>
4047 shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
4048 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
4051 #ifndef _LIBCPP_NO_EXCEPTIONS
4054 #endif // _LIBCPP_NO_EXCEPTIONS
4055 typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
4056 __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>());
4057 __enable_weak_this(__p);
4058 #ifndef _LIBCPP_NO_EXCEPTIONS
4065 #endif // _LIBCPP_NO_EXCEPTIONS
4070 shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)
4073 #ifndef _LIBCPP_NO_EXCEPTIONS
4076 #endif // _LIBCPP_NO_EXCEPTIONS
4077 typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk;
4078 __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>());
4079 #ifndef _LIBCPP_NO_EXCEPTIONS
4086 #endif // _LIBCPP_NO_EXCEPTIONS
4090 template<class _Yp, class _Dp, class _Alloc>
4091 shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
4092 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
4095 #ifndef _LIBCPP_NO_EXCEPTIONS
4098 #endif // _LIBCPP_NO_EXCEPTIONS
4099 typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;
4100 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
4101 typedef __allocator_destructor<_A2> _D2;
4103 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
4104 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
4105 _CntrlBlk(__p, __d, __a);
4106 __cntrl_ = _VSTD::addressof(*__hold2.release());
4107 __enable_weak_this(__p);
4108 #ifndef _LIBCPP_NO_EXCEPTIONS
4115 #endif // _LIBCPP_NO_EXCEPTIONS
4119 template<class _Dp, class _Alloc>
4120 shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
4123 #ifndef _LIBCPP_NO_EXCEPTIONS
4126 #endif // _LIBCPP_NO_EXCEPTIONS
4127 typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;
4128 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
4129 typedef __allocator_destructor<_A2> _D2;
4131 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
4132 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
4133 _CntrlBlk(__p, __d, __a);
4134 __cntrl_ = _VSTD::addressof(*__hold2.release());
4135 #ifndef _LIBCPP_NO_EXCEPTIONS
4142 #endif // _LIBCPP_NO_EXCEPTIONS
4147 inline _LIBCPP_INLINE_VISIBILITY
4148 shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT
4150 __cntrl_(__r.__cntrl_)
4153 __cntrl_->__add_shared();
4157 inline _LIBCPP_INLINE_VISIBILITY
4158 shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT
4159 : __ptr_(__r.__ptr_),
4160 __cntrl_(__r.__cntrl_)
4163 __cntrl_->__add_shared();
4168 inline _LIBCPP_INLINE_VISIBILITY
4169 shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,
4170 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type)
4172 : __ptr_(__r.__ptr_),
4173 __cntrl_(__r.__cntrl_)
4176 __cntrl_->__add_shared();
4179 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4182 inline _LIBCPP_INLINE_VISIBILITY
4183 shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT
4184 : __ptr_(__r.__ptr_),
4185 __cntrl_(__r.__cntrl_)
4193 inline _LIBCPP_INLINE_VISIBILITY
4194 shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
4195 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type)
4197 : __ptr_(__r.__ptr_),
4198 __cntrl_(__r.__cntrl_)
4204 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4208 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4209 shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,
4211 shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r,
4213 typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
4216 typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
4217 __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>());
4218 __enable_weak_this(__r.get());
4223 template <class _Yp, class _Dp>
4224 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4225 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
4227 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
4231 !is_lvalue_reference<_Dp>::value &&
4232 !is_array<_Yp>::value &&
4233 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
4238 typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
4239 __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
4240 __enable_weak_this(__r.get());
4245 template <class _Yp, class _Dp>
4246 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4247 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
4249 shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
4253 is_lvalue_reference<_Dp>::value &&
4254 !is_array<_Yp>::value &&
4255 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
4260 typedef __shared_ptr_pointer<_Yp*,
4261 reference_wrapper<typename remove_reference<_Dp>::type>,
4262 allocator<_Yp> > _CntrlBlk;
4263 __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>());
4264 __enable_weak_this(__r.get());
4268 #ifndef _LIBCPP_HAS_NO_VARIADICS
4271 template<class ..._Args>
4273 shared_ptr<_Tp>::make_shared(_Args&& ...__args)
4275 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
4276 typedef allocator<_CntrlBlk> _A2;
4277 typedef __allocator_destructor<_A2> _D2;
4279 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
4280 ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
4281 shared_ptr<_Tp> __r;
4282 __r.__ptr_ = __hold2.get()->get();
4283 __r.__cntrl_ = __hold2.release();
4284 __r.__enable_weak_this(__r.__ptr_);
4289 template<class _Alloc, class ..._Args>
4291 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
4293 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
4294 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
4295 typedef __allocator_destructor<_A2> _D2;
4297 unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
4298 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
4299 _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...);
4300 shared_ptr<_Tp> __r;
4301 __r.__ptr_ = __hold2.get()->get();
4302 __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
4303 __r.__enable_weak_this(__r.__ptr_);
4307 #else // _LIBCPP_HAS_NO_VARIADICS
4311 shared_ptr<_Tp>::make_shared()
4313 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
4314 typedef allocator<_CntrlBlk> _Alloc2;
4315 typedef __allocator_destructor<_Alloc2> _D2;
4317 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
4318 ::new(__hold2.get()) _CntrlBlk(__alloc2);
4319 shared_ptr<_Tp> __r;
4320 __r.__ptr_ = __hold2.get()->get();
4321 __r.__cntrl_ = __hold2.release();
4322 __r.__enable_weak_this(__r.__ptr_);
4329 shared_ptr<_Tp>::make_shared(_A0& __a0)
4331 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
4332 typedef allocator<_CntrlBlk> _Alloc2;
4333 typedef __allocator_destructor<_Alloc2> _D2;
4335 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
4336 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0);
4337 shared_ptr<_Tp> __r;
4338 __r.__ptr_ = __hold2.get()->get();
4339 __r.__cntrl_ = __hold2.release();
4340 __r.__enable_weak_this(__r.__ptr_);
4345 template<class _A0, class _A1>
4347 shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1)
4349 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
4350 typedef allocator<_CntrlBlk> _Alloc2;
4351 typedef __allocator_destructor<_Alloc2> _D2;
4353 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
4354 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1);
4355 shared_ptr<_Tp> __r;
4356 __r.__ptr_ = __hold2.get()->get();
4357 __r.__cntrl_ = __hold2.release();
4358 __r.__enable_weak_this(__r.__ptr_);
4363 template<class _A0, class _A1, class _A2>
4365 shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
4367 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
4368 typedef allocator<_CntrlBlk> _Alloc2;
4369 typedef __allocator_destructor<_Alloc2> _D2;
4371 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
4372 ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2);
4373 shared_ptr<_Tp> __r;
4374 __r.__ptr_ = __hold2.get()->get();
4375 __r.__cntrl_ = __hold2.release();
4376 __r.__enable_weak_this(__r.__ptr_);
4381 template<class _Alloc>
4383 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a)
4385 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
4386 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
4387 typedef __allocator_destructor<_Alloc2> _D2;
4388 _Alloc2 __alloc2(__a);
4389 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
4390 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
4392 shared_ptr<_Tp> __r;
4393 __r.__ptr_ = __hold2.get()->get();
4394 __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
4395 __r.__enable_weak_this(__r.__ptr_);
4400 template<class _Alloc, class _A0>
4402 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0)
4404 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
4405 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
4406 typedef __allocator_destructor<_Alloc2> _D2;
4407 _Alloc2 __alloc2(__a);
4408 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
4409 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
4410 _CntrlBlk(__a, __a0);
4411 shared_ptr<_Tp> __r;
4412 __r.__ptr_ = __hold2.get()->get();
4413 __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
4414 __r.__enable_weak_this(__r.__ptr_);
4419 template<class _Alloc, class _A0, class _A1>
4421 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
4423 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
4424 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
4425 typedef __allocator_destructor<_Alloc2> _D2;
4426 _Alloc2 __alloc2(__a);
4427 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
4428 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
4429 _CntrlBlk(__a, __a0, __a1);
4430 shared_ptr<_Tp> __r;
4431 __r.__ptr_ = __hold2.get()->get();
4432 __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
4433 __r.__enable_weak_this(__r.__ptr_);
4438 template<class _Alloc, class _A0, class _A1, class _A2>
4440 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2)
4442 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
4443 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
4444 typedef __allocator_destructor<_Alloc2> _D2;
4445 _Alloc2 __alloc2(__a);
4446 unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
4447 ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get())))
4448 _CntrlBlk(__a, __a0, __a1, __a2);
4449 shared_ptr<_Tp> __r;
4450 __r.__ptr_ = __hold2.get()->get();
4451 __r.__cntrl_ = _VSTD::addressof(*__hold2.release());
4452 __r.__enable_weak_this(__r.__ptr_);
4456 #endif // _LIBCPP_HAS_NO_VARIADICS
4459 shared_ptr<_Tp>::~shared_ptr()
4462 __cntrl_->__release_shared();
4466 inline _LIBCPP_INLINE_VISIBILITY
4468 shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT
4470 shared_ptr(__r).swap(*this);
4476 inline _LIBCPP_INLINE_VISIBILITY
4479 is_convertible<_Yp*, _Tp*>::value,
4482 shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
4484 shared_ptr(__r).swap(*this);
4488 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4491 inline _LIBCPP_INLINE_VISIBILITY
4493 shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT
4495 shared_ptr(_VSTD::move(__r)).swap(*this);
4501 inline _LIBCPP_INLINE_VISIBILITY
4504 is_convertible<_Yp*, _Tp*>::value,
4507 shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r)
4509 shared_ptr(_VSTD::move(__r)).swap(*this);
4515 inline _LIBCPP_INLINE_VISIBILITY
4518 !is_array<_Yp>::value &&
4519 is_convertible<_Yp*, _Tp*>::value,
4522 shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r)
4524 shared_ptr(_VSTD::move(__r)).swap(*this);
4529 template <class _Yp, class _Dp>
4530 inline _LIBCPP_INLINE_VISIBILITY
4533 !is_array<_Yp>::value &&
4534 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value,
4537 shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r)
4539 shared_ptr(_VSTD::move(__r)).swap(*this);
4543 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4547 inline _LIBCPP_INLINE_VISIBILITY
4550 !is_array<_Yp>::value &&
4551 is_convertible<_Yp*, _Tp*>::value,
4554 shared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r)
4556 shared_ptr(__r).swap(*this);
4561 template <class _Yp, class _Dp>
4562 inline _LIBCPP_INLINE_VISIBILITY
4565 !is_array<_Yp>::value &&
4566 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value,
4569 shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r)
4571 shared_ptr(_VSTD::move(__r)).swap(*this);
4575 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4578 inline _LIBCPP_INLINE_VISIBILITY
4580 shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT
4582 _VSTD::swap(__ptr_, __r.__ptr_);
4583 _VSTD::swap(__cntrl_, __r.__cntrl_);
4587 inline _LIBCPP_INLINE_VISIBILITY
4589 shared_ptr<_Tp>::reset() _NOEXCEPT
4591 shared_ptr().swap(*this);
4596 inline _LIBCPP_INLINE_VISIBILITY
4599 is_convertible<_Yp*, _Tp*>::value,
4602 shared_ptr<_Tp>::reset(_Yp* __p)
4604 shared_ptr(__p).swap(*this);
4608 template<class _Yp, class _Dp>
4609 inline _LIBCPP_INLINE_VISIBILITY
4612 is_convertible<_Yp*, _Tp*>::value,
4615 shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d)
4617 shared_ptr(__p, __d).swap(*this);
4621 template<class _Yp, class _Dp, class _Alloc>
4622 inline _LIBCPP_INLINE_VISIBILITY
4625 is_convertible<_Yp*, _Tp*>::value,
4628 shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)
4630 shared_ptr(__p, __d, __a).swap(*this);
4633 #ifndef _LIBCPP_HAS_NO_VARIADICS
4635 template<class _Tp, class ..._Args>
4636 inline _LIBCPP_INLINE_VISIBILITY
4639 !is_array<_Tp>::value,
4642 make_shared(_Args&& ...__args)
4644 return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
4647 template<class _Tp, class _Alloc, class ..._Args>
4648 inline _LIBCPP_INLINE_VISIBILITY
4651 !is_array<_Tp>::value,
4654 allocate_shared(const _Alloc& __a, _Args&& ...__args)
4656 return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...);
4659 #else // _LIBCPP_HAS_NO_VARIADICS
4662 inline _LIBCPP_INLINE_VISIBILITY
4666 return shared_ptr<_Tp>::make_shared();
4669 template<class _Tp, class _A0>
4670 inline _LIBCPP_INLINE_VISIBILITY
4672 make_shared(_A0& __a0)
4674 return shared_ptr<_Tp>::make_shared(__a0);
4677 template<class _Tp, class _A0, class _A1>
4678 inline _LIBCPP_INLINE_VISIBILITY
4680 make_shared(_A0& __a0, _A1& __a1)
4682 return shared_ptr<_Tp>::make_shared(__a0, __a1);
4685 template<class _Tp, class _A0, class _A1, class _A2>
4686 inline _LIBCPP_INLINE_VISIBILITY
4688 make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
4690 return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2);
4693 template<class _Tp, class _Alloc>
4694 inline _LIBCPP_INLINE_VISIBILITY
4696 allocate_shared(const _Alloc& __a)
4698 return shared_ptr<_Tp>::allocate_shared(__a);
4701 template<class _Tp, class _Alloc, class _A0>
4702 inline _LIBCPP_INLINE_VISIBILITY
4704 allocate_shared(const _Alloc& __a, _A0& __a0)
4706 return shared_ptr<_Tp>::allocate_shared(__a, __a0);
4709 template<class _Tp, class _Alloc, class _A0, class _A1>
4710 inline _LIBCPP_INLINE_VISIBILITY
4712 allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
4714 return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1);
4717 template<class _Tp, class _Alloc, class _A0, class _A1, class _A2>
4718 inline _LIBCPP_INLINE_VISIBILITY
4720 allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2)
4722 return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2);
4725 #endif // _LIBCPP_HAS_NO_VARIADICS
4727 template<class _Tp, class _Up>
4728 inline _LIBCPP_INLINE_VISIBILITY
4730 operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
4732 return __x.get() == __y.get();
4735 template<class _Tp, class _Up>
4736 inline _LIBCPP_INLINE_VISIBILITY
4738 operator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
4740 return !(__x == __y);
4743 template<class _Tp, class _Up>
4744 inline _LIBCPP_INLINE_VISIBILITY
4746 operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
4748 typedef typename common_type<_Tp*, _Up*>::type _V;
4749 return less<_V>()(__x.get(), __y.get());
4752 template<class _Tp, class _Up>
4753 inline _LIBCPP_INLINE_VISIBILITY
4755 operator>(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
4760 template<class _Tp, class _Up>
4761 inline _LIBCPP_INLINE_VISIBILITY
4763 operator<=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
4765 return !(__y < __x);
4768 template<class _Tp, class _Up>
4769 inline _LIBCPP_INLINE_VISIBILITY
4771 operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
4773 return !(__x < __y);
4777 inline _LIBCPP_INLINE_VISIBILITY
4779 operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
4785 inline _LIBCPP_INLINE_VISIBILITY
4787 operator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
4793 inline _LIBCPP_INLINE_VISIBILITY
4795 operator!=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
4797 return static_cast<bool>(__x);
4801 inline _LIBCPP_INLINE_VISIBILITY
4803 operator!=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
4805 return static_cast<bool>(__x);
4809 inline _LIBCPP_INLINE_VISIBILITY
4811 operator<(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
4813 return less<_Tp*>()(__x.get(), nullptr);
4817 inline _LIBCPP_INLINE_VISIBILITY
4819 operator<(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
4821 return less<_Tp*>()(nullptr, __x.get());
4825 inline _LIBCPP_INLINE_VISIBILITY
4827 operator>(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
4829 return nullptr < __x;
4833 inline _LIBCPP_INLINE_VISIBILITY
4835 operator>(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
4837 return __x < nullptr;
4841 inline _LIBCPP_INLINE_VISIBILITY
4843 operator<=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
4845 return !(nullptr < __x);
4849 inline _LIBCPP_INLINE_VISIBILITY
4851 operator<=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
4853 return !(__x < nullptr);
4857 inline _LIBCPP_INLINE_VISIBILITY
4859 operator>=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
4861 return !(__x < nullptr);
4865 inline _LIBCPP_INLINE_VISIBILITY
4867 operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
4869 return !(nullptr < __x);
4873 inline _LIBCPP_INLINE_VISIBILITY
4875 swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT
4880 template<class _Tp, class _Up>
4881 inline _LIBCPP_INLINE_VISIBILITY
4884 !is_array<_Tp>::value && !is_array<_Up>::value,
4887 static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
4889 return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get()));
4892 template<class _Tp, class _Up>
4893 inline _LIBCPP_INLINE_VISIBILITY
4896 !is_array<_Tp>::value && !is_array<_Up>::value,
4899 dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
4901 _Tp* __p = dynamic_cast<_Tp*>(__r.get());
4902 return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>();
4905 template<class _Tp, class _Up>
4908 is_array<_Tp>::value == is_array<_Up>::value,
4911 const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
4913 typedef typename remove_extent<_Tp>::type _RTp;
4914 return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get()));
4917 #ifndef _LIBCPP_NO_RTTI
4919 template<class _Dp, class _Tp>
4920 inline _LIBCPP_INLINE_VISIBILITY
4922 get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT
4924 return __p.template __get_deleter<_Dp>();
4927 #endif // _LIBCPP_NO_RTTI
4930 class _LIBCPP_TYPE_VIS_ONLY weak_ptr
4933 typedef _Tp element_type;
4935 element_type* __ptr_;
4936 __shared_weak_count* __cntrl_;
4939 _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT;
4940 template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r,
4941 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
4943 weak_ptr(weak_ptr const& __r) _NOEXCEPT;
4944 template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r,
4945 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
4948 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4949 weak_ptr(weak_ptr&& __r) _NOEXCEPT;
4950 template<class _Yp> weak_ptr(weak_ptr<_Yp>&& __r,
4951 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
4953 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4956 weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT;
4960 is_convertible<_Yp*, element_type*>::value,
4963 operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;
4965 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
4967 weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;
4971 is_convertible<_Yp*, element_type*>::value,
4974 operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
4976 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
4981 is_convertible<_Yp*, element_type*>::value,
4984 operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT;
4986 void swap(weak_ptr& __r) _NOEXCEPT;
4987 void reset() _NOEXCEPT;
4989 _LIBCPP_INLINE_VISIBILITY
4990 long use_count() const _NOEXCEPT
4991 {return __cntrl_ ? __cntrl_->use_count() : 0;}
4992 _LIBCPP_INLINE_VISIBILITY
4993 bool expired() const _NOEXCEPT
4994 {return __cntrl_ == 0 || __cntrl_->use_count() == 0;}
4995 shared_ptr<_Tp> lock() const _NOEXCEPT;
4997 _LIBCPP_INLINE_VISIBILITY
4998 bool owner_before(const shared_ptr<_Up>& __r) const
4999 {return __cntrl_ < __r.__cntrl_;}
5001 _LIBCPP_INLINE_VISIBILITY
5002 bool owner_before(const weak_ptr<_Up>& __r) const
5003 {return __cntrl_ < __r.__cntrl_;}
5005 template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
5006 template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr;
5010 inline _LIBCPP_INLINE_VISIBILITY
5012 weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
5019 inline _LIBCPP_INLINE_VISIBILITY
5020 weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT
5021 : __ptr_(__r.__ptr_),
5022 __cntrl_(__r.__cntrl_)
5025 __cntrl_->__add_weak();
5030 inline _LIBCPP_INLINE_VISIBILITY
5031 weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r,
5032 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
5034 : __ptr_(__r.__ptr_),
5035 __cntrl_(__r.__cntrl_)
5038 __cntrl_->__add_weak();
5043 inline _LIBCPP_INLINE_VISIBILITY
5044 weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
5045 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
5047 : __ptr_(__r.__ptr_),
5048 __cntrl_(__r.__cntrl_)
5051 __cntrl_->__add_weak();
5054 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
5057 inline _LIBCPP_INLINE_VISIBILITY
5058 weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
5059 : __ptr_(__r.__ptr_),
5060 __cntrl_(__r.__cntrl_)
5068 inline _LIBCPP_INLINE_VISIBILITY
5069 weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,
5070 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
5072 : __ptr_(__r.__ptr_),
5073 __cntrl_(__r.__cntrl_)
5079 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
5082 weak_ptr<_Tp>::~weak_ptr()
5085 __cntrl_->__release_weak();
5089 inline _LIBCPP_INLINE_VISIBILITY
5091 weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT
5093 weak_ptr(__r).swap(*this);
5099 inline _LIBCPP_INLINE_VISIBILITY
5102 is_convertible<_Yp*, _Tp*>::value,
5105 weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT
5107 weak_ptr(__r).swap(*this);
5111 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
5114 inline _LIBCPP_INLINE_VISIBILITY
5116 weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT
5118 weak_ptr(_VSTD::move(__r)).swap(*this);
5124 inline _LIBCPP_INLINE_VISIBILITY
5127 is_convertible<_Yp*, _Tp*>::value,
5130 weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT
5132 weak_ptr(_VSTD::move(__r)).swap(*this);
5136 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
5140 inline _LIBCPP_INLINE_VISIBILITY
5143 is_convertible<_Yp*, _Tp*>::value,
5146 weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT
5148 weak_ptr(__r).swap(*this);
5153 inline _LIBCPP_INLINE_VISIBILITY
5155 weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT
5157 _VSTD::swap(__ptr_, __r.__ptr_);
5158 _VSTD::swap(__cntrl_, __r.__cntrl_);
5162 inline _LIBCPP_INLINE_VISIBILITY
5164 swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT
5170 inline _LIBCPP_INLINE_VISIBILITY
5172 weak_ptr<_Tp>::reset() _NOEXCEPT
5174 weak_ptr().swap(*this);
5179 shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,
5180 typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type)
5181 : __ptr_(__r.__ptr_),
5182 __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
5185 #ifndef _LIBCPP_NO_EXCEPTIONS
5186 throw bad_weak_ptr();
5188 assert(!"bad_weak_ptr");
5194 weak_ptr<_Tp>::lock() const _NOEXCEPT
5196 shared_ptr<_Tp> __r;
5197 __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_;
5199 __r.__ptr_ = __ptr_;
5203 template <class _Tp> struct owner_less;
5205 template <class _Tp>
5206 struct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> >
5207 : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
5209 typedef bool result_type;
5210 _LIBCPP_INLINE_VISIBILITY
5211 bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const
5212 {return __x.owner_before(__y);}
5213 _LIBCPP_INLINE_VISIBILITY
5214 bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const
5215 {return __x.owner_before(__y);}
5216 _LIBCPP_INLINE_VISIBILITY
5217 bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const
5218 {return __x.owner_before(__y);}
5221 template <class _Tp>
5222 struct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> >
5223 : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
5225 typedef bool result_type;
5226 _LIBCPP_INLINE_VISIBILITY
5227 bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const
5228 {return __x.owner_before(__y);}
5229 _LIBCPP_INLINE_VISIBILITY
5230 bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const
5231 {return __x.owner_before(__y);}
5232 _LIBCPP_INLINE_VISIBILITY
5233 bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const
5234 {return __x.owner_before(__y);}
5238 class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this
5240 mutable weak_ptr<_Tp> __weak_this_;
5242 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
5243 enable_shared_from_this() _NOEXCEPT {}
5244 _LIBCPP_INLINE_VISIBILITY
5245 enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {}
5246 _LIBCPP_INLINE_VISIBILITY
5247 enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT
5249 _LIBCPP_INLINE_VISIBILITY
5250 ~enable_shared_from_this() {}
5252 _LIBCPP_INLINE_VISIBILITY
5253 shared_ptr<_Tp> shared_from_this()
5254 {return shared_ptr<_Tp>(__weak_this_);}
5255 _LIBCPP_INLINE_VISIBILITY
5256 shared_ptr<_Tp const> shared_from_this() const
5257 {return shared_ptr<const _Tp>(__weak_this_);}
5259 template <class _Up> friend class shared_ptr;
5262 template <class _Tp>
5263 struct _LIBCPP_TYPE_VIS_ONLY hash<shared_ptr<_Tp> >
5265 typedef shared_ptr<_Tp> argument_type;
5266 typedef size_t result_type;
5267 _LIBCPP_INLINE_VISIBILITY
5268 result_type operator()(const argument_type& __ptr) const _NOEXCEPT
5270 return hash<_Tp*>()(__ptr.get());
5274 template<class _CharT, class _Traits, class _Yp>
5275 inline _LIBCPP_INLINE_VISIBILITY
5276 basic_ostream<_CharT, _Traits>&
5277 operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
5279 #if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
5281 class _LIBCPP_TYPE_VIS __sp_mut
5285 void lock() _NOEXCEPT;
5286 void unlock() _NOEXCEPT;
5289 _LIBCPP_CONSTEXPR __sp_mut(void*) _NOEXCEPT;
5290 __sp_mut(const __sp_mut&);
5291 __sp_mut& operator=(const __sp_mut&);
5293 friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*);
5296 _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*);
5298 template <class _Tp>
5299 inline _LIBCPP_INLINE_VISIBILITY
5301 atomic_is_lock_free(const shared_ptr<_Tp>*)
5306 template <class _Tp>
5308 atomic_load(const shared_ptr<_Tp>* __p)
5310 __sp_mut& __m = __get_sp_mut(__p);
5312 shared_ptr<_Tp> __q = *__p;
5317 template <class _Tp>
5318 inline _LIBCPP_INLINE_VISIBILITY
5320 atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
5322 return atomic_load(__p);
5325 template <class _Tp>
5327 atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
5329 __sp_mut& __m = __get_sp_mut(__p);
5335 template <class _Tp>
5336 inline _LIBCPP_INLINE_VISIBILITY
5338 atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
5340 atomic_store(__p, __r);
5343 template <class _Tp>
5345 atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
5347 __sp_mut& __m = __get_sp_mut(__p);
5354 template <class _Tp>
5355 inline _LIBCPP_INLINE_VISIBILITY
5357 atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
5359 return atomic_exchange(__p, __r);
5362 template <class _Tp>
5364 atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
5366 __sp_mut& __m = __get_sp_mut(__p);
5368 if (__p->__owner_equivalent(*__v))
5379 template <class _Tp>
5380 inline _LIBCPP_INLINE_VISIBILITY
5382 atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
5384 return atomic_compare_exchange_strong(__p, __v, __w);
5387 template <class _Tp>
5388 inline _LIBCPP_INLINE_VISIBILITY
5390 atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
5391 shared_ptr<_Tp> __w, memory_order, memory_order)
5393 return atomic_compare_exchange_strong(__p, __v, __w);
5396 template <class _Tp>
5397 inline _LIBCPP_INLINE_VISIBILITY
5399 atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
5400 shared_ptr<_Tp> __w, memory_order, memory_order)
5402 return atomic_compare_exchange_weak(__p, __v, __w);
5405 #endif // __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS)
5408 struct _LIBCPP_TYPE_VIS pointer_safety
5419 _LIBCPP_INLINE_VISIBILITY
5420 pointer_safety(__lx __v) : __v_(__v) {}
5421 _LIBCPP_INLINE_VISIBILITY
5422 operator int() const {return __v_;}
5425 _LIBCPP_FUNC_VIS void declare_reachable(void* __p);
5426 _LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n);
5427 _LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n);
5428 _LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT;
5429 _LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p);
5431 template <class _Tp>
5432 inline _LIBCPP_INLINE_VISIBILITY
5434 undeclare_reachable(_Tp* __p)
5436 return static_cast<_Tp*>(__undeclare_reachable(__p));
5439 _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
5441 _LIBCPP_END_NAMESPACE_STD
5443 #endif // _LIBCPP_MEMORY