14684ddb6SLionel Sambuc// -*- C++ -*- 24684ddb6SLionel Sambuc//===-------------------------- memory ------------------------------------===// 34684ddb6SLionel Sambuc// 44684ddb6SLionel Sambuc// The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc// 64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open 74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc// 94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuc#ifndef _LIBCPP_MEMORY 124684ddb6SLionel Sambuc#define _LIBCPP_MEMORY 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc/* 154684ddb6SLionel Sambuc memory synopsis 164684ddb6SLionel Sambuc 174684ddb6SLionel Sambucnamespace std 184684ddb6SLionel Sambuc{ 194684ddb6SLionel Sambuc 204684ddb6SLionel Sambucstruct allocator_arg_t { }; 214684ddb6SLionel Sambucconstexpr allocator_arg_t allocator_arg = allocator_arg_t(); 224684ddb6SLionel Sambuc 234684ddb6SLionel Sambuctemplate <class T, class Alloc> struct uses_allocator; 244684ddb6SLionel Sambuc 254684ddb6SLionel Sambuctemplate <class Ptr> 264684ddb6SLionel Sambucstruct pointer_traits 274684ddb6SLionel Sambuc{ 284684ddb6SLionel Sambuc typedef Ptr pointer; 294684ddb6SLionel Sambuc typedef <details> element_type; 304684ddb6SLionel Sambuc typedef <details> difference_type; 314684ddb6SLionel Sambuc 324684ddb6SLionel Sambuc template <class U> using rebind = <details>; 334684ddb6SLionel Sambuc 344684ddb6SLionel Sambuc static pointer pointer_to(<details>); 354684ddb6SLionel Sambuc}; 364684ddb6SLionel Sambuc 374684ddb6SLionel Sambuctemplate <class T> 384684ddb6SLionel Sambucstruct pointer_traits<T*> 394684ddb6SLionel Sambuc{ 404684ddb6SLionel Sambuc typedef T* pointer; 414684ddb6SLionel Sambuc typedef T element_type; 424684ddb6SLionel Sambuc typedef ptrdiff_t difference_type; 434684ddb6SLionel Sambuc 444684ddb6SLionel Sambuc template <class U> using rebind = U*; 454684ddb6SLionel Sambuc 464684ddb6SLionel Sambuc static pointer pointer_to(<details>) noexcept; 474684ddb6SLionel Sambuc}; 484684ddb6SLionel Sambuc 494684ddb6SLionel Sambuctemplate <class Alloc> 504684ddb6SLionel Sambucstruct allocator_traits 514684ddb6SLionel Sambuc{ 524684ddb6SLionel Sambuc typedef Alloc allocator_type; 534684ddb6SLionel Sambuc typedef typename allocator_type::value_type 544684ddb6SLionel Sambuc value_type; 554684ddb6SLionel Sambuc 564684ddb6SLionel Sambuc typedef Alloc::pointer | value_type* pointer; 574684ddb6SLionel Sambuc typedef Alloc::const_pointer 584684ddb6SLionel Sambuc | pointer_traits<pointer>::rebind<const value_type> 594684ddb6SLionel Sambuc const_pointer; 604684ddb6SLionel Sambuc typedef Alloc::void_pointer 614684ddb6SLionel Sambuc | pointer_traits<pointer>::rebind<void> 624684ddb6SLionel Sambuc void_pointer; 634684ddb6SLionel Sambuc typedef Alloc::const_void_pointer 644684ddb6SLionel Sambuc | pointer_traits<pointer>::rebind<const void> 654684ddb6SLionel Sambuc const_void_pointer; 664684ddb6SLionel Sambuc typedef Alloc::difference_type 674684ddb6SLionel Sambuc | pointer_traits<pointer>::difference_type 684684ddb6SLionel Sambuc difference_type; 694684ddb6SLionel Sambuc typedef Alloc::size_type 704684ddb6SLionel Sambuc | make_unsigned<difference_type>::type 714684ddb6SLionel Sambuc size_type; 724684ddb6SLionel Sambuc typedef Alloc::propagate_on_container_copy_assignment 734684ddb6SLionel Sambuc | false_type propagate_on_container_copy_assignment; 744684ddb6SLionel Sambuc typedef Alloc::propagate_on_container_move_assignment 754684ddb6SLionel Sambuc | false_type propagate_on_container_move_assignment; 764684ddb6SLionel Sambuc typedef Alloc::propagate_on_container_swap 774684ddb6SLionel Sambuc | false_type propagate_on_container_swap; 78*0a6a1f1dSLionel Sambuc typedef Alloc::is_always_equal 79*0a6a1f1dSLionel Sambuc | is_empty is_always_equal; 804684ddb6SLionel Sambuc 814684ddb6SLionel Sambuc template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>; 824684ddb6SLionel Sambuc template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; 834684ddb6SLionel Sambuc 844684ddb6SLionel Sambuc static pointer allocate(allocator_type& a, size_type n); 854684ddb6SLionel Sambuc static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); 864684ddb6SLionel Sambuc 874684ddb6SLionel Sambuc static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; 884684ddb6SLionel Sambuc 894684ddb6SLionel Sambuc template <class T, class... Args> 904684ddb6SLionel Sambuc static void construct(allocator_type& a, T* p, Args&&... args); 914684ddb6SLionel Sambuc 924684ddb6SLionel Sambuc template <class T> 934684ddb6SLionel Sambuc static void destroy(allocator_type& a, T* p); 944684ddb6SLionel Sambuc 954684ddb6SLionel Sambuc static size_type max_size(const allocator_type& a); // noexcept in C++14 964684ddb6SLionel Sambuc 974684ddb6SLionel Sambuc static allocator_type 984684ddb6SLionel Sambuc select_on_container_copy_construction(const allocator_type& a); 994684ddb6SLionel Sambuc}; 1004684ddb6SLionel Sambuc 1014684ddb6SLionel Sambuctemplate <> 1024684ddb6SLionel Sambucclass allocator<void> 1034684ddb6SLionel Sambuc{ 1044684ddb6SLionel Sambucpublic: 1054684ddb6SLionel Sambuc typedef void* pointer; 1064684ddb6SLionel Sambuc typedef const void* const_pointer; 1074684ddb6SLionel Sambuc typedef void value_type; 1084684ddb6SLionel Sambuc 1094684ddb6SLionel Sambuc template <class _Up> struct rebind {typedef allocator<_Up> other;}; 1104684ddb6SLionel Sambuc}; 1114684ddb6SLionel Sambuc 1124684ddb6SLionel Sambuctemplate <class T> 1134684ddb6SLionel Sambucclass allocator 1144684ddb6SLionel Sambuc{ 1154684ddb6SLionel Sambucpublic: 1164684ddb6SLionel Sambuc typedef size_t size_type; 1174684ddb6SLionel Sambuc typedef ptrdiff_t difference_type; 1184684ddb6SLionel Sambuc typedef T* pointer; 1194684ddb6SLionel Sambuc typedef const T* const_pointer; 1204684ddb6SLionel Sambuc typedef typename add_lvalue_reference<T>::type reference; 1214684ddb6SLionel Sambuc typedef typename add_lvalue_reference<const T>::type const_reference; 1224684ddb6SLionel Sambuc typedef T value_type; 1234684ddb6SLionel Sambuc 1244684ddb6SLionel Sambuc template <class U> struct rebind {typedef allocator<U> other;}; 1254684ddb6SLionel Sambuc 1264684ddb6SLionel Sambuc allocator() noexcept; 1274684ddb6SLionel Sambuc allocator(const allocator&) noexcept; 1284684ddb6SLionel Sambuc template <class U> allocator(const allocator<U>&) noexcept; 1294684ddb6SLionel Sambuc ~allocator(); 1304684ddb6SLionel Sambuc pointer address(reference x) const noexcept; 1314684ddb6SLionel Sambuc const_pointer address(const_reference x) const noexcept; 1324684ddb6SLionel Sambuc pointer allocate(size_type, allocator<void>::const_pointer hint = 0); 1334684ddb6SLionel Sambuc void deallocate(pointer p, size_type n) noexcept; 1344684ddb6SLionel Sambuc size_type max_size() const noexcept; 1354684ddb6SLionel Sambuc template<class U, class... Args> 1364684ddb6SLionel Sambuc void construct(U* p, Args&&... args); 1374684ddb6SLionel Sambuc template <class U> 1384684ddb6SLionel Sambuc void destroy(U* p); 1394684ddb6SLionel Sambuc}; 1404684ddb6SLionel Sambuc 1414684ddb6SLionel Sambuctemplate <class T, class U> 1424684ddb6SLionel Sambucbool operator==(const allocator<T>&, const allocator<U>&) noexcept; 1434684ddb6SLionel Sambuc 1444684ddb6SLionel Sambuctemplate <class T, class U> 1454684ddb6SLionel Sambucbool operator!=(const allocator<T>&, const allocator<U>&) noexcept; 1464684ddb6SLionel Sambuc 1474684ddb6SLionel Sambuctemplate <class OutputIterator, class T> 1484684ddb6SLionel Sambucclass raw_storage_iterator 1494684ddb6SLionel Sambuc : public iterator<output_iterator_tag, 1504684ddb6SLionel Sambuc T, // purposefully not C++03 1514684ddb6SLionel Sambuc ptrdiff_t, // purposefully not C++03 1524684ddb6SLionel Sambuc T*, // purposefully not C++03 1534684ddb6SLionel Sambuc raw_storage_iterator&> // purposefully not C++03 1544684ddb6SLionel Sambuc{ 1554684ddb6SLionel Sambucpublic: 1564684ddb6SLionel Sambuc explicit raw_storage_iterator(OutputIterator x); 1574684ddb6SLionel Sambuc raw_storage_iterator& operator*(); 1584684ddb6SLionel Sambuc raw_storage_iterator& operator=(const T& element); 1594684ddb6SLionel Sambuc raw_storage_iterator& operator++(); 1604684ddb6SLionel Sambuc raw_storage_iterator operator++(int); 1614684ddb6SLionel Sambuc}; 1624684ddb6SLionel Sambuc 1634684ddb6SLionel Sambuctemplate <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; 1644684ddb6SLionel Sambuctemplate <class T> void return_temporary_buffer(T* p) noexcept; 1654684ddb6SLionel Sambuc 1664684ddb6SLionel Sambuctemplate <class T> T* addressof(T& r) noexcept; 1674684ddb6SLionel Sambuc 1684684ddb6SLionel Sambuctemplate <class InputIterator, class ForwardIterator> 1694684ddb6SLionel SambucForwardIterator 1704684ddb6SLionel Sambucuninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); 1714684ddb6SLionel Sambuc 1724684ddb6SLionel Sambuctemplate <class InputIterator, class Size, class ForwardIterator> 1734684ddb6SLionel SambucForwardIterator 1744684ddb6SLionel Sambucuninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); 1754684ddb6SLionel Sambuc 1764684ddb6SLionel Sambuctemplate <class ForwardIterator, class T> 1774684ddb6SLionel Sambucvoid uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); 1784684ddb6SLionel Sambuc 1794684ddb6SLionel Sambuctemplate <class ForwardIterator, class Size, class T> 1804684ddb6SLionel SambucForwardIterator 1814684ddb6SLionel Sambucuninitialized_fill_n(ForwardIterator first, Size n, const T& x); 1824684ddb6SLionel Sambuc 1834684ddb6SLionel Sambuctemplate <class Y> struct auto_ptr_ref {}; 1844684ddb6SLionel Sambuc 1854684ddb6SLionel Sambuctemplate<class X> 1864684ddb6SLionel Sambucclass auto_ptr 1874684ddb6SLionel Sambuc{ 1884684ddb6SLionel Sambucpublic: 1894684ddb6SLionel Sambuc typedef X element_type; 1904684ddb6SLionel Sambuc 1914684ddb6SLionel Sambuc explicit auto_ptr(X* p =0) throw(); 1924684ddb6SLionel Sambuc auto_ptr(auto_ptr&) throw(); 1934684ddb6SLionel Sambuc template<class Y> auto_ptr(auto_ptr<Y>&) throw(); 1944684ddb6SLionel Sambuc auto_ptr& operator=(auto_ptr&) throw(); 1954684ddb6SLionel Sambuc template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw(); 1964684ddb6SLionel Sambuc auto_ptr& operator=(auto_ptr_ref<X> r) throw(); 1974684ddb6SLionel Sambuc ~auto_ptr() throw(); 1984684ddb6SLionel Sambuc 1994684ddb6SLionel Sambuc typename add_lvalue_reference<X>::type operator*() const throw(); 2004684ddb6SLionel Sambuc X* operator->() const throw(); 2014684ddb6SLionel Sambuc X* get() const throw(); 2024684ddb6SLionel Sambuc X* release() throw(); 2034684ddb6SLionel Sambuc void reset(X* p =0) throw(); 2044684ddb6SLionel Sambuc 2054684ddb6SLionel Sambuc auto_ptr(auto_ptr_ref<X>) throw(); 2064684ddb6SLionel Sambuc template<class Y> operator auto_ptr_ref<Y>() throw(); 2074684ddb6SLionel Sambuc template<class Y> operator auto_ptr<Y>() throw(); 2084684ddb6SLionel Sambuc}; 2094684ddb6SLionel Sambuc 2104684ddb6SLionel Sambuctemplate <class T> 2114684ddb6SLionel Sambucstruct default_delete 2124684ddb6SLionel Sambuc{ 2134684ddb6SLionel Sambuc constexpr default_delete() noexcept = default; 2144684ddb6SLionel Sambuc template <class U> default_delete(const default_delete<U>&) noexcept; 2154684ddb6SLionel Sambuc 2164684ddb6SLionel Sambuc void operator()(T*) const noexcept; 2174684ddb6SLionel Sambuc}; 2184684ddb6SLionel Sambuc 2194684ddb6SLionel Sambuctemplate <class T> 2204684ddb6SLionel Sambucstruct default_delete<T[]> 2214684ddb6SLionel Sambuc{ 2224684ddb6SLionel Sambuc constexpr default_delete() noexcept = default; 2234684ddb6SLionel Sambuc void operator()(T*) const noexcept; 2244684ddb6SLionel Sambuc template <class U> void operator()(U*) const = delete; 2254684ddb6SLionel Sambuc}; 2264684ddb6SLionel Sambuc 2274684ddb6SLionel Sambuctemplate <class T, class D = default_delete<T>> 2284684ddb6SLionel Sambucclass unique_ptr 2294684ddb6SLionel Sambuc{ 2304684ddb6SLionel Sambucpublic: 2314684ddb6SLionel Sambuc typedef see below pointer; 2324684ddb6SLionel Sambuc typedef T element_type; 2334684ddb6SLionel Sambuc typedef D deleter_type; 2344684ddb6SLionel Sambuc 2354684ddb6SLionel Sambuc // constructors 2364684ddb6SLionel Sambuc constexpr unique_ptr() noexcept; 2374684ddb6SLionel Sambuc explicit unique_ptr(pointer p) noexcept; 2384684ddb6SLionel Sambuc unique_ptr(pointer p, see below d1) noexcept; 2394684ddb6SLionel Sambuc unique_ptr(pointer p, see below d2) noexcept; 2404684ddb6SLionel Sambuc unique_ptr(unique_ptr&& u) noexcept; 2414684ddb6SLionel Sambuc unique_ptr(nullptr_t) noexcept : unique_ptr() { } 2424684ddb6SLionel Sambuc template <class U, class E> 2434684ddb6SLionel Sambuc unique_ptr(unique_ptr<U, E>&& u) noexcept; 2444684ddb6SLionel Sambuc template <class U> 2454684ddb6SLionel Sambuc unique_ptr(auto_ptr<U>&& u) noexcept; 2464684ddb6SLionel Sambuc 2474684ddb6SLionel Sambuc // destructor 2484684ddb6SLionel Sambuc ~unique_ptr(); 2494684ddb6SLionel Sambuc 2504684ddb6SLionel Sambuc // assignment 2514684ddb6SLionel Sambuc unique_ptr& operator=(unique_ptr&& u) noexcept; 2524684ddb6SLionel Sambuc template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept; 2534684ddb6SLionel Sambuc unique_ptr& operator=(nullptr_t) noexcept; 2544684ddb6SLionel Sambuc 2554684ddb6SLionel Sambuc // observers 2564684ddb6SLionel Sambuc typename add_lvalue_reference<T>::type operator*() const; 2574684ddb6SLionel Sambuc pointer operator->() const noexcept; 2584684ddb6SLionel Sambuc pointer get() const noexcept; 2594684ddb6SLionel Sambuc deleter_type& get_deleter() noexcept; 2604684ddb6SLionel Sambuc const deleter_type& get_deleter() const noexcept; 2614684ddb6SLionel Sambuc explicit operator bool() const noexcept; 2624684ddb6SLionel Sambuc 2634684ddb6SLionel Sambuc // modifiers 2644684ddb6SLionel Sambuc pointer release() noexcept; 2654684ddb6SLionel Sambuc void reset(pointer p = pointer()) noexcept; 2664684ddb6SLionel Sambuc void swap(unique_ptr& u) noexcept; 2674684ddb6SLionel Sambuc}; 2684684ddb6SLionel Sambuc 2694684ddb6SLionel Sambuctemplate <class T, class D> 2704684ddb6SLionel Sambucclass unique_ptr<T[], D> 2714684ddb6SLionel Sambuc{ 2724684ddb6SLionel Sambucpublic: 2734684ddb6SLionel Sambuc typedef implementation-defined pointer; 2744684ddb6SLionel Sambuc typedef T element_type; 2754684ddb6SLionel Sambuc typedef D deleter_type; 2764684ddb6SLionel Sambuc 2774684ddb6SLionel Sambuc // constructors 2784684ddb6SLionel Sambuc constexpr unique_ptr() noexcept; 2794684ddb6SLionel Sambuc explicit unique_ptr(pointer p) noexcept; 2804684ddb6SLionel Sambuc unique_ptr(pointer p, see below d) noexcept; 2814684ddb6SLionel Sambuc unique_ptr(pointer p, see below d) noexcept; 2824684ddb6SLionel Sambuc unique_ptr(unique_ptr&& u) noexcept; 2834684ddb6SLionel Sambuc unique_ptr(nullptr_t) noexcept : unique_ptr() { } 2844684ddb6SLionel Sambuc 2854684ddb6SLionel Sambuc // destructor 2864684ddb6SLionel Sambuc ~unique_ptr(); 2874684ddb6SLionel Sambuc 2884684ddb6SLionel Sambuc // assignment 2894684ddb6SLionel Sambuc unique_ptr& operator=(unique_ptr&& u) noexcept; 2904684ddb6SLionel Sambuc unique_ptr& operator=(nullptr_t) noexcept; 2914684ddb6SLionel Sambuc 2924684ddb6SLionel Sambuc // observers 2934684ddb6SLionel Sambuc T& operator[](size_t i) const; 2944684ddb6SLionel Sambuc pointer get() const noexcept; 2954684ddb6SLionel Sambuc deleter_type& get_deleter() noexcept; 2964684ddb6SLionel Sambuc const deleter_type& get_deleter() const noexcept; 2974684ddb6SLionel Sambuc explicit operator bool() const noexcept; 2984684ddb6SLionel Sambuc 2994684ddb6SLionel Sambuc // modifiers 3004684ddb6SLionel Sambuc pointer release() noexcept; 3014684ddb6SLionel Sambuc void reset(pointer p = pointer()) noexcept; 3024684ddb6SLionel Sambuc void reset(nullptr_t) noexcept; 3034684ddb6SLionel Sambuc template <class U> void reset(U) = delete; 3044684ddb6SLionel Sambuc void swap(unique_ptr& u) noexcept; 3054684ddb6SLionel Sambuc}; 3064684ddb6SLionel Sambuc 3074684ddb6SLionel Sambuctemplate <class T, class D> 3084684ddb6SLionel Sambuc void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept; 3094684ddb6SLionel Sambuc 3104684ddb6SLionel Sambuctemplate <class T1, class D1, class T2, class D2> 3114684ddb6SLionel Sambuc bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 3124684ddb6SLionel Sambuctemplate <class T1, class D1, class T2, class D2> 3134684ddb6SLionel Sambuc bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 3144684ddb6SLionel Sambuctemplate <class T1, class D1, class T2, class D2> 3154684ddb6SLionel Sambuc bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 3164684ddb6SLionel Sambuctemplate <class T1, class D1, class T2, class D2> 3174684ddb6SLionel Sambuc bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 3184684ddb6SLionel Sambuctemplate <class T1, class D1, class T2, class D2> 3194684ddb6SLionel Sambuc bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 3204684ddb6SLionel Sambuctemplate <class T1, class D1, class T2, class D2> 3214684ddb6SLionel Sambuc bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); 3224684ddb6SLionel Sambuc 3234684ddb6SLionel Sambuctemplate <class T, class D> 3244684ddb6SLionel Sambuc bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; 3254684ddb6SLionel Sambuctemplate <class T, class D> 3264684ddb6SLionel Sambuc bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; 3274684ddb6SLionel Sambuctemplate <class T, class D> 3284684ddb6SLionel Sambuc bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; 3294684ddb6SLionel Sambuctemplate <class T, class D> 3304684ddb6SLionel Sambuc bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; 3314684ddb6SLionel Sambuc 3324684ddb6SLionel Sambuctemplate <class T, class D> 3334684ddb6SLionel Sambuc bool operator<(const unique_ptr<T, D>& x, nullptr_t); 3344684ddb6SLionel Sambuctemplate <class T, class D> 3354684ddb6SLionel Sambuc bool operator<(nullptr_t, const unique_ptr<T, D>& y); 3364684ddb6SLionel Sambuctemplate <class T, class D> 3374684ddb6SLionel Sambuc bool operator<=(const unique_ptr<T, D>& x, nullptr_t); 3384684ddb6SLionel Sambuctemplate <class T, class D> 3394684ddb6SLionel Sambuc bool operator<=(nullptr_t, const unique_ptr<T, D>& y); 3404684ddb6SLionel Sambuctemplate <class T, class D> 3414684ddb6SLionel Sambuc bool operator>(const unique_ptr<T, D>& x, nullptr_t); 3424684ddb6SLionel Sambuctemplate <class T, class D> 3434684ddb6SLionel Sambuc bool operator>(nullptr_t, const unique_ptr<T, D>& y); 3444684ddb6SLionel Sambuctemplate <class T, class D> 3454684ddb6SLionel Sambuc bool operator>=(const unique_ptr<T, D>& x, nullptr_t); 3464684ddb6SLionel Sambuctemplate <class T, class D> 3474684ddb6SLionel Sambuc bool operator>=(nullptr_t, const unique_ptr<T, D>& y); 3484684ddb6SLionel Sambuc 3494684ddb6SLionel Sambucclass bad_weak_ptr 3504684ddb6SLionel Sambuc : public std::exception 3514684ddb6SLionel Sambuc{ 3524684ddb6SLionel Sambuc bad_weak_ptr() noexcept; 3534684ddb6SLionel Sambuc}; 3544684ddb6SLionel Sambuc 3554684ddb6SLionel Sambuctemplate<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // C++14 3564684ddb6SLionel Sambuctemplate<class T> unique_ptr<T> make_unique(size_t n); // C++14 3574684ddb6SLionel Sambuctemplate<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N] 3584684ddb6SLionel Sambuc 3594684ddb6SLionel Sambuctemplate<class T> 3604684ddb6SLionel Sambucclass shared_ptr 3614684ddb6SLionel Sambuc{ 3624684ddb6SLionel Sambucpublic: 3634684ddb6SLionel Sambuc typedef T element_type; 3644684ddb6SLionel Sambuc 3654684ddb6SLionel Sambuc // constructors: 3664684ddb6SLionel Sambuc constexpr shared_ptr() noexcept; 3674684ddb6SLionel Sambuc template<class Y> explicit shared_ptr(Y* p); 3684684ddb6SLionel Sambuc template<class Y, class D> shared_ptr(Y* p, D d); 3694684ddb6SLionel Sambuc template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); 3704684ddb6SLionel Sambuc template <class D> shared_ptr(nullptr_t p, D d); 3714684ddb6SLionel Sambuc template <class D, class A> shared_ptr(nullptr_t p, D d, A a); 3724684ddb6SLionel Sambuc template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept; 3734684ddb6SLionel Sambuc shared_ptr(const shared_ptr& r) noexcept; 3744684ddb6SLionel Sambuc template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept; 3754684ddb6SLionel Sambuc shared_ptr(shared_ptr&& r) noexcept; 3764684ddb6SLionel Sambuc template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept; 3774684ddb6SLionel Sambuc template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); 3784684ddb6SLionel Sambuc template<class Y> shared_ptr(auto_ptr<Y>&& r); 3794684ddb6SLionel Sambuc template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r); 3804684ddb6SLionel Sambuc shared_ptr(nullptr_t) : shared_ptr() { } 3814684ddb6SLionel Sambuc 3824684ddb6SLionel Sambuc // destructor: 3834684ddb6SLionel Sambuc ~shared_ptr(); 3844684ddb6SLionel Sambuc 3854684ddb6SLionel Sambuc // assignment: 3864684ddb6SLionel Sambuc shared_ptr& operator=(const shared_ptr& r) noexcept; 3874684ddb6SLionel Sambuc template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept; 3884684ddb6SLionel Sambuc shared_ptr& operator=(shared_ptr&& r) noexcept; 3894684ddb6SLionel Sambuc template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r); 3904684ddb6SLionel Sambuc template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); 3914684ddb6SLionel Sambuc template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); 3924684ddb6SLionel Sambuc 3934684ddb6SLionel Sambuc // modifiers: 3944684ddb6SLionel Sambuc void swap(shared_ptr& r) noexcept; 3954684ddb6SLionel Sambuc void reset() noexcept; 3964684ddb6SLionel Sambuc template<class Y> void reset(Y* p); 3974684ddb6SLionel Sambuc template<class Y, class D> void reset(Y* p, D d); 3984684ddb6SLionel Sambuc template<class Y, class D, class A> void reset(Y* p, D d, A a); 3994684ddb6SLionel Sambuc 4004684ddb6SLionel Sambuc // observers: 4014684ddb6SLionel Sambuc T* get() const noexcept; 4024684ddb6SLionel Sambuc T& operator*() const noexcept; 4034684ddb6SLionel Sambuc T* operator->() const noexcept; 4044684ddb6SLionel Sambuc long use_count() const noexcept; 4054684ddb6SLionel Sambuc bool unique() const noexcept; 4064684ddb6SLionel Sambuc explicit operator bool() const noexcept; 4074684ddb6SLionel Sambuc template<class U> bool owner_before(shared_ptr<U> const& b) const; 4084684ddb6SLionel Sambuc template<class U> bool owner_before(weak_ptr<U> const& b) const; 4094684ddb6SLionel Sambuc}; 4104684ddb6SLionel Sambuc 4114684ddb6SLionel Sambuc// shared_ptr comparisons: 4124684ddb6SLionel Sambuctemplate<class T, class U> 4134684ddb6SLionel Sambuc bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 4144684ddb6SLionel Sambuctemplate<class T, class U> 4154684ddb6SLionel Sambuc bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 4164684ddb6SLionel Sambuctemplate<class T, class U> 4174684ddb6SLionel Sambuc bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 4184684ddb6SLionel Sambuctemplate<class T, class U> 4194684ddb6SLionel Sambuc bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 4204684ddb6SLionel Sambuctemplate<class T, class U> 4214684ddb6SLionel Sambuc bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 4224684ddb6SLionel Sambuctemplate<class T, class U> 4234684ddb6SLionel Sambuc bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; 4244684ddb6SLionel Sambuc 4254684ddb6SLionel Sambuctemplate <class T> 4264684ddb6SLionel Sambuc bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept; 4274684ddb6SLionel Sambuctemplate <class T> 4284684ddb6SLionel Sambuc bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept; 4294684ddb6SLionel Sambuctemplate <class T> 4304684ddb6SLionel Sambuc bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept; 4314684ddb6SLionel Sambuctemplate <class T> 4324684ddb6SLionel Sambuc bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept; 4334684ddb6SLionel Sambuctemplate <class T> 4344684ddb6SLionel Sambuc bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept; 4354684ddb6SLionel Sambuctemplate <class T> 4364684ddb6SLionel Sambucbool operator<(nullptr_t, const shared_ptr<T>& y) noexcept; 4374684ddb6SLionel Sambuctemplate <class T> 4384684ddb6SLionel Sambuc bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept; 4394684ddb6SLionel Sambuctemplate <class T> 4404684ddb6SLionel Sambuc bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept; 4414684ddb6SLionel Sambuctemplate <class T> 4424684ddb6SLionel Sambuc bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept; 4434684ddb6SLionel Sambuctemplate <class T> 4444684ddb6SLionel Sambuc bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept; 4454684ddb6SLionel Sambuctemplate <class T> 4464684ddb6SLionel Sambuc bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept; 4474684ddb6SLionel Sambuctemplate <class T> 4484684ddb6SLionel Sambuc bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept; 4494684ddb6SLionel Sambuc 4504684ddb6SLionel Sambuc// shared_ptr specialized algorithms: 4514684ddb6SLionel Sambuctemplate<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept; 4524684ddb6SLionel Sambuc 4534684ddb6SLionel Sambuc// shared_ptr casts: 4544684ddb6SLionel Sambuctemplate<class T, class U> 4554684ddb6SLionel Sambuc shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept; 4564684ddb6SLionel Sambuctemplate<class T, class U> 4574684ddb6SLionel Sambuc shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept; 4584684ddb6SLionel Sambuctemplate<class T, class U> 4594684ddb6SLionel Sambuc shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept; 4604684ddb6SLionel Sambuc 4614684ddb6SLionel Sambuc// shared_ptr I/O: 4624684ddb6SLionel Sambuctemplate<class E, class T, class Y> 4634684ddb6SLionel Sambuc basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p); 4644684ddb6SLionel Sambuc 4654684ddb6SLionel Sambuc// shared_ptr get_deleter: 4664684ddb6SLionel Sambuctemplate<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept; 4674684ddb6SLionel Sambuc 4684684ddb6SLionel Sambuctemplate<class T, class... Args> 4694684ddb6SLionel Sambuc shared_ptr<T> make_shared(Args&&... args); 4704684ddb6SLionel Sambuctemplate<class T, class A, class... Args> 4714684ddb6SLionel Sambuc shared_ptr<T> allocate_shared(const A& a, Args&&... args); 4724684ddb6SLionel Sambuc 4734684ddb6SLionel Sambuctemplate<class T> 4744684ddb6SLionel Sambucclass weak_ptr 4754684ddb6SLionel Sambuc{ 4764684ddb6SLionel Sambucpublic: 4774684ddb6SLionel Sambuc typedef T element_type; 4784684ddb6SLionel Sambuc 4794684ddb6SLionel Sambuc // constructors 4804684ddb6SLionel Sambuc constexpr weak_ptr() noexcept; 4814684ddb6SLionel Sambuc template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept; 4824684ddb6SLionel Sambuc weak_ptr(weak_ptr const& r) noexcept; 4834684ddb6SLionel Sambuc template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept; 484*0a6a1f1dSLionel Sambuc weak_ptr(weak_ptr&& r) noexcept; // C++14 485*0a6a1f1dSLionel Sambuc template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14 4864684ddb6SLionel Sambuc 4874684ddb6SLionel Sambuc // destructor 4884684ddb6SLionel Sambuc ~weak_ptr(); 4894684ddb6SLionel Sambuc 4904684ddb6SLionel Sambuc // assignment 4914684ddb6SLionel Sambuc weak_ptr& operator=(weak_ptr const& r) noexcept; 4924684ddb6SLionel Sambuc template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept; 4934684ddb6SLionel Sambuc template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept; 494*0a6a1f1dSLionel Sambuc weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 495*0a6a1f1dSLionel Sambuc template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14 4964684ddb6SLionel Sambuc 4974684ddb6SLionel Sambuc // modifiers 4984684ddb6SLionel Sambuc void swap(weak_ptr& r) noexcept; 4994684ddb6SLionel Sambuc void reset() noexcept; 5004684ddb6SLionel Sambuc 5014684ddb6SLionel Sambuc // observers 5024684ddb6SLionel Sambuc long use_count() const noexcept; 5034684ddb6SLionel Sambuc bool expired() const noexcept; 5044684ddb6SLionel Sambuc shared_ptr<T> lock() const noexcept; 5054684ddb6SLionel Sambuc template<class U> bool owner_before(shared_ptr<U> const& b) const; 5064684ddb6SLionel Sambuc template<class U> bool owner_before(weak_ptr<U> const& b) const; 5074684ddb6SLionel Sambuc}; 5084684ddb6SLionel Sambuc 5094684ddb6SLionel Sambuc// weak_ptr specialized algorithms: 5104684ddb6SLionel Sambuctemplate<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept; 5114684ddb6SLionel Sambuc 5124684ddb6SLionel Sambuc// class owner_less: 5134684ddb6SLionel Sambuctemplate<class T> struct owner_less; 5144684ddb6SLionel Sambuc 5154684ddb6SLionel Sambuctemplate<class T> 5164684ddb6SLionel Sambucstruct owner_less<shared_ptr<T>> 5174684ddb6SLionel Sambuc : binary_function<shared_ptr<T>, shared_ptr<T>, bool> 5184684ddb6SLionel Sambuc{ 5194684ddb6SLionel Sambuc typedef bool result_type; 5204684ddb6SLionel Sambuc bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const; 5214684ddb6SLionel Sambuc bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; 5224684ddb6SLionel Sambuc bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; 5234684ddb6SLionel Sambuc}; 5244684ddb6SLionel Sambuc 5254684ddb6SLionel Sambuctemplate<class T> 5264684ddb6SLionel Sambucstruct owner_less<weak_ptr<T>> 5274684ddb6SLionel Sambuc : binary_function<weak_ptr<T>, weak_ptr<T>, bool> 5284684ddb6SLionel Sambuc{ 5294684ddb6SLionel Sambuc typedef bool result_type; 5304684ddb6SLionel Sambuc bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; 5314684ddb6SLionel Sambuc bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; 5324684ddb6SLionel Sambuc bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; 5334684ddb6SLionel Sambuc}; 5344684ddb6SLionel Sambuc 5354684ddb6SLionel Sambuctemplate<class T> 5364684ddb6SLionel Sambucclass enable_shared_from_this 5374684ddb6SLionel Sambuc{ 5384684ddb6SLionel Sambucprotected: 5394684ddb6SLionel Sambuc constexpr enable_shared_from_this() noexcept; 5404684ddb6SLionel Sambuc enable_shared_from_this(enable_shared_from_this const&) noexcept; 5414684ddb6SLionel Sambuc enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; 5424684ddb6SLionel Sambuc ~enable_shared_from_this(); 5434684ddb6SLionel Sambucpublic: 5444684ddb6SLionel Sambuc shared_ptr<T> shared_from_this(); 5454684ddb6SLionel Sambuc shared_ptr<T const> shared_from_this() const; 5464684ddb6SLionel Sambuc}; 5474684ddb6SLionel Sambuc 5484684ddb6SLionel Sambuctemplate<class T> 5494684ddb6SLionel Sambuc bool atomic_is_lock_free(const shared_ptr<T>* p); 5504684ddb6SLionel Sambuctemplate<class T> 5514684ddb6SLionel Sambuc shared_ptr<T> atomic_load(const shared_ptr<T>* p); 5524684ddb6SLionel Sambuctemplate<class T> 5534684ddb6SLionel Sambuc shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo); 5544684ddb6SLionel Sambuctemplate<class T> 5554684ddb6SLionel Sambuc void atomic_store(shared_ptr<T>* p, shared_ptr<T> r); 5564684ddb6SLionel Sambuctemplate<class T> 5574684ddb6SLionel Sambuc void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); 5584684ddb6SLionel Sambuctemplate<class T> 5594684ddb6SLionel Sambuc shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r); 5604684ddb6SLionel Sambuctemplate<class T> 5614684ddb6SLionel Sambuc shared_ptr<T> 5624684ddb6SLionel Sambuc atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); 5634684ddb6SLionel Sambuctemplate<class T> 5644684ddb6SLionel Sambuc bool 5654684ddb6SLionel Sambuc atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); 5664684ddb6SLionel Sambuctemplate<class T> 5674684ddb6SLionel Sambuc bool 5684684ddb6SLionel Sambuc atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); 5694684ddb6SLionel Sambuctemplate<class T> 5704684ddb6SLionel Sambuc bool 5714684ddb6SLionel Sambuc atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, 5724684ddb6SLionel Sambuc shared_ptr<T> w, memory_order success, 5734684ddb6SLionel Sambuc memory_order failure); 5744684ddb6SLionel Sambuctemplate<class T> 5754684ddb6SLionel Sambuc bool 5764684ddb6SLionel Sambuc atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, 5774684ddb6SLionel Sambuc shared_ptr<T> w, memory_order success, 5784684ddb6SLionel Sambuc memory_order failure); 5794684ddb6SLionel Sambuc// Hash support 5804684ddb6SLionel Sambuctemplate <class T> struct hash; 5814684ddb6SLionel Sambuctemplate <class T, class D> struct hash<unique_ptr<T, D> >; 5824684ddb6SLionel Sambuctemplate <class T> struct hash<shared_ptr<T> >; 5834684ddb6SLionel Sambuc 5844684ddb6SLionel Sambuc// Pointer safety 5854684ddb6SLionel Sambucenum class pointer_safety { relaxed, preferred, strict }; 5864684ddb6SLionel Sambucvoid declare_reachable(void *p); 5874684ddb6SLionel Sambuctemplate <class T> T *undeclare_reachable(T *p); 5884684ddb6SLionel Sambucvoid declare_no_pointers(char *p, size_t n); 5894684ddb6SLionel Sambucvoid undeclare_no_pointers(char *p, size_t n); 5904684ddb6SLionel Sambucpointer_safety get_pointer_safety() noexcept; 5914684ddb6SLionel Sambuc 5924684ddb6SLionel Sambucvoid* align(size_t alignment, size_t size, void*& ptr, size_t& space); 5934684ddb6SLionel Sambuc 5944684ddb6SLionel Sambuc} // std 5954684ddb6SLionel Sambuc 5964684ddb6SLionel Sambuc*/ 5974684ddb6SLionel Sambuc 5984684ddb6SLionel Sambuc#include <__config> 5994684ddb6SLionel Sambuc#include <type_traits> 6004684ddb6SLionel Sambuc#include <typeinfo> 6014684ddb6SLionel Sambuc#include <cstddef> 6024684ddb6SLionel Sambuc#include <cstdint> 6034684ddb6SLionel Sambuc#include <new> 6044684ddb6SLionel Sambuc#include <utility> 6054684ddb6SLionel Sambuc#include <limits> 6064684ddb6SLionel Sambuc#include <iterator> 6074684ddb6SLionel Sambuc#include <__functional_base> 6084684ddb6SLionel Sambuc#include <iosfwd> 6094684ddb6SLionel Sambuc#include <tuple> 6104684ddb6SLionel Sambuc#include <cstring> 6114684ddb6SLionel Sambuc#if defined(_LIBCPP_NO_EXCEPTIONS) 6124684ddb6SLionel Sambuc #include <cassert> 6134684ddb6SLionel Sambuc#endif 6144684ddb6SLionel Sambuc 615*0a6a1f1dSLionel Sambuc#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) 6164684ddb6SLionel Sambuc# include <atomic> 6174684ddb6SLionel Sambuc#endif 6184684ddb6SLionel Sambuc 6194684ddb6SLionel Sambuc#include <__undef_min_max> 620*0a6a1f1dSLionel Sambuc#include <__undef___deallocate> 6214684ddb6SLionel Sambuc 6224684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 6234684ddb6SLionel Sambuc#pragma GCC system_header 6244684ddb6SLionel Sambuc#endif 6254684ddb6SLionel Sambuc 6264684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD 6274684ddb6SLionel Sambuc 628*0a6a1f1dSLionel Sambuctemplate <class _ValueType> 629*0a6a1f1dSLionel Sambucinline _LIBCPP_ALWAYS_INLINE 630*0a6a1f1dSLionel Sambuc_ValueType __libcpp_relaxed_load(_ValueType const* __value) { 631*0a6a1f1dSLionel Sambuc#if !defined(_LIBCPP_HAS_NO_THREADS) && \ 632*0a6a1f1dSLionel Sambuc defined(__ATOMIC_RELAXED) && \ 633*0a6a1f1dSLionel Sambuc (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407) 634*0a6a1f1dSLionel Sambuc return __atomic_load_n(__value, __ATOMIC_RELAXED); 635*0a6a1f1dSLionel Sambuc#else 636*0a6a1f1dSLionel Sambuc return *__value; 637*0a6a1f1dSLionel Sambuc#endif 638*0a6a1f1dSLionel Sambuc} 639*0a6a1f1dSLionel Sambuc 6404684ddb6SLionel Sambuc// addressof moved to <__functional_base> 6414684ddb6SLionel Sambuc 6424684ddb6SLionel Sambuctemplate <class _Tp> class allocator; 6434684ddb6SLionel Sambuc 6444684ddb6SLionel Sambuctemplate <> 6454684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY allocator<void> 6464684ddb6SLionel Sambuc{ 6474684ddb6SLionel Sambucpublic: 6484684ddb6SLionel Sambuc typedef void* pointer; 6494684ddb6SLionel Sambuc typedef const void* const_pointer; 6504684ddb6SLionel Sambuc typedef void value_type; 6514684ddb6SLionel Sambuc 6524684ddb6SLionel Sambuc template <class _Up> struct rebind {typedef allocator<_Up> other;}; 6534684ddb6SLionel Sambuc}; 6544684ddb6SLionel Sambuc 6554684ddb6SLionel Sambuctemplate <> 6564684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY allocator<const void> 6574684ddb6SLionel Sambuc{ 6584684ddb6SLionel Sambucpublic: 6594684ddb6SLionel Sambuc typedef const void* pointer; 6604684ddb6SLionel Sambuc typedef const void* const_pointer; 6614684ddb6SLionel Sambuc typedef const void value_type; 6624684ddb6SLionel Sambuc 6634684ddb6SLionel Sambuc template <class _Up> struct rebind {typedef allocator<_Up> other;}; 6644684ddb6SLionel Sambuc}; 6654684ddb6SLionel Sambuc 6664684ddb6SLionel Sambuc// pointer_traits 6674684ddb6SLionel Sambuc 6684684ddb6SLionel Sambuctemplate <class _Tp> 6694684ddb6SLionel Sambucstruct __has_element_type 6704684ddb6SLionel Sambuc{ 6714684ddb6SLionel Sambucprivate: 6724684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 6734684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 6744684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::element_type* = 0); 6754684ddb6SLionel Sambucpublic: 6764684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 6774684ddb6SLionel Sambuc}; 6784684ddb6SLionel Sambuc 6794684ddb6SLionel Sambuctemplate <class _Ptr, bool = __has_element_type<_Ptr>::value> 6804684ddb6SLionel Sambucstruct __pointer_traits_element_type; 6814684ddb6SLionel Sambuc 6824684ddb6SLionel Sambuctemplate <class _Ptr> 6834684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Ptr, true> 6844684ddb6SLionel Sambuc{ 6854684ddb6SLionel Sambuc typedef typename _Ptr::element_type type; 6864684ddb6SLionel Sambuc}; 6874684ddb6SLionel Sambuc 6884684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 6894684ddb6SLionel Sambuc 6904684ddb6SLionel Sambuctemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 6914684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> 6924684ddb6SLionel Sambuc{ 6934684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _Args...>::element_type type; 6944684ddb6SLionel Sambuc}; 6954684ddb6SLionel Sambuc 6964684ddb6SLionel Sambuctemplate <template <class, class...> class _Sp, class _Tp, class ..._Args> 6974684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> 6984684ddb6SLionel Sambuc{ 6994684ddb6SLionel Sambuc typedef _Tp type; 7004684ddb6SLionel Sambuc}; 7014684ddb6SLionel Sambuc 7024684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 7034684ddb6SLionel Sambuc 7044684ddb6SLionel Sambuctemplate <template <class> class _Sp, class _Tp> 7054684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp>, true> 7064684ddb6SLionel Sambuc{ 7074684ddb6SLionel Sambuc typedef typename _Sp<_Tp>::element_type type; 7084684ddb6SLionel Sambuc}; 7094684ddb6SLionel Sambuc 7104684ddb6SLionel Sambuctemplate <template <class> class _Sp, class _Tp> 7114684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp>, false> 7124684ddb6SLionel Sambuc{ 7134684ddb6SLionel Sambuc typedef _Tp type; 7144684ddb6SLionel Sambuc}; 7154684ddb6SLionel Sambuc 7164684ddb6SLionel Sambuctemplate <template <class, class> class _Sp, class _Tp, class _A0> 7174684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, true> 7184684ddb6SLionel Sambuc{ 7194684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0>::element_type type; 7204684ddb6SLionel Sambuc}; 7214684ddb6SLionel Sambuc 7224684ddb6SLionel Sambuctemplate <template <class, class> class _Sp, class _Tp, class _A0> 7234684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp, _A0>, false> 7244684ddb6SLionel Sambuc{ 7254684ddb6SLionel Sambuc typedef _Tp type; 7264684ddb6SLionel Sambuc}; 7274684ddb6SLionel Sambuc 7284684ddb6SLionel Sambuctemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 7294684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true> 7304684ddb6SLionel Sambuc{ 7314684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0, _A1>::element_type type; 7324684ddb6SLionel Sambuc}; 7334684ddb6SLionel Sambuc 7344684ddb6SLionel Sambuctemplate <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> 7354684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false> 7364684ddb6SLionel Sambuc{ 7374684ddb6SLionel Sambuc typedef _Tp type; 7384684ddb6SLionel Sambuc}; 7394684ddb6SLionel Sambuc 7404684ddb6SLionel Sambuctemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 7414684ddb6SLionel Sambuc class _A1, class _A2> 7424684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true> 7434684ddb6SLionel Sambuc{ 7444684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type; 7454684ddb6SLionel Sambuc}; 7464684ddb6SLionel Sambuc 7474684ddb6SLionel Sambuctemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 7484684ddb6SLionel Sambuc class _A1, class _A2> 7494684ddb6SLionel Sambucstruct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false> 7504684ddb6SLionel Sambuc{ 7514684ddb6SLionel Sambuc typedef _Tp type; 7524684ddb6SLionel Sambuc}; 7534684ddb6SLionel Sambuc 7544684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 7554684ddb6SLionel Sambuc 7564684ddb6SLionel Sambuctemplate <class _Tp> 7574684ddb6SLionel Sambucstruct __has_difference_type 7584684ddb6SLionel Sambuc{ 7594684ddb6SLionel Sambucprivate: 7604684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 7614684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 7624684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::difference_type* = 0); 7634684ddb6SLionel Sambucpublic: 7644684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 7654684ddb6SLionel Sambuc}; 7664684ddb6SLionel Sambuc 7674684ddb6SLionel Sambuctemplate <class _Ptr, bool = __has_difference_type<_Ptr>::value> 7684684ddb6SLionel Sambucstruct __pointer_traits_difference_type 7694684ddb6SLionel Sambuc{ 7704684ddb6SLionel Sambuc typedef ptrdiff_t type; 7714684ddb6SLionel Sambuc}; 7724684ddb6SLionel Sambuc 7734684ddb6SLionel Sambuctemplate <class _Ptr> 7744684ddb6SLionel Sambucstruct __pointer_traits_difference_type<_Ptr, true> 7754684ddb6SLionel Sambuc{ 7764684ddb6SLionel Sambuc typedef typename _Ptr::difference_type type; 7774684ddb6SLionel Sambuc}; 7784684ddb6SLionel Sambuc 7794684ddb6SLionel Sambuctemplate <class _Tp, class _Up> 7804684ddb6SLionel Sambucstruct __has_rebind 7814684ddb6SLionel Sambuc{ 7824684ddb6SLionel Sambucprivate: 7834684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 7844684ddb6SLionel Sambuc template <class _Xp> static __two __test(...); 7854684ddb6SLionel Sambuc template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); 7864684ddb6SLionel Sambucpublic: 7874684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 7884684ddb6SLionel Sambuc}; 7894684ddb6SLionel Sambuc 7904684ddb6SLionel Sambuctemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 7914684ddb6SLionel Sambucstruct __pointer_traits_rebind 7924684ddb6SLionel Sambuc{ 7934684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 7944684ddb6SLionel Sambuc typedef typename _Tp::template rebind<_Up> type; 7954684ddb6SLionel Sambuc#else 7964684ddb6SLionel Sambuc typedef typename _Tp::template rebind<_Up>::other type; 7974684ddb6SLionel Sambuc#endif 7984684ddb6SLionel Sambuc}; 7994684ddb6SLionel Sambuc 8004684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 8014684ddb6SLionel Sambuc 8024684ddb6SLionel Sambuctemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 8034684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> 8044684ddb6SLionel Sambuc{ 8054684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 8064684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; 8074684ddb6SLionel Sambuc#else 8084684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; 8094684ddb6SLionel Sambuc#endif 8104684ddb6SLionel Sambuc}; 8114684ddb6SLionel Sambuc 8124684ddb6SLionel Sambuctemplate <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> 8134684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> 8144684ddb6SLionel Sambuc{ 8154684ddb6SLionel Sambuc typedef _Sp<_Up, _Args...> type; 8164684ddb6SLionel Sambuc}; 8174684ddb6SLionel Sambuc 8184684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 8194684ddb6SLionel Sambuc 8204684ddb6SLionel Sambuctemplate <template <class> class _Sp, class _Tp, class _Up> 8214684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> 8224684ddb6SLionel Sambuc{ 8234684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 8244684ddb6SLionel Sambuc typedef typename _Sp<_Tp>::template rebind<_Up> type; 8254684ddb6SLionel Sambuc#else 8264684ddb6SLionel Sambuc typedef typename _Sp<_Tp>::template rebind<_Up>::other type; 8274684ddb6SLionel Sambuc#endif 8284684ddb6SLionel Sambuc}; 8294684ddb6SLionel Sambuc 8304684ddb6SLionel Sambuctemplate <template <class> class _Sp, class _Tp, class _Up> 8314684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp>, _Up, false> 8324684ddb6SLionel Sambuc{ 8334684ddb6SLionel Sambuc typedef _Sp<_Up> type; 8344684ddb6SLionel Sambuc}; 8354684ddb6SLionel Sambuc 8364684ddb6SLionel Sambuctemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 8374684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> 8384684ddb6SLionel Sambuc{ 8394684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 8404684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; 8414684ddb6SLionel Sambuc#else 8424684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; 8434684ddb6SLionel Sambuc#endif 8444684ddb6SLionel Sambuc}; 8454684ddb6SLionel Sambuc 8464684ddb6SLionel Sambuctemplate <template <class, class> class _Sp, class _Tp, class _A0, class _Up> 8474684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false> 8484684ddb6SLionel Sambuc{ 8494684ddb6SLionel Sambuc typedef _Sp<_Up, _A0> type; 8504684ddb6SLionel Sambuc}; 8514684ddb6SLionel Sambuc 8524684ddb6SLionel Sambuctemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 8534684ddb6SLionel Sambuc class _A1, class _Up> 8544684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> 8554684ddb6SLionel Sambuc{ 8564684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 8574684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; 8584684ddb6SLionel Sambuc#else 8594684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; 8604684ddb6SLionel Sambuc#endif 8614684ddb6SLionel Sambuc}; 8624684ddb6SLionel Sambuc 8634684ddb6SLionel Sambuctemplate <template <class, class, class> class _Sp, class _Tp, class _A0, 8644684ddb6SLionel Sambuc class _A1, class _Up> 8654684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false> 8664684ddb6SLionel Sambuc{ 8674684ddb6SLionel Sambuc typedef _Sp<_Up, _A0, _A1> type; 8684684ddb6SLionel Sambuc}; 8694684ddb6SLionel Sambuc 8704684ddb6SLionel Sambuctemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 8714684ddb6SLionel Sambuc class _A1, class _A2, class _Up> 8724684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> 8734684ddb6SLionel Sambuc{ 8744684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 8754684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; 8764684ddb6SLionel Sambuc#else 8774684ddb6SLionel Sambuc typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 8784684ddb6SLionel Sambuc#endif 8794684ddb6SLionel Sambuc}; 8804684ddb6SLionel Sambuc 8814684ddb6SLionel Sambuctemplate <template <class, class, class, class> class _Sp, class _Tp, class _A0, 8824684ddb6SLionel Sambuc class _A1, class _A2, class _Up> 8834684ddb6SLionel Sambucstruct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> 8844684ddb6SLionel Sambuc{ 8854684ddb6SLionel Sambuc typedef _Sp<_Up, _A0, _A1, _A2> type; 8864684ddb6SLionel Sambuc}; 8874684ddb6SLionel Sambuc 8884684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 8894684ddb6SLionel Sambuc 8904684ddb6SLionel Sambuctemplate <class _Ptr> 8914684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY pointer_traits 8924684ddb6SLionel Sambuc{ 8934684ddb6SLionel Sambuc typedef _Ptr pointer; 8944684ddb6SLionel Sambuc typedef typename __pointer_traits_element_type<pointer>::type element_type; 8954684ddb6SLionel Sambuc typedef typename __pointer_traits_difference_type<pointer>::type difference_type; 8964684ddb6SLionel Sambuc 8974684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 8984684ddb6SLionel Sambuc template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; 8994684ddb6SLionel Sambuc#else 9004684ddb6SLionel Sambuc template <class _Up> struct rebind 9014684ddb6SLionel Sambuc {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; 9024684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 9034684ddb6SLionel Sambuc 9044684ddb6SLionel Sambucprivate: 9054684ddb6SLionel Sambuc struct __nat {}; 9064684ddb6SLionel Sambucpublic: 9074684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9084684ddb6SLionel Sambuc static pointer pointer_to(typename conditional<is_void<element_type>::value, 9094684ddb6SLionel Sambuc __nat, element_type>::type& __r) 9104684ddb6SLionel Sambuc {return pointer::pointer_to(__r);} 9114684ddb6SLionel Sambuc}; 9124684ddb6SLionel Sambuc 9134684ddb6SLionel Sambuctemplate <class _Tp> 9144684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*> 9154684ddb6SLionel Sambuc{ 9164684ddb6SLionel Sambuc typedef _Tp* pointer; 9174684ddb6SLionel Sambuc typedef _Tp element_type; 9184684ddb6SLionel Sambuc typedef ptrdiff_t difference_type; 9194684ddb6SLionel Sambuc 9204684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 9214684ddb6SLionel Sambuc template <class _Up> using rebind = _Up*; 9224684ddb6SLionel Sambuc#else 9234684ddb6SLionel Sambuc template <class _Up> struct rebind {typedef _Up* other;}; 9244684ddb6SLionel Sambuc#endif 9254684ddb6SLionel Sambuc 9264684ddb6SLionel Sambucprivate: 9274684ddb6SLionel Sambuc struct __nat {}; 9284684ddb6SLionel Sambucpublic: 9294684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 9304684ddb6SLionel Sambuc static pointer pointer_to(typename conditional<is_void<element_type>::value, 9314684ddb6SLionel Sambuc __nat, element_type>::type& __r) _NOEXCEPT 9324684ddb6SLionel Sambuc {return _VSTD::addressof(__r);} 9334684ddb6SLionel Sambuc}; 9344684ddb6SLionel Sambuc 9354684ddb6SLionel Sambuc// allocator_traits 9364684ddb6SLionel Sambuc 9374684ddb6SLionel Sambucnamespace __has_pointer_type_imp 9384684ddb6SLionel Sambuc{ 9394684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 9404684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::pointer* = 0); 9414684ddb6SLionel Sambuc} 9424684ddb6SLionel Sambuc 9434684ddb6SLionel Sambuctemplate <class _Tp> 9444684ddb6SLionel Sambucstruct __has_pointer_type 9454684ddb6SLionel Sambuc : public integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1> 9464684ddb6SLionel Sambuc{ 9474684ddb6SLionel Sambuc}; 9484684ddb6SLionel Sambuc 9494684ddb6SLionel Sambucnamespace __pointer_type_imp 9504684ddb6SLionel Sambuc{ 9514684ddb6SLionel Sambuc 9524684ddb6SLionel Sambuctemplate <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value> 9534684ddb6SLionel Sambucstruct __pointer_type 9544684ddb6SLionel Sambuc{ 9554684ddb6SLionel Sambuc typedef typename _Dp::pointer type; 9564684ddb6SLionel Sambuc}; 9574684ddb6SLionel Sambuc 9584684ddb6SLionel Sambuctemplate <class _Tp, class _Dp> 9594684ddb6SLionel Sambucstruct __pointer_type<_Tp, _Dp, false> 9604684ddb6SLionel Sambuc{ 9614684ddb6SLionel Sambuc typedef _Tp* type; 9624684ddb6SLionel Sambuc}; 9634684ddb6SLionel Sambuc 9644684ddb6SLionel Sambuc} // __pointer_type_imp 9654684ddb6SLionel Sambuc 9664684ddb6SLionel Sambuctemplate <class _Tp, class _Dp> 9674684ddb6SLionel Sambucstruct __pointer_type 9684684ddb6SLionel Sambuc{ 9694684ddb6SLionel Sambuc typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type; 9704684ddb6SLionel Sambuc}; 9714684ddb6SLionel Sambuc 9724684ddb6SLionel Sambuctemplate <class _Tp> 9734684ddb6SLionel Sambucstruct __has_const_pointer 9744684ddb6SLionel Sambuc{ 9754684ddb6SLionel Sambucprivate: 9764684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 9774684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 9784684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::const_pointer* = 0); 9794684ddb6SLionel Sambucpublic: 9804684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 9814684ddb6SLionel Sambuc}; 9824684ddb6SLionel Sambuc 9834684ddb6SLionel Sambuctemplate <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value> 9844684ddb6SLionel Sambucstruct __const_pointer 9854684ddb6SLionel Sambuc{ 9864684ddb6SLionel Sambuc typedef typename _Alloc::const_pointer type; 9874684ddb6SLionel Sambuc}; 9884684ddb6SLionel Sambuc 9894684ddb6SLionel Sambuctemplate <class _Tp, class _Ptr, class _Alloc> 9904684ddb6SLionel Sambucstruct __const_pointer<_Tp, _Ptr, _Alloc, false> 9914684ddb6SLionel Sambuc{ 9924684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 9934684ddb6SLionel Sambuc typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; 9944684ddb6SLionel Sambuc#else 9954684ddb6SLionel Sambuc typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; 9964684ddb6SLionel Sambuc#endif 9974684ddb6SLionel Sambuc}; 9984684ddb6SLionel Sambuc 9994684ddb6SLionel Sambuctemplate <class _Tp> 10004684ddb6SLionel Sambucstruct __has_void_pointer 10014684ddb6SLionel Sambuc{ 10024684ddb6SLionel Sambucprivate: 10034684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 10044684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 10054684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::void_pointer* = 0); 10064684ddb6SLionel Sambucpublic: 10074684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 10084684ddb6SLionel Sambuc}; 10094684ddb6SLionel Sambuc 10104684ddb6SLionel Sambuctemplate <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value> 10114684ddb6SLionel Sambucstruct __void_pointer 10124684ddb6SLionel Sambuc{ 10134684ddb6SLionel Sambuc typedef typename _Alloc::void_pointer type; 10144684ddb6SLionel Sambuc}; 10154684ddb6SLionel Sambuc 10164684ddb6SLionel Sambuctemplate <class _Ptr, class _Alloc> 10174684ddb6SLionel Sambucstruct __void_pointer<_Ptr, _Alloc, false> 10184684ddb6SLionel Sambuc{ 10194684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 10204684ddb6SLionel Sambuc typedef typename pointer_traits<_Ptr>::template rebind<void> type; 10214684ddb6SLionel Sambuc#else 10224684ddb6SLionel Sambuc typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; 10234684ddb6SLionel Sambuc#endif 10244684ddb6SLionel Sambuc}; 10254684ddb6SLionel Sambuc 10264684ddb6SLionel Sambuctemplate <class _Tp> 10274684ddb6SLionel Sambucstruct __has_const_void_pointer 10284684ddb6SLionel Sambuc{ 10294684ddb6SLionel Sambucprivate: 10304684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 10314684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 10324684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::const_void_pointer* = 0); 10334684ddb6SLionel Sambucpublic: 10344684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 10354684ddb6SLionel Sambuc}; 10364684ddb6SLionel Sambuc 10374684ddb6SLionel Sambuctemplate <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value> 10384684ddb6SLionel Sambucstruct __const_void_pointer 10394684ddb6SLionel Sambuc{ 10404684ddb6SLionel Sambuc typedef typename _Alloc::const_void_pointer type; 10414684ddb6SLionel Sambuc}; 10424684ddb6SLionel Sambuc 10434684ddb6SLionel Sambuctemplate <class _Ptr, class _Alloc> 10444684ddb6SLionel Sambucstruct __const_void_pointer<_Ptr, _Alloc, false> 10454684ddb6SLionel Sambuc{ 10464684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 10474684ddb6SLionel Sambuc typedef typename pointer_traits<_Ptr>::template rebind<const void> type; 10484684ddb6SLionel Sambuc#else 10494684ddb6SLionel Sambuc typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; 10504684ddb6SLionel Sambuc#endif 10514684ddb6SLionel Sambuc}; 10524684ddb6SLionel Sambuc 10534684ddb6SLionel Sambuctemplate <class _Tp> 10544684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10554684ddb6SLionel Sambuc_Tp* 10564684ddb6SLionel Sambuc__to_raw_pointer(_Tp* __p) _NOEXCEPT 10574684ddb6SLionel Sambuc{ 10584684ddb6SLionel Sambuc return __p; 10594684ddb6SLionel Sambuc} 10604684ddb6SLionel Sambuc 10614684ddb6SLionel Sambuctemplate <class _Pointer> 10624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10634684ddb6SLionel Sambuctypename pointer_traits<_Pointer>::element_type* 10644684ddb6SLionel Sambuc__to_raw_pointer(_Pointer __p) _NOEXCEPT 10654684ddb6SLionel Sambuc{ 10664684ddb6SLionel Sambuc return _VSTD::__to_raw_pointer(__p.operator->()); 10674684ddb6SLionel Sambuc} 10684684ddb6SLionel Sambuc 10694684ddb6SLionel Sambuctemplate <class _Tp> 10704684ddb6SLionel Sambucstruct __has_size_type 10714684ddb6SLionel Sambuc{ 10724684ddb6SLionel Sambucprivate: 10734684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 10744684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 10754684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::size_type* = 0); 10764684ddb6SLionel Sambucpublic: 10774684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 10784684ddb6SLionel Sambuc}; 10794684ddb6SLionel Sambuc 10804684ddb6SLionel Sambuctemplate <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> 10814684ddb6SLionel Sambucstruct __size_type 10824684ddb6SLionel Sambuc{ 10834684ddb6SLionel Sambuc typedef typename make_unsigned<_DiffType>::type type; 10844684ddb6SLionel Sambuc}; 10854684ddb6SLionel Sambuc 10864684ddb6SLionel Sambuctemplate <class _Alloc, class _DiffType> 10874684ddb6SLionel Sambucstruct __size_type<_Alloc, _DiffType, true> 10884684ddb6SLionel Sambuc{ 10894684ddb6SLionel Sambuc typedef typename _Alloc::size_type type; 10904684ddb6SLionel Sambuc}; 10914684ddb6SLionel Sambuc 10924684ddb6SLionel Sambuctemplate <class _Tp> 10934684ddb6SLionel Sambucstruct __has_propagate_on_container_copy_assignment 10944684ddb6SLionel Sambuc{ 10954684ddb6SLionel Sambucprivate: 10964684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 10974684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 10984684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0); 10994684ddb6SLionel Sambucpublic: 11004684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 11014684ddb6SLionel Sambuc}; 11024684ddb6SLionel Sambuc 11034684ddb6SLionel Sambuctemplate <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value> 11044684ddb6SLionel Sambucstruct __propagate_on_container_copy_assignment 11054684ddb6SLionel Sambuc{ 11064684ddb6SLionel Sambuc typedef false_type type; 11074684ddb6SLionel Sambuc}; 11084684ddb6SLionel Sambuc 11094684ddb6SLionel Sambuctemplate <class _Alloc> 11104684ddb6SLionel Sambucstruct __propagate_on_container_copy_assignment<_Alloc, true> 11114684ddb6SLionel Sambuc{ 11124684ddb6SLionel Sambuc typedef typename _Alloc::propagate_on_container_copy_assignment type; 11134684ddb6SLionel Sambuc}; 11144684ddb6SLionel Sambuc 11154684ddb6SLionel Sambuctemplate <class _Tp> 11164684ddb6SLionel Sambucstruct __has_propagate_on_container_move_assignment 11174684ddb6SLionel Sambuc{ 11184684ddb6SLionel Sambucprivate: 11194684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 11204684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 11214684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0); 11224684ddb6SLionel Sambucpublic: 11234684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 11244684ddb6SLionel Sambuc}; 11254684ddb6SLionel Sambuc 11264684ddb6SLionel Sambuctemplate <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value> 11274684ddb6SLionel Sambucstruct __propagate_on_container_move_assignment 11284684ddb6SLionel Sambuc{ 11294684ddb6SLionel Sambuc typedef false_type type; 11304684ddb6SLionel Sambuc}; 11314684ddb6SLionel Sambuc 11324684ddb6SLionel Sambuctemplate <class _Alloc> 11334684ddb6SLionel Sambucstruct __propagate_on_container_move_assignment<_Alloc, true> 11344684ddb6SLionel Sambuc{ 11354684ddb6SLionel Sambuc typedef typename _Alloc::propagate_on_container_move_assignment type; 11364684ddb6SLionel Sambuc}; 11374684ddb6SLionel Sambuc 11384684ddb6SLionel Sambuctemplate <class _Tp> 11394684ddb6SLionel Sambucstruct __has_propagate_on_container_swap 11404684ddb6SLionel Sambuc{ 11414684ddb6SLionel Sambucprivate: 11424684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 11434684ddb6SLionel Sambuc template <class _Up> static __two __test(...); 11444684ddb6SLionel Sambuc template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0); 11454684ddb6SLionel Sambucpublic: 11464684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 11474684ddb6SLionel Sambuc}; 11484684ddb6SLionel Sambuc 11494684ddb6SLionel Sambuctemplate <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> 11504684ddb6SLionel Sambucstruct __propagate_on_container_swap 11514684ddb6SLionel Sambuc{ 11524684ddb6SLionel Sambuc typedef false_type type; 11534684ddb6SLionel Sambuc}; 11544684ddb6SLionel Sambuc 11554684ddb6SLionel Sambuctemplate <class _Alloc> 11564684ddb6SLionel Sambucstruct __propagate_on_container_swap<_Alloc, true> 11574684ddb6SLionel Sambuc{ 11584684ddb6SLionel Sambuc typedef typename _Alloc::propagate_on_container_swap type; 11594684ddb6SLionel Sambuc}; 11604684ddb6SLionel Sambuc 1161*0a6a1f1dSLionel Sambuctemplate <class _Tp> 1162*0a6a1f1dSLionel Sambucstruct __has_is_always_equal 1163*0a6a1f1dSLionel Sambuc{ 1164*0a6a1f1dSLionel Sambucprivate: 1165*0a6a1f1dSLionel Sambuc struct __two {char __lx; char __lxx;}; 1166*0a6a1f1dSLionel Sambuc template <class _Up> static __two __test(...); 1167*0a6a1f1dSLionel Sambuc template <class _Up> static char __test(typename _Up::is_always_equal* = 0); 1168*0a6a1f1dSLionel Sambucpublic: 1169*0a6a1f1dSLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 1170*0a6a1f1dSLionel Sambuc}; 1171*0a6a1f1dSLionel Sambuc 1172*0a6a1f1dSLionel Sambuctemplate <class _Alloc, bool = __has_is_always_equal<_Alloc>::value> 1173*0a6a1f1dSLionel Sambucstruct __is_always_equal 1174*0a6a1f1dSLionel Sambuc{ 1175*0a6a1f1dSLionel Sambuc typedef typename _VSTD::is_empty<_Alloc>::type type; 1176*0a6a1f1dSLionel Sambuc}; 1177*0a6a1f1dSLionel Sambuc 1178*0a6a1f1dSLionel Sambuctemplate <class _Alloc> 1179*0a6a1f1dSLionel Sambucstruct __is_always_equal<_Alloc, true> 1180*0a6a1f1dSLionel Sambuc{ 1181*0a6a1f1dSLionel Sambuc typedef typename _Alloc::is_always_equal type; 1182*0a6a1f1dSLionel Sambuc}; 1183*0a6a1f1dSLionel Sambuc 11844684ddb6SLionel Sambuctemplate <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> 11854684ddb6SLionel Sambucstruct __has_rebind_other 11864684ddb6SLionel Sambuc{ 11874684ddb6SLionel Sambucprivate: 11884684ddb6SLionel Sambuc struct __two {char __lx; char __lxx;}; 11894684ddb6SLionel Sambuc template <class _Xp> static __two __test(...); 11904684ddb6SLionel Sambuc template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); 11914684ddb6SLionel Sambucpublic: 11924684ddb6SLionel Sambuc static const bool value = sizeof(__test<_Tp>(0)) == 1; 11934684ddb6SLionel Sambuc}; 11944684ddb6SLionel Sambuc 11954684ddb6SLionel Sambuctemplate <class _Tp, class _Up> 11964684ddb6SLionel Sambucstruct __has_rebind_other<_Tp, _Up, false> 11974684ddb6SLionel Sambuc{ 11984684ddb6SLionel Sambuc static const bool value = false; 11994684ddb6SLionel Sambuc}; 12004684ddb6SLionel Sambuc 12014684ddb6SLionel Sambuctemplate <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> 12024684ddb6SLionel Sambucstruct __allocator_traits_rebind 12034684ddb6SLionel Sambuc{ 12044684ddb6SLionel Sambuc typedef typename _Tp::template rebind<_Up>::other type; 12054684ddb6SLionel Sambuc}; 12064684ddb6SLionel Sambuc 12074684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 12084684ddb6SLionel Sambuc 12094684ddb6SLionel Sambuctemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 12104684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> 12114684ddb6SLionel Sambuc{ 12124684ddb6SLionel Sambuc typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; 12134684ddb6SLionel Sambuc}; 12144684ddb6SLionel Sambuc 12154684ddb6SLionel Sambuctemplate <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> 12164684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> 12174684ddb6SLionel Sambuc{ 12184684ddb6SLionel Sambuc typedef _Alloc<_Up, _Args...> type; 12194684ddb6SLionel Sambuc}; 12204684ddb6SLionel Sambuc 12214684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 12224684ddb6SLionel Sambuc 12234684ddb6SLionel Sambuctemplate <template <class> class _Alloc, class _Tp, class _Up> 12244684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true> 12254684ddb6SLionel Sambuc{ 12264684ddb6SLionel Sambuc typedef typename _Alloc<_Tp>::template rebind<_Up>::other type; 12274684ddb6SLionel Sambuc}; 12284684ddb6SLionel Sambuc 12294684ddb6SLionel Sambuctemplate <template <class> class _Alloc, class _Tp, class _Up> 12304684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false> 12314684ddb6SLionel Sambuc{ 12324684ddb6SLionel Sambuc typedef _Alloc<_Up> type; 12334684ddb6SLionel Sambuc}; 12344684ddb6SLionel Sambuc 12354684ddb6SLionel Sambuctemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 12364684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true> 12374684ddb6SLionel Sambuc{ 12384684ddb6SLionel Sambuc typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type; 12394684ddb6SLionel Sambuc}; 12404684ddb6SLionel Sambuc 12414684ddb6SLionel Sambuctemplate <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> 12424684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false> 12434684ddb6SLionel Sambuc{ 12444684ddb6SLionel Sambuc typedef _Alloc<_Up, _A0> type; 12454684ddb6SLionel Sambuc}; 12464684ddb6SLionel Sambuc 12474684ddb6SLionel Sambuctemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 12484684ddb6SLionel Sambuc class _A1, class _Up> 12494684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true> 12504684ddb6SLionel Sambuc{ 12514684ddb6SLionel Sambuc typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type; 12524684ddb6SLionel Sambuc}; 12534684ddb6SLionel Sambuc 12544684ddb6SLionel Sambuctemplate <template <class, class, class> class _Alloc, class _Tp, class _A0, 12554684ddb6SLionel Sambuc class _A1, class _Up> 12564684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false> 12574684ddb6SLionel Sambuc{ 12584684ddb6SLionel Sambuc typedef _Alloc<_Up, _A0, _A1> type; 12594684ddb6SLionel Sambuc}; 12604684ddb6SLionel Sambuc 12614684ddb6SLionel Sambuctemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 12624684ddb6SLionel Sambuc class _A1, class _A2, class _Up> 12634684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true> 12644684ddb6SLionel Sambuc{ 12654684ddb6SLionel Sambuc typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; 12664684ddb6SLionel Sambuc}; 12674684ddb6SLionel Sambuc 12684684ddb6SLionel Sambuctemplate <template <class, class, class, class> class _Alloc, class _Tp, class _A0, 12694684ddb6SLionel Sambuc class _A1, class _A2, class _Up> 12704684ddb6SLionel Sambucstruct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> 12714684ddb6SLionel Sambuc{ 12724684ddb6SLionel Sambuc typedef _Alloc<_Up, _A0, _A1, _A2> type; 12734684ddb6SLionel Sambuc}; 12744684ddb6SLionel Sambuc 12754684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 12764684ddb6SLionel Sambuc 12774684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 12784684ddb6SLionel Sambuc 12794684ddb6SLionel Sambuctemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 12804684ddb6SLionel Sambucauto 12814684ddb6SLionel Sambuc__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 12824684ddb6SLionel Sambuc -> decltype(__a.allocate(__sz, __p), true_type()); 12834684ddb6SLionel Sambuc 12844684ddb6SLionel Sambuctemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 12854684ddb6SLionel Sambucauto 12864684ddb6SLionel Sambuc__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) 12874684ddb6SLionel Sambuc -> false_type; 12884684ddb6SLionel Sambuc 12894684ddb6SLionel Sambuctemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 12904684ddb6SLionel Sambucstruct __has_allocate_hint 12914684ddb6SLionel Sambuc : integral_constant<bool, 12924684ddb6SLionel Sambuc is_same< 12934684ddb6SLionel Sambuc decltype(__has_allocate_hint_test(declval<_Alloc>(), 12944684ddb6SLionel Sambuc declval<_SizeType>(), 12954684ddb6SLionel Sambuc declval<_ConstVoidPtr>())), 12964684ddb6SLionel Sambuc true_type>::value> 12974684ddb6SLionel Sambuc{ 12984684ddb6SLionel Sambuc}; 12994684ddb6SLionel Sambuc 13004684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 13014684ddb6SLionel Sambuc 13024684ddb6SLionel Sambuctemplate <class _Alloc, class _SizeType, class _ConstVoidPtr> 13034684ddb6SLionel Sambucstruct __has_allocate_hint 13044684ddb6SLionel Sambuc : true_type 13054684ddb6SLionel Sambuc{ 13064684ddb6SLionel Sambuc}; 13074684ddb6SLionel Sambuc 13084684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 13094684ddb6SLionel Sambuc 13104684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS) 13114684ddb6SLionel Sambuc 13124684ddb6SLionel Sambuctemplate <class _Alloc, class _Tp, class ..._Args> 13134684ddb6SLionel Sambucdecltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), 13144684ddb6SLionel Sambuc _VSTD::declval<_Args>()...), 13154684ddb6SLionel Sambuc true_type()) 13164684ddb6SLionel Sambuc__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args); 13174684ddb6SLionel Sambuc 13184684ddb6SLionel Sambuctemplate <class _Alloc, class _Pointer, class ..._Args> 13194684ddb6SLionel Sambucfalse_type 13204684ddb6SLionel Sambuc__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args); 13214684ddb6SLionel Sambuc 13224684ddb6SLionel Sambuctemplate <class _Alloc, class _Pointer, class ..._Args> 13234684ddb6SLionel Sambucstruct __has_construct 13244684ddb6SLionel Sambuc : integral_constant<bool, 13254684ddb6SLionel Sambuc is_same< 13264684ddb6SLionel Sambuc decltype(__has_construct_test(declval<_Alloc>(), 13274684ddb6SLionel Sambuc declval<_Pointer>(), 13284684ddb6SLionel Sambuc declval<_Args>()...)), 13294684ddb6SLionel Sambuc true_type>::value> 13304684ddb6SLionel Sambuc{ 13314684ddb6SLionel Sambuc}; 13324684ddb6SLionel Sambuc 13334684ddb6SLionel Sambuctemplate <class _Alloc, class _Pointer> 13344684ddb6SLionel Sambucauto 13354684ddb6SLionel Sambuc__has_destroy_test(_Alloc&& __a, _Pointer&& __p) 13364684ddb6SLionel Sambuc -> decltype(__a.destroy(__p), true_type()); 13374684ddb6SLionel Sambuc 13384684ddb6SLionel Sambuctemplate <class _Alloc, class _Pointer> 13394684ddb6SLionel Sambucauto 13404684ddb6SLionel Sambuc__has_destroy_test(const _Alloc& __a, _Pointer&& __p) 13414684ddb6SLionel Sambuc -> false_type; 13424684ddb6SLionel Sambuc 13434684ddb6SLionel Sambuctemplate <class _Alloc, class _Pointer> 13444684ddb6SLionel Sambucstruct __has_destroy 13454684ddb6SLionel Sambuc : integral_constant<bool, 13464684ddb6SLionel Sambuc is_same< 13474684ddb6SLionel Sambuc decltype(__has_destroy_test(declval<_Alloc>(), 13484684ddb6SLionel Sambuc declval<_Pointer>())), 13494684ddb6SLionel Sambuc true_type>::value> 13504684ddb6SLionel Sambuc{ 13514684ddb6SLionel Sambuc}; 13524684ddb6SLionel Sambuc 13534684ddb6SLionel Sambuctemplate <class _Alloc> 13544684ddb6SLionel Sambucauto 13554684ddb6SLionel Sambuc__has_max_size_test(_Alloc&& __a) 13564684ddb6SLionel Sambuc -> decltype(__a.max_size(), true_type()); 13574684ddb6SLionel Sambuc 13584684ddb6SLionel Sambuctemplate <class _Alloc> 13594684ddb6SLionel Sambucauto 13604684ddb6SLionel Sambuc__has_max_size_test(const volatile _Alloc& __a) 13614684ddb6SLionel Sambuc -> false_type; 13624684ddb6SLionel Sambuc 13634684ddb6SLionel Sambuctemplate <class _Alloc> 13644684ddb6SLionel Sambucstruct __has_max_size 13654684ddb6SLionel Sambuc : integral_constant<bool, 13664684ddb6SLionel Sambuc is_same< 13674684ddb6SLionel Sambuc decltype(__has_max_size_test(declval<_Alloc&>())), 13684684ddb6SLionel Sambuc true_type>::value> 13694684ddb6SLionel Sambuc{ 13704684ddb6SLionel Sambuc}; 13714684ddb6SLionel Sambuc 13724684ddb6SLionel Sambuctemplate <class _Alloc> 13734684ddb6SLionel Sambucauto 13744684ddb6SLionel Sambuc__has_select_on_container_copy_construction_test(_Alloc&& __a) 13754684ddb6SLionel Sambuc -> decltype(__a.select_on_container_copy_construction(), true_type()); 13764684ddb6SLionel Sambuc 13774684ddb6SLionel Sambuctemplate <class _Alloc> 13784684ddb6SLionel Sambucauto 13794684ddb6SLionel Sambuc__has_select_on_container_copy_construction_test(const volatile _Alloc& __a) 13804684ddb6SLionel Sambuc -> false_type; 13814684ddb6SLionel Sambuc 13824684ddb6SLionel Sambuctemplate <class _Alloc> 13834684ddb6SLionel Sambucstruct __has_select_on_container_copy_construction 13844684ddb6SLionel Sambuc : integral_constant<bool, 13854684ddb6SLionel Sambuc is_same< 13864684ddb6SLionel Sambuc decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())), 13874684ddb6SLionel Sambuc true_type>::value> 13884684ddb6SLionel Sambuc{ 13894684ddb6SLionel Sambuc}; 13904684ddb6SLionel Sambuc 13914684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE 13924684ddb6SLionel Sambuc 13934684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 13944684ddb6SLionel Sambuc 13954684ddb6SLionel Sambuctemplate <class _Alloc, class _Pointer, class ..._Args> 13964684ddb6SLionel Sambucstruct __has_construct 13974684ddb6SLionel Sambuc : false_type 13984684ddb6SLionel Sambuc{ 13994684ddb6SLionel Sambuc}; 14004684ddb6SLionel Sambuc 14014684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 14024684ddb6SLionel Sambuc 14034684ddb6SLionel Sambuctemplate <class _Alloc, class _Pointer, class _Args> 14044684ddb6SLionel Sambucstruct __has_construct 14054684ddb6SLionel Sambuc : false_type 14064684ddb6SLionel Sambuc{ 14074684ddb6SLionel Sambuc}; 14084684ddb6SLionel Sambuc 14094684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 14104684ddb6SLionel Sambuc 14114684ddb6SLionel Sambuctemplate <class _Alloc, class _Pointer> 14124684ddb6SLionel Sambucstruct __has_destroy 14134684ddb6SLionel Sambuc : false_type 14144684ddb6SLionel Sambuc{ 14154684ddb6SLionel Sambuc}; 14164684ddb6SLionel Sambuc 14174684ddb6SLionel Sambuctemplate <class _Alloc> 14184684ddb6SLionel Sambucstruct __has_max_size 14194684ddb6SLionel Sambuc : true_type 14204684ddb6SLionel Sambuc{ 14214684ddb6SLionel Sambuc}; 14224684ddb6SLionel Sambuc 14234684ddb6SLionel Sambuctemplate <class _Alloc> 14244684ddb6SLionel Sambucstruct __has_select_on_container_copy_construction 14254684ddb6SLionel Sambuc : false_type 14264684ddb6SLionel Sambuc{ 14274684ddb6SLionel Sambuc}; 14284684ddb6SLionel Sambuc 14294684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 14304684ddb6SLionel Sambuc 14314684ddb6SLionel Sambuctemplate <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> 14324684ddb6SLionel Sambucstruct __alloc_traits_difference_type 14334684ddb6SLionel Sambuc{ 14344684ddb6SLionel Sambuc typedef typename pointer_traits<_Ptr>::difference_type type; 14354684ddb6SLionel Sambuc}; 14364684ddb6SLionel Sambuc 14374684ddb6SLionel Sambuctemplate <class _Alloc, class _Ptr> 14384684ddb6SLionel Sambucstruct __alloc_traits_difference_type<_Alloc, _Ptr, true> 14394684ddb6SLionel Sambuc{ 14404684ddb6SLionel Sambuc typedef typename _Alloc::difference_type type; 14414684ddb6SLionel Sambuc}; 14424684ddb6SLionel Sambuc 14434684ddb6SLionel Sambuctemplate <class _Alloc> 14444684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY allocator_traits 14454684ddb6SLionel Sambuc{ 14464684ddb6SLionel Sambuc typedef _Alloc allocator_type; 14474684ddb6SLionel Sambuc typedef typename allocator_type::value_type value_type; 14484684ddb6SLionel Sambuc 14494684ddb6SLionel Sambuc typedef typename __pointer_type<value_type, allocator_type>::type pointer; 14504684ddb6SLionel Sambuc typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer; 14514684ddb6SLionel Sambuc typedef typename __void_pointer<pointer, allocator_type>::type void_pointer; 14524684ddb6SLionel Sambuc typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer; 14534684ddb6SLionel Sambuc 14544684ddb6SLionel Sambuc typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type; 14554684ddb6SLionel Sambuc typedef typename __size_type<allocator_type, difference_type>::type size_type; 14564684ddb6SLionel Sambuc 14574684ddb6SLionel Sambuc typedef typename __propagate_on_container_copy_assignment<allocator_type>::type 14584684ddb6SLionel Sambuc propagate_on_container_copy_assignment; 14594684ddb6SLionel Sambuc typedef typename __propagate_on_container_move_assignment<allocator_type>::type 14604684ddb6SLionel Sambuc propagate_on_container_move_assignment; 14614684ddb6SLionel Sambuc typedef typename __propagate_on_container_swap<allocator_type>::type 14624684ddb6SLionel Sambuc propagate_on_container_swap; 1463*0a6a1f1dSLionel Sambuc typedef typename __is_always_equal<allocator_type>::type 1464*0a6a1f1dSLionel Sambuc is_always_equal; 14654684ddb6SLionel Sambuc 14664684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 14674684ddb6SLionel Sambuc template <class _Tp> using rebind_alloc = 14684684ddb6SLionel Sambuc typename __allocator_traits_rebind<allocator_type, _Tp>::type; 14694684ddb6SLionel Sambuc template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; 14704684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 14714684ddb6SLionel Sambuc template <class _Tp> struct rebind_alloc 14724684ddb6SLionel Sambuc {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;}; 14734684ddb6SLionel Sambuc template <class _Tp> struct rebind_traits 14744684ddb6SLionel Sambuc {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;}; 14754684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES 14764684ddb6SLionel Sambuc 14774684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14784684ddb6SLionel Sambuc static pointer allocate(allocator_type& __a, size_type __n) 14794684ddb6SLionel Sambuc {return __a.allocate(__n);} 14804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14814684ddb6SLionel Sambuc static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) 14824684ddb6SLionel Sambuc {return allocate(__a, __n, __hint, 14834684ddb6SLionel Sambuc __has_allocate_hint<allocator_type, size_type, const_void_pointer>());} 14844684ddb6SLionel Sambuc 14854684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14864684ddb6SLionel Sambuc static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT 14874684ddb6SLionel Sambuc {__a.deallocate(__p, __n);} 14884684ddb6SLionel Sambuc 14894684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 14904684ddb6SLionel Sambuc template <class _Tp, class... _Args> 14914684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14924684ddb6SLionel Sambuc static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) 1493*0a6a1f1dSLionel Sambuc {__construct(__has_construct<allocator_type, _Tp*, _Args...>(), 14944684ddb6SLionel Sambuc __a, __p, _VSTD::forward<_Args>(__args)...);} 14954684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 14964684ddb6SLionel Sambuc template <class _Tp> 14974684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14984684ddb6SLionel Sambuc static void construct(allocator_type& __a, _Tp* __p) 14994684ddb6SLionel Sambuc { 15004684ddb6SLionel Sambuc ::new ((void*)__p) _Tp(); 15014684ddb6SLionel Sambuc } 15024684ddb6SLionel Sambuc template <class _Tp, class _A0> 15034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15044684ddb6SLionel Sambuc static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0) 15054684ddb6SLionel Sambuc { 15064684ddb6SLionel Sambuc ::new ((void*)__p) _Tp(__a0); 15074684ddb6SLionel Sambuc } 15084684ddb6SLionel Sambuc template <class _Tp, class _A0, class _A1> 15094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15104684ddb6SLionel Sambuc static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, 15114684ddb6SLionel Sambuc const _A1& __a1) 15124684ddb6SLionel Sambuc { 15134684ddb6SLionel Sambuc ::new ((void*)__p) _Tp(__a0, __a1); 15144684ddb6SLionel Sambuc } 15154684ddb6SLionel Sambuc template <class _Tp, class _A0, class _A1, class _A2> 15164684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15174684ddb6SLionel Sambuc static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, 15184684ddb6SLionel Sambuc const _A1& __a1, const _A2& __a2) 15194684ddb6SLionel Sambuc { 15204684ddb6SLionel Sambuc ::new ((void*)__p) _Tp(__a0, __a1, __a2); 15214684ddb6SLionel Sambuc } 15224684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 15234684ddb6SLionel Sambuc 15244684ddb6SLionel Sambuc template <class _Tp> 15254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15264684ddb6SLionel Sambuc static void destroy(allocator_type& __a, _Tp* __p) 15274684ddb6SLionel Sambuc {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} 15284684ddb6SLionel Sambuc 15294684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15304684ddb6SLionel Sambuc static size_type max_size(const allocator_type& __a) _NOEXCEPT 15314684ddb6SLionel Sambuc {return __max_size(__has_max_size<const allocator_type>(), __a);} 15324684ddb6SLionel Sambuc 15334684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15344684ddb6SLionel Sambuc static allocator_type 15354684ddb6SLionel Sambuc select_on_container_copy_construction(const allocator_type& __a) 15364684ddb6SLionel Sambuc {return select_on_container_copy_construction( 15374684ddb6SLionel Sambuc __has_select_on_container_copy_construction<const allocator_type>(), 15384684ddb6SLionel Sambuc __a);} 15394684ddb6SLionel Sambuc 15404684ddb6SLionel Sambuc template <class _Ptr> 15414684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15424684ddb6SLionel Sambuc static 15434684ddb6SLionel Sambuc void 15444684ddb6SLionel Sambuc __construct_forward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) 15454684ddb6SLionel Sambuc { 15464684ddb6SLionel Sambuc for (; __begin1 != __end1; ++__begin1, ++__begin2) 15474684ddb6SLionel Sambuc construct(__a, _VSTD::__to_raw_pointer(__begin2), _VSTD::move_if_noexcept(*__begin1)); 15484684ddb6SLionel Sambuc } 15494684ddb6SLionel Sambuc 15504684ddb6SLionel Sambuc template <class _Tp> 15514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15524684ddb6SLionel Sambuc static 15534684ddb6SLionel Sambuc typename enable_if 15544684ddb6SLionel Sambuc < 15554684ddb6SLionel Sambuc (is_same<allocator_type, allocator<_Tp> >::value 15564684ddb6SLionel Sambuc || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 15574684ddb6SLionel Sambuc is_trivially_move_constructible<_Tp>::value, 15584684ddb6SLionel Sambuc void 15594684ddb6SLionel Sambuc >::type 15604684ddb6SLionel Sambuc __construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) 15614684ddb6SLionel Sambuc { 15624684ddb6SLionel Sambuc ptrdiff_t _Np = __end1 - __begin1; 1563*0a6a1f1dSLionel Sambuc if (_Np > 0) 1564*0a6a1f1dSLionel Sambuc { 15654684ddb6SLionel Sambuc _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); 15664684ddb6SLionel Sambuc __begin2 += _Np; 15674684ddb6SLionel Sambuc } 1568*0a6a1f1dSLionel Sambuc } 1569*0a6a1f1dSLionel Sambuc 1570*0a6a1f1dSLionel Sambuc template <class _Iter, class _Ptr> 1571*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1572*0a6a1f1dSLionel Sambuc static 1573*0a6a1f1dSLionel Sambuc void 1574*0a6a1f1dSLionel Sambuc __construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) 1575*0a6a1f1dSLionel Sambuc { 1576*0a6a1f1dSLionel Sambuc for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) 1577*0a6a1f1dSLionel Sambuc construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1); 1578*0a6a1f1dSLionel Sambuc } 1579*0a6a1f1dSLionel Sambuc 1580*0a6a1f1dSLionel Sambuc template <class _Tp> 1581*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1582*0a6a1f1dSLionel Sambuc static 1583*0a6a1f1dSLionel Sambuc typename enable_if 1584*0a6a1f1dSLionel Sambuc < 1585*0a6a1f1dSLionel Sambuc (is_same<allocator_type, allocator<_Tp> >::value 1586*0a6a1f1dSLionel Sambuc || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 1587*0a6a1f1dSLionel Sambuc is_trivially_move_constructible<_Tp>::value, 1588*0a6a1f1dSLionel Sambuc void 1589*0a6a1f1dSLionel Sambuc >::type 1590*0a6a1f1dSLionel Sambuc __construct_range_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) 1591*0a6a1f1dSLionel Sambuc { 1592*0a6a1f1dSLionel Sambuc typedef typename remove_const<_Tp>::type _Vp; 1593*0a6a1f1dSLionel Sambuc ptrdiff_t _Np = __end1 - __begin1; 1594*0a6a1f1dSLionel Sambuc if (_Np > 0) 1595*0a6a1f1dSLionel Sambuc { 1596*0a6a1f1dSLionel Sambuc _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp)); 1597*0a6a1f1dSLionel Sambuc __begin2 += _Np; 1598*0a6a1f1dSLionel Sambuc } 1599*0a6a1f1dSLionel Sambuc } 16004684ddb6SLionel Sambuc 16014684ddb6SLionel Sambuc template <class _Ptr> 16024684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16034684ddb6SLionel Sambuc static 16044684ddb6SLionel Sambuc void 16054684ddb6SLionel Sambuc __construct_backward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) 16064684ddb6SLionel Sambuc { 16074684ddb6SLionel Sambuc while (__end1 != __begin1) 16084684ddb6SLionel Sambuc { 16094684ddb6SLionel Sambuc construct(__a, _VSTD::__to_raw_pointer(__end2-1), _VSTD::move_if_noexcept(*--__end1)); 16104684ddb6SLionel Sambuc --__end2; 16114684ddb6SLionel Sambuc } 16124684ddb6SLionel Sambuc } 16134684ddb6SLionel Sambuc 16144684ddb6SLionel Sambuc template <class _Tp> 16154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16164684ddb6SLionel Sambuc static 16174684ddb6SLionel Sambuc typename enable_if 16184684ddb6SLionel Sambuc < 16194684ddb6SLionel Sambuc (is_same<allocator_type, allocator<_Tp> >::value 16204684ddb6SLionel Sambuc || !__has_construct<allocator_type, _Tp*, _Tp>::value) && 16214684ddb6SLionel Sambuc is_trivially_move_constructible<_Tp>::value, 16224684ddb6SLionel Sambuc void 16234684ddb6SLionel Sambuc >::type 16244684ddb6SLionel Sambuc __construct_backward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) 16254684ddb6SLionel Sambuc { 16264684ddb6SLionel Sambuc ptrdiff_t _Np = __end1 - __begin1; 16274684ddb6SLionel Sambuc __end2 -= _Np; 1628*0a6a1f1dSLionel Sambuc if (_Np > 0) 16294684ddb6SLionel Sambuc _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp)); 16304684ddb6SLionel Sambuc } 16314684ddb6SLionel Sambuc 16324684ddb6SLionel Sambucprivate: 16334684ddb6SLionel Sambuc 16344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16354684ddb6SLionel Sambuc static pointer allocate(allocator_type& __a, size_type __n, 16364684ddb6SLionel Sambuc const_void_pointer __hint, true_type) 16374684ddb6SLionel Sambuc {return __a.allocate(__n, __hint);} 16384684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16394684ddb6SLionel Sambuc static pointer allocate(allocator_type& __a, size_type __n, 16404684ddb6SLionel Sambuc const_void_pointer, false_type) 16414684ddb6SLionel Sambuc {return __a.allocate(__n);} 16424684ddb6SLionel Sambuc 16434684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 16444684ddb6SLionel Sambuc template <class _Tp, class... _Args> 16454684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16464684ddb6SLionel Sambuc static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) 16474684ddb6SLionel Sambuc {__a.construct(__p, _VSTD::forward<_Args>(__args)...);} 16484684ddb6SLionel Sambuc template <class _Tp, class... _Args> 16494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16504684ddb6SLionel Sambuc static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) 16514684ddb6SLionel Sambuc { 16524684ddb6SLionel Sambuc ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); 16534684ddb6SLionel Sambuc } 16544684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 16554684ddb6SLionel Sambuc 16564684ddb6SLionel Sambuc template <class _Tp> 16574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16584684ddb6SLionel Sambuc static void __destroy(true_type, allocator_type& __a, _Tp* __p) 16594684ddb6SLionel Sambuc {__a.destroy(__p);} 16604684ddb6SLionel Sambuc template <class _Tp> 16614684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16624684ddb6SLionel Sambuc static void __destroy(false_type, allocator_type&, _Tp* __p) 16634684ddb6SLionel Sambuc { 16644684ddb6SLionel Sambuc __p->~_Tp(); 16654684ddb6SLionel Sambuc } 16664684ddb6SLionel Sambuc 16674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16684684ddb6SLionel Sambuc static size_type __max_size(true_type, const allocator_type& __a) 16694684ddb6SLionel Sambuc {return __a.max_size();} 16704684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16714684ddb6SLionel Sambuc static size_type __max_size(false_type, const allocator_type&) 16724684ddb6SLionel Sambuc {return numeric_limits<size_type>::max();} 16734684ddb6SLionel Sambuc 16744684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16754684ddb6SLionel Sambuc static allocator_type 16764684ddb6SLionel Sambuc select_on_container_copy_construction(true_type, const allocator_type& __a) 16774684ddb6SLionel Sambuc {return __a.select_on_container_copy_construction();} 16784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16794684ddb6SLionel Sambuc static allocator_type 16804684ddb6SLionel Sambuc select_on_container_copy_construction(false_type, const allocator_type& __a) 16814684ddb6SLionel Sambuc {return __a;} 16824684ddb6SLionel Sambuc}; 16834684ddb6SLionel Sambuc 1684*0a6a1f1dSLionel Sambuctemplate <class _Traits, class _Tp> 1685*0a6a1f1dSLionel Sambucstruct __rebind_alloc_helper 1686*0a6a1f1dSLionel Sambuc{ 1687*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1688*0a6a1f1dSLionel Sambuc typedef typename _Traits::template rebind_alloc<_Tp> type; 1689*0a6a1f1dSLionel Sambuc#else 1690*0a6a1f1dSLionel Sambuc typedef typename _Traits::template rebind_alloc<_Tp>::other type; 1691*0a6a1f1dSLionel Sambuc#endif 1692*0a6a1f1dSLionel Sambuc}; 1693*0a6a1f1dSLionel Sambuc 16944684ddb6SLionel Sambuc// allocator 16954684ddb6SLionel Sambuc 16964684ddb6SLionel Sambuctemplate <class _Tp> 16974684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY allocator 16984684ddb6SLionel Sambuc{ 16994684ddb6SLionel Sambucpublic: 17004684ddb6SLionel Sambuc typedef size_t size_type; 17014684ddb6SLionel Sambuc typedef ptrdiff_t difference_type; 17024684ddb6SLionel Sambuc typedef _Tp* pointer; 17034684ddb6SLionel Sambuc typedef const _Tp* const_pointer; 17044684ddb6SLionel Sambuc typedef _Tp& reference; 17054684ddb6SLionel Sambuc typedef const _Tp& const_reference; 17064684ddb6SLionel Sambuc typedef _Tp value_type; 17074684ddb6SLionel Sambuc 17084684ddb6SLionel Sambuc typedef true_type propagate_on_container_move_assignment; 1709*0a6a1f1dSLionel Sambuc typedef true_type is_always_equal; 17104684ddb6SLionel Sambuc 17114684ddb6SLionel Sambuc template <class _Up> struct rebind {typedef allocator<_Up> other;}; 17124684ddb6SLionel Sambuc 17134684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 17144684ddb6SLionel Sambuc template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 17154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT 17164684ddb6SLionel Sambuc {return _VSTD::addressof(__x);} 17174684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 17184684ddb6SLionel Sambuc {return _VSTD::addressof(__x);} 17194684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1720*0a6a1f1dSLionel Sambuc {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));} 17214684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1722*0a6a1f1dSLionel Sambuc {_VSTD::__deallocate((void*)__p);} 17234684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 17244684ddb6SLionel Sambuc {return size_type(~0) / sizeof(_Tp);} 17254684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 17264684ddb6SLionel Sambuc template <class _Up, class... _Args> 17274684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17284684ddb6SLionel Sambuc void 17294684ddb6SLionel Sambuc construct(_Up* __p, _Args&&... __args) 17304684ddb6SLionel Sambuc { 17314684ddb6SLionel Sambuc ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 17324684ddb6SLionel Sambuc } 17334684ddb6SLionel Sambuc#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 17344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17354684ddb6SLionel Sambuc void 17364684ddb6SLionel Sambuc construct(pointer __p) 17374684ddb6SLionel Sambuc { 17384684ddb6SLionel Sambuc ::new((void*)__p) _Tp(); 17394684ddb6SLionel Sambuc } 17404684ddb6SLionel Sambuc# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 17414684ddb6SLionel Sambuc 17424684ddb6SLionel Sambuc template <class _A0> 17434684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17444684ddb6SLionel Sambuc void 17454684ddb6SLionel Sambuc construct(pointer __p, _A0& __a0) 17464684ddb6SLionel Sambuc { 17474684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0); 17484684ddb6SLionel Sambuc } 17494684ddb6SLionel Sambuc template <class _A0> 17504684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17514684ddb6SLionel Sambuc void 17524684ddb6SLionel Sambuc construct(pointer __p, const _A0& __a0) 17534684ddb6SLionel Sambuc { 17544684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0); 17554684ddb6SLionel Sambuc } 17564684ddb6SLionel Sambuc# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 17574684ddb6SLionel Sambuc template <class _A0, class _A1> 17584684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17594684ddb6SLionel Sambuc void 17604684ddb6SLionel Sambuc construct(pointer __p, _A0& __a0, _A1& __a1) 17614684ddb6SLionel Sambuc { 17624684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0, __a1); 17634684ddb6SLionel Sambuc } 17644684ddb6SLionel Sambuc template <class _A0, class _A1> 17654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17664684ddb6SLionel Sambuc void 17674684ddb6SLionel Sambuc construct(pointer __p, const _A0& __a0, _A1& __a1) 17684684ddb6SLionel Sambuc { 17694684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0, __a1); 17704684ddb6SLionel Sambuc } 17714684ddb6SLionel Sambuc template <class _A0, class _A1> 17724684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17734684ddb6SLionel Sambuc void 17744684ddb6SLionel Sambuc construct(pointer __p, _A0& __a0, const _A1& __a1) 17754684ddb6SLionel Sambuc { 17764684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0, __a1); 17774684ddb6SLionel Sambuc } 17784684ddb6SLionel Sambuc template <class _A0, class _A1> 17794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17804684ddb6SLionel Sambuc void 17814684ddb6SLionel Sambuc construct(pointer __p, const _A0& __a0, const _A1& __a1) 17824684ddb6SLionel Sambuc { 17834684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0, __a1); 17844684ddb6SLionel Sambuc } 17854684ddb6SLionel Sambuc#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 17864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 17874684ddb6SLionel Sambuc}; 17884684ddb6SLionel Sambuc 17894684ddb6SLionel Sambuctemplate <class _Tp> 17904684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY allocator<const _Tp> 17914684ddb6SLionel Sambuc{ 17924684ddb6SLionel Sambucpublic: 17934684ddb6SLionel Sambuc typedef size_t size_type; 17944684ddb6SLionel Sambuc typedef ptrdiff_t difference_type; 17954684ddb6SLionel Sambuc typedef const _Tp* pointer; 17964684ddb6SLionel Sambuc typedef const _Tp* const_pointer; 17974684ddb6SLionel Sambuc typedef const _Tp& reference; 17984684ddb6SLionel Sambuc typedef const _Tp& const_reference; 17994684ddb6SLionel Sambuc typedef const _Tp value_type; 18004684ddb6SLionel Sambuc 18014684ddb6SLionel Sambuc typedef true_type propagate_on_container_move_assignment; 1802*0a6a1f1dSLionel Sambuc typedef true_type is_always_equal; 18034684ddb6SLionel Sambuc 18044684ddb6SLionel Sambuc template <class _Up> struct rebind {typedef allocator<_Up> other;}; 18054684ddb6SLionel Sambuc 18064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} 18074684ddb6SLionel Sambuc template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} 18084684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT 18094684ddb6SLionel Sambuc {return _VSTD::addressof(__x);} 18104684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) 1811*0a6a1f1dSLionel Sambuc {return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));} 18124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT 1813*0a6a1f1dSLionel Sambuc {_VSTD::__deallocate((void*)__p);} 18144684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT 18154684ddb6SLionel Sambuc {return size_type(~0) / sizeof(_Tp);} 18164684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 18174684ddb6SLionel Sambuc template <class _Up, class... _Args> 18184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18194684ddb6SLionel Sambuc void 18204684ddb6SLionel Sambuc construct(_Up* __p, _Args&&... __args) 18214684ddb6SLionel Sambuc { 18224684ddb6SLionel Sambuc ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); 18234684ddb6SLionel Sambuc } 18244684ddb6SLionel Sambuc#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 18254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18264684ddb6SLionel Sambuc void 18274684ddb6SLionel Sambuc construct(pointer __p) 18284684ddb6SLionel Sambuc { 18294684ddb6SLionel Sambuc ::new((void*)__p) _Tp(); 18304684ddb6SLionel Sambuc } 18314684ddb6SLionel Sambuc# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 18324684ddb6SLionel Sambuc 18334684ddb6SLionel Sambuc template <class _A0> 18344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18354684ddb6SLionel Sambuc void 18364684ddb6SLionel Sambuc construct(pointer __p, _A0& __a0) 18374684ddb6SLionel Sambuc { 18384684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0); 18394684ddb6SLionel Sambuc } 18404684ddb6SLionel Sambuc template <class _A0> 18414684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18424684ddb6SLionel Sambuc void 18434684ddb6SLionel Sambuc construct(pointer __p, const _A0& __a0) 18444684ddb6SLionel Sambuc { 18454684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0); 18464684ddb6SLionel Sambuc } 18474684ddb6SLionel Sambuc# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 18484684ddb6SLionel Sambuc template <class _A0, class _A1> 18494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18504684ddb6SLionel Sambuc void 18514684ddb6SLionel Sambuc construct(pointer __p, _A0& __a0, _A1& __a1) 18524684ddb6SLionel Sambuc { 18534684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0, __a1); 18544684ddb6SLionel Sambuc } 18554684ddb6SLionel Sambuc template <class _A0, class _A1> 18564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18574684ddb6SLionel Sambuc void 18584684ddb6SLionel Sambuc construct(pointer __p, const _A0& __a0, _A1& __a1) 18594684ddb6SLionel Sambuc { 18604684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0, __a1); 18614684ddb6SLionel Sambuc } 18624684ddb6SLionel Sambuc template <class _A0, class _A1> 18634684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18644684ddb6SLionel Sambuc void 18654684ddb6SLionel Sambuc construct(pointer __p, _A0& __a0, const _A1& __a1) 18664684ddb6SLionel Sambuc { 18674684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0, __a1); 18684684ddb6SLionel Sambuc } 18694684ddb6SLionel Sambuc template <class _A0, class _A1> 18704684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18714684ddb6SLionel Sambuc void 18724684ddb6SLionel Sambuc construct(pointer __p, const _A0& __a0, const _A1& __a1) 18734684ddb6SLionel Sambuc { 18744684ddb6SLionel Sambuc ::new((void*)__p) _Tp(__a0, __a1); 18754684ddb6SLionel Sambuc } 18764684ddb6SLionel Sambuc#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) 18774684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} 18784684ddb6SLionel Sambuc}; 18794684ddb6SLionel Sambuc 18804684ddb6SLionel Sambuctemplate <class _Tp, class _Up> 18814684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 18824684ddb6SLionel Sambucbool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} 18834684ddb6SLionel Sambuc 18844684ddb6SLionel Sambuctemplate <class _Tp, class _Up> 18854684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 18864684ddb6SLionel Sambucbool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} 18874684ddb6SLionel Sambuc 18884684ddb6SLionel Sambuctemplate <class _OutputIterator, class _Tp> 18894684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator 18904684ddb6SLionel Sambuc : public iterator<output_iterator_tag, 18914684ddb6SLionel Sambuc _Tp, // purposefully not C++03 18924684ddb6SLionel Sambuc ptrdiff_t, // purposefully not C++03 18934684ddb6SLionel Sambuc _Tp*, // purposefully not C++03 18944684ddb6SLionel Sambuc raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03 18954684ddb6SLionel Sambuc{ 18964684ddb6SLionel Sambucprivate: 18974684ddb6SLionel Sambuc _OutputIterator __x_; 18984684ddb6SLionel Sambucpublic: 18994684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} 19004684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} 19014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) 19024684ddb6SLionel Sambuc {::new(&*__x_) _Tp(__element); return *this;} 19034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} 19044684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) 19054684ddb6SLionel Sambuc {raw_storage_iterator __t(*this); ++__x_; return __t;} 1906*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER >= 14 1907*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; } 1908*0a6a1f1dSLionel Sambuc#endif 19094684ddb6SLionel Sambuc}; 19104684ddb6SLionel Sambuc 19114684ddb6SLionel Sambuctemplate <class _Tp> 19124684ddb6SLionel Sambucpair<_Tp*, ptrdiff_t> 19134684ddb6SLionel Sambucget_temporary_buffer(ptrdiff_t __n) _NOEXCEPT 19144684ddb6SLionel Sambuc{ 19154684ddb6SLionel Sambuc pair<_Tp*, ptrdiff_t> __r(0, 0); 19164684ddb6SLionel Sambuc const ptrdiff_t __m = (~ptrdiff_t(0) ^ 19174684ddb6SLionel Sambuc ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) 19184684ddb6SLionel Sambuc / sizeof(_Tp); 19194684ddb6SLionel Sambuc if (__n > __m) 19204684ddb6SLionel Sambuc __n = __m; 19214684ddb6SLionel Sambuc while (__n > 0) 19224684ddb6SLionel Sambuc { 19234684ddb6SLionel Sambuc __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); 19244684ddb6SLionel Sambuc if (__r.first) 19254684ddb6SLionel Sambuc { 19264684ddb6SLionel Sambuc __r.second = __n; 19274684ddb6SLionel Sambuc break; 19284684ddb6SLionel Sambuc } 19294684ddb6SLionel Sambuc __n /= 2; 19304684ddb6SLionel Sambuc } 19314684ddb6SLionel Sambuc return __r; 19324684ddb6SLionel Sambuc} 19334684ddb6SLionel Sambuc 19344684ddb6SLionel Sambuctemplate <class _Tp> 19354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 19364684ddb6SLionel Sambucvoid return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);} 19374684ddb6SLionel Sambuc 19384684ddb6SLionel Sambuctemplate <class _Tp> 19394684ddb6SLionel Sambucstruct auto_ptr_ref 19404684ddb6SLionel Sambuc{ 19414684ddb6SLionel Sambuc _Tp* __ptr_; 19424684ddb6SLionel Sambuc}; 19434684ddb6SLionel Sambuc 19444684ddb6SLionel Sambuctemplate<class _Tp> 19454684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY auto_ptr 19464684ddb6SLionel Sambuc{ 19474684ddb6SLionel Sambucprivate: 19484684ddb6SLionel Sambuc _Tp* __ptr_; 19494684ddb6SLionel Sambucpublic: 19504684ddb6SLionel Sambuc typedef _Tp element_type; 19514684ddb6SLionel Sambuc 19524684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} 19534684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} 19544684ddb6SLionel Sambuc template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() 19554684ddb6SLionel Sambuc : __ptr_(__p.release()) {} 19564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() 19574684ddb6SLionel Sambuc {reset(__p.release()); return *this;} 19584684ddb6SLionel Sambuc template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() 19594684ddb6SLionel Sambuc {reset(__p.release()); return *this;} 19604684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() 19614684ddb6SLionel Sambuc {reset(__p.__ptr_); return *this;} 19624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} 19634684ddb6SLionel Sambuc 19644684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() 19654684ddb6SLionel Sambuc {return *__ptr_;} 19664684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} 19674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} 19684684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() 19694684ddb6SLionel Sambuc { 19704684ddb6SLionel Sambuc _Tp* __t = __ptr_; 19714684ddb6SLionel Sambuc __ptr_ = 0; 19724684ddb6SLionel Sambuc return __t; 19734684ddb6SLionel Sambuc } 19744684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() 19754684ddb6SLionel Sambuc { 19764684ddb6SLionel Sambuc if (__ptr_ != __p) 19774684ddb6SLionel Sambuc delete __ptr_; 19784684ddb6SLionel Sambuc __ptr_ = __p; 19794684ddb6SLionel Sambuc } 19804684ddb6SLionel Sambuc 19814684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} 19824684ddb6SLionel Sambuc template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() 19834684ddb6SLionel Sambuc {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} 19844684ddb6SLionel Sambuc template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() 19854684ddb6SLionel Sambuc {return auto_ptr<_Up>(release());} 19864684ddb6SLionel Sambuc}; 19874684ddb6SLionel Sambuc 19884684ddb6SLionel Sambuctemplate <> 19894684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY auto_ptr<void> 19904684ddb6SLionel Sambuc{ 19914684ddb6SLionel Sambucpublic: 19924684ddb6SLionel Sambuc typedef void element_type; 19934684ddb6SLionel Sambuc}; 19944684ddb6SLionel Sambuc 19954684ddb6SLionel Sambuctemplate <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, 19964684ddb6SLionel Sambuc typename remove_cv<_T2>::type>::value, 19974684ddb6SLionel Sambuc bool = is_empty<_T1>::value 1998*0a6a1f1dSLionel Sambuc && !__libcpp_is_final<_T1>::value, 19994684ddb6SLionel Sambuc bool = is_empty<_T2>::value 2000*0a6a1f1dSLionel Sambuc && !__libcpp_is_final<_T2>::value 20014684ddb6SLionel Sambuc > 20024684ddb6SLionel Sambucstruct __libcpp_compressed_pair_switch; 20034684ddb6SLionel Sambuc 20044684ddb6SLionel Sambuctemplate <class _T1, class _T2, bool IsSame> 20054684ddb6SLionel Sambucstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};}; 20064684ddb6SLionel Sambuc 20074684ddb6SLionel Sambuctemplate <class _T1, class _T2, bool IsSame> 20084684ddb6SLionel Sambucstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false> {enum {value = 1};}; 20094684ddb6SLionel Sambuc 20104684ddb6SLionel Sambuctemplate <class _T1, class _T2, bool IsSame> 20114684ddb6SLionel Sambucstruct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true> {enum {value = 2};}; 20124684ddb6SLionel Sambuc 20134684ddb6SLionel Sambuctemplate <class _T1, class _T2> 20144684ddb6SLionel Sambucstruct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true> {enum {value = 3};}; 20154684ddb6SLionel Sambuc 20164684ddb6SLionel Sambuctemplate <class _T1, class _T2> 20174684ddb6SLionel Sambucstruct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true> {enum {value = 1};}; 20184684ddb6SLionel Sambuc 20194684ddb6SLionel Sambuctemplate <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value> 20204684ddb6SLionel Sambucclass __libcpp_compressed_pair_imp; 20214684ddb6SLionel Sambuc 20224684ddb6SLionel Sambuctemplate <class _T1, class _T2> 20234684ddb6SLionel Sambucclass __libcpp_compressed_pair_imp<_T1, _T2, 0> 20244684ddb6SLionel Sambuc{ 20254684ddb6SLionel Sambucprivate: 20264684ddb6SLionel Sambuc _T1 __first_; 20274684ddb6SLionel Sambuc _T2 __second_; 20284684ddb6SLionel Sambucpublic: 20294684ddb6SLionel Sambuc typedef _T1 _T1_param; 20304684ddb6SLionel Sambuc typedef _T2 _T2_param; 20314684ddb6SLionel Sambuc 20324684ddb6SLionel Sambuc typedef typename remove_reference<_T1>::type& _T1_reference; 20334684ddb6SLionel Sambuc typedef typename remove_reference<_T2>::type& _T2_reference; 20344684ddb6SLionel Sambuc 20354684ddb6SLionel Sambuc typedef const typename remove_reference<_T1>::type& _T1_const_reference; 20364684ddb6SLionel Sambuc typedef const typename remove_reference<_T2>::type& _T2_const_reference; 20374684ddb6SLionel Sambuc 2038*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_(), __second_() {} 20394684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2040*0a6a1f1dSLionel Sambuc : __first_(_VSTD::forward<_T1_param>(__t1)), __second_() {} 20414684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2042*0a6a1f1dSLionel Sambuc : __first_(), __second_(_VSTD::forward<_T2_param>(__t2)) {} 20434684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 20444684ddb6SLionel Sambuc : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 20454684ddb6SLionel Sambuc 20464684ddb6SLionel Sambuc#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 20474684ddb6SLionel Sambuc 20484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20494684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 20504684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 20514684ddb6SLionel Sambuc is_nothrow_copy_constructible<_T2>::value) 20524684ddb6SLionel Sambuc : __first_(__p.first()), 20534684ddb6SLionel Sambuc __second_(__p.second()) {} 20544684ddb6SLionel Sambuc 20554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20564684ddb6SLionel Sambuc __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 20574684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 20584684ddb6SLionel Sambuc is_nothrow_copy_assignable<_T2>::value) 20594684ddb6SLionel Sambuc { 20604684ddb6SLionel Sambuc __first_ = __p.first(); 20614684ddb6SLionel Sambuc __second_ = __p.second(); 20624684ddb6SLionel Sambuc return *this; 20634684ddb6SLionel Sambuc } 20644684ddb6SLionel Sambuc 20654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20664684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 20674684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 20684684ddb6SLionel Sambuc is_nothrow_move_constructible<_T2>::value) 20694684ddb6SLionel Sambuc : __first_(_VSTD::forward<_T1>(__p.first())), 20704684ddb6SLionel Sambuc __second_(_VSTD::forward<_T2>(__p.second())) {} 20714684ddb6SLionel Sambuc 20724684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20734684ddb6SLionel Sambuc __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 20744684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 20754684ddb6SLionel Sambuc is_nothrow_move_assignable<_T2>::value) 20764684ddb6SLionel Sambuc { 20774684ddb6SLionel Sambuc __first_ = _VSTD::forward<_T1>(__p.first()); 20784684ddb6SLionel Sambuc __second_ = _VSTD::forward<_T2>(__p.second()); 20794684ddb6SLionel Sambuc return *this; 20804684ddb6SLionel Sambuc } 20814684ddb6SLionel Sambuc 20824684ddb6SLionel Sambuc#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 20834684ddb6SLionel Sambuc 20844684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 20854684ddb6SLionel Sambuc 20864684ddb6SLionel Sambuc template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 20874684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 20884684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 20894684ddb6SLionel Sambuc tuple<_Args1...> __first_args, 20904684ddb6SLionel Sambuc tuple<_Args2...> __second_args, 20914684ddb6SLionel Sambuc __tuple_indices<_I1...>, 20924684ddb6SLionel Sambuc __tuple_indices<_I2...>) 2093*0a6a1f1dSLionel Sambuc : __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), 2094*0a6a1f1dSLionel Sambuc __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) 20954684ddb6SLionel Sambuc {} 20964684ddb6SLionel Sambuc 20974684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 20984684ddb6SLionel Sambuc 20994684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 21004684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 21014684ddb6SLionel Sambuc 21024684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 21034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 21044684ddb6SLionel Sambuc 21054684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 21064684ddb6SLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2107*0a6a1f1dSLionel Sambuc __is_nothrow_swappable<_T2>::value) 21084684ddb6SLionel Sambuc { 21094684ddb6SLionel Sambuc using _VSTD::swap; 21104684ddb6SLionel Sambuc swap(__first_, __x.__first_); 21114684ddb6SLionel Sambuc swap(__second_, __x.__second_); 21124684ddb6SLionel Sambuc } 21134684ddb6SLionel Sambuc}; 21144684ddb6SLionel Sambuc 21154684ddb6SLionel Sambuctemplate <class _T1, class _T2> 21164684ddb6SLionel Sambucclass __libcpp_compressed_pair_imp<_T1, _T2, 1> 21174684ddb6SLionel Sambuc : private _T1 21184684ddb6SLionel Sambuc{ 21194684ddb6SLionel Sambucprivate: 21204684ddb6SLionel Sambuc _T2 __second_; 21214684ddb6SLionel Sambucpublic: 21224684ddb6SLionel Sambuc typedef _T1 _T1_param; 21234684ddb6SLionel Sambuc typedef _T2 _T2_param; 21244684ddb6SLionel Sambuc 21254684ddb6SLionel Sambuc typedef _T1& _T1_reference; 21264684ddb6SLionel Sambuc typedef typename remove_reference<_T2>::type& _T2_reference; 21274684ddb6SLionel Sambuc 21284684ddb6SLionel Sambuc typedef const _T1& _T1_const_reference; 21294684ddb6SLionel Sambuc typedef const typename remove_reference<_T2>::type& _T2_const_reference; 21304684ddb6SLionel Sambuc 2131*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __second_() {} 21324684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 2133*0a6a1f1dSLionel Sambuc : _T1(_VSTD::forward<_T1_param>(__t1)), __second_() {} 21344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 21354684ddb6SLionel Sambuc : __second_(_VSTD::forward<_T2_param>(__t2)) {} 21364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 21374684ddb6SLionel Sambuc : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} 21384684ddb6SLionel Sambuc 21394684ddb6SLionel Sambuc#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 21404684ddb6SLionel Sambuc 21414684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 21424684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 21434684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 21444684ddb6SLionel Sambuc is_nothrow_copy_constructible<_T2>::value) 21454684ddb6SLionel Sambuc : _T1(__p.first()), __second_(__p.second()) {} 21464684ddb6SLionel Sambuc 21474684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 21484684ddb6SLionel Sambuc __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 21494684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 21504684ddb6SLionel Sambuc is_nothrow_copy_assignable<_T2>::value) 21514684ddb6SLionel Sambuc { 21524684ddb6SLionel Sambuc _T1::operator=(__p.first()); 21534684ddb6SLionel Sambuc __second_ = __p.second(); 21544684ddb6SLionel Sambuc return *this; 21554684ddb6SLionel Sambuc } 21564684ddb6SLionel Sambuc 21574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 21584684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 21594684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 21604684ddb6SLionel Sambuc is_nothrow_move_constructible<_T2>::value) 21614684ddb6SLionel Sambuc : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {} 21624684ddb6SLionel Sambuc 21634684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 21644684ddb6SLionel Sambuc __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 21654684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 21664684ddb6SLionel Sambuc is_nothrow_move_assignable<_T2>::value) 21674684ddb6SLionel Sambuc { 21684684ddb6SLionel Sambuc _T1::operator=(_VSTD::move(__p.first())); 21694684ddb6SLionel Sambuc __second_ = _VSTD::forward<_T2>(__p.second()); 21704684ddb6SLionel Sambuc return *this; 21714684ddb6SLionel Sambuc } 21724684ddb6SLionel Sambuc 21734684ddb6SLionel Sambuc#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 21744684ddb6SLionel Sambuc 21754684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 21764684ddb6SLionel Sambuc 21774684ddb6SLionel Sambuc template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 21784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 21794684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 21804684ddb6SLionel Sambuc tuple<_Args1...> __first_args, 21814684ddb6SLionel Sambuc tuple<_Args2...> __second_args, 21824684ddb6SLionel Sambuc __tuple_indices<_I1...>, 21834684ddb6SLionel Sambuc __tuple_indices<_I2...>) 2184*0a6a1f1dSLionel Sambuc : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), 2185*0a6a1f1dSLionel Sambuc __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) 21864684ddb6SLionel Sambuc {} 21874684ddb6SLionel Sambuc 21884684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 21894684ddb6SLionel Sambuc 21904684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 21914684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 21924684ddb6SLionel Sambuc 21934684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return __second_;} 21944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} 21954684ddb6SLionel Sambuc 21964684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 21974684ddb6SLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2198*0a6a1f1dSLionel Sambuc __is_nothrow_swappable<_T2>::value) 21994684ddb6SLionel Sambuc { 22004684ddb6SLionel Sambuc using _VSTD::swap; 22014684ddb6SLionel Sambuc swap(__second_, __x.__second_); 22024684ddb6SLionel Sambuc } 22034684ddb6SLionel Sambuc}; 22044684ddb6SLionel Sambuc 22054684ddb6SLionel Sambuctemplate <class _T1, class _T2> 22064684ddb6SLionel Sambucclass __libcpp_compressed_pair_imp<_T1, _T2, 2> 22074684ddb6SLionel Sambuc : private _T2 22084684ddb6SLionel Sambuc{ 22094684ddb6SLionel Sambucprivate: 22104684ddb6SLionel Sambuc _T1 __first_; 22114684ddb6SLionel Sambucpublic: 22124684ddb6SLionel Sambuc typedef _T1 _T1_param; 22134684ddb6SLionel Sambuc typedef _T2 _T2_param; 22144684ddb6SLionel Sambuc 22154684ddb6SLionel Sambuc typedef typename remove_reference<_T1>::type& _T1_reference; 22164684ddb6SLionel Sambuc typedef _T2& _T2_reference; 22174684ddb6SLionel Sambuc 22184684ddb6SLionel Sambuc typedef const typename remove_reference<_T1>::type& _T1_const_reference; 22194684ddb6SLionel Sambuc typedef const _T2& _T2_const_reference; 22204684ddb6SLionel Sambuc 2221*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_() {} 22224684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 22234684ddb6SLionel Sambuc : __first_(_VSTD::forward<_T1_param>(__t1)) {} 22244684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 2225*0a6a1f1dSLionel Sambuc : _T2(_VSTD::forward<_T2_param>(__t2)), __first_() {} 22264684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 22274684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 22284684ddb6SLionel Sambuc is_nothrow_move_constructible<_T2>::value) 22294684ddb6SLionel Sambuc : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} 22304684ddb6SLionel Sambuc 22314684ddb6SLionel Sambuc#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 22324684ddb6SLionel Sambuc 22334684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 22344684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 22354684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 22364684ddb6SLionel Sambuc is_nothrow_copy_constructible<_T2>::value) 22374684ddb6SLionel Sambuc : _T2(__p.second()), __first_(__p.first()) {} 22384684ddb6SLionel Sambuc 22394684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 22404684ddb6SLionel Sambuc __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 22414684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 22424684ddb6SLionel Sambuc is_nothrow_copy_assignable<_T2>::value) 22434684ddb6SLionel Sambuc { 22444684ddb6SLionel Sambuc _T2::operator=(__p.second()); 22454684ddb6SLionel Sambuc __first_ = __p.first(); 22464684ddb6SLionel Sambuc return *this; 22474684ddb6SLionel Sambuc } 22484684ddb6SLionel Sambuc 22494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 22504684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 22514684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 22524684ddb6SLionel Sambuc is_nothrow_move_constructible<_T2>::value) 22534684ddb6SLionel Sambuc : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {} 22544684ddb6SLionel Sambuc 22554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 22564684ddb6SLionel Sambuc __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 22574684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 22584684ddb6SLionel Sambuc is_nothrow_move_assignable<_T2>::value) 22594684ddb6SLionel Sambuc { 22604684ddb6SLionel Sambuc _T2::operator=(_VSTD::forward<_T2>(__p.second())); 22614684ddb6SLionel Sambuc __first_ = _VSTD::move(__p.first()); 22624684ddb6SLionel Sambuc return *this; 22634684ddb6SLionel Sambuc } 22644684ddb6SLionel Sambuc 22654684ddb6SLionel Sambuc#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 22664684ddb6SLionel Sambuc 22674684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 22684684ddb6SLionel Sambuc 22694684ddb6SLionel Sambuc template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 22704684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 22714684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 22724684ddb6SLionel Sambuc tuple<_Args1...> __first_args, 22734684ddb6SLionel Sambuc tuple<_Args2...> __second_args, 22744684ddb6SLionel Sambuc __tuple_indices<_I1...>, 22754684ddb6SLionel Sambuc __tuple_indices<_I2...>) 2276*0a6a1f1dSLionel Sambuc : _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...), 2277*0a6a1f1dSLionel Sambuc __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...) 22784684ddb6SLionel Sambuc 22794684ddb6SLionel Sambuc {} 22804684ddb6SLionel Sambuc 22814684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 22824684ddb6SLionel Sambuc 22834684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;} 22844684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} 22854684ddb6SLionel Sambuc 22864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 22874684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 22884684ddb6SLionel Sambuc 22894684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) 22904684ddb6SLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2291*0a6a1f1dSLionel Sambuc __is_nothrow_swappable<_T2>::value) 22924684ddb6SLionel Sambuc { 22934684ddb6SLionel Sambuc using _VSTD::swap; 22944684ddb6SLionel Sambuc swap(__first_, __x.__first_); 22954684ddb6SLionel Sambuc } 22964684ddb6SLionel Sambuc}; 22974684ddb6SLionel Sambuc 22984684ddb6SLionel Sambuctemplate <class _T1, class _T2> 22994684ddb6SLionel Sambucclass __libcpp_compressed_pair_imp<_T1, _T2, 3> 23004684ddb6SLionel Sambuc : private _T1, 23014684ddb6SLionel Sambuc private _T2 23024684ddb6SLionel Sambuc{ 23034684ddb6SLionel Sambucpublic: 23044684ddb6SLionel Sambuc typedef _T1 _T1_param; 23054684ddb6SLionel Sambuc typedef _T2 _T2_param; 23064684ddb6SLionel Sambuc 23074684ddb6SLionel Sambuc typedef _T1& _T1_reference; 23084684ddb6SLionel Sambuc typedef _T2& _T2_reference; 23094684ddb6SLionel Sambuc 23104684ddb6SLionel Sambuc typedef const _T1& _T1_const_reference; 23114684ddb6SLionel Sambuc typedef const _T2& _T2_const_reference; 23124684ddb6SLionel Sambuc 23134684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} 23144684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) 23154684ddb6SLionel Sambuc : _T1(_VSTD::forward<_T1_param>(__t1)) {} 23164684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) 23174684ddb6SLionel Sambuc : _T2(_VSTD::forward<_T2_param>(__t2)) {} 23184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) 23194684ddb6SLionel Sambuc : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} 23204684ddb6SLionel Sambuc 23214684ddb6SLionel Sambuc#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 23224684ddb6SLionel Sambuc 23234684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 23244684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) 23254684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 23264684ddb6SLionel Sambuc is_nothrow_copy_constructible<_T2>::value) 23274684ddb6SLionel Sambuc : _T1(__p.first()), _T2(__p.second()) {} 23284684ddb6SLionel Sambuc 23294684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 23304684ddb6SLionel Sambuc __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) 23314684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 23324684ddb6SLionel Sambuc is_nothrow_copy_assignable<_T2>::value) 23334684ddb6SLionel Sambuc { 23344684ddb6SLionel Sambuc _T1::operator=(__p.first()); 23354684ddb6SLionel Sambuc _T2::operator=(__p.second()); 23364684ddb6SLionel Sambuc return *this; 23374684ddb6SLionel Sambuc } 23384684ddb6SLionel Sambuc 23394684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 23404684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) 23414684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 23424684ddb6SLionel Sambuc is_nothrow_move_constructible<_T2>::value) 23434684ddb6SLionel Sambuc : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {} 23444684ddb6SLionel Sambuc 23454684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 23464684ddb6SLionel Sambuc __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) 23474684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 23484684ddb6SLionel Sambuc is_nothrow_move_assignable<_T2>::value) 23494684ddb6SLionel Sambuc { 23504684ddb6SLionel Sambuc _T1::operator=(_VSTD::move(__p.first())); 23514684ddb6SLionel Sambuc _T2::operator=(_VSTD::move(__p.second())); 23524684ddb6SLionel Sambuc return *this; 23534684ddb6SLionel Sambuc } 23544684ddb6SLionel Sambuc 23554684ddb6SLionel Sambuc#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 23564684ddb6SLionel Sambuc 23574684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 23584684ddb6SLionel Sambuc 23594684ddb6SLionel Sambuc template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 23604684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 23614684ddb6SLionel Sambuc __libcpp_compressed_pair_imp(piecewise_construct_t __pc, 23624684ddb6SLionel Sambuc tuple<_Args1...> __first_args, 23634684ddb6SLionel Sambuc tuple<_Args2...> __second_args, 23644684ddb6SLionel Sambuc __tuple_indices<_I1...>, 23654684ddb6SLionel Sambuc __tuple_indices<_I2...>) 2366*0a6a1f1dSLionel Sambuc : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...), 2367*0a6a1f1dSLionel Sambuc _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) 23684684ddb6SLionel Sambuc {} 23694684ddb6SLionel Sambuc 23704684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 23714684ddb6SLionel Sambuc 23724684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;} 23734684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} 23744684ddb6SLionel Sambuc 23754684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return *this;} 23764684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} 23774684ddb6SLionel Sambuc 23784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&) 23794684ddb6SLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2380*0a6a1f1dSLionel Sambuc __is_nothrow_swappable<_T2>::value) 23814684ddb6SLionel Sambuc { 23824684ddb6SLionel Sambuc } 23834684ddb6SLionel Sambuc}; 23844684ddb6SLionel Sambuc 23854684ddb6SLionel Sambuctemplate <class _T1, class _T2> 23864684ddb6SLionel Sambucclass __compressed_pair 23874684ddb6SLionel Sambuc : private __libcpp_compressed_pair_imp<_T1, _T2> 23884684ddb6SLionel Sambuc{ 23894684ddb6SLionel Sambuc typedef __libcpp_compressed_pair_imp<_T1, _T2> base; 23904684ddb6SLionel Sambucpublic: 23914684ddb6SLionel Sambuc typedef typename base::_T1_param _T1_param; 23924684ddb6SLionel Sambuc typedef typename base::_T2_param _T2_param; 23934684ddb6SLionel Sambuc 23944684ddb6SLionel Sambuc typedef typename base::_T1_reference _T1_reference; 23954684ddb6SLionel Sambuc typedef typename base::_T2_reference _T2_reference; 23964684ddb6SLionel Sambuc 23974684ddb6SLionel Sambuc typedef typename base::_T1_const_reference _T1_const_reference; 23984684ddb6SLionel Sambuc typedef typename base::_T2_const_reference _T2_const_reference; 23994684ddb6SLionel Sambuc 24004684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY __compressed_pair() {} 24014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1) 24024684ddb6SLionel Sambuc : base(_VSTD::forward<_T1_param>(__t1)) {} 24034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2) 24044684ddb6SLionel Sambuc : base(_VSTD::forward<_T2_param>(__t2)) {} 24054684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) 24064684ddb6SLionel Sambuc : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} 24074684ddb6SLionel Sambuc 24084684ddb6SLionel Sambuc#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 24094684ddb6SLionel Sambuc 24104684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 24114684ddb6SLionel Sambuc __compressed_pair(const __compressed_pair& __p) 24124684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && 24134684ddb6SLionel Sambuc is_nothrow_copy_constructible<_T2>::value) 24144684ddb6SLionel Sambuc : base(__p) {} 24154684ddb6SLionel Sambuc 24164684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 24174684ddb6SLionel Sambuc __compressed_pair& operator=(const __compressed_pair& __p) 24184684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && 24194684ddb6SLionel Sambuc is_nothrow_copy_assignable<_T2>::value) 24204684ddb6SLionel Sambuc { 24214684ddb6SLionel Sambuc base::operator=(__p); 24224684ddb6SLionel Sambuc return *this; 24234684ddb6SLionel Sambuc } 24244684ddb6SLionel Sambuc 24254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 24264684ddb6SLionel Sambuc __compressed_pair(__compressed_pair&& __p) 24274684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && 24284684ddb6SLionel Sambuc is_nothrow_move_constructible<_T2>::value) 24294684ddb6SLionel Sambuc : base(_VSTD::move(__p)) {} 24304684ddb6SLionel Sambuc 24314684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 24324684ddb6SLionel Sambuc __compressed_pair& operator=(__compressed_pair&& __p) 24334684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && 24344684ddb6SLionel Sambuc is_nothrow_move_assignable<_T2>::value) 24354684ddb6SLionel Sambuc { 24364684ddb6SLionel Sambuc base::operator=(_VSTD::move(__p)); 24374684ddb6SLionel Sambuc return *this; 24384684ddb6SLionel Sambuc } 24394684ddb6SLionel Sambuc 24404684ddb6SLionel Sambuc#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) 24414684ddb6SLionel Sambuc 24424684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 24434684ddb6SLionel Sambuc 24444684ddb6SLionel Sambuc template <class... _Args1, class... _Args2> 24454684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 24464684ddb6SLionel Sambuc __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, 24474684ddb6SLionel Sambuc tuple<_Args2...> __second_args) 24484684ddb6SLionel Sambuc : base(__pc, _VSTD::move(__first_args), _VSTD::move(__second_args), 24494684ddb6SLionel Sambuc typename __make_tuple_indices<sizeof...(_Args1)>::type(), 24504684ddb6SLionel Sambuc typename __make_tuple_indices<sizeof...(_Args2) >::type()) 24514684ddb6SLionel Sambuc {} 24524684ddb6SLionel Sambuc 24534684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 24544684ddb6SLionel Sambuc 24554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return base::first();} 24564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();} 24574684ddb6SLionel Sambuc 24584684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_reference second() _NOEXCEPT {return base::second();} 24594684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();} 24604684ddb6SLionel Sambuc 24614684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) 24624684ddb6SLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2463*0a6a1f1dSLionel Sambuc __is_nothrow_swappable<_T2>::value) 24644684ddb6SLionel Sambuc {base::swap(__x);} 24654684ddb6SLionel Sambuc}; 24664684ddb6SLionel Sambuc 24674684ddb6SLionel Sambuctemplate <class _T1, class _T2> 24684684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 24694684ddb6SLionel Sambucvoid 24704684ddb6SLionel Sambucswap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) 24714684ddb6SLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && 2472*0a6a1f1dSLionel Sambuc __is_nothrow_swappable<_T2>::value) 24734684ddb6SLionel Sambuc {__x.swap(__y);} 24744684ddb6SLionel Sambuc 24754684ddb6SLionel Sambuc// __same_or_less_cv_qualified 24764684ddb6SLionel Sambuc 24774684ddb6SLionel Sambuctemplate <class _Ptr1, class _Ptr2, 24784684ddb6SLionel Sambuc bool = is_same<typename remove_cv<typename pointer_traits<_Ptr1>::element_type>::type, 24794684ddb6SLionel Sambuc typename remove_cv<typename pointer_traits<_Ptr2>::element_type>::type 24804684ddb6SLionel Sambuc >::value 24814684ddb6SLionel Sambuc > 24824684ddb6SLionel Sambucstruct __same_or_less_cv_qualified_imp 24834684ddb6SLionel Sambuc : is_convertible<_Ptr1, _Ptr2> {}; 24844684ddb6SLionel Sambuc 24854684ddb6SLionel Sambuctemplate <class _Ptr1, class _Ptr2> 24864684ddb6SLionel Sambucstruct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false> 24874684ddb6SLionel Sambuc : false_type {}; 24884684ddb6SLionel Sambuc 2489*0a6a1f1dSLionel Sambuctemplate <class _Ptr1, class _Ptr2, bool = is_pointer<_Ptr1>::value || 2490*0a6a1f1dSLionel Sambuc is_same<_Ptr1, _Ptr2>::value || 2491*0a6a1f1dSLionel Sambuc __has_element_type<_Ptr1>::value> 24924684ddb6SLionel Sambucstruct __same_or_less_cv_qualified 24934684ddb6SLionel Sambuc : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {}; 24944684ddb6SLionel Sambuc 24954684ddb6SLionel Sambuctemplate <class _Ptr1, class _Ptr2> 2496*0a6a1f1dSLionel Sambucstruct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false> 24974684ddb6SLionel Sambuc : false_type {}; 24984684ddb6SLionel Sambuc 24994684ddb6SLionel Sambuc// default_delete 25004684ddb6SLionel Sambuc 25014684ddb6SLionel Sambuctemplate <class _Tp> 25024684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY default_delete 25034684ddb6SLionel Sambuc{ 25044684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 25054684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; 25064684ddb6SLionel Sambuc#else 25074684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} 25084684ddb6SLionel Sambuc#endif 25094684ddb6SLionel Sambuc template <class _Up> 25104684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, 25114684ddb6SLionel Sambuc typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 25124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT 25134684ddb6SLionel Sambuc { 25144684ddb6SLionel Sambuc static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 25154684ddb6SLionel Sambuc static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); 25164684ddb6SLionel Sambuc delete __ptr; 25174684ddb6SLionel Sambuc } 25184684ddb6SLionel Sambuc}; 25194684ddb6SLionel Sambuc 25204684ddb6SLionel Sambuctemplate <class _Tp> 25214684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]> 25224684ddb6SLionel Sambuc{ 25234684ddb6SLionel Sambucpublic: 25244684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 25254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; 25264684ddb6SLionel Sambuc#else 25274684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} 25284684ddb6SLionel Sambuc#endif 25294684ddb6SLionel Sambuc template <class _Up> 25304684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&, 25314684ddb6SLionel Sambuc typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} 25324684ddb6SLionel Sambuc template <class _Up> 25334684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 25344684ddb6SLionel Sambuc void operator() (_Up* __ptr, 25354684ddb6SLionel Sambuc typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT 25364684ddb6SLionel Sambuc { 25374684ddb6SLionel Sambuc static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); 25384684ddb6SLionel Sambuc static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); 25394684ddb6SLionel Sambuc delete [] __ptr; 25404684ddb6SLionel Sambuc } 25414684ddb6SLionel Sambuc}; 25424684ddb6SLionel Sambuc 25434684ddb6SLionel Sambuctemplate <class _Tp, class _Dp = default_delete<_Tp> > 25444684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY unique_ptr 25454684ddb6SLionel Sambuc{ 25464684ddb6SLionel Sambucpublic: 25474684ddb6SLionel Sambuc typedef _Tp element_type; 25484684ddb6SLionel Sambuc typedef _Dp deleter_type; 25494684ddb6SLionel Sambuc typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 25504684ddb6SLionel Sambucprivate: 25514684ddb6SLionel Sambuc __compressed_pair<pointer, deleter_type> __ptr_; 25524684ddb6SLionel Sambuc 25534684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 25544684ddb6SLionel Sambuc unique_ptr(unique_ptr&); 25554684ddb6SLionel Sambuc template <class _Up, class _Ep> 25564684ddb6SLionel Sambuc unique_ptr(unique_ptr<_Up, _Ep>&); 25574684ddb6SLionel Sambuc unique_ptr& operator=(unique_ptr&); 25584684ddb6SLionel Sambuc template <class _Up, class _Ep> 25594684ddb6SLionel Sambuc unique_ptr& operator=(unique_ptr<_Up, _Ep>&); 25604684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 25614684ddb6SLionel Sambuc 25624684ddb6SLionel Sambuc struct __nat {int __for_bool_;}; 25634684ddb6SLionel Sambuc 25644684ddb6SLionel Sambuc typedef typename remove_reference<deleter_type>::type& _Dp_reference; 25654684ddb6SLionel Sambuc typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 25664684ddb6SLionel Sambucpublic: 25674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT 25684684ddb6SLionel Sambuc : __ptr_(pointer()) 25694684ddb6SLionel Sambuc { 25704684ddb6SLionel Sambuc static_assert(!is_pointer<deleter_type>::value, 25714684ddb6SLionel Sambuc "unique_ptr constructed with null function pointer deleter"); 25724684ddb6SLionel Sambuc } 25734684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT 25744684ddb6SLionel Sambuc : __ptr_(pointer()) 25754684ddb6SLionel Sambuc { 25764684ddb6SLionel Sambuc static_assert(!is_pointer<deleter_type>::value, 25774684ddb6SLionel Sambuc "unique_ptr constructed with null function pointer deleter"); 25784684ddb6SLionel Sambuc } 25794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT 25804684ddb6SLionel Sambuc : __ptr_(_VSTD::move(__p)) 25814684ddb6SLionel Sambuc { 25824684ddb6SLionel Sambuc static_assert(!is_pointer<deleter_type>::value, 25834684ddb6SLionel Sambuc "unique_ptr constructed with null function pointer deleter"); 25844684ddb6SLionel Sambuc } 25854684ddb6SLionel Sambuc 25864684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 25874684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional< 25884684ddb6SLionel Sambuc is_reference<deleter_type>::value, 25894684ddb6SLionel Sambuc deleter_type, 25904684ddb6SLionel Sambuc typename add_lvalue_reference<const deleter_type>::type>::type __d) 25914684ddb6SLionel Sambuc _NOEXCEPT 25924684ddb6SLionel Sambuc : __ptr_(__p, __d) {} 25934684ddb6SLionel Sambuc 25944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d) 25954684ddb6SLionel Sambuc _NOEXCEPT 25964684ddb6SLionel Sambuc : __ptr_(__p, _VSTD::move(__d)) 25974684ddb6SLionel Sambuc { 25984684ddb6SLionel Sambuc static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 25994684ddb6SLionel Sambuc } 26004684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 26014684ddb6SLionel Sambuc : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 26024684ddb6SLionel Sambuc template <class _Up, class _Ep> 26034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 26044684ddb6SLionel Sambuc unique_ptr(unique_ptr<_Up, _Ep>&& __u, 26054684ddb6SLionel Sambuc typename enable_if 26064684ddb6SLionel Sambuc < 26074684ddb6SLionel Sambuc !is_array<_Up>::value && 26084684ddb6SLionel Sambuc is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 26094684ddb6SLionel Sambuc is_convertible<_Ep, deleter_type>::value && 26104684ddb6SLionel Sambuc ( 26114684ddb6SLionel Sambuc !is_reference<deleter_type>::value || 26124684ddb6SLionel Sambuc is_same<deleter_type, _Ep>::value 26134684ddb6SLionel Sambuc ), 26144684ddb6SLionel Sambuc __nat 26154684ddb6SLionel Sambuc >::type = __nat()) _NOEXCEPT 26164684ddb6SLionel Sambuc : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} 26174684ddb6SLionel Sambuc 26184684ddb6SLionel Sambuc template <class _Up> 26194684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, 26204684ddb6SLionel Sambuc typename enable_if< 26214684ddb6SLionel Sambuc is_convertible<_Up*, _Tp*>::value && 26224684ddb6SLionel Sambuc is_same<_Dp, default_delete<_Tp> >::value, 26234684ddb6SLionel Sambuc __nat 26244684ddb6SLionel Sambuc >::type = __nat()) _NOEXCEPT 26254684ddb6SLionel Sambuc : __ptr_(__p.release()) 26264684ddb6SLionel Sambuc { 26274684ddb6SLionel Sambuc } 26284684ddb6SLionel Sambuc 26294684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 26304684ddb6SLionel Sambuc { 26314684ddb6SLionel Sambuc reset(__u.release()); 26324684ddb6SLionel Sambuc __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 26334684ddb6SLionel Sambuc return *this; 26344684ddb6SLionel Sambuc } 26354684ddb6SLionel Sambuc 26364684ddb6SLionel Sambuc template <class _Up, class _Ep> 26374684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 26384684ddb6SLionel Sambuc typename enable_if 26394684ddb6SLionel Sambuc < 26404684ddb6SLionel Sambuc !is_array<_Up>::value && 26414684ddb6SLionel Sambuc is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 26424684ddb6SLionel Sambuc is_assignable<deleter_type&, _Ep&&>::value, 26434684ddb6SLionel Sambuc unique_ptr& 26444684ddb6SLionel Sambuc >::type 26454684ddb6SLionel Sambuc operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 26464684ddb6SLionel Sambuc { 26474684ddb6SLionel Sambuc reset(__u.release()); 26484684ddb6SLionel Sambuc __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 26494684ddb6SLionel Sambuc return *this; 26504684ddb6SLionel Sambuc } 26514684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 26524684ddb6SLionel Sambuc 26534684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 26544684ddb6SLionel Sambuc { 26554684ddb6SLionel Sambuc return __rv<unique_ptr>(*this); 26564684ddb6SLionel Sambuc } 26574684ddb6SLionel Sambuc 26584684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 26594684ddb6SLionel Sambuc : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 26604684ddb6SLionel Sambuc 26614684ddb6SLionel Sambuc template <class _Up, class _Ep> 26624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) 26634684ddb6SLionel Sambuc { 26644684ddb6SLionel Sambuc reset(__u.release()); 26654684ddb6SLionel Sambuc __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 26664684ddb6SLionel Sambuc return *this; 26674684ddb6SLionel Sambuc } 26684684ddb6SLionel Sambuc 26694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 26704684ddb6SLionel Sambuc : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {} 26714684ddb6SLionel Sambuc 26724684ddb6SLionel Sambuc template <class _Up> 26734684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 26744684ddb6SLionel Sambuc typename enable_if< 26754684ddb6SLionel Sambuc is_convertible<_Up*, _Tp*>::value && 26764684ddb6SLionel Sambuc is_same<_Dp, default_delete<_Tp> >::value, 26774684ddb6SLionel Sambuc unique_ptr& 26784684ddb6SLionel Sambuc >::type 26794684ddb6SLionel Sambuc operator=(auto_ptr<_Up> __p) 26804684ddb6SLionel Sambuc {reset(__p.release()); return *this;} 26814684ddb6SLionel Sambuc 26824684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 26834684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 26844684ddb6SLionel Sambuc 26854684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 26864684ddb6SLionel Sambuc { 26874684ddb6SLionel Sambuc reset(); 26884684ddb6SLionel Sambuc return *this; 26894684ddb6SLionel Sambuc } 26904684ddb6SLionel Sambuc 26914684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const 26924684ddb6SLionel Sambuc {return *__ptr_.first();} 26934684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();} 26944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 26954684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 26964684ddb6SLionel Sambuc {return __ptr_.second();} 26974684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 26984684ddb6SLionel Sambuc {return __ptr_.second();} 26994684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 27004684ddb6SLionel Sambuc _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT 27014684ddb6SLionel Sambuc {return __ptr_.first() != nullptr;} 27024684ddb6SLionel Sambuc 27034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 27044684ddb6SLionel Sambuc { 27054684ddb6SLionel Sambuc pointer __t = __ptr_.first(); 27064684ddb6SLionel Sambuc __ptr_.first() = pointer(); 27074684ddb6SLionel Sambuc return __t; 27084684ddb6SLionel Sambuc } 27094684ddb6SLionel Sambuc 27104684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT 27114684ddb6SLionel Sambuc { 27124684ddb6SLionel Sambuc pointer __tmp = __ptr_.first(); 27134684ddb6SLionel Sambuc __ptr_.first() = __p; 27144684ddb6SLionel Sambuc if (__tmp) 27154684ddb6SLionel Sambuc __ptr_.second()(__tmp); 27164684ddb6SLionel Sambuc } 27174684ddb6SLionel Sambuc 27184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT 27194684ddb6SLionel Sambuc {__ptr_.swap(__u.__ptr_);} 27204684ddb6SLionel Sambuc}; 27214684ddb6SLionel Sambuc 27224684ddb6SLionel Sambuctemplate <class _Tp, class _Dp> 27234684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY unique_ptr<_Tp[], _Dp> 27244684ddb6SLionel Sambuc{ 27254684ddb6SLionel Sambucpublic: 27264684ddb6SLionel Sambuc typedef _Tp element_type; 27274684ddb6SLionel Sambuc typedef _Dp deleter_type; 27284684ddb6SLionel Sambuc typedef typename __pointer_type<_Tp, deleter_type>::type pointer; 27294684ddb6SLionel Sambucprivate: 27304684ddb6SLionel Sambuc __compressed_pair<pointer, deleter_type> __ptr_; 27314684ddb6SLionel Sambuc 27324684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 27334684ddb6SLionel Sambuc unique_ptr(unique_ptr&); 27344684ddb6SLionel Sambuc template <class _Up> 27354684ddb6SLionel Sambuc unique_ptr(unique_ptr<_Up>&); 27364684ddb6SLionel Sambuc unique_ptr& operator=(unique_ptr&); 27374684ddb6SLionel Sambuc template <class _Up> 27384684ddb6SLionel Sambuc unique_ptr& operator=(unique_ptr<_Up>&); 27394684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 27404684ddb6SLionel Sambuc 27414684ddb6SLionel Sambuc struct __nat {int __for_bool_;}; 27424684ddb6SLionel Sambuc 27434684ddb6SLionel Sambuc typedef typename remove_reference<deleter_type>::type& _Dp_reference; 27444684ddb6SLionel Sambuc typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; 27454684ddb6SLionel Sambucpublic: 27464684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT 27474684ddb6SLionel Sambuc : __ptr_(pointer()) 27484684ddb6SLionel Sambuc { 27494684ddb6SLionel Sambuc static_assert(!is_pointer<deleter_type>::value, 27504684ddb6SLionel Sambuc "unique_ptr constructed with null function pointer deleter"); 27514684ddb6SLionel Sambuc } 27524684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT 27534684ddb6SLionel Sambuc : __ptr_(pointer()) 27544684ddb6SLionel Sambuc { 27554684ddb6SLionel Sambuc static_assert(!is_pointer<deleter_type>::value, 27564684ddb6SLionel Sambuc "unique_ptr constructed with null function pointer deleter"); 27574684ddb6SLionel Sambuc } 27584684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2759*0a6a1f1dSLionel Sambuc template <class _Pp> 2760*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p, 2761*0a6a1f1dSLionel Sambuc typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT 27624684ddb6SLionel Sambuc : __ptr_(__p) 27634684ddb6SLionel Sambuc { 27644684ddb6SLionel Sambuc static_assert(!is_pointer<deleter_type>::value, 27654684ddb6SLionel Sambuc "unique_ptr constructed with null function pointer deleter"); 27664684ddb6SLionel Sambuc } 27674684ddb6SLionel Sambuc 2768*0a6a1f1dSLionel Sambuc template <class _Pp> 27694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional< 27704684ddb6SLionel Sambuc is_reference<deleter_type>::value, 27714684ddb6SLionel Sambuc deleter_type, 2772*0a6a1f1dSLionel Sambuc typename add_lvalue_reference<const deleter_type>::type>::type __d, 2773*0a6a1f1dSLionel Sambuc typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) 27744684ddb6SLionel Sambuc _NOEXCEPT 27754684ddb6SLionel Sambuc : __ptr_(__p, __d) {} 27764684ddb6SLionel Sambuc 27774684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional< 27784684ddb6SLionel Sambuc is_reference<deleter_type>::value, 27794684ddb6SLionel Sambuc deleter_type, 27804684ddb6SLionel Sambuc typename add_lvalue_reference<const deleter_type>::type>::type __d) 27814684ddb6SLionel Sambuc _NOEXCEPT 27824684ddb6SLionel Sambuc : __ptr_(pointer(), __d) {} 27834684ddb6SLionel Sambuc 2784*0a6a1f1dSLionel Sambuc template <class _Pp> 2785*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, 2786*0a6a1f1dSLionel Sambuc typename remove_reference<deleter_type>::type&& __d, 2787*0a6a1f1dSLionel Sambuc typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) 27884684ddb6SLionel Sambuc _NOEXCEPT 27894684ddb6SLionel Sambuc : __ptr_(__p, _VSTD::move(__d)) 27904684ddb6SLionel Sambuc { 27914684ddb6SLionel Sambuc static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 27924684ddb6SLionel Sambuc } 27934684ddb6SLionel Sambuc 27944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d) 27954684ddb6SLionel Sambuc _NOEXCEPT 27964684ddb6SLionel Sambuc : __ptr_(pointer(), _VSTD::move(__d)) 27974684ddb6SLionel Sambuc { 27984684ddb6SLionel Sambuc static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); 27994684ddb6SLionel Sambuc } 28004684ddb6SLionel Sambuc 28014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT 28024684ddb6SLionel Sambuc : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 28034684ddb6SLionel Sambuc 28044684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT 28054684ddb6SLionel Sambuc { 28064684ddb6SLionel Sambuc reset(__u.release()); 28074684ddb6SLionel Sambuc __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); 28084684ddb6SLionel Sambuc return *this; 28094684ddb6SLionel Sambuc } 28104684ddb6SLionel Sambuc 28114684ddb6SLionel Sambuc template <class _Up, class _Ep> 28124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 28134684ddb6SLionel Sambuc unique_ptr(unique_ptr<_Up, _Ep>&& __u, 28144684ddb6SLionel Sambuc typename enable_if 28154684ddb6SLionel Sambuc < 28164684ddb6SLionel Sambuc is_array<_Up>::value && 28174684ddb6SLionel Sambuc __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value 28184684ddb6SLionel Sambuc && is_convertible<_Ep, deleter_type>::value && 28194684ddb6SLionel Sambuc ( 28204684ddb6SLionel Sambuc !is_reference<deleter_type>::value || 28214684ddb6SLionel Sambuc is_same<deleter_type, _Ep>::value 28224684ddb6SLionel Sambuc ), 28234684ddb6SLionel Sambuc __nat 28244684ddb6SLionel Sambuc >::type = __nat() 28254684ddb6SLionel Sambuc ) _NOEXCEPT 28264684ddb6SLionel Sambuc : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} 28274684ddb6SLionel Sambuc 28284684ddb6SLionel Sambuc 28294684ddb6SLionel Sambuc template <class _Up, class _Ep> 28304684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 28314684ddb6SLionel Sambuc typename enable_if 28324684ddb6SLionel Sambuc < 28334684ddb6SLionel Sambuc is_array<_Up>::value && 28344684ddb6SLionel Sambuc __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && 28354684ddb6SLionel Sambuc is_assignable<deleter_type&, _Ep&&>::value, 28364684ddb6SLionel Sambuc unique_ptr& 28374684ddb6SLionel Sambuc >::type 28384684ddb6SLionel Sambuc operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT 28394684ddb6SLionel Sambuc { 28404684ddb6SLionel Sambuc reset(__u.release()); 28414684ddb6SLionel Sambuc __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); 28424684ddb6SLionel Sambuc return *this; 28434684ddb6SLionel Sambuc } 28444684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 28454684ddb6SLionel Sambuc 28464684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) 28474684ddb6SLionel Sambuc : __ptr_(__p) 28484684ddb6SLionel Sambuc { 28494684ddb6SLionel Sambuc static_assert(!is_pointer<deleter_type>::value, 28504684ddb6SLionel Sambuc "unique_ptr constructed with null function pointer deleter"); 28514684ddb6SLionel Sambuc } 28524684ddb6SLionel Sambuc 28534684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) 28544684ddb6SLionel Sambuc : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {} 28554684ddb6SLionel Sambuc 28564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d) 28574684ddb6SLionel Sambuc : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {} 28584684ddb6SLionel Sambuc 28594684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() 28604684ddb6SLionel Sambuc { 28614684ddb6SLionel Sambuc return __rv<unique_ptr>(*this); 28624684ddb6SLionel Sambuc } 28634684ddb6SLionel Sambuc 28644684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) 28654684ddb6SLionel Sambuc : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} 28664684ddb6SLionel Sambuc 28674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u) 28684684ddb6SLionel Sambuc { 28694684ddb6SLionel Sambuc reset(__u->release()); 28704684ddb6SLionel Sambuc __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter()); 28714684ddb6SLionel Sambuc return *this; 28724684ddb6SLionel Sambuc } 28734684ddb6SLionel Sambuc 28744684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 28754684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} 28764684ddb6SLionel Sambuc 28774684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT 28784684ddb6SLionel Sambuc { 28794684ddb6SLionel Sambuc reset(); 28804684ddb6SLionel Sambuc return *this; 28814684ddb6SLionel Sambuc } 28824684ddb6SLionel Sambuc 28834684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const 28844684ddb6SLionel Sambuc {return __ptr_.first()[__i];} 28854684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} 28864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _Dp_reference get_deleter() _NOEXCEPT 28874684ddb6SLionel Sambuc {return __ptr_.second();} 28884684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT 28894684ddb6SLionel Sambuc {return __ptr_.second();} 28904684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 28914684ddb6SLionel Sambuc _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT 28924684ddb6SLionel Sambuc {return __ptr_.first() != nullptr;} 28934684ddb6SLionel Sambuc 28944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT 28954684ddb6SLionel Sambuc { 28964684ddb6SLionel Sambuc pointer __t = __ptr_.first(); 28974684ddb6SLionel Sambuc __ptr_.first() = pointer(); 28984684ddb6SLionel Sambuc return __t; 28994684ddb6SLionel Sambuc } 29004684ddb6SLionel Sambuc 29014684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2902*0a6a1f1dSLionel Sambuc template <class _Pp> 2903*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2904*0a6a1f1dSLionel Sambuc typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type 2905*0a6a1f1dSLionel Sambuc reset(_Pp __p) _NOEXCEPT 29064684ddb6SLionel Sambuc { 29074684ddb6SLionel Sambuc pointer __tmp = __ptr_.first(); 29084684ddb6SLionel Sambuc __ptr_.first() = __p; 29094684ddb6SLionel Sambuc if (__tmp) 29104684ddb6SLionel Sambuc __ptr_.second()(__tmp); 29114684ddb6SLionel Sambuc } 29124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT 29134684ddb6SLionel Sambuc { 29144684ddb6SLionel Sambuc pointer __tmp = __ptr_.first(); 29154684ddb6SLionel Sambuc __ptr_.first() = nullptr; 29164684ddb6SLionel Sambuc if (__tmp) 29174684ddb6SLionel Sambuc __ptr_.second()(__tmp); 29184684ddb6SLionel Sambuc } 29194684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT 29204684ddb6SLionel Sambuc { 29214684ddb6SLionel Sambuc pointer __tmp = __ptr_.first(); 29224684ddb6SLionel Sambuc __ptr_.first() = nullptr; 29234684ddb6SLionel Sambuc if (__tmp) 29244684ddb6SLionel Sambuc __ptr_.second()(__tmp); 29254684ddb6SLionel Sambuc } 29264684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 29274684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) 29284684ddb6SLionel Sambuc { 29294684ddb6SLionel Sambuc pointer __tmp = __ptr_.first(); 29304684ddb6SLionel Sambuc __ptr_.first() = __p; 29314684ddb6SLionel Sambuc if (__tmp) 29324684ddb6SLionel Sambuc __ptr_.second()(__tmp); 29334684ddb6SLionel Sambuc } 29344684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 29354684ddb6SLionel Sambuc 29364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} 29374684ddb6SLionel Sambucprivate: 29384684ddb6SLionel Sambuc 29394684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 29404684ddb6SLionel Sambuc template <class _Up> 29414684ddb6SLionel Sambuc explicit unique_ptr(_Up); 29424684ddb6SLionel Sambuc template <class _Up> 29434684ddb6SLionel Sambuc unique_ptr(_Up __u, 29444684ddb6SLionel Sambuc typename conditional< 29454684ddb6SLionel Sambuc is_reference<deleter_type>::value, 29464684ddb6SLionel Sambuc deleter_type, 29474684ddb6SLionel Sambuc typename add_lvalue_reference<const deleter_type>::type>::type, 29484684ddb6SLionel Sambuc typename enable_if 29494684ddb6SLionel Sambuc < 29504684ddb6SLionel Sambuc is_convertible<_Up, pointer>::value, 29514684ddb6SLionel Sambuc __nat 29524684ddb6SLionel Sambuc >::type = __nat()); 29534684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 29544684ddb6SLionel Sambuc}; 29554684ddb6SLionel Sambuc 29564684ddb6SLionel Sambuctemplate <class _Tp, class _Dp> 29574684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 29584684ddb6SLionel Sambucvoid 29594684ddb6SLionel Sambucswap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);} 29604684ddb6SLionel Sambuc 29614684ddb6SLionel Sambuctemplate <class _T1, class _D1, class _T2, class _D2> 29624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 29634684ddb6SLionel Sambucbool 29644684ddb6SLionel Sambucoperator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();} 29654684ddb6SLionel Sambuc 29664684ddb6SLionel Sambuctemplate <class _T1, class _D1, class _T2, class _D2> 29674684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 29684684ddb6SLionel Sambucbool 29694684ddb6SLionel Sambucoperator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);} 29704684ddb6SLionel Sambuc 29714684ddb6SLionel Sambuctemplate <class _T1, class _D1, class _T2, class _D2> 29724684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 29734684ddb6SLionel Sambucbool 29744684ddb6SLionel Sambucoperator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) 29754684ddb6SLionel Sambuc{ 29764684ddb6SLionel Sambuc typedef typename unique_ptr<_T1, _D1>::pointer _P1; 29774684ddb6SLionel Sambuc typedef typename unique_ptr<_T2, _D2>::pointer _P2; 2978*0a6a1f1dSLionel Sambuc typedef typename common_type<_P1, _P2>::type _Vp; 2979*0a6a1f1dSLionel Sambuc return less<_Vp>()(__x.get(), __y.get()); 29804684ddb6SLionel Sambuc} 29814684ddb6SLionel Sambuc 29824684ddb6SLionel Sambuctemplate <class _T1, class _D1, class _T2, class _D2> 29834684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 29844684ddb6SLionel Sambucbool 29854684ddb6SLionel Sambucoperator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;} 29864684ddb6SLionel Sambuc 29874684ddb6SLionel Sambuctemplate <class _T1, class _D1, class _T2, class _D2> 29884684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 29894684ddb6SLionel Sambucbool 29904684ddb6SLionel Sambucoperator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);} 29914684ddb6SLionel Sambuc 29924684ddb6SLionel Sambuctemplate <class _T1, class _D1, class _T2, class _D2> 29934684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 29944684ddb6SLionel Sambucbool 29954684ddb6SLionel Sambucoperator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} 29964684ddb6SLionel Sambuc 29974684ddb6SLionel Sambuctemplate <class _T1, class _D1> 29984684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 29994684ddb6SLionel Sambucbool 30004684ddb6SLionel Sambucoperator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT 30014684ddb6SLionel Sambuc{ 30024684ddb6SLionel Sambuc return !__x; 30034684ddb6SLionel Sambuc} 30044684ddb6SLionel Sambuc 30054684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30064684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30074684ddb6SLionel Sambucbool 30084684ddb6SLionel Sambucoperator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT 30094684ddb6SLionel Sambuc{ 30104684ddb6SLionel Sambuc return !__x; 30114684ddb6SLionel Sambuc} 30124684ddb6SLionel Sambuc 30134684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30144684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30154684ddb6SLionel Sambucbool 30164684ddb6SLionel Sambucoperator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT 30174684ddb6SLionel Sambuc{ 30184684ddb6SLionel Sambuc return static_cast<bool>(__x); 30194684ddb6SLionel Sambuc} 30204684ddb6SLionel Sambuc 30214684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30224684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30234684ddb6SLionel Sambucbool 30244684ddb6SLionel Sambucoperator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT 30254684ddb6SLionel Sambuc{ 30264684ddb6SLionel Sambuc return static_cast<bool>(__x); 30274684ddb6SLionel Sambuc} 30284684ddb6SLionel Sambuc 30294684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30304684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30314684ddb6SLionel Sambucbool 30324684ddb6SLionel Sambucoperator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) 30334684ddb6SLionel Sambuc{ 30344684ddb6SLionel Sambuc typedef typename unique_ptr<_T1, _D1>::pointer _P1; 30354684ddb6SLionel Sambuc return less<_P1>()(__x.get(), nullptr); 30364684ddb6SLionel Sambuc} 30374684ddb6SLionel Sambuc 30384684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30394684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30404684ddb6SLionel Sambucbool 30414684ddb6SLionel Sambucoperator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) 30424684ddb6SLionel Sambuc{ 30434684ddb6SLionel Sambuc typedef typename unique_ptr<_T1, _D1>::pointer _P1; 30444684ddb6SLionel Sambuc return less<_P1>()(nullptr, __x.get()); 30454684ddb6SLionel Sambuc} 30464684ddb6SLionel Sambuc 30474684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30494684ddb6SLionel Sambucbool 30504684ddb6SLionel Sambucoperator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) 30514684ddb6SLionel Sambuc{ 30524684ddb6SLionel Sambuc return nullptr < __x; 30534684ddb6SLionel Sambuc} 30544684ddb6SLionel Sambuc 30554684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30564684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30574684ddb6SLionel Sambucbool 30584684ddb6SLionel Sambucoperator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) 30594684ddb6SLionel Sambuc{ 30604684ddb6SLionel Sambuc return __x < nullptr; 30614684ddb6SLionel Sambuc} 30624684ddb6SLionel Sambuc 30634684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30644684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30654684ddb6SLionel Sambucbool 30664684ddb6SLionel Sambucoperator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) 30674684ddb6SLionel Sambuc{ 30684684ddb6SLionel Sambuc return !(nullptr < __x); 30694684ddb6SLionel Sambuc} 30704684ddb6SLionel Sambuc 30714684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30724684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30734684ddb6SLionel Sambucbool 30744684ddb6SLionel Sambucoperator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) 30754684ddb6SLionel Sambuc{ 30764684ddb6SLionel Sambuc return !(__x < nullptr); 30774684ddb6SLionel Sambuc} 30784684ddb6SLionel Sambuc 30794684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30804684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30814684ddb6SLionel Sambucbool 30824684ddb6SLionel Sambucoperator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) 30834684ddb6SLionel Sambuc{ 30844684ddb6SLionel Sambuc return !(__x < nullptr); 30854684ddb6SLionel Sambuc} 30864684ddb6SLionel Sambuc 30874684ddb6SLionel Sambuctemplate <class _T1, class _D1> 30884684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30894684ddb6SLionel Sambucbool 30904684ddb6SLionel Sambucoperator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) 30914684ddb6SLionel Sambuc{ 30924684ddb6SLionel Sambuc return !(nullptr < __x); 30934684ddb6SLionel Sambuc} 30944684ddb6SLionel Sambuc 30954684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES 30964684ddb6SLionel Sambuc 30974684ddb6SLionel Sambuctemplate <class _Tp, class _Dp> 30984684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30994684ddb6SLionel Sambucunique_ptr<_Tp, _Dp> 31004684ddb6SLionel Sambucmove(unique_ptr<_Tp, _Dp>& __t) 31014684ddb6SLionel Sambuc{ 31024684ddb6SLionel Sambuc return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t)); 31034684ddb6SLionel Sambuc} 31044684ddb6SLionel Sambuc 31054684ddb6SLionel Sambuc#endif 31064684ddb6SLionel Sambuc 31074684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 31084684ddb6SLionel Sambuc 31094684ddb6SLionel Sambuctemplate<class _Tp> 31104684ddb6SLionel Sambucstruct __unique_if 31114684ddb6SLionel Sambuc{ 31124684ddb6SLionel Sambuc typedef unique_ptr<_Tp> __unique_single; 31134684ddb6SLionel Sambuc}; 31144684ddb6SLionel Sambuc 31154684ddb6SLionel Sambuctemplate<class _Tp> 31164684ddb6SLionel Sambucstruct __unique_if<_Tp[]> 31174684ddb6SLionel Sambuc{ 31184684ddb6SLionel Sambuc typedef unique_ptr<_Tp[]> __unique_array_unknown_bound; 31194684ddb6SLionel Sambuc}; 31204684ddb6SLionel Sambuc 31214684ddb6SLionel Sambuctemplate<class _Tp, size_t _Np> 31224684ddb6SLionel Sambucstruct __unique_if<_Tp[_Np]> 31234684ddb6SLionel Sambuc{ 31244684ddb6SLionel Sambuc typedef void __unique_array_known_bound; 31254684ddb6SLionel Sambuc}; 31264684ddb6SLionel Sambuc 31274684ddb6SLionel Sambuctemplate<class _Tp, class... _Args> 31284684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 31294684ddb6SLionel Sambuctypename __unique_if<_Tp>::__unique_single 31304684ddb6SLionel Sambucmake_unique(_Args&&... __args) 31314684ddb6SLionel Sambuc{ 31324684ddb6SLionel Sambuc return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...)); 31334684ddb6SLionel Sambuc} 31344684ddb6SLionel Sambuc 31354684ddb6SLionel Sambuctemplate<class _Tp> 31364684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 31374684ddb6SLionel Sambuctypename __unique_if<_Tp>::__unique_array_unknown_bound 31384684ddb6SLionel Sambucmake_unique(size_t __n) 31394684ddb6SLionel Sambuc{ 31404684ddb6SLionel Sambuc typedef typename remove_extent<_Tp>::type _Up; 31414684ddb6SLionel Sambuc return unique_ptr<_Tp>(new _Up[__n]()); 31424684ddb6SLionel Sambuc} 31434684ddb6SLionel Sambuc 31444684ddb6SLionel Sambuctemplate<class _Tp, class... _Args> 31454684ddb6SLionel Sambuc typename __unique_if<_Tp>::__unique_array_known_bound 31464684ddb6SLionel Sambuc make_unique(_Args&&...) = delete; 31474684ddb6SLionel Sambuc 31484684ddb6SLionel Sambuc#endif // _LIBCPP_STD_VER > 11 31494684ddb6SLionel Sambuc 31504684ddb6SLionel Sambuctemplate <class _Tp> struct hash; 31514684ddb6SLionel Sambuc 31524684ddb6SLionel Sambuctemplate <class _Size> 31534684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 31544684ddb6SLionel Sambuc_Size 31554684ddb6SLionel Sambuc__loadword(const void* __p) 31564684ddb6SLionel Sambuc{ 31574684ddb6SLionel Sambuc _Size __r; 31584684ddb6SLionel Sambuc std::memcpy(&__r, __p, sizeof(__r)); 31594684ddb6SLionel Sambuc return __r; 31604684ddb6SLionel Sambuc} 31614684ddb6SLionel Sambuc 31624684ddb6SLionel Sambuc// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t 31634684ddb6SLionel Sambuc// is 64 bits. This is because cityhash64 uses 64bit x 64bit 31644684ddb6SLionel Sambuc// multiplication, which can be very slow on 32-bit systems. 31654684ddb6SLionel Sambuctemplate <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__> 31664684ddb6SLionel Sambucstruct __murmur2_or_cityhash; 31674684ddb6SLionel Sambuc 31684684ddb6SLionel Sambuctemplate <class _Size> 31694684ddb6SLionel Sambucstruct __murmur2_or_cityhash<_Size, 32> 31704684ddb6SLionel Sambuc{ 31714684ddb6SLionel Sambuc _Size operator()(const void* __key, _Size __len); 31724684ddb6SLionel Sambuc}; 31734684ddb6SLionel Sambuc 31744684ddb6SLionel Sambuc// murmur2 31754684ddb6SLionel Sambuctemplate <class _Size> 31764684ddb6SLionel Sambuc_Size 31774684ddb6SLionel Sambuc__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) 31784684ddb6SLionel Sambuc{ 31794684ddb6SLionel Sambuc const _Size __m = 0x5bd1e995; 31804684ddb6SLionel Sambuc const _Size __r = 24; 31814684ddb6SLionel Sambuc _Size __h = __len; 31824684ddb6SLionel Sambuc const unsigned char* __data = static_cast<const unsigned char*>(__key); 31834684ddb6SLionel Sambuc for (; __len >= 4; __data += 4, __len -= 4) 31844684ddb6SLionel Sambuc { 31854684ddb6SLionel Sambuc _Size __k = __loadword<_Size>(__data); 31864684ddb6SLionel Sambuc __k *= __m; 31874684ddb6SLionel Sambuc __k ^= __k >> __r; 31884684ddb6SLionel Sambuc __k *= __m; 31894684ddb6SLionel Sambuc __h *= __m; 31904684ddb6SLionel Sambuc __h ^= __k; 31914684ddb6SLionel Sambuc } 31924684ddb6SLionel Sambuc switch (__len) 31934684ddb6SLionel Sambuc { 31944684ddb6SLionel Sambuc case 3: 31954684ddb6SLionel Sambuc __h ^= __data[2] << 16; 31964684ddb6SLionel Sambuc case 2: 31974684ddb6SLionel Sambuc __h ^= __data[1] << 8; 31984684ddb6SLionel Sambuc case 1: 31994684ddb6SLionel Sambuc __h ^= __data[0]; 32004684ddb6SLionel Sambuc __h *= __m; 32014684ddb6SLionel Sambuc } 32024684ddb6SLionel Sambuc __h ^= __h >> 13; 32034684ddb6SLionel Sambuc __h *= __m; 32044684ddb6SLionel Sambuc __h ^= __h >> 15; 32054684ddb6SLionel Sambuc return __h; 32064684ddb6SLionel Sambuc} 32074684ddb6SLionel Sambuc 32084684ddb6SLionel Sambuctemplate <class _Size> 32094684ddb6SLionel Sambucstruct __murmur2_or_cityhash<_Size, 64> 32104684ddb6SLionel Sambuc{ 32114684ddb6SLionel Sambuc _Size operator()(const void* __key, _Size __len); 32124684ddb6SLionel Sambuc 32134684ddb6SLionel Sambuc private: 32144684ddb6SLionel Sambuc // Some primes between 2^63 and 2^64. 32154684ddb6SLionel Sambuc static const _Size __k0 = 0xc3a5c85c97cb3127ULL; 32164684ddb6SLionel Sambuc static const _Size __k1 = 0xb492b66fbe98f273ULL; 32174684ddb6SLionel Sambuc static const _Size __k2 = 0x9ae16a3b2f90404fULL; 32184684ddb6SLionel Sambuc static const _Size __k3 = 0xc949d7c7509e6557ULL; 32194684ddb6SLionel Sambuc 32204684ddb6SLionel Sambuc static _Size __rotate(_Size __val, int __shift) { 32214684ddb6SLionel Sambuc return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); 32224684ddb6SLionel Sambuc } 32234684ddb6SLionel Sambuc 32244684ddb6SLionel Sambuc static _Size __rotate_by_at_least_1(_Size __val, int __shift) { 32254684ddb6SLionel Sambuc return (__val >> __shift) | (__val << (64 - __shift)); 32264684ddb6SLionel Sambuc } 32274684ddb6SLionel Sambuc 32284684ddb6SLionel Sambuc static _Size __shift_mix(_Size __val) { 32294684ddb6SLionel Sambuc return __val ^ (__val >> 47); 32304684ddb6SLionel Sambuc } 32314684ddb6SLionel Sambuc 32324684ddb6SLionel Sambuc static _Size __hash_len_16(_Size __u, _Size __v) { 32334684ddb6SLionel Sambuc const _Size __mul = 0x9ddfea08eb382d69ULL; 32344684ddb6SLionel Sambuc _Size __a = (__u ^ __v) * __mul; 32354684ddb6SLionel Sambuc __a ^= (__a >> 47); 32364684ddb6SLionel Sambuc _Size __b = (__v ^ __a) * __mul; 32374684ddb6SLionel Sambuc __b ^= (__b >> 47); 32384684ddb6SLionel Sambuc __b *= __mul; 32394684ddb6SLionel Sambuc return __b; 32404684ddb6SLionel Sambuc } 32414684ddb6SLionel Sambuc 32424684ddb6SLionel Sambuc static _Size __hash_len_0_to_16(const char* __s, _Size __len) { 32434684ddb6SLionel Sambuc if (__len > 8) { 32444684ddb6SLionel Sambuc const _Size __a = __loadword<_Size>(__s); 32454684ddb6SLionel Sambuc const _Size __b = __loadword<_Size>(__s + __len - 8); 32464684ddb6SLionel Sambuc return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; 32474684ddb6SLionel Sambuc } 32484684ddb6SLionel Sambuc if (__len >= 4) { 32494684ddb6SLionel Sambuc const uint32_t __a = __loadword<uint32_t>(__s); 32504684ddb6SLionel Sambuc const uint32_t __b = __loadword<uint32_t>(__s + __len - 4); 32514684ddb6SLionel Sambuc return __hash_len_16(__len + (__a << 3), __b); 32524684ddb6SLionel Sambuc } 32534684ddb6SLionel Sambuc if (__len > 0) { 32544684ddb6SLionel Sambuc const unsigned char __a = __s[0]; 32554684ddb6SLionel Sambuc const unsigned char __b = __s[__len >> 1]; 32564684ddb6SLionel Sambuc const unsigned char __c = __s[__len - 1]; 32574684ddb6SLionel Sambuc const uint32_t __y = static_cast<uint32_t>(__a) + 32584684ddb6SLionel Sambuc (static_cast<uint32_t>(__b) << 8); 32594684ddb6SLionel Sambuc const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2); 32604684ddb6SLionel Sambuc return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; 32614684ddb6SLionel Sambuc } 32624684ddb6SLionel Sambuc return __k2; 32634684ddb6SLionel Sambuc } 32644684ddb6SLionel Sambuc 32654684ddb6SLionel Sambuc static _Size __hash_len_17_to_32(const char *__s, _Size __len) { 32664684ddb6SLionel Sambuc const _Size __a = __loadword<_Size>(__s) * __k1; 32674684ddb6SLionel Sambuc const _Size __b = __loadword<_Size>(__s + 8); 32684684ddb6SLionel Sambuc const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2; 32694684ddb6SLionel Sambuc const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0; 32704684ddb6SLionel Sambuc return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, 32714684ddb6SLionel Sambuc __a + __rotate(__b ^ __k3, 20) - __c + __len); 32724684ddb6SLionel Sambuc } 32734684ddb6SLionel Sambuc 32744684ddb6SLionel Sambuc // Return a 16-byte hash for 48 bytes. Quick and dirty. 32754684ddb6SLionel Sambuc // Callers do best to use "random-looking" values for a and b. 32764684ddb6SLionel Sambuc static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 32774684ddb6SLionel Sambuc _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) { 32784684ddb6SLionel Sambuc __a += __w; 32794684ddb6SLionel Sambuc __b = __rotate(__b + __a + __z, 21); 32804684ddb6SLionel Sambuc const _Size __c = __a; 32814684ddb6SLionel Sambuc __a += __x; 32824684ddb6SLionel Sambuc __a += __y; 32834684ddb6SLionel Sambuc __b += __rotate(__a, 44); 32844684ddb6SLionel Sambuc return pair<_Size, _Size>(__a + __z, __b + __c); 32854684ddb6SLionel Sambuc } 32864684ddb6SLionel Sambuc 32874684ddb6SLionel Sambuc // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. 32884684ddb6SLionel Sambuc static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 32894684ddb6SLionel Sambuc const char* __s, _Size __a, _Size __b) { 32904684ddb6SLionel Sambuc return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s), 32914684ddb6SLionel Sambuc __loadword<_Size>(__s + 8), 32924684ddb6SLionel Sambuc __loadword<_Size>(__s + 16), 32934684ddb6SLionel Sambuc __loadword<_Size>(__s + 24), 32944684ddb6SLionel Sambuc __a, 32954684ddb6SLionel Sambuc __b); 32964684ddb6SLionel Sambuc } 32974684ddb6SLionel Sambuc 32984684ddb6SLionel Sambuc // Return an 8-byte hash for 33 to 64 bytes. 32994684ddb6SLionel Sambuc static _Size __hash_len_33_to_64(const char *__s, size_t __len) { 33004684ddb6SLionel Sambuc _Size __z = __loadword<_Size>(__s + 24); 33014684ddb6SLionel Sambuc _Size __a = __loadword<_Size>(__s) + 33024684ddb6SLionel Sambuc (__len + __loadword<_Size>(__s + __len - 16)) * __k0; 33034684ddb6SLionel Sambuc _Size __b = __rotate(__a + __z, 52); 33044684ddb6SLionel Sambuc _Size __c = __rotate(__a, 37); 33054684ddb6SLionel Sambuc __a += __loadword<_Size>(__s + 8); 33064684ddb6SLionel Sambuc __c += __rotate(__a, 7); 33074684ddb6SLionel Sambuc __a += __loadword<_Size>(__s + 16); 33084684ddb6SLionel Sambuc _Size __vf = __a + __z; 33094684ddb6SLionel Sambuc _Size __vs = __b + __rotate(__a, 31) + __c; 33104684ddb6SLionel Sambuc __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32); 33114684ddb6SLionel Sambuc __z += __loadword<_Size>(__s + __len - 8); 33124684ddb6SLionel Sambuc __b = __rotate(__a + __z, 52); 33134684ddb6SLionel Sambuc __c = __rotate(__a, 37); 33144684ddb6SLionel Sambuc __a += __loadword<_Size>(__s + __len - 24); 33154684ddb6SLionel Sambuc __c += __rotate(__a, 7); 33164684ddb6SLionel Sambuc __a += __loadword<_Size>(__s + __len - 16); 33174684ddb6SLionel Sambuc _Size __wf = __a + __z; 33184684ddb6SLionel Sambuc _Size __ws = __b + __rotate(__a, 31) + __c; 33194684ddb6SLionel Sambuc _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); 33204684ddb6SLionel Sambuc return __shift_mix(__r * __k0 + __vs) * __k2; 33214684ddb6SLionel Sambuc } 33224684ddb6SLionel Sambuc}; 33234684ddb6SLionel Sambuc 33244684ddb6SLionel Sambuc// cityhash64 33254684ddb6SLionel Sambuctemplate <class _Size> 33264684ddb6SLionel Sambuc_Size 33274684ddb6SLionel Sambuc__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) 33284684ddb6SLionel Sambuc{ 33294684ddb6SLionel Sambuc const char* __s = static_cast<const char*>(__key); 33304684ddb6SLionel Sambuc if (__len <= 32) { 33314684ddb6SLionel Sambuc if (__len <= 16) { 33324684ddb6SLionel Sambuc return __hash_len_0_to_16(__s, __len); 33334684ddb6SLionel Sambuc } else { 33344684ddb6SLionel Sambuc return __hash_len_17_to_32(__s, __len); 33354684ddb6SLionel Sambuc } 33364684ddb6SLionel Sambuc } else if (__len <= 64) { 33374684ddb6SLionel Sambuc return __hash_len_33_to_64(__s, __len); 33384684ddb6SLionel Sambuc } 33394684ddb6SLionel Sambuc 33404684ddb6SLionel Sambuc // For strings over 64 bytes we hash the end first, and then as we 33414684ddb6SLionel Sambuc // loop we keep 56 bytes of state: v, w, x, y, and z. 33424684ddb6SLionel Sambuc _Size __x = __loadword<_Size>(__s + __len - 40); 33434684ddb6SLionel Sambuc _Size __y = __loadword<_Size>(__s + __len - 16) + 33444684ddb6SLionel Sambuc __loadword<_Size>(__s + __len - 56); 33454684ddb6SLionel Sambuc _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len, 33464684ddb6SLionel Sambuc __loadword<_Size>(__s + __len - 24)); 33474684ddb6SLionel Sambuc pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); 33484684ddb6SLionel Sambuc pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); 33494684ddb6SLionel Sambuc __x = __x * __k1 + __loadword<_Size>(__s); 33504684ddb6SLionel Sambuc 33514684ddb6SLionel Sambuc // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. 33524684ddb6SLionel Sambuc __len = (__len - 1) & ~static_cast<_Size>(63); 33534684ddb6SLionel Sambuc do { 33544684ddb6SLionel Sambuc __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1; 33554684ddb6SLionel Sambuc __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1; 33564684ddb6SLionel Sambuc __x ^= __w.second; 33574684ddb6SLionel Sambuc __y += __v.first + __loadword<_Size>(__s + 40); 33584684ddb6SLionel Sambuc __z = __rotate(__z + __w.first, 33) * __k1; 33594684ddb6SLionel Sambuc __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); 33604684ddb6SLionel Sambuc __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, 33614684ddb6SLionel Sambuc __y + __loadword<_Size>(__s + 16)); 33624684ddb6SLionel Sambuc std::swap(__z, __x); 33634684ddb6SLionel Sambuc __s += 64; 33644684ddb6SLionel Sambuc __len -= 64; 33654684ddb6SLionel Sambuc } while (__len != 0); 33664684ddb6SLionel Sambuc return __hash_len_16( 33674684ddb6SLionel Sambuc __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, 33684684ddb6SLionel Sambuc __hash_len_16(__v.second, __w.second) + __x); 33694684ddb6SLionel Sambuc} 33704684ddb6SLionel Sambuc 33714684ddb6SLionel Sambuctemplate <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> 33724684ddb6SLionel Sambucstruct __scalar_hash; 33734684ddb6SLionel Sambuc 33744684ddb6SLionel Sambuctemplate <class _Tp> 33754684ddb6SLionel Sambucstruct __scalar_hash<_Tp, 0> 33764684ddb6SLionel Sambuc : public unary_function<_Tp, size_t> 33774684ddb6SLionel Sambuc{ 33784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 33794684ddb6SLionel Sambuc size_t operator()(_Tp __v) const _NOEXCEPT 33804684ddb6SLionel Sambuc { 33814684ddb6SLionel Sambuc union 33824684ddb6SLionel Sambuc { 33834684ddb6SLionel Sambuc _Tp __t; 33844684ddb6SLionel Sambuc size_t __a; 33854684ddb6SLionel Sambuc } __u; 33864684ddb6SLionel Sambuc __u.__a = 0; 33874684ddb6SLionel Sambuc __u.__t = __v; 33884684ddb6SLionel Sambuc return __u.__a; 33894684ddb6SLionel Sambuc } 33904684ddb6SLionel Sambuc}; 33914684ddb6SLionel Sambuc 33924684ddb6SLionel Sambuctemplate <class _Tp> 33934684ddb6SLionel Sambucstruct __scalar_hash<_Tp, 1> 33944684ddb6SLionel Sambuc : public unary_function<_Tp, size_t> 33954684ddb6SLionel Sambuc{ 33964684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 33974684ddb6SLionel Sambuc size_t operator()(_Tp __v) const _NOEXCEPT 33984684ddb6SLionel Sambuc { 33994684ddb6SLionel Sambuc union 34004684ddb6SLionel Sambuc { 34014684ddb6SLionel Sambuc _Tp __t; 34024684ddb6SLionel Sambuc size_t __a; 34034684ddb6SLionel Sambuc } __u; 34044684ddb6SLionel Sambuc __u.__t = __v; 34054684ddb6SLionel Sambuc return __u.__a; 34064684ddb6SLionel Sambuc } 34074684ddb6SLionel Sambuc}; 34084684ddb6SLionel Sambuc 34094684ddb6SLionel Sambuctemplate <class _Tp> 34104684ddb6SLionel Sambucstruct __scalar_hash<_Tp, 2> 34114684ddb6SLionel Sambuc : public unary_function<_Tp, size_t> 34124684ddb6SLionel Sambuc{ 34134684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 34144684ddb6SLionel Sambuc size_t operator()(_Tp __v) const _NOEXCEPT 34154684ddb6SLionel Sambuc { 34164684ddb6SLionel Sambuc union 34174684ddb6SLionel Sambuc { 34184684ddb6SLionel Sambuc _Tp __t; 34194684ddb6SLionel Sambuc struct 34204684ddb6SLionel Sambuc { 34214684ddb6SLionel Sambuc size_t __a; 34224684ddb6SLionel Sambuc size_t __b; 3423*0a6a1f1dSLionel Sambuc } __s; 34244684ddb6SLionel Sambuc } __u; 34254684ddb6SLionel Sambuc __u.__t = __v; 34264684ddb6SLionel Sambuc return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 34274684ddb6SLionel Sambuc } 34284684ddb6SLionel Sambuc}; 34294684ddb6SLionel Sambuc 34304684ddb6SLionel Sambuctemplate <class _Tp> 34314684ddb6SLionel Sambucstruct __scalar_hash<_Tp, 3> 34324684ddb6SLionel Sambuc : public unary_function<_Tp, size_t> 34334684ddb6SLionel Sambuc{ 34344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 34354684ddb6SLionel Sambuc size_t operator()(_Tp __v) const _NOEXCEPT 34364684ddb6SLionel Sambuc { 34374684ddb6SLionel Sambuc union 34384684ddb6SLionel Sambuc { 34394684ddb6SLionel Sambuc _Tp __t; 34404684ddb6SLionel Sambuc struct 34414684ddb6SLionel Sambuc { 34424684ddb6SLionel Sambuc size_t __a; 34434684ddb6SLionel Sambuc size_t __b; 34444684ddb6SLionel Sambuc size_t __c; 3445*0a6a1f1dSLionel Sambuc } __s; 34464684ddb6SLionel Sambuc } __u; 34474684ddb6SLionel Sambuc __u.__t = __v; 34484684ddb6SLionel Sambuc return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 34494684ddb6SLionel Sambuc } 34504684ddb6SLionel Sambuc}; 34514684ddb6SLionel Sambuc 34524684ddb6SLionel Sambuctemplate <class _Tp> 34534684ddb6SLionel Sambucstruct __scalar_hash<_Tp, 4> 34544684ddb6SLionel Sambuc : public unary_function<_Tp, size_t> 34554684ddb6SLionel Sambuc{ 34564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 34574684ddb6SLionel Sambuc size_t operator()(_Tp __v) const _NOEXCEPT 34584684ddb6SLionel Sambuc { 34594684ddb6SLionel Sambuc union 34604684ddb6SLionel Sambuc { 34614684ddb6SLionel Sambuc _Tp __t; 34624684ddb6SLionel Sambuc struct 34634684ddb6SLionel Sambuc { 34644684ddb6SLionel Sambuc size_t __a; 34654684ddb6SLionel Sambuc size_t __b; 34664684ddb6SLionel Sambuc size_t __c; 34674684ddb6SLionel Sambuc size_t __d; 3468*0a6a1f1dSLionel Sambuc } __s; 34694684ddb6SLionel Sambuc } __u; 34704684ddb6SLionel Sambuc __u.__t = __v; 34714684ddb6SLionel Sambuc return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 34724684ddb6SLionel Sambuc } 34734684ddb6SLionel Sambuc}; 34744684ddb6SLionel Sambuc 34754684ddb6SLionel Sambuctemplate<class _Tp> 34764684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*> 34774684ddb6SLionel Sambuc : public unary_function<_Tp*, size_t> 34784684ddb6SLionel Sambuc{ 34794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 34804684ddb6SLionel Sambuc size_t operator()(_Tp* __v) const _NOEXCEPT 34814684ddb6SLionel Sambuc { 34824684ddb6SLionel Sambuc union 34834684ddb6SLionel Sambuc { 34844684ddb6SLionel Sambuc _Tp* __t; 34854684ddb6SLionel Sambuc size_t __a; 34864684ddb6SLionel Sambuc } __u; 34874684ddb6SLionel Sambuc __u.__t = __v; 34884684ddb6SLionel Sambuc return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 34894684ddb6SLionel Sambuc } 34904684ddb6SLionel Sambuc}; 34914684ddb6SLionel Sambuc 34924684ddb6SLionel Sambuctemplate <class _Tp, class _Dp> 34934684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<unique_ptr<_Tp, _Dp> > 34944684ddb6SLionel Sambuc{ 34954684ddb6SLionel Sambuc typedef unique_ptr<_Tp, _Dp> argument_type; 34964684ddb6SLionel Sambuc typedef size_t result_type; 34974684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 34984684ddb6SLionel Sambuc result_type operator()(const argument_type& __ptr) const _NOEXCEPT 34994684ddb6SLionel Sambuc { 35004684ddb6SLionel Sambuc typedef typename argument_type::pointer pointer; 35014684ddb6SLionel Sambuc return hash<pointer>()(__ptr.get()); 35024684ddb6SLionel Sambuc } 35034684ddb6SLionel Sambuc}; 35044684ddb6SLionel Sambuc 35054684ddb6SLionel Sambucstruct __destruct_n 35064684ddb6SLionel Sambuc{ 35074684ddb6SLionel Sambucprivate: 35084684ddb6SLionel Sambuc size_t size; 35094684ddb6SLionel Sambuc 35104684ddb6SLionel Sambuc template <class _Tp> 35114684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT 35124684ddb6SLionel Sambuc {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} 35134684ddb6SLionel Sambuc 35144684ddb6SLionel Sambuc template <class _Tp> 35154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT 35164684ddb6SLionel Sambuc {} 35174684ddb6SLionel Sambuc 35184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT 35194684ddb6SLionel Sambuc {++size;} 35204684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT 35214684ddb6SLionel Sambuc {} 35224684ddb6SLionel Sambuc 35234684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT 35244684ddb6SLionel Sambuc {size = __s;} 35254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT 35264684ddb6SLionel Sambuc {} 35274684ddb6SLionel Sambucpublic: 35284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT 35294684ddb6SLionel Sambuc : size(__s) {} 35304684ddb6SLionel Sambuc 35314684ddb6SLionel Sambuc template <class _Tp> 35324684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT 35334684ddb6SLionel Sambuc {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 35344684ddb6SLionel Sambuc 35354684ddb6SLionel Sambuc template <class _Tp> 35364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT 35374684ddb6SLionel Sambuc {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 35384684ddb6SLionel Sambuc 35394684ddb6SLionel Sambuc template <class _Tp> 35404684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT 35414684ddb6SLionel Sambuc {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} 35424684ddb6SLionel Sambuc}; 35434684ddb6SLionel Sambuc 35444684ddb6SLionel Sambuctemplate <class _Alloc> 35454684ddb6SLionel Sambucclass __allocator_destructor 35464684ddb6SLionel Sambuc{ 35474684ddb6SLionel Sambuc typedef allocator_traits<_Alloc> __alloc_traits; 35484684ddb6SLionel Sambucpublic: 35494684ddb6SLionel Sambuc typedef typename __alloc_traits::pointer pointer; 35504684ddb6SLionel Sambuc typedef typename __alloc_traits::size_type size_type; 35514684ddb6SLionel Sambucprivate: 35524684ddb6SLionel Sambuc _Alloc& __alloc_; 35534684ddb6SLionel Sambuc size_type __s_; 35544684ddb6SLionel Sambucpublic: 35554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) 35564684ddb6SLionel Sambuc _NOEXCEPT 35574684ddb6SLionel Sambuc : __alloc_(__a), __s_(__s) {} 35584684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 35594684ddb6SLionel Sambuc void operator()(pointer __p) _NOEXCEPT 35604684ddb6SLionel Sambuc {__alloc_traits::deallocate(__alloc_, __p, __s_);} 35614684ddb6SLionel Sambuc}; 35624684ddb6SLionel Sambuc 35634684ddb6SLionel Sambuctemplate <class _InputIterator, class _ForwardIterator> 35644684ddb6SLionel Sambuc_ForwardIterator 35654684ddb6SLionel Sambucuninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) 35664684ddb6SLionel Sambuc{ 35674684ddb6SLionel Sambuc typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 35684684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 35694684ddb6SLionel Sambuc _ForwardIterator __s = __r; 35704684ddb6SLionel Sambuc try 35714684ddb6SLionel Sambuc { 35724684ddb6SLionel Sambuc#endif 3573*0a6a1f1dSLionel Sambuc for (; __f != __l; ++__f, (void) ++__r) 3574*0a6a1f1dSLionel Sambuc ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f); 35754684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 35764684ddb6SLionel Sambuc } 35774684ddb6SLionel Sambuc catch (...) 35784684ddb6SLionel Sambuc { 35794684ddb6SLionel Sambuc for (; __s != __r; ++__s) 35804684ddb6SLionel Sambuc __s->~value_type(); 35814684ddb6SLionel Sambuc throw; 35824684ddb6SLionel Sambuc } 35834684ddb6SLionel Sambuc#endif 35844684ddb6SLionel Sambuc return __r; 35854684ddb6SLionel Sambuc} 35864684ddb6SLionel Sambuc 35874684ddb6SLionel Sambuctemplate <class _InputIterator, class _Size, class _ForwardIterator> 35884684ddb6SLionel Sambuc_ForwardIterator 35894684ddb6SLionel Sambucuninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) 35904684ddb6SLionel Sambuc{ 35914684ddb6SLionel Sambuc typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 35924684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 35934684ddb6SLionel Sambuc _ForwardIterator __s = __r; 35944684ddb6SLionel Sambuc try 35954684ddb6SLionel Sambuc { 35964684ddb6SLionel Sambuc#endif 3597*0a6a1f1dSLionel Sambuc for (; __n > 0; ++__f, (void) ++__r, (void) --__n) 3598*0a6a1f1dSLionel Sambuc ::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f); 35994684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 36004684ddb6SLionel Sambuc } 36014684ddb6SLionel Sambuc catch (...) 36024684ddb6SLionel Sambuc { 36034684ddb6SLionel Sambuc for (; __s != __r; ++__s) 36044684ddb6SLionel Sambuc __s->~value_type(); 36054684ddb6SLionel Sambuc throw; 36064684ddb6SLionel Sambuc } 36074684ddb6SLionel Sambuc#endif 36084684ddb6SLionel Sambuc return __r; 36094684ddb6SLionel Sambuc} 36104684ddb6SLionel Sambuc 36114684ddb6SLionel Sambuctemplate <class _ForwardIterator, class _Tp> 36124684ddb6SLionel Sambucvoid 36134684ddb6SLionel Sambucuninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) 36144684ddb6SLionel Sambuc{ 36154684ddb6SLionel Sambuc typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 36164684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 36174684ddb6SLionel Sambuc _ForwardIterator __s = __f; 36184684ddb6SLionel Sambuc try 36194684ddb6SLionel Sambuc { 36204684ddb6SLionel Sambuc#endif 36214684ddb6SLionel Sambuc for (; __f != __l; ++__f) 3622*0a6a1f1dSLionel Sambuc ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x); 36234684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 36244684ddb6SLionel Sambuc } 36254684ddb6SLionel Sambuc catch (...) 36264684ddb6SLionel Sambuc { 36274684ddb6SLionel Sambuc for (; __s != __f; ++__s) 36284684ddb6SLionel Sambuc __s->~value_type(); 36294684ddb6SLionel Sambuc throw; 36304684ddb6SLionel Sambuc } 36314684ddb6SLionel Sambuc#endif 36324684ddb6SLionel Sambuc} 36334684ddb6SLionel Sambuc 36344684ddb6SLionel Sambuctemplate <class _ForwardIterator, class _Size, class _Tp> 36354684ddb6SLionel Sambuc_ForwardIterator 36364684ddb6SLionel Sambucuninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) 36374684ddb6SLionel Sambuc{ 36384684ddb6SLionel Sambuc typedef typename iterator_traits<_ForwardIterator>::value_type value_type; 36394684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 36404684ddb6SLionel Sambuc _ForwardIterator __s = __f; 36414684ddb6SLionel Sambuc try 36424684ddb6SLionel Sambuc { 36434684ddb6SLionel Sambuc#endif 3644*0a6a1f1dSLionel Sambuc for (; __n > 0; ++__f, (void) --__n) 3645*0a6a1f1dSLionel Sambuc ::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x); 36464684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 36474684ddb6SLionel Sambuc } 36484684ddb6SLionel Sambuc catch (...) 36494684ddb6SLionel Sambuc { 36504684ddb6SLionel Sambuc for (; __s != __f; ++__s) 36514684ddb6SLionel Sambuc __s->~value_type(); 36524684ddb6SLionel Sambuc throw; 36534684ddb6SLionel Sambuc } 36544684ddb6SLionel Sambuc#endif 36554684ddb6SLionel Sambuc return __f; 36564684ddb6SLionel Sambuc} 36574684ddb6SLionel Sambuc 36584684ddb6SLionel Sambucclass _LIBCPP_EXCEPTION_ABI bad_weak_ptr 36594684ddb6SLionel Sambuc : public std::exception 36604684ddb6SLionel Sambuc{ 36614684ddb6SLionel Sambucpublic: 36624684ddb6SLionel Sambuc virtual ~bad_weak_ptr() _NOEXCEPT; 36634684ddb6SLionel Sambuc virtual const char* what() const _NOEXCEPT; 36644684ddb6SLionel Sambuc}; 36654684ddb6SLionel Sambuc 36664684ddb6SLionel Sambuctemplate<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 36674684ddb6SLionel Sambuc 36684684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __shared_count 36694684ddb6SLionel Sambuc{ 36704684ddb6SLionel Sambuc __shared_count(const __shared_count&); 36714684ddb6SLionel Sambuc __shared_count& operator=(const __shared_count&); 36724684ddb6SLionel Sambuc 36734684ddb6SLionel Sambucprotected: 36744684ddb6SLionel Sambuc long __shared_owners_; 36754684ddb6SLionel Sambuc virtual ~__shared_count(); 36764684ddb6SLionel Sambucprivate: 36774684ddb6SLionel Sambuc virtual void __on_zero_shared() _NOEXCEPT = 0; 36784684ddb6SLionel Sambuc 36794684ddb6SLionel Sambucpublic: 36804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 36814684ddb6SLionel Sambuc explicit __shared_count(long __refs = 0) _NOEXCEPT 36824684ddb6SLionel Sambuc : __shared_owners_(__refs) {} 36834684ddb6SLionel Sambuc 36844684ddb6SLionel Sambuc void __add_shared() _NOEXCEPT; 36854684ddb6SLionel Sambuc bool __release_shared() _NOEXCEPT; 36864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3687*0a6a1f1dSLionel Sambuc long use_count() const _NOEXCEPT { 3688*0a6a1f1dSLionel Sambuc return __libcpp_relaxed_load(&__shared_owners_) + 1; 3689*0a6a1f1dSLionel Sambuc } 36904684ddb6SLionel Sambuc}; 36914684ddb6SLionel Sambuc 36924684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __shared_weak_count 36934684ddb6SLionel Sambuc : private __shared_count 36944684ddb6SLionel Sambuc{ 36954684ddb6SLionel Sambuc long __shared_weak_owners_; 36964684ddb6SLionel Sambuc 36974684ddb6SLionel Sambucpublic: 36984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 36994684ddb6SLionel Sambuc explicit __shared_weak_count(long __refs = 0) _NOEXCEPT 37004684ddb6SLionel Sambuc : __shared_count(__refs), 37014684ddb6SLionel Sambuc __shared_weak_owners_(__refs) {} 37024684ddb6SLionel Sambucprotected: 37034684ddb6SLionel Sambuc virtual ~__shared_weak_count(); 37044684ddb6SLionel Sambuc 37054684ddb6SLionel Sambucpublic: 37064684ddb6SLionel Sambuc void __add_shared() _NOEXCEPT; 37074684ddb6SLionel Sambuc void __add_weak() _NOEXCEPT; 37084684ddb6SLionel Sambuc void __release_shared() _NOEXCEPT; 37094684ddb6SLionel Sambuc void __release_weak() _NOEXCEPT; 37104684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 37114684ddb6SLionel Sambuc long use_count() const _NOEXCEPT {return __shared_count::use_count();} 37124684ddb6SLionel Sambuc __shared_weak_count* lock() _NOEXCEPT; 37134684ddb6SLionel Sambuc 37144684ddb6SLionel Sambuc // Define the function out only if we build static libc++ without RTTI. 37154684ddb6SLionel Sambuc // Otherwise we may break clients who need to compile their projects with 37164684ddb6SLionel Sambuc // -fno-rtti and yet link against a libc++.dylib compiled 37174684ddb6SLionel Sambuc // without -fno-rtti. 37184684ddb6SLionel Sambuc#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC) 37194684ddb6SLionel Sambuc virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 37204684ddb6SLionel Sambuc#endif 37214684ddb6SLionel Sambucprivate: 37224684ddb6SLionel Sambuc virtual void __on_zero_shared_weak() _NOEXCEPT = 0; 37234684ddb6SLionel Sambuc}; 37244684ddb6SLionel Sambuc 37254684ddb6SLionel Sambuctemplate <class _Tp, class _Dp, class _Alloc> 37264684ddb6SLionel Sambucclass __shared_ptr_pointer 37274684ddb6SLionel Sambuc : public __shared_weak_count 37284684ddb6SLionel Sambuc{ 37294684ddb6SLionel Sambuc __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; 37304684ddb6SLionel Sambucpublic: 37314684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 37324684ddb6SLionel Sambuc __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) 37334684ddb6SLionel Sambuc : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {} 37344684ddb6SLionel Sambuc 37354684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI 37364684ddb6SLionel Sambuc virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; 37374684ddb6SLionel Sambuc#endif 37384684ddb6SLionel Sambuc 37394684ddb6SLionel Sambucprivate: 37404684ddb6SLionel Sambuc virtual void __on_zero_shared() _NOEXCEPT; 37414684ddb6SLionel Sambuc virtual void __on_zero_shared_weak() _NOEXCEPT; 37424684ddb6SLionel Sambuc}; 37434684ddb6SLionel Sambuc 37444684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI 37454684ddb6SLionel Sambuc 37464684ddb6SLionel Sambuctemplate <class _Tp, class _Dp, class _Alloc> 37474684ddb6SLionel Sambucconst void* 37484684ddb6SLionel Sambuc__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT 37494684ddb6SLionel Sambuc{ 3750*0a6a1f1dSLionel Sambuc return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : 0; 37514684ddb6SLionel Sambuc} 37524684ddb6SLionel Sambuc 37534684ddb6SLionel Sambuc#endif // _LIBCPP_NO_RTTI 37544684ddb6SLionel Sambuc 37554684ddb6SLionel Sambuctemplate <class _Tp, class _Dp, class _Alloc> 37564684ddb6SLionel Sambucvoid 37574684ddb6SLionel Sambuc__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT 37584684ddb6SLionel Sambuc{ 37594684ddb6SLionel Sambuc __data_.first().second()(__data_.first().first()); 37604684ddb6SLionel Sambuc __data_.first().second().~_Dp(); 37614684ddb6SLionel Sambuc} 37624684ddb6SLionel Sambuc 37634684ddb6SLionel Sambuctemplate <class _Tp, class _Dp, class _Alloc> 37644684ddb6SLionel Sambucvoid 37654684ddb6SLionel Sambuc__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 37664684ddb6SLionel Sambuc{ 3767*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _Al; 3768*0a6a1f1dSLionel Sambuc typedef allocator_traits<_Al> _ATraits; 3769*0a6a1f1dSLionel Sambuc typedef pointer_traits<typename _ATraits::pointer> _PTraits; 3770*0a6a1f1dSLionel Sambuc 3771*0a6a1f1dSLionel Sambuc _Al __a(__data_.second()); 37724684ddb6SLionel Sambuc __data_.second().~_Alloc(); 3773*0a6a1f1dSLionel Sambuc __a.deallocate(_PTraits::pointer_to(*this), 1); 37744684ddb6SLionel Sambuc} 37754684ddb6SLionel Sambuc 37764684ddb6SLionel Sambuctemplate <class _Tp, class _Alloc> 37774684ddb6SLionel Sambucclass __shared_ptr_emplace 37784684ddb6SLionel Sambuc : public __shared_weak_count 37794684ddb6SLionel Sambuc{ 37804684ddb6SLionel Sambuc __compressed_pair<_Alloc, _Tp> __data_; 37814684ddb6SLionel Sambucpublic: 37824684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 37834684ddb6SLionel Sambuc 37844684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 37854684ddb6SLionel Sambuc __shared_ptr_emplace(_Alloc __a) 37864684ddb6SLionel Sambuc : __data_(_VSTD::move(__a)) {} 37874684ddb6SLionel Sambuc 37884684ddb6SLionel Sambuc template <class ..._Args> 37894684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 37904684ddb6SLionel Sambuc __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) 37914684ddb6SLionel Sambuc : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), 37924684ddb6SLionel Sambuc _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} 37934684ddb6SLionel Sambuc 37944684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 37954684ddb6SLionel Sambuc 37964684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 37974684ddb6SLionel Sambuc __shared_ptr_emplace(_Alloc __a) 37984684ddb6SLionel Sambuc : __data_(__a) {} 37994684ddb6SLionel Sambuc 38004684ddb6SLionel Sambuc template <class _A0> 38014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 38024684ddb6SLionel Sambuc __shared_ptr_emplace(_Alloc __a, _A0& __a0) 38034684ddb6SLionel Sambuc : __data_(__a, _Tp(__a0)) {} 38044684ddb6SLionel Sambuc 38054684ddb6SLionel Sambuc template <class _A0, class _A1> 38064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 38074684ddb6SLionel Sambuc __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1) 38084684ddb6SLionel Sambuc : __data_(__a, _Tp(__a0, __a1)) {} 38094684ddb6SLionel Sambuc 38104684ddb6SLionel Sambuc template <class _A0, class _A1, class _A2> 38114684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 38124684ddb6SLionel Sambuc __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2) 38134684ddb6SLionel Sambuc : __data_(__a, _Tp(__a0, __a1, __a2)) {} 38144684ddb6SLionel Sambuc 38154684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 38164684ddb6SLionel Sambuc 38174684ddb6SLionel Sambucprivate: 38184684ddb6SLionel Sambuc virtual void __on_zero_shared() _NOEXCEPT; 38194684ddb6SLionel Sambuc virtual void __on_zero_shared_weak() _NOEXCEPT; 38204684ddb6SLionel Sambucpublic: 38214684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 38224684ddb6SLionel Sambuc _Tp* get() _NOEXCEPT {return &__data_.second();} 38234684ddb6SLionel Sambuc}; 38244684ddb6SLionel Sambuc 38254684ddb6SLionel Sambuctemplate <class _Tp, class _Alloc> 38264684ddb6SLionel Sambucvoid 38274684ddb6SLionel Sambuc__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT 38284684ddb6SLionel Sambuc{ 38294684ddb6SLionel Sambuc __data_.second().~_Tp(); 38304684ddb6SLionel Sambuc} 38314684ddb6SLionel Sambuc 38324684ddb6SLionel Sambuctemplate <class _Tp, class _Alloc> 38334684ddb6SLionel Sambucvoid 38344684ddb6SLionel Sambuc__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT 38354684ddb6SLionel Sambuc{ 3836*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type _Al; 3837*0a6a1f1dSLionel Sambuc typedef allocator_traits<_Al> _ATraits; 3838*0a6a1f1dSLionel Sambuc typedef pointer_traits<typename _ATraits::pointer> _PTraits; 3839*0a6a1f1dSLionel Sambuc _Al __a(__data_.first()); 38404684ddb6SLionel Sambuc __data_.first().~_Alloc(); 3841*0a6a1f1dSLionel Sambuc __a.deallocate(_PTraits::pointer_to(*this), 1); 38424684ddb6SLionel Sambuc} 38434684ddb6SLionel Sambuc 38444684ddb6SLionel Sambuctemplate<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this; 38454684ddb6SLionel Sambuc 38464684ddb6SLionel Sambuctemplate<class _Tp> 38474684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY shared_ptr 38484684ddb6SLionel Sambuc{ 38494684ddb6SLionel Sambucpublic: 38504684ddb6SLionel Sambuc typedef _Tp element_type; 38514684ddb6SLionel Sambucprivate: 38524684ddb6SLionel Sambuc element_type* __ptr_; 38534684ddb6SLionel Sambuc __shared_weak_count* __cntrl_; 38544684ddb6SLionel Sambuc 38554684ddb6SLionel Sambuc struct __nat {int __for_bool_;}; 38564684ddb6SLionel Sambucpublic: 38574684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; 38584684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; 3859*0a6a1f1dSLionel Sambuc template<class _Yp> 3860*0a6a1f1dSLionel Sambuc explicit shared_ptr(_Yp* __p, 3861*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 3862*0a6a1f1dSLionel Sambuc template<class _Yp, class _Dp> 3863*0a6a1f1dSLionel Sambuc shared_ptr(_Yp* __p, _Dp __d, 3864*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 3865*0a6a1f1dSLionel Sambuc template<class _Yp, class _Dp, class _Alloc> 3866*0a6a1f1dSLionel Sambuc shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, 3867*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 38684684ddb6SLionel Sambuc template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); 38694684ddb6SLionel Sambuc template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); 38704684ddb6SLionel Sambuc template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; 38714684ddb6SLionel Sambuc shared_ptr(const shared_ptr& __r) _NOEXCEPT; 38724684ddb6SLionel Sambuc template<class _Yp> 38734684ddb6SLionel Sambuc shared_ptr(const shared_ptr<_Yp>& __r, 38744684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 38754684ddb6SLionel Sambuc _NOEXCEPT; 38764684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 38774684ddb6SLionel Sambuc shared_ptr(shared_ptr&& __r) _NOEXCEPT; 38784684ddb6SLionel Sambuc template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r, 38794684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) 38804684ddb6SLionel Sambuc _NOEXCEPT; 38814684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 38824684ddb6SLionel Sambuc template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, 38834684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); 38844684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3885*0a6a1f1dSLionel Sambuc template<class _Yp> 3886*0a6a1f1dSLionel Sambuc shared_ptr(auto_ptr<_Yp>&& __r, 3887*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 38884684ddb6SLionel Sambuc#else 3889*0a6a1f1dSLionel Sambuc template<class _Yp> 3890*0a6a1f1dSLionel Sambuc shared_ptr(auto_ptr<_Yp> __r, 3891*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); 38924684ddb6SLionel Sambuc#endif 38934684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3894*0a6a1f1dSLionel Sambuc template <class _Yp, class _Dp> 38954684ddb6SLionel Sambuc shared_ptr(unique_ptr<_Yp, _Dp>&&, 3896*0a6a1f1dSLionel Sambuc typename enable_if 38974684ddb6SLionel Sambuc < 3898*0a6a1f1dSLionel Sambuc !is_lvalue_reference<_Dp>::value && 38994684ddb6SLionel Sambuc !is_array<_Yp>::value && 3900*0a6a1f1dSLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3901*0a6a1f1dSLionel Sambuc __nat 3902*0a6a1f1dSLionel Sambuc >::type = __nat()); 3903*0a6a1f1dSLionel Sambuc template <class _Yp, class _Dp> 39044684ddb6SLionel Sambuc shared_ptr(unique_ptr<_Yp, _Dp>&&, 3905*0a6a1f1dSLionel Sambuc typename enable_if 3906*0a6a1f1dSLionel Sambuc < 3907*0a6a1f1dSLionel Sambuc is_lvalue_reference<_Dp>::value && 3908*0a6a1f1dSLionel Sambuc !is_array<_Yp>::value && 3909*0a6a1f1dSLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3910*0a6a1f1dSLionel Sambuc __nat 3911*0a6a1f1dSLionel Sambuc >::type = __nat()); 39124684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3913*0a6a1f1dSLionel Sambuc template <class _Yp, class _Dp> 39144684ddb6SLionel Sambuc shared_ptr(unique_ptr<_Yp, _Dp>, 3915*0a6a1f1dSLionel Sambuc typename enable_if 3916*0a6a1f1dSLionel Sambuc < 3917*0a6a1f1dSLionel Sambuc !is_lvalue_reference<_Dp>::value && 3918*0a6a1f1dSLionel Sambuc !is_array<_Yp>::value && 3919*0a6a1f1dSLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3920*0a6a1f1dSLionel Sambuc __nat 3921*0a6a1f1dSLionel Sambuc >::type = __nat()); 3922*0a6a1f1dSLionel Sambuc template <class _Yp, class _Dp> 3923*0a6a1f1dSLionel Sambuc shared_ptr(unique_ptr<_Yp, _Dp>, 3924*0a6a1f1dSLionel Sambuc typename enable_if 3925*0a6a1f1dSLionel Sambuc < 3926*0a6a1f1dSLionel Sambuc is_lvalue_reference<_Dp>::value && 3927*0a6a1f1dSLionel Sambuc !is_array<_Yp>::value && 3928*0a6a1f1dSLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 3929*0a6a1f1dSLionel Sambuc __nat 3930*0a6a1f1dSLionel Sambuc >::type = __nat()); 39314684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 39324684ddb6SLionel Sambuc 39334684ddb6SLionel Sambuc ~shared_ptr(); 39344684ddb6SLionel Sambuc 39354684ddb6SLionel Sambuc shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; 39364684ddb6SLionel Sambuc template<class _Yp> 39374684ddb6SLionel Sambuc typename enable_if 39384684ddb6SLionel Sambuc < 39394684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 39404684ddb6SLionel Sambuc shared_ptr& 39414684ddb6SLionel Sambuc >::type 39424684ddb6SLionel Sambuc operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; 39434684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 39444684ddb6SLionel Sambuc shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; 39454684ddb6SLionel Sambuc template<class _Yp> 39464684ddb6SLionel Sambuc typename enable_if 39474684ddb6SLionel Sambuc < 39484684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 39494684ddb6SLionel Sambuc shared_ptr<_Tp>& 39504684ddb6SLionel Sambuc >::type 39514684ddb6SLionel Sambuc operator=(shared_ptr<_Yp>&& __r); 39524684ddb6SLionel Sambuc template<class _Yp> 39534684ddb6SLionel Sambuc typename enable_if 39544684ddb6SLionel Sambuc < 39554684ddb6SLionel Sambuc !is_array<_Yp>::value && 39564684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 39574684ddb6SLionel Sambuc shared_ptr 39584684ddb6SLionel Sambuc >::type& 39594684ddb6SLionel Sambuc operator=(auto_ptr<_Yp>&& __r); 39604684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 39614684ddb6SLionel Sambuc template<class _Yp> 39624684ddb6SLionel Sambuc typename enable_if 39634684ddb6SLionel Sambuc < 39644684ddb6SLionel Sambuc !is_array<_Yp>::value && 39654684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 39664684ddb6SLionel Sambuc shared_ptr& 39674684ddb6SLionel Sambuc >::type 39684684ddb6SLionel Sambuc operator=(auto_ptr<_Yp> __r); 39694684ddb6SLionel Sambuc#endif 39704684ddb6SLionel Sambuc template <class _Yp, class _Dp> 39714684ddb6SLionel Sambuc typename enable_if 39724684ddb6SLionel Sambuc < 39734684ddb6SLionel Sambuc !is_array<_Yp>::value && 39744684ddb6SLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 39754684ddb6SLionel Sambuc shared_ptr& 39764684ddb6SLionel Sambuc >::type 39774684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 39784684ddb6SLionel Sambuc operator=(unique_ptr<_Yp, _Dp>&& __r); 39794684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 39804684ddb6SLionel Sambuc operator=(unique_ptr<_Yp, _Dp> __r); 39814684ddb6SLionel Sambuc#endif 39824684ddb6SLionel Sambuc 39834684ddb6SLionel Sambuc void swap(shared_ptr& __r) _NOEXCEPT; 39844684ddb6SLionel Sambuc void reset() _NOEXCEPT; 39854684ddb6SLionel Sambuc template<class _Yp> 39864684ddb6SLionel Sambuc typename enable_if 39874684ddb6SLionel Sambuc < 39884684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 39894684ddb6SLionel Sambuc void 39904684ddb6SLionel Sambuc >::type 39914684ddb6SLionel Sambuc reset(_Yp* __p); 39924684ddb6SLionel Sambuc template<class _Yp, class _Dp> 39934684ddb6SLionel Sambuc typename enable_if 39944684ddb6SLionel Sambuc < 39954684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 39964684ddb6SLionel Sambuc void 39974684ddb6SLionel Sambuc >::type 39984684ddb6SLionel Sambuc reset(_Yp* __p, _Dp __d); 39994684ddb6SLionel Sambuc template<class _Yp, class _Dp, class _Alloc> 40004684ddb6SLionel Sambuc typename enable_if 40014684ddb6SLionel Sambuc < 40024684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 40034684ddb6SLionel Sambuc void 40044684ddb6SLionel Sambuc >::type 40054684ddb6SLionel Sambuc reset(_Yp* __p, _Dp __d, _Alloc __a); 40064684ddb6SLionel Sambuc 40074684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40084684ddb6SLionel Sambuc element_type* get() const _NOEXCEPT {return __ptr_;} 40094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40104684ddb6SLionel Sambuc typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT 40114684ddb6SLionel Sambuc {return *__ptr_;} 40124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40134684ddb6SLionel Sambuc element_type* operator->() const _NOEXCEPT {return __ptr_;} 40144684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40154684ddb6SLionel Sambuc long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} 40164684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40174684ddb6SLionel Sambuc bool unique() const _NOEXCEPT {return use_count() == 1;} 40184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40194684ddb6SLionel Sambuc _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;} 40204684ddb6SLionel Sambuc template <class _Up> 40214684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40224684ddb6SLionel Sambuc bool owner_before(shared_ptr<_Up> const& __p) const 40234684ddb6SLionel Sambuc {return __cntrl_ < __p.__cntrl_;} 40244684ddb6SLionel Sambuc template <class _Up> 40254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40264684ddb6SLionel Sambuc bool owner_before(weak_ptr<_Up> const& __p) const 40274684ddb6SLionel Sambuc {return __cntrl_ < __p.__cntrl_;} 40284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40294684ddb6SLionel Sambuc bool 40304684ddb6SLionel Sambuc __owner_equivalent(const shared_ptr& __p) const 40314684ddb6SLionel Sambuc {return __cntrl_ == __p.__cntrl_;} 40324684ddb6SLionel Sambuc 40334684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI 40344684ddb6SLionel Sambuc template <class _Dp> 40354684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40364684ddb6SLionel Sambuc _Dp* __get_deleter() const _NOEXCEPT 40374684ddb6SLionel Sambuc {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} 40384684ddb6SLionel Sambuc#endif // _LIBCPP_NO_RTTI 40394684ddb6SLionel Sambuc 40404684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 40414684ddb6SLionel Sambuc 40424684ddb6SLionel Sambuc template<class ..._Args> 40434684ddb6SLionel Sambuc static 40444684ddb6SLionel Sambuc shared_ptr<_Tp> 40454684ddb6SLionel Sambuc make_shared(_Args&& ...__args); 40464684ddb6SLionel Sambuc 40474684ddb6SLionel Sambuc template<class _Alloc, class ..._Args> 40484684ddb6SLionel Sambuc static 40494684ddb6SLionel Sambuc shared_ptr<_Tp> 40504684ddb6SLionel Sambuc allocate_shared(const _Alloc& __a, _Args&& ...__args); 40514684ddb6SLionel Sambuc 40524684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 40534684ddb6SLionel Sambuc 40544684ddb6SLionel Sambuc static shared_ptr<_Tp> make_shared(); 40554684ddb6SLionel Sambuc 40564684ddb6SLionel Sambuc template<class _A0> 40574684ddb6SLionel Sambuc static shared_ptr<_Tp> make_shared(_A0&); 40584684ddb6SLionel Sambuc 40594684ddb6SLionel Sambuc template<class _A0, class _A1> 40604684ddb6SLionel Sambuc static shared_ptr<_Tp> make_shared(_A0&, _A1&); 40614684ddb6SLionel Sambuc 40624684ddb6SLionel Sambuc template<class _A0, class _A1, class _A2> 40634684ddb6SLionel Sambuc static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&); 40644684ddb6SLionel Sambuc 40654684ddb6SLionel Sambuc template<class _Alloc> 40664684ddb6SLionel Sambuc static shared_ptr<_Tp> 40674684ddb6SLionel Sambuc allocate_shared(const _Alloc& __a); 40684684ddb6SLionel Sambuc 40694684ddb6SLionel Sambuc template<class _Alloc, class _A0> 40704684ddb6SLionel Sambuc static shared_ptr<_Tp> 40714684ddb6SLionel Sambuc allocate_shared(const _Alloc& __a, _A0& __a0); 40724684ddb6SLionel Sambuc 40734684ddb6SLionel Sambuc template<class _Alloc, class _A0, class _A1> 40744684ddb6SLionel Sambuc static shared_ptr<_Tp> 40754684ddb6SLionel Sambuc allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1); 40764684ddb6SLionel Sambuc 40774684ddb6SLionel Sambuc template<class _Alloc, class _A0, class _A1, class _A2> 40784684ddb6SLionel Sambuc static shared_ptr<_Tp> 40794684ddb6SLionel Sambuc allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2); 40804684ddb6SLionel Sambuc 40814684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 40824684ddb6SLionel Sambuc 40834684ddb6SLionel Sambucprivate: 40844684ddb6SLionel Sambuc 40854684ddb6SLionel Sambuc template <class _Yp> 40864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 40874684ddb6SLionel Sambuc void 40884684ddb6SLionel Sambuc __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT 40894684ddb6SLionel Sambuc { 40904684ddb6SLionel Sambuc if (__e) 4091*0a6a1f1dSLionel Sambuc { 4092*0a6a1f1dSLionel Sambuc __e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast<const _Yp*>(__e)); 4093*0a6a1f1dSLionel Sambuc __e->__weak_this_.__cntrl_ = __cntrl_; 4094*0a6a1f1dSLionel Sambuc __cntrl_->__add_weak(); 4095*0a6a1f1dSLionel Sambuc } 40964684ddb6SLionel Sambuc } 40974684ddb6SLionel Sambuc 40984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 4099*0a6a1f1dSLionel Sambuc void __enable_weak_this(const volatile void*) _NOEXCEPT {} 41004684ddb6SLionel Sambuc 41014684ddb6SLionel Sambuc template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; 41024684ddb6SLionel Sambuc template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 41034684ddb6SLionel Sambuc}; 41044684ddb6SLionel Sambuc 41054684ddb6SLionel Sambuctemplate<class _Tp> 41064684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 41074684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 41084684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr() _NOEXCEPT 41094684ddb6SLionel Sambuc : __ptr_(0), 41104684ddb6SLionel Sambuc __cntrl_(0) 41114684ddb6SLionel Sambuc{ 41124684ddb6SLionel Sambuc} 41134684ddb6SLionel Sambuc 41144684ddb6SLionel Sambuctemplate<class _Tp> 41154684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 41164684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 41174684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT 41184684ddb6SLionel Sambuc : __ptr_(0), 41194684ddb6SLionel Sambuc __cntrl_(0) 41204684ddb6SLionel Sambuc{ 41214684ddb6SLionel Sambuc} 41224684ddb6SLionel Sambuc 41234684ddb6SLionel Sambuctemplate<class _Tp> 4124*0a6a1f1dSLionel Sambuctemplate<class _Yp> 4125*0a6a1f1dSLionel Sambucshared_ptr<_Tp>::shared_ptr(_Yp* __p, 4126*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) 41274684ddb6SLionel Sambuc : __ptr_(__p) 41284684ddb6SLionel Sambuc{ 41294684ddb6SLionel Sambuc unique_ptr<_Yp> __hold(__p); 41304684ddb6SLionel Sambuc typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 41314684ddb6SLionel Sambuc __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); 41324684ddb6SLionel Sambuc __hold.release(); 41334684ddb6SLionel Sambuc __enable_weak_this(__p); 41344684ddb6SLionel Sambuc} 41354684ddb6SLionel Sambuc 41364684ddb6SLionel Sambuctemplate<class _Tp> 4137*0a6a1f1dSLionel Sambuctemplate<class _Yp, class _Dp> 4138*0a6a1f1dSLionel Sambucshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, 4139*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) 41404684ddb6SLionel Sambuc : __ptr_(__p) 41414684ddb6SLionel Sambuc{ 41424684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 41434684ddb6SLionel Sambuc try 41444684ddb6SLionel Sambuc { 41454684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 41464684ddb6SLionel Sambuc typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 41474684ddb6SLionel Sambuc __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); 41484684ddb6SLionel Sambuc __enable_weak_this(__p); 41494684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 41504684ddb6SLionel Sambuc } 41514684ddb6SLionel Sambuc catch (...) 41524684ddb6SLionel Sambuc { 41534684ddb6SLionel Sambuc __d(__p); 41544684ddb6SLionel Sambuc throw; 41554684ddb6SLionel Sambuc } 41564684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 41574684ddb6SLionel Sambuc} 41584684ddb6SLionel Sambuc 41594684ddb6SLionel Sambuctemplate<class _Tp> 41604684ddb6SLionel Sambuctemplate<class _Dp> 41614684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) 41624684ddb6SLionel Sambuc : __ptr_(0) 41634684ddb6SLionel Sambuc{ 41644684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 41654684ddb6SLionel Sambuc try 41664684ddb6SLionel Sambuc { 41674684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 41684684ddb6SLionel Sambuc typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; 41694684ddb6SLionel Sambuc __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); 41704684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 41714684ddb6SLionel Sambuc } 41724684ddb6SLionel Sambuc catch (...) 41734684ddb6SLionel Sambuc { 41744684ddb6SLionel Sambuc __d(__p); 41754684ddb6SLionel Sambuc throw; 41764684ddb6SLionel Sambuc } 41774684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 41784684ddb6SLionel Sambuc} 41794684ddb6SLionel Sambuc 41804684ddb6SLionel Sambuctemplate<class _Tp> 4181*0a6a1f1dSLionel Sambuctemplate<class _Yp, class _Dp, class _Alloc> 4182*0a6a1f1dSLionel Sambucshared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, 4183*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) 41844684ddb6SLionel Sambuc : __ptr_(__p) 41854684ddb6SLionel Sambuc{ 41864684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 41874684ddb6SLionel Sambuc try 41884684ddb6SLionel Sambuc { 41894684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 41904684ddb6SLionel Sambuc typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; 4191*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; 41924684ddb6SLionel Sambuc typedef __allocator_destructor<_A2> _D2; 41934684ddb6SLionel Sambuc _A2 __a2(__a); 41944684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4195*0a6a1f1dSLionel Sambuc ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4196*0a6a1f1dSLionel Sambuc _CntrlBlk(__p, __d, __a); 4197*0a6a1f1dSLionel Sambuc __cntrl_ = _VSTD::addressof(*__hold2.release()); 41984684ddb6SLionel Sambuc __enable_weak_this(__p); 41994684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 42004684ddb6SLionel Sambuc } 42014684ddb6SLionel Sambuc catch (...) 42024684ddb6SLionel Sambuc { 42034684ddb6SLionel Sambuc __d(__p); 42044684ddb6SLionel Sambuc throw; 42054684ddb6SLionel Sambuc } 42064684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 42074684ddb6SLionel Sambuc} 42084684ddb6SLionel Sambuc 42094684ddb6SLionel Sambuctemplate<class _Tp> 42104684ddb6SLionel Sambuctemplate<class _Dp, class _Alloc> 42114684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) 42124684ddb6SLionel Sambuc : __ptr_(0) 42134684ddb6SLionel Sambuc{ 42144684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 42154684ddb6SLionel Sambuc try 42164684ddb6SLionel Sambuc { 42174684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 42184684ddb6SLionel Sambuc typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; 4219*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; 42204684ddb6SLionel Sambuc typedef __allocator_destructor<_A2> _D2; 42214684ddb6SLionel Sambuc _A2 __a2(__a); 42224684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4223*0a6a1f1dSLionel Sambuc ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4224*0a6a1f1dSLionel Sambuc _CntrlBlk(__p, __d, __a); 4225*0a6a1f1dSLionel Sambuc __cntrl_ = _VSTD::addressof(*__hold2.release()); 42264684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 42274684ddb6SLionel Sambuc } 42284684ddb6SLionel Sambuc catch (...) 42294684ddb6SLionel Sambuc { 42304684ddb6SLionel Sambuc __d(__p); 42314684ddb6SLionel Sambuc throw; 42324684ddb6SLionel Sambuc } 42334684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 42344684ddb6SLionel Sambuc} 42354684ddb6SLionel Sambuc 42364684ddb6SLionel Sambuctemplate<class _Tp> 42374684ddb6SLionel Sambuctemplate<class _Yp> 42384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 42394684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT 42404684ddb6SLionel Sambuc : __ptr_(__p), 42414684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 42424684ddb6SLionel Sambuc{ 42434684ddb6SLionel Sambuc if (__cntrl_) 42444684ddb6SLionel Sambuc __cntrl_->__add_shared(); 42454684ddb6SLionel Sambuc} 42464684ddb6SLionel Sambuc 42474684ddb6SLionel Sambuctemplate<class _Tp> 42484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 42494684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT 42504684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 42514684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 42524684ddb6SLionel Sambuc{ 42534684ddb6SLionel Sambuc if (__cntrl_) 42544684ddb6SLionel Sambuc __cntrl_->__add_shared(); 42554684ddb6SLionel Sambuc} 42564684ddb6SLionel Sambuc 42574684ddb6SLionel Sambuctemplate<class _Tp> 42584684ddb6SLionel Sambuctemplate<class _Yp> 42594684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 42604684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, 42614684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 42624684ddb6SLionel Sambuc _NOEXCEPT 42634684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 42644684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 42654684ddb6SLionel Sambuc{ 42664684ddb6SLionel Sambuc if (__cntrl_) 42674684ddb6SLionel Sambuc __cntrl_->__add_shared(); 42684684ddb6SLionel Sambuc} 42694684ddb6SLionel Sambuc 42704684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 42714684ddb6SLionel Sambuc 42724684ddb6SLionel Sambuctemplate<class _Tp> 42734684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 42744684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT 42754684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 42764684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 42774684ddb6SLionel Sambuc{ 42784684ddb6SLionel Sambuc __r.__ptr_ = 0; 42794684ddb6SLionel Sambuc __r.__cntrl_ = 0; 42804684ddb6SLionel Sambuc} 42814684ddb6SLionel Sambuc 42824684ddb6SLionel Sambuctemplate<class _Tp> 42834684ddb6SLionel Sambuctemplate<class _Yp> 42844684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 42854684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, 42864684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 42874684ddb6SLionel Sambuc _NOEXCEPT 42884684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 42894684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 42904684ddb6SLionel Sambuc{ 42914684ddb6SLionel Sambuc __r.__ptr_ = 0; 42924684ddb6SLionel Sambuc __r.__cntrl_ = 0; 42934684ddb6SLionel Sambuc} 42944684ddb6SLionel Sambuc 42954684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 42964684ddb6SLionel Sambuc 42974684ddb6SLionel Sambuctemplate<class _Tp> 4298*0a6a1f1dSLionel Sambuctemplate<class _Yp> 42994684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4300*0a6a1f1dSLionel Sambucshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r, 43014684ddb6SLionel Sambuc#else 4302*0a6a1f1dSLionel Sambucshared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r, 43034684ddb6SLionel Sambuc#endif 4304*0a6a1f1dSLionel Sambuc typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) 43054684ddb6SLionel Sambuc : __ptr_(__r.get()) 43064684ddb6SLionel Sambuc{ 43074684ddb6SLionel Sambuc typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; 43084684ddb6SLionel Sambuc __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); 43094684ddb6SLionel Sambuc __enable_weak_this(__r.get()); 43104684ddb6SLionel Sambuc __r.release(); 43114684ddb6SLionel Sambuc} 43124684ddb6SLionel Sambuc 43134684ddb6SLionel Sambuctemplate<class _Tp> 4314*0a6a1f1dSLionel Sambuctemplate <class _Yp, class _Dp> 43154684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 43164684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 43174684ddb6SLionel Sambuc#else 43184684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 43194684ddb6SLionel Sambuc#endif 4320*0a6a1f1dSLionel Sambuc typename enable_if 4321*0a6a1f1dSLionel Sambuc < 4322*0a6a1f1dSLionel Sambuc !is_lvalue_reference<_Dp>::value && 4323*0a6a1f1dSLionel Sambuc !is_array<_Yp>::value && 4324*0a6a1f1dSLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 4325*0a6a1f1dSLionel Sambuc __nat 4326*0a6a1f1dSLionel Sambuc >::type) 43274684ddb6SLionel Sambuc : __ptr_(__r.get()) 43284684ddb6SLionel Sambuc{ 4329*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 11 4330*0a6a1f1dSLionel Sambuc if (__ptr_ == nullptr) 4331*0a6a1f1dSLionel Sambuc __cntrl_ = nullptr; 4332*0a6a1f1dSLionel Sambuc else 4333*0a6a1f1dSLionel Sambuc#endif 4334*0a6a1f1dSLionel Sambuc { 43354684ddb6SLionel Sambuc typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; 43364684ddb6SLionel Sambuc __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); 43374684ddb6SLionel Sambuc __enable_weak_this(__r.get()); 4338*0a6a1f1dSLionel Sambuc } 43394684ddb6SLionel Sambuc __r.release(); 43404684ddb6SLionel Sambuc} 43414684ddb6SLionel Sambuc 43424684ddb6SLionel Sambuctemplate<class _Tp> 4343*0a6a1f1dSLionel Sambuctemplate <class _Yp, class _Dp> 43444684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 43454684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, 43464684ddb6SLionel Sambuc#else 43474684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, 43484684ddb6SLionel Sambuc#endif 4349*0a6a1f1dSLionel Sambuc typename enable_if 4350*0a6a1f1dSLionel Sambuc < 4351*0a6a1f1dSLionel Sambuc is_lvalue_reference<_Dp>::value && 4352*0a6a1f1dSLionel Sambuc !is_array<_Yp>::value && 4353*0a6a1f1dSLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, 4354*0a6a1f1dSLionel Sambuc __nat 4355*0a6a1f1dSLionel Sambuc >::type) 43564684ddb6SLionel Sambuc : __ptr_(__r.get()) 43574684ddb6SLionel Sambuc{ 4358*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 11 4359*0a6a1f1dSLionel Sambuc if (__ptr_ == nullptr) 4360*0a6a1f1dSLionel Sambuc __cntrl_ = nullptr; 4361*0a6a1f1dSLionel Sambuc else 4362*0a6a1f1dSLionel Sambuc#endif 4363*0a6a1f1dSLionel Sambuc { 43644684ddb6SLionel Sambuc typedef __shared_ptr_pointer<_Yp*, 43654684ddb6SLionel Sambuc reference_wrapper<typename remove_reference<_Dp>::type>, 43664684ddb6SLionel Sambuc allocator<_Yp> > _CntrlBlk; 43674684ddb6SLionel Sambuc __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); 43684684ddb6SLionel Sambuc __enable_weak_this(__r.get()); 4369*0a6a1f1dSLionel Sambuc } 43704684ddb6SLionel Sambuc __r.release(); 43714684ddb6SLionel Sambuc} 43724684ddb6SLionel Sambuc 43734684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 43744684ddb6SLionel Sambuc 43754684ddb6SLionel Sambuctemplate<class _Tp> 43764684ddb6SLionel Sambuctemplate<class ..._Args> 43774684ddb6SLionel Sambucshared_ptr<_Tp> 43784684ddb6SLionel Sambucshared_ptr<_Tp>::make_shared(_Args&& ...__args) 43794684ddb6SLionel Sambuc{ 43804684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 43814684ddb6SLionel Sambuc typedef allocator<_CntrlBlk> _A2; 43824684ddb6SLionel Sambuc typedef __allocator_destructor<_A2> _D2; 43834684ddb6SLionel Sambuc _A2 __a2; 43844684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 43854684ddb6SLionel Sambuc ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); 43864684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 43874684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 43884684ddb6SLionel Sambuc __r.__cntrl_ = __hold2.release(); 43894684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 43904684ddb6SLionel Sambuc return __r; 43914684ddb6SLionel Sambuc} 43924684ddb6SLionel Sambuc 43934684ddb6SLionel Sambuctemplate<class _Tp> 43944684ddb6SLionel Sambuctemplate<class _Alloc, class ..._Args> 43954684ddb6SLionel Sambucshared_ptr<_Tp> 43964684ddb6SLionel Sambucshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) 43974684ddb6SLionel Sambuc{ 43984684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4399*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; 44004684ddb6SLionel Sambuc typedef __allocator_destructor<_A2> _D2; 44014684ddb6SLionel Sambuc _A2 __a2(__a); 44024684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); 4403*0a6a1f1dSLionel Sambuc ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4404*0a6a1f1dSLionel Sambuc _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); 44054684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 44064684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 4407*0a6a1f1dSLionel Sambuc __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 44084684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 44094684ddb6SLionel Sambuc return __r; 44104684ddb6SLionel Sambuc} 44114684ddb6SLionel Sambuc 44124684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 44134684ddb6SLionel Sambuc 44144684ddb6SLionel Sambuctemplate<class _Tp> 44154684ddb6SLionel Sambucshared_ptr<_Tp> 44164684ddb6SLionel Sambucshared_ptr<_Tp>::make_shared() 44174684ddb6SLionel Sambuc{ 44184684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 44194684ddb6SLionel Sambuc typedef allocator<_CntrlBlk> _Alloc2; 44204684ddb6SLionel Sambuc typedef __allocator_destructor<_Alloc2> _D2; 44214684ddb6SLionel Sambuc _Alloc2 __alloc2; 44224684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 44234684ddb6SLionel Sambuc ::new(__hold2.get()) _CntrlBlk(__alloc2); 44244684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 44254684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 44264684ddb6SLionel Sambuc __r.__cntrl_ = __hold2.release(); 44274684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 44284684ddb6SLionel Sambuc return __r; 44294684ddb6SLionel Sambuc} 44304684ddb6SLionel Sambuc 44314684ddb6SLionel Sambuctemplate<class _Tp> 44324684ddb6SLionel Sambuctemplate<class _A0> 44334684ddb6SLionel Sambucshared_ptr<_Tp> 44344684ddb6SLionel Sambucshared_ptr<_Tp>::make_shared(_A0& __a0) 44354684ddb6SLionel Sambuc{ 44364684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 44374684ddb6SLionel Sambuc typedef allocator<_CntrlBlk> _Alloc2; 44384684ddb6SLionel Sambuc typedef __allocator_destructor<_Alloc2> _D2; 44394684ddb6SLionel Sambuc _Alloc2 __alloc2; 44404684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 44414684ddb6SLionel Sambuc ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); 44424684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 44434684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 44444684ddb6SLionel Sambuc __r.__cntrl_ = __hold2.release(); 44454684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 44464684ddb6SLionel Sambuc return __r; 44474684ddb6SLionel Sambuc} 44484684ddb6SLionel Sambuc 44494684ddb6SLionel Sambuctemplate<class _Tp> 44504684ddb6SLionel Sambuctemplate<class _A0, class _A1> 44514684ddb6SLionel Sambucshared_ptr<_Tp> 44524684ddb6SLionel Sambucshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) 44534684ddb6SLionel Sambuc{ 44544684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 44554684ddb6SLionel Sambuc typedef allocator<_CntrlBlk> _Alloc2; 44564684ddb6SLionel Sambuc typedef __allocator_destructor<_Alloc2> _D2; 44574684ddb6SLionel Sambuc _Alloc2 __alloc2; 44584684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 44594684ddb6SLionel Sambuc ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); 44604684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 44614684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 44624684ddb6SLionel Sambuc __r.__cntrl_ = __hold2.release(); 44634684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 44644684ddb6SLionel Sambuc return __r; 44654684ddb6SLionel Sambuc} 44664684ddb6SLionel Sambuc 44674684ddb6SLionel Sambuctemplate<class _Tp> 44684684ddb6SLionel Sambuctemplate<class _A0, class _A1, class _A2> 44694684ddb6SLionel Sambucshared_ptr<_Tp> 44704684ddb6SLionel Sambucshared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) 44714684ddb6SLionel Sambuc{ 44724684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; 44734684ddb6SLionel Sambuc typedef allocator<_CntrlBlk> _Alloc2; 44744684ddb6SLionel Sambuc typedef __allocator_destructor<_Alloc2> _D2; 44754684ddb6SLionel Sambuc _Alloc2 __alloc2; 44764684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 44774684ddb6SLionel Sambuc ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); 44784684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 44794684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 44804684ddb6SLionel Sambuc __r.__cntrl_ = __hold2.release(); 44814684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 44824684ddb6SLionel Sambuc return __r; 44834684ddb6SLionel Sambuc} 44844684ddb6SLionel Sambuc 44854684ddb6SLionel Sambuctemplate<class _Tp> 44864684ddb6SLionel Sambuctemplate<class _Alloc> 44874684ddb6SLionel Sambucshared_ptr<_Tp> 44884684ddb6SLionel Sambucshared_ptr<_Tp>::allocate_shared(const _Alloc& __a) 44894684ddb6SLionel Sambuc{ 44904684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4491*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; 44924684ddb6SLionel Sambuc typedef __allocator_destructor<_Alloc2> _D2; 44934684ddb6SLionel Sambuc _Alloc2 __alloc2(__a); 44944684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4495*0a6a1f1dSLionel Sambuc ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4496*0a6a1f1dSLionel Sambuc _CntrlBlk(__a); 44974684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 44984684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 4499*0a6a1f1dSLionel Sambuc __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 45004684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 45014684ddb6SLionel Sambuc return __r; 45024684ddb6SLionel Sambuc} 45034684ddb6SLionel Sambuc 45044684ddb6SLionel Sambuctemplate<class _Tp> 45054684ddb6SLionel Sambuctemplate<class _Alloc, class _A0> 45064684ddb6SLionel Sambucshared_ptr<_Tp> 45074684ddb6SLionel Sambucshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) 45084684ddb6SLionel Sambuc{ 45094684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4510*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; 45114684ddb6SLionel Sambuc typedef __allocator_destructor<_Alloc2> _D2; 45124684ddb6SLionel Sambuc _Alloc2 __alloc2(__a); 45134684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4514*0a6a1f1dSLionel Sambuc ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4515*0a6a1f1dSLionel Sambuc _CntrlBlk(__a, __a0); 45164684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 45174684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 4518*0a6a1f1dSLionel Sambuc __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 45194684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 45204684ddb6SLionel Sambuc return __r; 45214684ddb6SLionel Sambuc} 45224684ddb6SLionel Sambuc 45234684ddb6SLionel Sambuctemplate<class _Tp> 45244684ddb6SLionel Sambuctemplate<class _Alloc, class _A0, class _A1> 45254684ddb6SLionel Sambucshared_ptr<_Tp> 45264684ddb6SLionel Sambucshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 45274684ddb6SLionel Sambuc{ 45284684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4529*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; 45304684ddb6SLionel Sambuc typedef __allocator_destructor<_Alloc2> _D2; 45314684ddb6SLionel Sambuc _Alloc2 __alloc2(__a); 45324684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4533*0a6a1f1dSLionel Sambuc ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4534*0a6a1f1dSLionel Sambuc _CntrlBlk(__a, __a0, __a1); 45354684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 45364684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 4537*0a6a1f1dSLionel Sambuc __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 45384684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 45394684ddb6SLionel Sambuc return __r; 45404684ddb6SLionel Sambuc} 45414684ddb6SLionel Sambuc 45424684ddb6SLionel Sambuctemplate<class _Tp> 45434684ddb6SLionel Sambuctemplate<class _Alloc, class _A0, class _A1, class _A2> 45444684ddb6SLionel Sambucshared_ptr<_Tp> 45454684ddb6SLionel Sambucshared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 45464684ddb6SLionel Sambuc{ 45474684ddb6SLionel Sambuc typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; 4548*0a6a1f1dSLionel Sambuc typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2; 45494684ddb6SLionel Sambuc typedef __allocator_destructor<_Alloc2> _D2; 45504684ddb6SLionel Sambuc _Alloc2 __alloc2(__a); 45514684ddb6SLionel Sambuc unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); 4552*0a6a1f1dSLionel Sambuc ::new(static_cast<void*>(_VSTD::addressof(*__hold2.get()))) 4553*0a6a1f1dSLionel Sambuc _CntrlBlk(__a, __a0, __a1, __a2); 45544684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 45554684ddb6SLionel Sambuc __r.__ptr_ = __hold2.get()->get(); 4556*0a6a1f1dSLionel Sambuc __r.__cntrl_ = _VSTD::addressof(*__hold2.release()); 45574684ddb6SLionel Sambuc __r.__enable_weak_this(__r.__ptr_); 45584684ddb6SLionel Sambuc return __r; 45594684ddb6SLionel Sambuc} 45604684ddb6SLionel Sambuc 45614684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 45624684ddb6SLionel Sambuc 45634684ddb6SLionel Sambuctemplate<class _Tp> 45644684ddb6SLionel Sambucshared_ptr<_Tp>::~shared_ptr() 45654684ddb6SLionel Sambuc{ 45664684ddb6SLionel Sambuc if (__cntrl_) 45674684ddb6SLionel Sambuc __cntrl_->__release_shared(); 45684684ddb6SLionel Sambuc} 45694684ddb6SLionel Sambuc 45704684ddb6SLionel Sambuctemplate<class _Tp> 45714684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 45724684ddb6SLionel Sambucshared_ptr<_Tp>& 45734684ddb6SLionel Sambucshared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT 45744684ddb6SLionel Sambuc{ 45754684ddb6SLionel Sambuc shared_ptr(__r).swap(*this); 45764684ddb6SLionel Sambuc return *this; 45774684ddb6SLionel Sambuc} 45784684ddb6SLionel Sambuc 45794684ddb6SLionel Sambuctemplate<class _Tp> 45804684ddb6SLionel Sambuctemplate<class _Yp> 45814684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 45824684ddb6SLionel Sambuctypename enable_if 45834684ddb6SLionel Sambuc< 45844684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 45854684ddb6SLionel Sambuc shared_ptr<_Tp>& 45864684ddb6SLionel Sambuc>::type 45874684ddb6SLionel Sambucshared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT 45884684ddb6SLionel Sambuc{ 45894684ddb6SLionel Sambuc shared_ptr(__r).swap(*this); 45904684ddb6SLionel Sambuc return *this; 45914684ddb6SLionel Sambuc} 45924684ddb6SLionel Sambuc 45934684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 45944684ddb6SLionel Sambuc 45954684ddb6SLionel Sambuctemplate<class _Tp> 45964684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 45974684ddb6SLionel Sambucshared_ptr<_Tp>& 45984684ddb6SLionel Sambucshared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT 45994684ddb6SLionel Sambuc{ 46004684ddb6SLionel Sambuc shared_ptr(_VSTD::move(__r)).swap(*this); 46014684ddb6SLionel Sambuc return *this; 46024684ddb6SLionel Sambuc} 46034684ddb6SLionel Sambuc 46044684ddb6SLionel Sambuctemplate<class _Tp> 46054684ddb6SLionel Sambuctemplate<class _Yp> 46064684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 46074684ddb6SLionel Sambuctypename enable_if 46084684ddb6SLionel Sambuc< 46094684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 46104684ddb6SLionel Sambuc shared_ptr<_Tp>& 46114684ddb6SLionel Sambuc>::type 46124684ddb6SLionel Sambucshared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) 46134684ddb6SLionel Sambuc{ 46144684ddb6SLionel Sambuc shared_ptr(_VSTD::move(__r)).swap(*this); 46154684ddb6SLionel Sambuc return *this; 46164684ddb6SLionel Sambuc} 46174684ddb6SLionel Sambuc 46184684ddb6SLionel Sambuctemplate<class _Tp> 46194684ddb6SLionel Sambuctemplate<class _Yp> 46204684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 46214684ddb6SLionel Sambuctypename enable_if 46224684ddb6SLionel Sambuc< 46234684ddb6SLionel Sambuc !is_array<_Yp>::value && 46244684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 46254684ddb6SLionel Sambuc shared_ptr<_Tp> 46264684ddb6SLionel Sambuc>::type& 46274684ddb6SLionel Sambucshared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) 46284684ddb6SLionel Sambuc{ 46294684ddb6SLionel Sambuc shared_ptr(_VSTD::move(__r)).swap(*this); 46304684ddb6SLionel Sambuc return *this; 46314684ddb6SLionel Sambuc} 46324684ddb6SLionel Sambuc 46334684ddb6SLionel Sambuctemplate<class _Tp> 46344684ddb6SLionel Sambuctemplate <class _Yp, class _Dp> 46354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 46364684ddb6SLionel Sambuctypename enable_if 46374684ddb6SLionel Sambuc< 46384684ddb6SLionel Sambuc !is_array<_Yp>::value && 46394684ddb6SLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, 46404684ddb6SLionel Sambuc shared_ptr<_Tp>& 46414684ddb6SLionel Sambuc>::type 46424684ddb6SLionel Sambucshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) 46434684ddb6SLionel Sambuc{ 46444684ddb6SLionel Sambuc shared_ptr(_VSTD::move(__r)).swap(*this); 46454684ddb6SLionel Sambuc return *this; 46464684ddb6SLionel Sambuc} 46474684ddb6SLionel Sambuc 46484684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 46494684ddb6SLionel Sambuc 46504684ddb6SLionel Sambuctemplate<class _Tp> 46514684ddb6SLionel Sambuctemplate<class _Yp> 46524684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 46534684ddb6SLionel Sambuctypename enable_if 46544684ddb6SLionel Sambuc< 46554684ddb6SLionel Sambuc !is_array<_Yp>::value && 46564684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 46574684ddb6SLionel Sambuc shared_ptr<_Tp>& 46584684ddb6SLionel Sambuc>::type 46594684ddb6SLionel Sambucshared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) 46604684ddb6SLionel Sambuc{ 46614684ddb6SLionel Sambuc shared_ptr(__r).swap(*this); 46624684ddb6SLionel Sambuc return *this; 46634684ddb6SLionel Sambuc} 46644684ddb6SLionel Sambuc 46654684ddb6SLionel Sambuctemplate<class _Tp> 46664684ddb6SLionel Sambuctemplate <class _Yp, class _Dp> 46674684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 46684684ddb6SLionel Sambuctypename enable_if 46694684ddb6SLionel Sambuc< 46704684ddb6SLionel Sambuc !is_array<_Yp>::value && 46714684ddb6SLionel Sambuc is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, 46724684ddb6SLionel Sambuc shared_ptr<_Tp>& 46734684ddb6SLionel Sambuc>::type 46744684ddb6SLionel Sambucshared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) 46754684ddb6SLionel Sambuc{ 46764684ddb6SLionel Sambuc shared_ptr(_VSTD::move(__r)).swap(*this); 46774684ddb6SLionel Sambuc return *this; 46784684ddb6SLionel Sambuc} 46794684ddb6SLionel Sambuc 46804684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 46814684ddb6SLionel Sambuc 46824684ddb6SLionel Sambuctemplate<class _Tp> 46834684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 46844684ddb6SLionel Sambucvoid 46854684ddb6SLionel Sambucshared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT 46864684ddb6SLionel Sambuc{ 46874684ddb6SLionel Sambuc _VSTD::swap(__ptr_, __r.__ptr_); 46884684ddb6SLionel Sambuc _VSTD::swap(__cntrl_, __r.__cntrl_); 46894684ddb6SLionel Sambuc} 46904684ddb6SLionel Sambuc 46914684ddb6SLionel Sambuctemplate<class _Tp> 46924684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 46934684ddb6SLionel Sambucvoid 46944684ddb6SLionel Sambucshared_ptr<_Tp>::reset() _NOEXCEPT 46954684ddb6SLionel Sambuc{ 46964684ddb6SLionel Sambuc shared_ptr().swap(*this); 46974684ddb6SLionel Sambuc} 46984684ddb6SLionel Sambuc 46994684ddb6SLionel Sambuctemplate<class _Tp> 47004684ddb6SLionel Sambuctemplate<class _Yp> 47014684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47024684ddb6SLionel Sambuctypename enable_if 47034684ddb6SLionel Sambuc< 47044684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 47054684ddb6SLionel Sambuc void 47064684ddb6SLionel Sambuc>::type 47074684ddb6SLionel Sambucshared_ptr<_Tp>::reset(_Yp* __p) 47084684ddb6SLionel Sambuc{ 47094684ddb6SLionel Sambuc shared_ptr(__p).swap(*this); 47104684ddb6SLionel Sambuc} 47114684ddb6SLionel Sambuc 47124684ddb6SLionel Sambuctemplate<class _Tp> 47134684ddb6SLionel Sambuctemplate<class _Yp, class _Dp> 47144684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47154684ddb6SLionel Sambuctypename enable_if 47164684ddb6SLionel Sambuc< 47174684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 47184684ddb6SLionel Sambuc void 47194684ddb6SLionel Sambuc>::type 47204684ddb6SLionel Sambucshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) 47214684ddb6SLionel Sambuc{ 47224684ddb6SLionel Sambuc shared_ptr(__p, __d).swap(*this); 47234684ddb6SLionel Sambuc} 47244684ddb6SLionel Sambuc 47254684ddb6SLionel Sambuctemplate<class _Tp> 47264684ddb6SLionel Sambuctemplate<class _Yp, class _Dp, class _Alloc> 47274684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47284684ddb6SLionel Sambuctypename enable_if 47294684ddb6SLionel Sambuc< 47304684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 47314684ddb6SLionel Sambuc void 47324684ddb6SLionel Sambuc>::type 47334684ddb6SLionel Sambucshared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) 47344684ddb6SLionel Sambuc{ 47354684ddb6SLionel Sambuc shared_ptr(__p, __d, __a).swap(*this); 47364684ddb6SLionel Sambuc} 47374684ddb6SLionel Sambuc 47384684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 47394684ddb6SLionel Sambuc 47404684ddb6SLionel Sambuctemplate<class _Tp, class ..._Args> 47414684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47424684ddb6SLionel Sambuctypename enable_if 47434684ddb6SLionel Sambuc< 47444684ddb6SLionel Sambuc !is_array<_Tp>::value, 47454684ddb6SLionel Sambuc shared_ptr<_Tp> 47464684ddb6SLionel Sambuc>::type 47474684ddb6SLionel Sambucmake_shared(_Args&& ...__args) 47484684ddb6SLionel Sambuc{ 47494684ddb6SLionel Sambuc return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...); 47504684ddb6SLionel Sambuc} 47514684ddb6SLionel Sambuc 47524684ddb6SLionel Sambuctemplate<class _Tp, class _Alloc, class ..._Args> 47534684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47544684ddb6SLionel Sambuctypename enable_if 47554684ddb6SLionel Sambuc< 47564684ddb6SLionel Sambuc !is_array<_Tp>::value, 47574684ddb6SLionel Sambuc shared_ptr<_Tp> 47584684ddb6SLionel Sambuc>::type 47594684ddb6SLionel Sambucallocate_shared(const _Alloc& __a, _Args&& ...__args) 47604684ddb6SLionel Sambuc{ 47614684ddb6SLionel Sambuc return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...); 47624684ddb6SLionel Sambuc} 47634684ddb6SLionel Sambuc 47644684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_VARIADICS 47654684ddb6SLionel Sambuc 47664684ddb6SLionel Sambuctemplate<class _Tp> 47674684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47684684ddb6SLionel Sambucshared_ptr<_Tp> 47694684ddb6SLionel Sambucmake_shared() 47704684ddb6SLionel Sambuc{ 47714684ddb6SLionel Sambuc return shared_ptr<_Tp>::make_shared(); 47724684ddb6SLionel Sambuc} 47734684ddb6SLionel Sambuc 47744684ddb6SLionel Sambuctemplate<class _Tp, class _A0> 47754684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47764684ddb6SLionel Sambucshared_ptr<_Tp> 47774684ddb6SLionel Sambucmake_shared(_A0& __a0) 47784684ddb6SLionel Sambuc{ 47794684ddb6SLionel Sambuc return shared_ptr<_Tp>::make_shared(__a0); 47804684ddb6SLionel Sambuc} 47814684ddb6SLionel Sambuc 47824684ddb6SLionel Sambuctemplate<class _Tp, class _A0, class _A1> 47834684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47844684ddb6SLionel Sambucshared_ptr<_Tp> 47854684ddb6SLionel Sambucmake_shared(_A0& __a0, _A1& __a1) 47864684ddb6SLionel Sambuc{ 47874684ddb6SLionel Sambuc return shared_ptr<_Tp>::make_shared(__a0, __a1); 47884684ddb6SLionel Sambuc} 47894684ddb6SLionel Sambuc 47904684ddb6SLionel Sambuctemplate<class _Tp, class _A0, class _A1, class _A2> 47914684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 47924684ddb6SLionel Sambucshared_ptr<_Tp> 47934684ddb6SLionel Sambucmake_shared(_A0& __a0, _A1& __a1, _A2& __a2) 47944684ddb6SLionel Sambuc{ 47954684ddb6SLionel Sambuc return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2); 47964684ddb6SLionel Sambuc} 47974684ddb6SLionel Sambuc 47984684ddb6SLionel Sambuctemplate<class _Tp, class _Alloc> 47994684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48004684ddb6SLionel Sambucshared_ptr<_Tp> 48014684ddb6SLionel Sambucallocate_shared(const _Alloc& __a) 48024684ddb6SLionel Sambuc{ 48034684ddb6SLionel Sambuc return shared_ptr<_Tp>::allocate_shared(__a); 48044684ddb6SLionel Sambuc} 48054684ddb6SLionel Sambuc 48064684ddb6SLionel Sambuctemplate<class _Tp, class _Alloc, class _A0> 48074684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48084684ddb6SLionel Sambucshared_ptr<_Tp> 48094684ddb6SLionel Sambucallocate_shared(const _Alloc& __a, _A0& __a0) 48104684ddb6SLionel Sambuc{ 48114684ddb6SLionel Sambuc return shared_ptr<_Tp>::allocate_shared(__a, __a0); 48124684ddb6SLionel Sambuc} 48134684ddb6SLionel Sambuc 48144684ddb6SLionel Sambuctemplate<class _Tp, class _Alloc, class _A0, class _A1> 48154684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48164684ddb6SLionel Sambucshared_ptr<_Tp> 48174684ddb6SLionel Sambucallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) 48184684ddb6SLionel Sambuc{ 48194684ddb6SLionel Sambuc return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1); 48204684ddb6SLionel Sambuc} 48214684ddb6SLionel Sambuc 48224684ddb6SLionel Sambuctemplate<class _Tp, class _Alloc, class _A0, class _A1, class _A2> 48234684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48244684ddb6SLionel Sambucshared_ptr<_Tp> 48254684ddb6SLionel Sambucallocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) 48264684ddb6SLionel Sambuc{ 48274684ddb6SLionel Sambuc return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2); 48284684ddb6SLionel Sambuc} 48294684ddb6SLionel Sambuc 48304684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 48314684ddb6SLionel Sambuc 48324684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 48334684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48344684ddb6SLionel Sambucbool 48354684ddb6SLionel Sambucoperator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 48364684ddb6SLionel Sambuc{ 48374684ddb6SLionel Sambuc return __x.get() == __y.get(); 48384684ddb6SLionel Sambuc} 48394684ddb6SLionel Sambuc 48404684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 48414684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48424684ddb6SLionel Sambucbool 48434684ddb6SLionel Sambucoperator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 48444684ddb6SLionel Sambuc{ 48454684ddb6SLionel Sambuc return !(__x == __y); 48464684ddb6SLionel Sambuc} 48474684ddb6SLionel Sambuc 48484684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 48494684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48504684ddb6SLionel Sambucbool 48514684ddb6SLionel Sambucoperator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 48524684ddb6SLionel Sambuc{ 4853*0a6a1f1dSLionel Sambuc typedef typename common_type<_Tp*, _Up*>::type _Vp; 4854*0a6a1f1dSLionel Sambuc return less<_Vp>()(__x.get(), __y.get()); 48554684ddb6SLionel Sambuc} 48564684ddb6SLionel Sambuc 48574684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 48584684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48594684ddb6SLionel Sambucbool 48604684ddb6SLionel Sambucoperator>(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 48614684ddb6SLionel Sambuc{ 48624684ddb6SLionel Sambuc return __y < __x; 48634684ddb6SLionel Sambuc} 48644684ddb6SLionel Sambuc 48654684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 48664684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48674684ddb6SLionel Sambucbool 48684684ddb6SLionel Sambucoperator<=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 48694684ddb6SLionel Sambuc{ 48704684ddb6SLionel Sambuc return !(__y < __x); 48714684ddb6SLionel Sambuc} 48724684ddb6SLionel Sambuc 48734684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 48744684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48754684ddb6SLionel Sambucbool 48764684ddb6SLionel Sambucoperator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT 48774684ddb6SLionel Sambuc{ 48784684ddb6SLionel Sambuc return !(__x < __y); 48794684ddb6SLionel Sambuc} 48804684ddb6SLionel Sambuc 48814684ddb6SLionel Sambuctemplate<class _Tp> 48824684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48834684ddb6SLionel Sambucbool 48844684ddb6SLionel Sambucoperator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 48854684ddb6SLionel Sambuc{ 48864684ddb6SLionel Sambuc return !__x; 48874684ddb6SLionel Sambuc} 48884684ddb6SLionel Sambuc 48894684ddb6SLionel Sambuctemplate<class _Tp> 48904684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48914684ddb6SLionel Sambucbool 48924684ddb6SLionel Sambucoperator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 48934684ddb6SLionel Sambuc{ 48944684ddb6SLionel Sambuc return !__x; 48954684ddb6SLionel Sambuc} 48964684ddb6SLionel Sambuc 48974684ddb6SLionel Sambuctemplate<class _Tp> 48984684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 48994684ddb6SLionel Sambucbool 49004684ddb6SLionel Sambucoperator!=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 49014684ddb6SLionel Sambuc{ 49024684ddb6SLionel Sambuc return static_cast<bool>(__x); 49034684ddb6SLionel Sambuc} 49044684ddb6SLionel Sambuc 49054684ddb6SLionel Sambuctemplate<class _Tp> 49064684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49074684ddb6SLionel Sambucbool 49084684ddb6SLionel Sambucoperator!=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 49094684ddb6SLionel Sambuc{ 49104684ddb6SLionel Sambuc return static_cast<bool>(__x); 49114684ddb6SLionel Sambuc} 49124684ddb6SLionel Sambuc 49134684ddb6SLionel Sambuctemplate<class _Tp> 49144684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49154684ddb6SLionel Sambucbool 49164684ddb6SLionel Sambucoperator<(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 49174684ddb6SLionel Sambuc{ 49184684ddb6SLionel Sambuc return less<_Tp*>()(__x.get(), nullptr); 49194684ddb6SLionel Sambuc} 49204684ddb6SLionel Sambuc 49214684ddb6SLionel Sambuctemplate<class _Tp> 49224684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49234684ddb6SLionel Sambucbool 49244684ddb6SLionel Sambucoperator<(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 49254684ddb6SLionel Sambuc{ 49264684ddb6SLionel Sambuc return less<_Tp*>()(nullptr, __x.get()); 49274684ddb6SLionel Sambuc} 49284684ddb6SLionel Sambuc 49294684ddb6SLionel Sambuctemplate<class _Tp> 49304684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49314684ddb6SLionel Sambucbool 49324684ddb6SLionel Sambucoperator>(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 49334684ddb6SLionel Sambuc{ 49344684ddb6SLionel Sambuc return nullptr < __x; 49354684ddb6SLionel Sambuc} 49364684ddb6SLionel Sambuc 49374684ddb6SLionel Sambuctemplate<class _Tp> 49384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49394684ddb6SLionel Sambucbool 49404684ddb6SLionel Sambucoperator>(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 49414684ddb6SLionel Sambuc{ 49424684ddb6SLionel Sambuc return __x < nullptr; 49434684ddb6SLionel Sambuc} 49444684ddb6SLionel Sambuc 49454684ddb6SLionel Sambuctemplate<class _Tp> 49464684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49474684ddb6SLionel Sambucbool 49484684ddb6SLionel Sambucoperator<=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 49494684ddb6SLionel Sambuc{ 49504684ddb6SLionel Sambuc return !(nullptr < __x); 49514684ddb6SLionel Sambuc} 49524684ddb6SLionel Sambuc 49534684ddb6SLionel Sambuctemplate<class _Tp> 49544684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49554684ddb6SLionel Sambucbool 49564684ddb6SLionel Sambucoperator<=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 49574684ddb6SLionel Sambuc{ 49584684ddb6SLionel Sambuc return !(__x < nullptr); 49594684ddb6SLionel Sambuc} 49604684ddb6SLionel Sambuc 49614684ddb6SLionel Sambuctemplate<class _Tp> 49624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49634684ddb6SLionel Sambucbool 49644684ddb6SLionel Sambucoperator>=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT 49654684ddb6SLionel Sambuc{ 49664684ddb6SLionel Sambuc return !(__x < nullptr); 49674684ddb6SLionel Sambuc} 49684684ddb6SLionel Sambuc 49694684ddb6SLionel Sambuctemplate<class _Tp> 49704684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49714684ddb6SLionel Sambucbool 49724684ddb6SLionel Sambucoperator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT 49734684ddb6SLionel Sambuc{ 49744684ddb6SLionel Sambuc return !(nullptr < __x); 49754684ddb6SLionel Sambuc} 49764684ddb6SLionel Sambuc 49774684ddb6SLionel Sambuctemplate<class _Tp> 49784684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49794684ddb6SLionel Sambucvoid 49804684ddb6SLionel Sambucswap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT 49814684ddb6SLionel Sambuc{ 49824684ddb6SLionel Sambuc __x.swap(__y); 49834684ddb6SLionel Sambuc} 49844684ddb6SLionel Sambuc 49854684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 49864684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49874684ddb6SLionel Sambuctypename enable_if 49884684ddb6SLionel Sambuc< 49894684ddb6SLionel Sambuc !is_array<_Tp>::value && !is_array<_Up>::value, 49904684ddb6SLionel Sambuc shared_ptr<_Tp> 49914684ddb6SLionel Sambuc>::type 49924684ddb6SLionel Sambucstatic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 49934684ddb6SLionel Sambuc{ 49944684ddb6SLionel Sambuc return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); 49954684ddb6SLionel Sambuc} 49964684ddb6SLionel Sambuc 49974684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 49984684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 49994684ddb6SLionel Sambuctypename enable_if 50004684ddb6SLionel Sambuc< 50014684ddb6SLionel Sambuc !is_array<_Tp>::value && !is_array<_Up>::value, 50024684ddb6SLionel Sambuc shared_ptr<_Tp> 50034684ddb6SLionel Sambuc>::type 50044684ddb6SLionel Sambucdynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 50054684ddb6SLionel Sambuc{ 50064684ddb6SLionel Sambuc _Tp* __p = dynamic_cast<_Tp*>(__r.get()); 50074684ddb6SLionel Sambuc return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); 50084684ddb6SLionel Sambuc} 50094684ddb6SLionel Sambuc 50104684ddb6SLionel Sambuctemplate<class _Tp, class _Up> 50114684ddb6SLionel Sambuctypename enable_if 50124684ddb6SLionel Sambuc< 50134684ddb6SLionel Sambuc is_array<_Tp>::value == is_array<_Up>::value, 50144684ddb6SLionel Sambuc shared_ptr<_Tp> 50154684ddb6SLionel Sambuc>::type 50164684ddb6SLionel Sambucconst_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT 50174684ddb6SLionel Sambuc{ 50184684ddb6SLionel Sambuc typedef typename remove_extent<_Tp>::type _RTp; 50194684ddb6SLionel Sambuc return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); 50204684ddb6SLionel Sambuc} 50214684ddb6SLionel Sambuc 50224684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_RTTI 50234684ddb6SLionel Sambuc 50244684ddb6SLionel Sambuctemplate<class _Dp, class _Tp> 50254684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 50264684ddb6SLionel Sambuc_Dp* 50274684ddb6SLionel Sambucget_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT 50284684ddb6SLionel Sambuc{ 50294684ddb6SLionel Sambuc return __p.template __get_deleter<_Dp>(); 50304684ddb6SLionel Sambuc} 50314684ddb6SLionel Sambuc 50324684ddb6SLionel Sambuc#endif // _LIBCPP_NO_RTTI 50334684ddb6SLionel Sambuc 50344684ddb6SLionel Sambuctemplate<class _Tp> 50354684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY weak_ptr 50364684ddb6SLionel Sambuc{ 50374684ddb6SLionel Sambucpublic: 50384684ddb6SLionel Sambuc typedef _Tp element_type; 50394684ddb6SLionel Sambucprivate: 50404684ddb6SLionel Sambuc element_type* __ptr_; 50414684ddb6SLionel Sambuc __shared_weak_count* __cntrl_; 50424684ddb6SLionel Sambuc 50434684ddb6SLionel Sambucpublic: 50444684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; 50454684ddb6SLionel Sambuc template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r, 50464684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 50474684ddb6SLionel Sambuc _NOEXCEPT; 50484684ddb6SLionel Sambuc weak_ptr(weak_ptr const& __r) _NOEXCEPT; 50494684ddb6SLionel Sambuc template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r, 50504684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 50514684ddb6SLionel Sambuc _NOEXCEPT; 50524684ddb6SLionel Sambuc 50534684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 50544684ddb6SLionel Sambuc weak_ptr(weak_ptr&& __r) _NOEXCEPT; 50554684ddb6SLionel Sambuc template<class _Yp> weak_ptr(weak_ptr<_Yp>&& __r, 50564684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) 50574684ddb6SLionel Sambuc _NOEXCEPT; 50584684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 50594684ddb6SLionel Sambuc ~weak_ptr(); 50604684ddb6SLionel Sambuc 50614684ddb6SLionel Sambuc weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; 50624684ddb6SLionel Sambuc template<class _Yp> 50634684ddb6SLionel Sambuc typename enable_if 50644684ddb6SLionel Sambuc < 50654684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 50664684ddb6SLionel Sambuc weak_ptr& 50674684ddb6SLionel Sambuc >::type 50684684ddb6SLionel Sambuc operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; 50694684ddb6SLionel Sambuc 50704684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 50714684ddb6SLionel Sambuc 50724684ddb6SLionel Sambuc weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT; 50734684ddb6SLionel Sambuc template<class _Yp> 50744684ddb6SLionel Sambuc typename enable_if 50754684ddb6SLionel Sambuc < 50764684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 50774684ddb6SLionel Sambuc weak_ptr& 50784684ddb6SLionel Sambuc >::type 50794684ddb6SLionel Sambuc operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT; 50804684ddb6SLionel Sambuc 50814684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 50824684ddb6SLionel Sambuc 50834684ddb6SLionel Sambuc template<class _Yp> 50844684ddb6SLionel Sambuc typename enable_if 50854684ddb6SLionel Sambuc < 50864684ddb6SLionel Sambuc is_convertible<_Yp*, element_type*>::value, 50874684ddb6SLionel Sambuc weak_ptr& 50884684ddb6SLionel Sambuc >::type 50894684ddb6SLionel Sambuc operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; 50904684ddb6SLionel Sambuc 50914684ddb6SLionel Sambuc void swap(weak_ptr& __r) _NOEXCEPT; 50924684ddb6SLionel Sambuc void reset() _NOEXCEPT; 50934684ddb6SLionel Sambuc 50944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 50954684ddb6SLionel Sambuc long use_count() const _NOEXCEPT 50964684ddb6SLionel Sambuc {return __cntrl_ ? __cntrl_->use_count() : 0;} 50974684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 50984684ddb6SLionel Sambuc bool expired() const _NOEXCEPT 50994684ddb6SLionel Sambuc {return __cntrl_ == 0 || __cntrl_->use_count() == 0;} 51004684ddb6SLionel Sambuc shared_ptr<_Tp> lock() const _NOEXCEPT; 51014684ddb6SLionel Sambuc template<class _Up> 51024684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 51034684ddb6SLionel Sambuc bool owner_before(const shared_ptr<_Up>& __r) const 51044684ddb6SLionel Sambuc {return __cntrl_ < __r.__cntrl_;} 51054684ddb6SLionel Sambuc template<class _Up> 51064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 51074684ddb6SLionel Sambuc bool owner_before(const weak_ptr<_Up>& __r) const 51084684ddb6SLionel Sambuc {return __cntrl_ < __r.__cntrl_;} 51094684ddb6SLionel Sambuc 51104684ddb6SLionel Sambuc template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; 51114684ddb6SLionel Sambuc template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; 51124684ddb6SLionel Sambuc}; 51134684ddb6SLionel Sambuc 51144684ddb6SLionel Sambuctemplate<class _Tp> 51154684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 51164684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 51174684ddb6SLionel Sambucweak_ptr<_Tp>::weak_ptr() _NOEXCEPT 51184684ddb6SLionel Sambuc : __ptr_(0), 51194684ddb6SLionel Sambuc __cntrl_(0) 51204684ddb6SLionel Sambuc{ 51214684ddb6SLionel Sambuc} 51224684ddb6SLionel Sambuc 51234684ddb6SLionel Sambuctemplate<class _Tp> 51244684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 51254684ddb6SLionel Sambucweak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT 51264684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 51274684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 51284684ddb6SLionel Sambuc{ 51294684ddb6SLionel Sambuc if (__cntrl_) 51304684ddb6SLionel Sambuc __cntrl_->__add_weak(); 51314684ddb6SLionel Sambuc} 51324684ddb6SLionel Sambuc 51334684ddb6SLionel Sambuctemplate<class _Tp> 51344684ddb6SLionel Sambuctemplate<class _Yp> 51354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 51364684ddb6SLionel Sambucweak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, 51374684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 51384684ddb6SLionel Sambuc _NOEXCEPT 51394684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 51404684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 51414684ddb6SLionel Sambuc{ 51424684ddb6SLionel Sambuc if (__cntrl_) 51434684ddb6SLionel Sambuc __cntrl_->__add_weak(); 51444684ddb6SLionel Sambuc} 51454684ddb6SLionel Sambuc 51464684ddb6SLionel Sambuctemplate<class _Tp> 51474684ddb6SLionel Sambuctemplate<class _Yp> 51484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 51494684ddb6SLionel Sambucweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, 51504684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 51514684ddb6SLionel Sambuc _NOEXCEPT 51524684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 51534684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 51544684ddb6SLionel Sambuc{ 51554684ddb6SLionel Sambuc if (__cntrl_) 51564684ddb6SLionel Sambuc __cntrl_->__add_weak(); 51574684ddb6SLionel Sambuc} 51584684ddb6SLionel Sambuc 51594684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 51604684ddb6SLionel Sambuc 51614684ddb6SLionel Sambuctemplate<class _Tp> 51624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 51634684ddb6SLionel Sambucweak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT 51644684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 51654684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 51664684ddb6SLionel Sambuc{ 51674684ddb6SLionel Sambuc __r.__ptr_ = 0; 51684684ddb6SLionel Sambuc __r.__cntrl_ = 0; 51694684ddb6SLionel Sambuc} 51704684ddb6SLionel Sambuc 51714684ddb6SLionel Sambuctemplate<class _Tp> 51724684ddb6SLionel Sambuctemplate<class _Yp> 51734684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 51744684ddb6SLionel Sambucweak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, 51754684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) 51764684ddb6SLionel Sambuc _NOEXCEPT 51774684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 51784684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_) 51794684ddb6SLionel Sambuc{ 51804684ddb6SLionel Sambuc __r.__ptr_ = 0; 51814684ddb6SLionel Sambuc __r.__cntrl_ = 0; 51824684ddb6SLionel Sambuc} 51834684ddb6SLionel Sambuc 51844684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 51854684ddb6SLionel Sambuc 51864684ddb6SLionel Sambuctemplate<class _Tp> 51874684ddb6SLionel Sambucweak_ptr<_Tp>::~weak_ptr() 51884684ddb6SLionel Sambuc{ 51894684ddb6SLionel Sambuc if (__cntrl_) 51904684ddb6SLionel Sambuc __cntrl_->__release_weak(); 51914684ddb6SLionel Sambuc} 51924684ddb6SLionel Sambuc 51934684ddb6SLionel Sambuctemplate<class _Tp> 51944684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 51954684ddb6SLionel Sambucweak_ptr<_Tp>& 51964684ddb6SLionel Sambucweak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT 51974684ddb6SLionel Sambuc{ 51984684ddb6SLionel Sambuc weak_ptr(__r).swap(*this); 51994684ddb6SLionel Sambuc return *this; 52004684ddb6SLionel Sambuc} 52014684ddb6SLionel Sambuc 52024684ddb6SLionel Sambuctemplate<class _Tp> 52034684ddb6SLionel Sambuctemplate<class _Yp> 52044684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 52054684ddb6SLionel Sambuctypename enable_if 52064684ddb6SLionel Sambuc< 52074684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 52084684ddb6SLionel Sambuc weak_ptr<_Tp>& 52094684ddb6SLionel Sambuc>::type 52104684ddb6SLionel Sambucweak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT 52114684ddb6SLionel Sambuc{ 52124684ddb6SLionel Sambuc weak_ptr(__r).swap(*this); 52134684ddb6SLionel Sambuc return *this; 52144684ddb6SLionel Sambuc} 52154684ddb6SLionel Sambuc 52164684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 52174684ddb6SLionel Sambuc 52184684ddb6SLionel Sambuctemplate<class _Tp> 52194684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 52204684ddb6SLionel Sambucweak_ptr<_Tp>& 52214684ddb6SLionel Sambucweak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT 52224684ddb6SLionel Sambuc{ 52234684ddb6SLionel Sambuc weak_ptr(_VSTD::move(__r)).swap(*this); 52244684ddb6SLionel Sambuc return *this; 52254684ddb6SLionel Sambuc} 52264684ddb6SLionel Sambuc 52274684ddb6SLionel Sambuctemplate<class _Tp> 52284684ddb6SLionel Sambuctemplate<class _Yp> 52294684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 52304684ddb6SLionel Sambuctypename enable_if 52314684ddb6SLionel Sambuc< 52324684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 52334684ddb6SLionel Sambuc weak_ptr<_Tp>& 52344684ddb6SLionel Sambuc>::type 52354684ddb6SLionel Sambucweak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT 52364684ddb6SLionel Sambuc{ 52374684ddb6SLionel Sambuc weak_ptr(_VSTD::move(__r)).swap(*this); 52384684ddb6SLionel Sambuc return *this; 52394684ddb6SLionel Sambuc} 52404684ddb6SLionel Sambuc 52414684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 52424684ddb6SLionel Sambuc 52434684ddb6SLionel Sambuctemplate<class _Tp> 52444684ddb6SLionel Sambuctemplate<class _Yp> 52454684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 52464684ddb6SLionel Sambuctypename enable_if 52474684ddb6SLionel Sambuc< 52484684ddb6SLionel Sambuc is_convertible<_Yp*, _Tp*>::value, 52494684ddb6SLionel Sambuc weak_ptr<_Tp>& 52504684ddb6SLionel Sambuc>::type 52514684ddb6SLionel Sambucweak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT 52524684ddb6SLionel Sambuc{ 52534684ddb6SLionel Sambuc weak_ptr(__r).swap(*this); 52544684ddb6SLionel Sambuc return *this; 52554684ddb6SLionel Sambuc} 52564684ddb6SLionel Sambuc 52574684ddb6SLionel Sambuctemplate<class _Tp> 52584684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 52594684ddb6SLionel Sambucvoid 52604684ddb6SLionel Sambucweak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT 52614684ddb6SLionel Sambuc{ 52624684ddb6SLionel Sambuc _VSTD::swap(__ptr_, __r.__ptr_); 52634684ddb6SLionel Sambuc _VSTD::swap(__cntrl_, __r.__cntrl_); 52644684ddb6SLionel Sambuc} 52654684ddb6SLionel Sambuc 52664684ddb6SLionel Sambuctemplate<class _Tp> 52674684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 52684684ddb6SLionel Sambucvoid 52694684ddb6SLionel Sambucswap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT 52704684ddb6SLionel Sambuc{ 52714684ddb6SLionel Sambuc __x.swap(__y); 52724684ddb6SLionel Sambuc} 52734684ddb6SLionel Sambuc 52744684ddb6SLionel Sambuctemplate<class _Tp> 52754684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 52764684ddb6SLionel Sambucvoid 52774684ddb6SLionel Sambucweak_ptr<_Tp>::reset() _NOEXCEPT 52784684ddb6SLionel Sambuc{ 52794684ddb6SLionel Sambuc weak_ptr().swap(*this); 52804684ddb6SLionel Sambuc} 52814684ddb6SLionel Sambuc 52824684ddb6SLionel Sambuctemplate<class _Tp> 52834684ddb6SLionel Sambuctemplate<class _Yp> 52844684ddb6SLionel Sambucshared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, 52854684ddb6SLionel Sambuc typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) 52864684ddb6SLionel Sambuc : __ptr_(__r.__ptr_), 52874684ddb6SLionel Sambuc __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) 52884684ddb6SLionel Sambuc{ 52894684ddb6SLionel Sambuc if (__cntrl_ == 0) 52904684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 52914684ddb6SLionel Sambuc throw bad_weak_ptr(); 52924684ddb6SLionel Sambuc#else 52934684ddb6SLionel Sambuc assert(!"bad_weak_ptr"); 52944684ddb6SLionel Sambuc#endif 52954684ddb6SLionel Sambuc} 52964684ddb6SLionel Sambuc 52974684ddb6SLionel Sambuctemplate<class _Tp> 52984684ddb6SLionel Sambucshared_ptr<_Tp> 52994684ddb6SLionel Sambucweak_ptr<_Tp>::lock() const _NOEXCEPT 53004684ddb6SLionel Sambuc{ 53014684ddb6SLionel Sambuc shared_ptr<_Tp> __r; 53024684ddb6SLionel Sambuc __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_; 53034684ddb6SLionel Sambuc if (__r.__cntrl_) 53044684ddb6SLionel Sambuc __r.__ptr_ = __ptr_; 53054684ddb6SLionel Sambuc return __r; 53064684ddb6SLionel Sambuc} 53074684ddb6SLionel Sambuc 53084684ddb6SLionel Sambuctemplate <class _Tp> struct owner_less; 53094684ddb6SLionel Sambuc 53104684ddb6SLionel Sambuctemplate <class _Tp> 53114684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> > 53124684ddb6SLionel Sambuc : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> 53134684ddb6SLionel Sambuc{ 53144684ddb6SLionel Sambuc typedef bool result_type; 53154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53164684ddb6SLionel Sambuc bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 53174684ddb6SLionel Sambuc {return __x.owner_before(__y);} 53184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53194684ddb6SLionel Sambuc bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 53204684ddb6SLionel Sambuc {return __x.owner_before(__y);} 53214684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53224684ddb6SLionel Sambuc bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 53234684ddb6SLionel Sambuc {return __x.owner_before(__y);} 53244684ddb6SLionel Sambuc}; 53254684ddb6SLionel Sambuc 53264684ddb6SLionel Sambuctemplate <class _Tp> 53274684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> > 53284684ddb6SLionel Sambuc : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> 53294684ddb6SLionel Sambuc{ 53304684ddb6SLionel Sambuc typedef bool result_type; 53314684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53324684ddb6SLionel Sambuc bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 53334684ddb6SLionel Sambuc {return __x.owner_before(__y);} 53344684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53354684ddb6SLionel Sambuc bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const 53364684ddb6SLionel Sambuc {return __x.owner_before(__y);} 53374684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53384684ddb6SLionel Sambuc bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const 53394684ddb6SLionel Sambuc {return __x.owner_before(__y);} 53404684ddb6SLionel Sambuc}; 53414684ddb6SLionel Sambuc 53424684ddb6SLionel Sambuctemplate<class _Tp> 53434684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this 53444684ddb6SLionel Sambuc{ 53454684ddb6SLionel Sambuc mutable weak_ptr<_Tp> __weak_this_; 53464684ddb6SLionel Sambucprotected: 53474684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 53484684ddb6SLionel Sambuc enable_shared_from_this() _NOEXCEPT {} 53494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53504684ddb6SLionel Sambuc enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {} 53514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53524684ddb6SLionel Sambuc enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT 53534684ddb6SLionel Sambuc {return *this;} 53544684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53554684ddb6SLionel Sambuc ~enable_shared_from_this() {} 53564684ddb6SLionel Sambucpublic: 53574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53584684ddb6SLionel Sambuc shared_ptr<_Tp> shared_from_this() 53594684ddb6SLionel Sambuc {return shared_ptr<_Tp>(__weak_this_);} 53604684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53614684ddb6SLionel Sambuc shared_ptr<_Tp const> shared_from_this() const 53624684ddb6SLionel Sambuc {return shared_ptr<const _Tp>(__weak_this_);} 53634684ddb6SLionel Sambuc 53644684ddb6SLionel Sambuc template <class _Up> friend class shared_ptr; 53654684ddb6SLionel Sambuc}; 53664684ddb6SLionel Sambuc 53674684ddb6SLionel Sambuctemplate <class _Tp> 53684684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<shared_ptr<_Tp> > 53694684ddb6SLionel Sambuc{ 53704684ddb6SLionel Sambuc typedef shared_ptr<_Tp> argument_type; 53714684ddb6SLionel Sambuc typedef size_t result_type; 53724684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 53734684ddb6SLionel Sambuc result_type operator()(const argument_type& __ptr) const _NOEXCEPT 53744684ddb6SLionel Sambuc { 53754684ddb6SLionel Sambuc return hash<_Tp*>()(__ptr.get()); 53764684ddb6SLionel Sambuc } 53774684ddb6SLionel Sambuc}; 53784684ddb6SLionel Sambuc 53794684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Yp> 53804684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 53814684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& 53824684ddb6SLionel Sambucoperator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); 53834684ddb6SLionel Sambuc 5384*0a6a1f1dSLionel Sambuc// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only 5385*0a6a1f1dSLionel Sambuc// enabled with clang. 5386*0a6a1f1dSLionel Sambuc#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) 53874684ddb6SLionel Sambuc 53884684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __sp_mut 53894684ddb6SLionel Sambuc{ 53904684ddb6SLionel Sambuc void* __lx; 53914684ddb6SLionel Sambucpublic: 53924684ddb6SLionel Sambuc void lock() _NOEXCEPT; 53934684ddb6SLionel Sambuc void unlock() _NOEXCEPT; 53944684ddb6SLionel Sambuc 53954684ddb6SLionel Sambucprivate: 53964684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR __sp_mut(void*) _NOEXCEPT; 53974684ddb6SLionel Sambuc __sp_mut(const __sp_mut&); 53984684ddb6SLionel Sambuc __sp_mut& operator=(const __sp_mut&); 53994684ddb6SLionel Sambuc 54004684ddb6SLionel Sambuc friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); 54014684ddb6SLionel Sambuc}; 54024684ddb6SLionel Sambuc 54034684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); 54044684ddb6SLionel Sambuc 54054684ddb6SLionel Sambuctemplate <class _Tp> 54064684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 54074684ddb6SLionel Sambucbool 54084684ddb6SLionel Sambucatomic_is_lock_free(const shared_ptr<_Tp>*) 54094684ddb6SLionel Sambuc{ 54104684ddb6SLionel Sambuc return false; 54114684ddb6SLionel Sambuc} 54124684ddb6SLionel Sambuc 54134684ddb6SLionel Sambuctemplate <class _Tp> 54144684ddb6SLionel Sambucshared_ptr<_Tp> 54154684ddb6SLionel Sambucatomic_load(const shared_ptr<_Tp>* __p) 54164684ddb6SLionel Sambuc{ 54174684ddb6SLionel Sambuc __sp_mut& __m = __get_sp_mut(__p); 54184684ddb6SLionel Sambuc __m.lock(); 54194684ddb6SLionel Sambuc shared_ptr<_Tp> __q = *__p; 54204684ddb6SLionel Sambuc __m.unlock(); 54214684ddb6SLionel Sambuc return __q; 54224684ddb6SLionel Sambuc} 54234684ddb6SLionel Sambuc 54244684ddb6SLionel Sambuctemplate <class _Tp> 54254684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 54264684ddb6SLionel Sambucshared_ptr<_Tp> 54274684ddb6SLionel Sambucatomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) 54284684ddb6SLionel Sambuc{ 54294684ddb6SLionel Sambuc return atomic_load(__p); 54304684ddb6SLionel Sambuc} 54314684ddb6SLionel Sambuc 54324684ddb6SLionel Sambuctemplate <class _Tp> 54334684ddb6SLionel Sambucvoid 54344684ddb6SLionel Sambucatomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) 54354684ddb6SLionel Sambuc{ 54364684ddb6SLionel Sambuc __sp_mut& __m = __get_sp_mut(__p); 54374684ddb6SLionel Sambuc __m.lock(); 54384684ddb6SLionel Sambuc __p->swap(__r); 54394684ddb6SLionel Sambuc __m.unlock(); 54404684ddb6SLionel Sambuc} 54414684ddb6SLionel Sambuc 54424684ddb6SLionel Sambuctemplate <class _Tp> 54434684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 54444684ddb6SLionel Sambucvoid 54454684ddb6SLionel Sambucatomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) 54464684ddb6SLionel Sambuc{ 54474684ddb6SLionel Sambuc atomic_store(__p, __r); 54484684ddb6SLionel Sambuc} 54494684ddb6SLionel Sambuc 54504684ddb6SLionel Sambuctemplate <class _Tp> 54514684ddb6SLionel Sambucshared_ptr<_Tp> 54524684ddb6SLionel Sambucatomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) 54534684ddb6SLionel Sambuc{ 54544684ddb6SLionel Sambuc __sp_mut& __m = __get_sp_mut(__p); 54554684ddb6SLionel Sambuc __m.lock(); 54564684ddb6SLionel Sambuc __p->swap(__r); 54574684ddb6SLionel Sambuc __m.unlock(); 54584684ddb6SLionel Sambuc return __r; 54594684ddb6SLionel Sambuc} 54604684ddb6SLionel Sambuc 54614684ddb6SLionel Sambuctemplate <class _Tp> 54624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 54634684ddb6SLionel Sambucshared_ptr<_Tp> 54644684ddb6SLionel Sambucatomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) 54654684ddb6SLionel Sambuc{ 54664684ddb6SLionel Sambuc return atomic_exchange(__p, __r); 54674684ddb6SLionel Sambuc} 54684684ddb6SLionel Sambuc 54694684ddb6SLionel Sambuctemplate <class _Tp> 54704684ddb6SLionel Sambucbool 54714684ddb6SLionel Sambucatomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) 54724684ddb6SLionel Sambuc{ 54734684ddb6SLionel Sambuc __sp_mut& __m = __get_sp_mut(__p); 54744684ddb6SLionel Sambuc __m.lock(); 54754684ddb6SLionel Sambuc if (__p->__owner_equivalent(*__v)) 54764684ddb6SLionel Sambuc { 54774684ddb6SLionel Sambuc *__p = __w; 54784684ddb6SLionel Sambuc __m.unlock(); 54794684ddb6SLionel Sambuc return true; 54804684ddb6SLionel Sambuc } 54814684ddb6SLionel Sambuc *__v = *__p; 54824684ddb6SLionel Sambuc __m.unlock(); 54834684ddb6SLionel Sambuc return false; 54844684ddb6SLionel Sambuc} 54854684ddb6SLionel Sambuc 54864684ddb6SLionel Sambuctemplate <class _Tp> 54874684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 54884684ddb6SLionel Sambucbool 54894684ddb6SLionel Sambucatomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) 54904684ddb6SLionel Sambuc{ 54914684ddb6SLionel Sambuc return atomic_compare_exchange_strong(__p, __v, __w); 54924684ddb6SLionel Sambuc} 54934684ddb6SLionel Sambuc 54944684ddb6SLionel Sambuctemplate <class _Tp> 54954684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 54964684ddb6SLionel Sambucbool 54974684ddb6SLionel Sambucatomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, 54984684ddb6SLionel Sambuc shared_ptr<_Tp> __w, memory_order, memory_order) 54994684ddb6SLionel Sambuc{ 55004684ddb6SLionel Sambuc return atomic_compare_exchange_strong(__p, __v, __w); 55014684ddb6SLionel Sambuc} 55024684ddb6SLionel Sambuc 55034684ddb6SLionel Sambuctemplate <class _Tp> 55044684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 55054684ddb6SLionel Sambucbool 55064684ddb6SLionel Sambucatomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, 55074684ddb6SLionel Sambuc shared_ptr<_Tp> __w, memory_order, memory_order) 55084684ddb6SLionel Sambuc{ 55094684ddb6SLionel Sambuc return atomic_compare_exchange_weak(__p, __v, __w); 55104684ddb6SLionel Sambuc} 55114684ddb6SLionel Sambuc 5512*0a6a1f1dSLionel Sambuc#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) 55134684ddb6SLionel Sambuc 55144684ddb6SLionel Sambuc//enum class 55154684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS pointer_safety 55164684ddb6SLionel Sambuc{ 55174684ddb6SLionel Sambuc enum __lx 55184684ddb6SLionel Sambuc { 55194684ddb6SLionel Sambuc relaxed, 55204684ddb6SLionel Sambuc preferred, 55214684ddb6SLionel Sambuc strict 55224684ddb6SLionel Sambuc }; 55234684ddb6SLionel Sambuc 55244684ddb6SLionel Sambuc __lx __v_; 55254684ddb6SLionel Sambuc 55264684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 55274684ddb6SLionel Sambuc pointer_safety(__lx __v) : __v_(__v) {} 55284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 55294684ddb6SLionel Sambuc operator int() const {return __v_;} 55304684ddb6SLionel Sambuc}; 55314684ddb6SLionel Sambuc 55324684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS void declare_reachable(void* __p); 55334684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n); 55344684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n); 55354684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT; 55364684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p); 55374684ddb6SLionel Sambuc 55384684ddb6SLionel Sambuctemplate <class _Tp> 55394684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 55404684ddb6SLionel Sambuc_Tp* 55414684ddb6SLionel Sambucundeclare_reachable(_Tp* __p) 55424684ddb6SLionel Sambuc{ 55434684ddb6SLionel Sambuc return static_cast<_Tp*>(__undeclare_reachable(__p)); 55444684ddb6SLionel Sambuc} 55454684ddb6SLionel Sambuc 55464684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); 55474684ddb6SLionel Sambuc 5548*0a6a1f1dSLionel Sambuc// --- Helper for container swap -- 5549*0a6a1f1dSLionel Sambuctemplate <typename _Alloc> 5550*0a6a1f1dSLionel Sambuc_LIBCPP_INLINE_VISIBILITY 5551*0a6a1f1dSLionel Sambucvoid __swap_allocator(_Alloc & __a1, _Alloc & __a2) 5552*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER >= 14 5553*0a6a1f1dSLionel Sambuc _NOEXCEPT 5554*0a6a1f1dSLionel Sambuc#else 5555*0a6a1f1dSLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) 5556*0a6a1f1dSLionel Sambuc#endif 5557*0a6a1f1dSLionel Sambuc{ 5558*0a6a1f1dSLionel Sambuc __swap_allocator(__a1, __a2, 5559*0a6a1f1dSLionel Sambuc integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>()); 5560*0a6a1f1dSLionel Sambuc} 5561*0a6a1f1dSLionel Sambuc 5562*0a6a1f1dSLionel Sambuctemplate <typename _Alloc> 5563*0a6a1f1dSLionel Sambuc_LIBCPP_INLINE_VISIBILITY 5564*0a6a1f1dSLionel Sambucvoid __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type) 5565*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER >= 14 5566*0a6a1f1dSLionel Sambuc _NOEXCEPT 5567*0a6a1f1dSLionel Sambuc#else 5568*0a6a1f1dSLionel Sambuc _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) 5569*0a6a1f1dSLionel Sambuc#endif 5570*0a6a1f1dSLionel Sambuc{ 5571*0a6a1f1dSLionel Sambuc using _VSTD::swap; 5572*0a6a1f1dSLionel Sambuc swap(__a1, __a2); 5573*0a6a1f1dSLionel Sambuc} 5574*0a6a1f1dSLionel Sambuc 5575*0a6a1f1dSLionel Sambuctemplate <typename _Alloc> 5576*0a6a1f1dSLionel Sambuc_LIBCPP_INLINE_VISIBILITY 5577*0a6a1f1dSLionel Sambucvoid __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} 5578*0a6a1f1dSLionel Sambuc 5579*0a6a1f1dSLionel Sambuctemplate <typename _Alloc, typename _Traits=allocator_traits<_Alloc> > 5580*0a6a1f1dSLionel Sambucstruct __noexcept_move_assign_container : public integral_constant<bool, 5581*0a6a1f1dSLionel Sambuc _Traits::propagate_on_container_move_assignment::value 5582*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 14 5583*0a6a1f1dSLionel Sambuc || _Traits::is_always_equal::value 5584*0a6a1f1dSLionel Sambuc#else 5585*0a6a1f1dSLionel Sambuc && is_nothrow_move_assignable<_Alloc>::value 5586*0a6a1f1dSLionel Sambuc#endif 5587*0a6a1f1dSLionel Sambuc > {}; 5588*0a6a1f1dSLionel Sambuc 55894684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD 55904684ddb6SLionel Sambuc 55914684ddb6SLionel Sambuc#endif // _LIBCPP_MEMORY 5592