| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- | 
 | 2 | //===-------------------------- memory ------------------------------------===// | 
 | 3 | // | 
| Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | //                     The LLVM Compiler Infrastructure | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // | 
| Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open | 
 | 7 | // Source Licenses. See LICENSE.TXT for details. | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // | 
 | 9 | //===----------------------------------------------------------------------===// | 
 | 10 |  | 
 | 11 | #ifndef _LIBCPP_MEMORY | 
 | 12 | #define _LIBCPP_MEMORY | 
 | 13 |  | 
 | 14 | /* | 
 | 15 |     memory synopsis | 
 | 16 |  | 
 | 17 | namespace std | 
 | 18 | { | 
 | 19 |  | 
 | 20 | struct allocator_arg_t { }; | 
 | 21 | constexpr allocator_arg_t allocator_arg = allocator_arg_t(); | 
 | 22 |  | 
 | 23 | template <class T, class Alloc> struct uses_allocator; | 
 | 24 |  | 
 | 25 | template <class Ptr> | 
 | 26 | struct pointer_traits | 
 | 27 | { | 
 | 28 |     typedef Ptr pointer; | 
 | 29 |     typedef <details> element_type; | 
 | 30 |     typedef <details> difference_type; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 31 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 32 |     template <class U> using rebind = <details>; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 33 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 34 |     static pointer pointer_to(<details>); | 
 | 35 | }; | 
 | 36 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 37 | template <class T> | 
 | 38 | struct pointer_traits<T*> | 
 | 39 | { | 
 | 40 |     typedef T* pointer; | 
 | 41 |     typedef T element_type; | 
 | 42 |     typedef ptrdiff_t difference_type; | 
 | 43 |  | 
 | 44 |     template <class U> using rebind = U*; | 
 | 45 |  | 
 | 46 |     static pointer pointer_to(<details>) noexcept; | 
 | 47 | }; | 
 | 48 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 49 | template <class Alloc> | 
 | 50 | struct allocator_traits | 
 | 51 | { | 
 | 52 |     typedef Alloc                        allocator_type; | 
 | 53 |     typedef typename allocator_type::value_type | 
 | 54 |                                          value_type; | 
 | 55 |  | 
 | 56 |     typedef Alloc::pointer | value_type* pointer; | 
 | 57 |     typedef Alloc::const_pointer | 
 | 58 |           | pointer_traits<pointer>::rebind<const value_type> | 
 | 59 |                                          const_pointer; | 
 | 60 |     typedef Alloc::void_pointer | 
 | 61 |           | pointer_traits<pointer>::rebind<void> | 
 | 62 |                                          void_pointer; | 
 | 63 |     typedef Alloc::const_void_pointer | 
 | 64 |           | pointer_traits<pointer>::rebind<const void> | 
 | 65 |                                          const_void_pointer; | 
 | 66 |     typedef Alloc::difference_type | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame] | 67 |           | pointer_traits<pointer>::difference_type | 
 | 68 |                                          difference_type; | 
 | 69 |     typedef Alloc::size_type | 
 | 70 |           | make_unsigned<difference_type>::type | 
 | 71 |                                          size_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 72 |     typedef Alloc::propagate_on_container_copy_assignment | 
 | 73 |           | false_type                   propagate_on_container_copy_assignment; | 
 | 74 |     typedef Alloc::propagate_on_container_move_assignment | 
 | 75 |           | false_type                   propagate_on_container_move_assignment; | 
 | 76 |     typedef Alloc::propagate_on_container_swap | 
 | 77 |           | false_type                   propagate_on_container_swap; | 
 | 78 |  | 
 | 79 |     template <class T> using rebind_alloc  = Alloc::rebind<U>::other | Alloc<T, Args...>; | 
 | 80 |     template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; | 
 | 81 |  | 
 | 82 |     static pointer allocate(allocator_type& a, size_type n); | 
 | 83 |     static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); | 
 | 84 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 85 |     static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 86 |  | 
 | 87 |     template <class T, class... Args> | 
 | 88 |         static void construct(allocator_type& a, T* p, Args&&... args); | 
 | 89 |  | 
 | 90 |     template <class T> | 
 | 91 |         static void destroy(allocator_type& a, T* p); | 
 | 92 |  | 
 | 93 |     static size_type max_size(const allocator_type& a); | 
 | 94 |  | 
 | 95 |     static allocator_type | 
 | 96 |         select_on_container_copy_construction(const allocator_type& a); | 
 | 97 | }; | 
 | 98 |  | 
 | 99 | template <> | 
 | 100 | class allocator<void> | 
 | 101 | { | 
 | 102 | public: | 
 | 103 |     typedef void*                                 pointer; | 
 | 104 |     typedef const void*                           const_pointer; | 
 | 105 |     typedef void                                  value_type; | 
 | 106 |  | 
 | 107 |     template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 
 | 108 | }; | 
 | 109 |  | 
 | 110 | template <class T> | 
 | 111 | class allocator | 
 | 112 | { | 
 | 113 | public: | 
 | 114 |     typedef size_t                                size_type; | 
 | 115 |     typedef ptrdiff_t                             difference_type; | 
 | 116 |     typedef T*                                    pointer; | 
 | 117 |     typedef const T*                              const_pointer; | 
 | 118 |     typedef typename add_lvalue_reference<T>::type       reference; | 
 | 119 |     typedef typename add_lvalue_reference<const T>::type const_reference; | 
 | 120 |     typedef T                                     value_type; | 
 | 121 |  | 
 | 122 |     template <class U> struct rebind {typedef allocator<U> other;}; | 
 | 123 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 124 |     allocator() noexcept; | 
 | 125 |     allocator(const allocator&) noexcept; | 
 | 126 |     template <class U> allocator(const allocator<U>&) noexcept; | 
 | 127 |     ~allocator(); | 
 | 128 |     pointer address(reference x) const noexcept; | 
 | 129 |     const_pointer address(const_reference x) const noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 130 |     pointer allocate(size_type, allocator<void>::const_pointer hint = 0); | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 131 |     void deallocate(pointer p, size_type n) noexcept; | 
 | 132 |     size_type max_size() const noexcept; | 
 | 133 |     template<class U, class... Args> | 
 | 134 |         void construct(U* p, Args&&... args); | 
 | 135 |     template <class U> | 
 | 136 |         void destroy(U* p); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 137 | }; | 
 | 138 |  | 
 | 139 | template <class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 140 | bool operator==(const allocator<T>&, const allocator<U>&) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 141 |  | 
 | 142 | template <class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 143 | bool operator!=(const allocator<T>&, const allocator<U>&) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 144 |  | 
 | 145 | template <class OutputIterator, class T> | 
 | 146 | class raw_storage_iterator | 
 | 147 |     : public iterator<output_iterator_tag, | 
 | 148 |                       T,                               // purposefully not C++03 | 
 | 149 |                       ptrdiff_t,                       // purposefully not C++03 | 
 | 150 |                       T*,                              // purposefully not C++03 | 
 | 151 |                       raw_storage_iterator&>           // purposefully not C++03 | 
 | 152 | { | 
 | 153 | public: | 
 | 154 |     explicit raw_storage_iterator(OutputIterator x); | 
 | 155 |     raw_storage_iterator& operator*(); | 
 | 156 |     raw_storage_iterator& operator=(const T& element); | 
 | 157 |     raw_storage_iterator& operator++(); | 
 | 158 |     raw_storage_iterator  operator++(int); | 
 | 159 | }; | 
 | 160 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 161 | template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; | 
 | 162 | template <class T> void               return_temporary_buffer(T* p) noexcept; | 
 | 163 |  | 
 | 164 | template <class T> T* addressof(T& r) noexcept; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 165 |  | 
 | 166 | template <class InputIterator, class ForwardIterator> | 
 | 167 | ForwardIterator | 
 | 168 | uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); | 
 | 169 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 170 | template <class InputIterator, class Size, class ForwardIterator> | 
 | 171 | ForwardIterator | 
 | 172 | uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); | 
 | 173 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 174 | template <class ForwardIterator, class T> | 
 | 175 | void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); | 
 | 176 |  | 
 | 177 | template <class ForwardIterator, class Size, class T> | 
| Howard Hinnant | 2f6a627 | 2010-11-18 16:13:03 +0000 | [diff] [blame] | 178 | ForwardIterator | 
 | 179 | uninitialized_fill_n(ForwardIterator first, Size n, const T& x); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 180 |  | 
 | 181 | template <class Y> struct auto_ptr_ref {}; | 
 | 182 |  | 
 | 183 | template<class X> | 
 | 184 | class auto_ptr | 
 | 185 | { | 
 | 186 | public: | 
 | 187 |     typedef X element_type; | 
 | 188 |  | 
 | 189 |     explicit auto_ptr(X* p =0) throw(); | 
 | 190 |     auto_ptr(auto_ptr&) throw(); | 
 | 191 |     template<class Y> auto_ptr(auto_ptr<Y>&) throw(); | 
 | 192 |     auto_ptr& operator=(auto_ptr&) throw(); | 
 | 193 |     template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw(); | 
 | 194 |     auto_ptr& operator=(auto_ptr_ref<X> r) throw(); | 
 | 195 |     ~auto_ptr() throw(); | 
 | 196 |  | 
 | 197 |     typename add_lvalue_reference<X>::type operator*() const throw(); | 
 | 198 |     X* operator->() const throw(); | 
 | 199 |     X* get() const throw(); | 
 | 200 |     X* release() throw(); | 
 | 201 |     void reset(X* p =0) throw(); | 
 | 202 |  | 
 | 203 |     auto_ptr(auto_ptr_ref<X>) throw(); | 
 | 204 |     template<class Y> operator auto_ptr_ref<Y>() throw(); | 
 | 205 |     template<class Y> operator auto_ptr<Y>() throw(); | 
 | 206 | }; | 
 | 207 |  | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 208 | template <class T> | 
 | 209 | struct default_delete | 
 | 210 | { | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 211 |     constexpr default_delete() noexcept = default; | 
 | 212 |     template <class U> default_delete(const default_delete<U>&) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 213 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 214 |     void operator()(T*) const noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 215 | }; | 
 | 216 |  | 
 | 217 | template <class T> | 
 | 218 | struct default_delete<T[]> | 
 | 219 | { | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 220 |     constexpr default_delete() noexcept = default; | 
 | 221 |     void operator()(T*) const noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 222 |     template <class U> void operator()(U*) const = delete; | 
 | 223 | }; | 
 | 224 |  | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 225 | template <class T, class D = default_delete<T>> | 
 | 226 | class unique_ptr | 
 | 227 | { | 
 | 228 | public: | 
 | 229 |     typedef see below pointer; | 
 | 230 |     typedef T element_type; | 
 | 231 |     typedef D deleter_type; | 
 | 232 |  | 
 | 233 |     // constructors | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 234 |     constexpr unique_ptr() noexcept; | 
 | 235 |     explicit unique_ptr(pointer p) noexcept; | 
 | 236 |     unique_ptr(pointer p, see below d1) noexcept; | 
 | 237 |     unique_ptr(pointer p, see below d2) noexcept; | 
 | 238 |     unique_ptr(unique_ptr&& u) noexcept; | 
 | 239 |     unique_ptr(nullptr_t) noexcept : unique_ptr() { } | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 240 |     template <class U, class E> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 241 |         unique_ptr(unique_ptr<U, E>&& u) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 242 |     template <class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 243 |         unique_ptr(auto_ptr<U>&& u) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 244 |  | 
 | 245 |     // destructor | 
 | 246 |     ~unique_ptr(); | 
 | 247 |  | 
 | 248 |     // assignment | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 249 |     unique_ptr& operator=(unique_ptr&& u) noexcept; | 
 | 250 |     template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept; | 
 | 251 |     unique_ptr& operator=(nullptr_t) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 252 |  | 
 | 253 |     // observers | 
 | 254 |     typename add_lvalue_reference<T>::type operator*() const; | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 255 |     pointer operator->() const noexcept; | 
 | 256 |     pointer get() const noexcept; | 
 | 257 |     deleter_type& get_deleter() noexcept; | 
 | 258 |     const deleter_type& get_deleter() const noexcept; | 
 | 259 |     explicit operator bool() const noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 260 |  | 
 | 261 |     // modifiers | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 262 |     pointer release() noexcept; | 
 | 263 |     void reset(pointer p = pointer()) noexcept; | 
 | 264 |     void swap(unique_ptr& u) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 265 | }; | 
 | 266 |  | 
 | 267 | template <class T, class D> | 
 | 268 | class unique_ptr<T[], D> | 
 | 269 | { | 
 | 270 | public: | 
 | 271 |     typedef implementation-defined pointer; | 
 | 272 |     typedef T element_type; | 
 | 273 |     typedef D deleter_type; | 
 | 274 |  | 
 | 275 |     // constructors | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 276 |     constexpr unique_ptr() noexcept; | 
 | 277 |     explicit unique_ptr(pointer p) noexcept; | 
 | 278 |     unique_ptr(pointer p, see below d) noexcept; | 
 | 279 |     unique_ptr(pointer p, see below d) noexcept; | 
 | 280 |     unique_ptr(unique_ptr&& u) noexcept; | 
 | 281 |     unique_ptr(nullptr_t) noexcept : unique_ptr() { } | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 282 |  | 
 | 283 |     // destructor | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 284 |     ~unique_ptr(); | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 285 |  | 
 | 286 |     // assignment | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 287 |     unique_ptr& operator=(unique_ptr&& u) noexcept; | 
 | 288 |     unique_ptr& operator=(nullptr_t) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 289 |  | 
 | 290 |     // observers | 
 | 291 |     T& operator[](size_t i) const; | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 292 |     pointer get() const noexcept; | 
 | 293 |     deleter_type& get_deleter() noexcept; | 
 | 294 |     const deleter_type& get_deleter() const noexcept; | 
 | 295 |     explicit operator bool() const noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 296 |  | 
 | 297 |     // modifiers | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 298 |     pointer release() noexcept; | 
 | 299 |     void reset(pointer p = pointer()) noexcept; | 
 | 300 |     void reset(nullptr_t) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 301 |     template <class U> void reset(U) = delete; | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 302 |     void swap(unique_ptr& u) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 303 | }; | 
 | 304 |  | 
 | 305 | template <class T, class D> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 306 |     void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 307 |  | 
 | 308 | template <class T1, class D1, class T2, class D2> | 
 | 309 |     bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 310 | template <class T1, class D1, class T2, class D2> | 
 | 311 |     bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 312 | template <class T1, class D1, class T2, class D2> | 
 | 313 |     bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 314 | template <class T1, class D1, class T2, class D2> | 
 | 315 |     bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 316 | template <class T1, class D1, class T2, class D2> | 
 | 317 |     bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 318 | template <class T1, class D1, class T2, class D2> | 
 | 319 |     bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); | 
 | 320 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 321 | template <class T, class D> | 
 | 322 |     bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; | 
 | 323 | template <class T, class D> | 
 | 324 |     bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; | 
 | 325 | template <class T, class D> | 
 | 326 |     bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; | 
 | 327 | template <class T, class D> | 
 | 328 |     bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; | 
 | 329 |  | 
 | 330 | template <class T, class D> | 
 | 331 |     bool operator<(const unique_ptr<T, D>& x, nullptr_t); | 
 | 332 | template <class T, class D> | 
 | 333 |     bool operator<(nullptr_t, const unique_ptr<T, D>& y); | 
 | 334 | template <class T, class D> | 
 | 335 |     bool operator<=(const unique_ptr<T, D>& x, nullptr_t); | 
 | 336 | template <class T, class D> | 
 | 337 |     bool operator<=(nullptr_t, const unique_ptr<T, D>& y); | 
 | 338 | template <class T, class D> | 
 | 339 |     bool operator>(const unique_ptr<T, D>& x, nullptr_t); | 
 | 340 | template <class T, class D> | 
 | 341 |     bool operator>(nullptr_t, const unique_ptr<T, D>& y); | 
 | 342 | template <class T, class D> | 
 | 343 |     bool operator>=(const unique_ptr<T, D>& x, nullptr_t); | 
 | 344 | template <class T, class D> | 
 | 345 |     bool operator>=(nullptr_t, const unique_ptr<T, D>& y); | 
 | 346 |  | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 347 | class bad_weak_ptr | 
 | 348 |     : public std::exception | 
 | 349 | { | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 350 |     bad_weak_ptr() noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 351 | }; | 
 | 352 |  | 
 | 353 | template<class T> | 
 | 354 | class shared_ptr | 
 | 355 | { | 
 | 356 | public: | 
 | 357 |     typedef T element_type; | 
 | 358 |  | 
 | 359 |     // constructors: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 360 |     constexpr shared_ptr() noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 361 |     template<class Y> explicit shared_ptr(Y* p); | 
 | 362 |     template<class Y, class D> shared_ptr(Y* p, D d); | 
 | 363 |     template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); | 
 | 364 |     template <class D> shared_ptr(nullptr_t p, D d); | 
 | 365 |     template <class D, class A> shared_ptr(nullptr_t p, D d, A a); | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 366 |     template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept; | 
 | 367 |     shared_ptr(const shared_ptr& r) noexcept; | 
 | 368 |     template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept; | 
 | 369 |     shared_ptr(shared_ptr&& r) noexcept; | 
 | 370 |     template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 371 |     template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); | 
 | 372 |     template<class Y> shared_ptr(auto_ptr<Y>&& r); | 
 | 373 |     template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r); | 
 | 374 |     shared_ptr(nullptr_t) : shared_ptr() { } | 
 | 375 |  | 
 | 376 |     // destructor: | 
 | 377 |     ~shared_ptr(); | 
 | 378 |  | 
 | 379 |     // assignment: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 380 |     shared_ptr& operator=(const shared_ptr& r) noexcept; | 
 | 381 |     template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept; | 
 | 382 |     shared_ptr& operator=(shared_ptr&& r) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 383 |     template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r); | 
 | 384 |     template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); | 
 | 385 |     template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); | 
 | 386 |  | 
 | 387 |     // modifiers: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 388 |     void swap(shared_ptr& r) noexcept; | 
 | 389 |     void reset() noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 390 |     template<class Y> void reset(Y* p); | 
 | 391 |     template<class Y, class D> void reset(Y* p, D d); | 
 | 392 |     template<class Y, class D, class A> void reset(Y* p, D d, A a); | 
 | 393 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 394 |     // observers: | 
 | 395 |     T* get() const noexcept; | 
 | 396 |     T& operator*() const noexcept; | 
 | 397 |     T* operator->() const noexcept; | 
 | 398 |     long use_count() const noexcept; | 
 | 399 |     bool unique() const noexcept; | 
 | 400 |     explicit operator bool() const noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 401 |     template<class U> bool owner_before(shared_ptr<U> const& b) const; | 
 | 402 |     template<class U> bool owner_before(weak_ptr<U> const& b) const; | 
 | 403 | }; | 
 | 404 |  | 
 | 405 | // shared_ptr comparisons: | 
 | 406 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 407 |     bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 408 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 409 |     bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 410 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 411 |     bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 412 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 413 |     bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 414 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 415 |     bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 416 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 417 |     bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; | 
 | 418 |  | 
 | 419 | template <class T> | 
 | 420 |     bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept; | 
 | 421 | template <class T> | 
 | 422 |     bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept; | 
 | 423 | template <class T> | 
 | 424 |     bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept; | 
 | 425 | template <class T> | 
 | 426 |     bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept; | 
 | 427 | template <class T> | 
 | 428 |     bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept; | 
 | 429 | template <class T> | 
 | 430 | bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept; | 
 | 431 | template <class T> | 
 | 432 |     bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept; | 
 | 433 | template <class T> | 
 | 434 |     bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept; | 
 | 435 | template <class T> | 
 | 436 |     bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept; | 
 | 437 | template <class T> | 
 | 438 |     bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept; | 
 | 439 | template <class T> | 
 | 440 |     bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept; | 
 | 441 | template <class T> | 
 | 442 |     bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 443 |  | 
 | 444 | // shared_ptr specialized algorithms: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 445 | template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 446 |  | 
 | 447 | // shared_ptr casts: | 
 | 448 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 449 |     shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 450 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 451 |     shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 452 | template<class T, class U> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 453 |     shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 454 |  | 
 | 455 | // shared_ptr I/O: | 
 | 456 | template<class E, class T, class Y> | 
 | 457 |     basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p); | 
 | 458 |  | 
 | 459 | // shared_ptr get_deleter: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 460 | template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 461 |  | 
 | 462 | template<class T, class... Args> | 
 | 463 |     shared_ptr<T> make_shared(Args&&... args); | 
 | 464 | template<class T, class A, class... Args> | 
 | 465 |     shared_ptr<T> allocate_shared(const A& a, Args&&... args); | 
 | 466 |  | 
 | 467 | template<class T> | 
 | 468 | class weak_ptr | 
 | 469 | { | 
 | 470 | public: | 
 | 471 |     typedef T element_type; | 
 | 472 |  | 
 | 473 |     // constructors | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 474 |     constexpr weak_ptr() noexcept; | 
 | 475 |     template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept; | 
 | 476 |     weak_ptr(weak_ptr const& r) noexcept; | 
 | 477 |     template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 478 |  | 
 | 479 |     // destructor | 
 | 480 |     ~weak_ptr(); | 
 | 481 |  | 
 | 482 |     // assignment | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 483 |     weak_ptr& operator=(weak_ptr const& r) noexcept; | 
 | 484 |     template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept; | 
 | 485 |     template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 486 |  | 
 | 487 |     // modifiers | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 488 |     void swap(weak_ptr& r) noexcept; | 
 | 489 |     void reset() noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 490 |  | 
 | 491 |     // observers | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 492 |     long use_count() const noexcept; | 
 | 493 |     bool expired() const noexcept; | 
 | 494 |     shared_ptr<T> lock() const noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 495 |     template<class U> bool owner_before(shared_ptr<U> const& b); | 
 | 496 |     template<class U> bool owner_before(weak_ptr<U> const& b); | 
 | 497 | }; | 
 | 498 |  | 
 | 499 | // weak_ptr specialized algorithms: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 500 | template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 501 |  | 
 | 502 | // class owner_less: | 
 | 503 | template<class T> struct owner_less; | 
 | 504 |  | 
 | 505 | template<class T> | 
 | 506 | struct owner_less<shared_ptr<T>> | 
 | 507 |     : binary_function<shared_ptr<T>, shared_ptr<T>, bool> | 
 | 508 | { | 
 | 509 |     typedef bool result_type; | 
 | 510 |     bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const; | 
 | 511 |     bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; | 
 | 512 |     bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; | 
 | 513 | }; | 
 | 514 |  | 
 | 515 | template<class T> | 
 | 516 | struct owner_less<weak_ptr<T>> | 
 | 517 |     : binary_function<weak_ptr<T>, weak_ptr<T>, bool> | 
 | 518 | { | 
 | 519 |     typedef bool result_type; | 
 | 520 |     bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; | 
 | 521 |     bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; | 
 | 522 |     bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; | 
 | 523 | }; | 
 | 524 |  | 
 | 525 | template<class T> | 
 | 526 | class enable_shared_from_this | 
 | 527 | { | 
 | 528 | protected: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 529 |     constexpr enable_shared_from_this() noexcept; | 
 | 530 |     enable_shared_from_this(enable_shared_from_this const&) noexcept; | 
 | 531 |     enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 532 |     ~enable_shared_from_this(); | 
 | 533 | public: | 
 | 534 |     shared_ptr<T> shared_from_this(); | 
 | 535 |     shared_ptr<T const> shared_from_this() const; | 
 | 536 | }; | 
 | 537 |  | 
 | 538 | template<class T> | 
 | 539 |     bool atomic_is_lock_free(const shared_ptr<T>* p); | 
 | 540 | template<class T> | 
 | 541 |     shared_ptr<T> atomic_load(const shared_ptr<T>* p); | 
 | 542 | template<class T> | 
 | 543 |     shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo); | 
 | 544 | template<class T> | 
 | 545 |     void atomic_store(shared_ptr<T>* p, shared_ptr<T> r); | 
 | 546 | template<class T> | 
 | 547 |     void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); | 
 | 548 | template<class T> | 
 | 549 |     shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r); | 
 | 550 | template<class T> | 
 | 551 |     shared_ptr<T> | 
 | 552 |     atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); | 
 | 553 | template<class T> | 
 | 554 |     bool | 
 | 555 |     atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); | 
 | 556 | template<class T> | 
 | 557 |     bool | 
 | 558 |     atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); | 
 | 559 | template<class T> | 
 | 560 |     bool | 
 | 561 |     atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, | 
 | 562 |                                           shared_ptr<T> w, memory_order success, | 
 | 563 |                                           memory_order failure); | 
 | 564 | template<class T> | 
 | 565 |     bool | 
 | 566 |     atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, | 
 | 567 |                                             shared_ptr<T> w, memory_order success, | 
 | 568 |                                             memory_order failure); | 
 | 569 | // Hash support | 
 | 570 | template <class T> struct hash; | 
 | 571 | template <class T, class D> struct hash<unique_ptr<T, D> >; | 
 | 572 | template <class T> struct hash<shared_ptr<T> >; | 
 | 573 |  | 
 | 574 | // Pointer safety | 
 | 575 | enum class pointer_safety { relaxed, preferred, strict }; | 
 | 576 | void declare_reachable(void *p); | 
 | 577 | template <class T> T *undeclare_reachable(T *p); | 
 | 578 | void declare_no_pointers(char *p, size_t n); | 
 | 579 | void undeclare_no_pointers(char *p, size_t n); | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 580 | pointer_safety get_pointer_safety() noexcept; | 
| Howard Hinnant | e92c3d7 | 2010-08-19 18:39:17 +0000 | [diff] [blame] | 581 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 582 | void* align(size_t alignment, size_t size, void*& ptr, size_t& space); | 
 | 583 |  | 
 | 584 | }  // std | 
 | 585 |  | 
 | 586 | */ | 
 | 587 |  | 
 | 588 | #include <__config> | 
 | 589 | #include <type_traits> | 
 | 590 | #include <typeinfo> | 
 | 591 | #include <cstddef> | 
 | 592 | #include <cstdint> | 
 | 593 | #include <new> | 
 | 594 | #include <utility> | 
 | 595 | #include <limits> | 
 | 596 | #include <iterator> | 
 | 597 | #include <__functional_base> | 
| Howard Hinnant | 464aa5c | 2011-07-18 15:51:59 +0000 | [diff] [blame] | 598 | #include <iosfwd> | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 599 | #include <tuple> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 600 | #if defined(_LIBCPP_NO_EXCEPTIONS) | 
 | 601 |     #include <cassert> | 
 | 602 | #endif | 
 | 603 |  | 
| Howard Hinnant | 66c6f97 | 2011-11-29 16:45:27 +0000 | [diff] [blame] | 604 | #include <__undef_min_max> | 
 | 605 |  | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 606 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 607 | #pragma GCC system_header | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 608 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 609 |  | 
 | 610 | _LIBCPP_BEGIN_NAMESPACE_STD | 
 | 611 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 612 | // addressof | 
 | 613 |  | 
 | 614 | template <class _Tp> | 
 | 615 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 616 | _Tp* | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 617 | addressof(_Tp& __x) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 618 | { | 
 | 619 |     return (_Tp*)&(char&)__x; | 
 | 620 | } | 
 | 621 |  | 
| Douglas Gregor | 35d2fcf | 2011-06-22 22:17:44 +0000 | [diff] [blame] | 622 | #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) | 
 | 623 | // Objective-C++ Automatic Reference Counting uses qualified pointers | 
 | 624 | // that require special addressof() signatures. When | 
 | 625 | // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler | 
 | 626 | // itself is providing these definitions. Otherwise, we provide them. | 
 | 627 | template <class _Tp> | 
 | 628 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 629 | __strong _Tp* | 
 | 630 | addressof(__strong _Tp& __x) _NOEXCEPT | 
 | 631 | { | 
 | 632 |   return &__x; | 
 | 633 | } | 
 | 634 |  | 
 | 635 | #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK | 
 | 636 | template <class _Tp> | 
 | 637 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 638 | __weak _Tp* | 
 | 639 | addressof(__weak _Tp& __x) _NOEXCEPT | 
 | 640 | { | 
 | 641 |   return &__x; | 
 | 642 | } | 
 | 643 | #endif | 
 | 644 |  | 
 | 645 | template <class _Tp> | 
 | 646 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 647 | __autoreleasing _Tp* | 
 | 648 | addressof(__autoreleasing _Tp& __x) _NOEXCEPT | 
 | 649 | { | 
 | 650 |   return &__x; | 
 | 651 | } | 
 | 652 |  | 
 | 653 | template <class _Tp> | 
 | 654 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 655 | __unsafe_unretained _Tp* | 
 | 656 | addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT | 
 | 657 | { | 
 | 658 |   return &__x; | 
 | 659 | } | 
 | 660 | #endif | 
 | 661 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 662 | template <class _Tp> class allocator; | 
 | 663 |  | 
 | 664 | template <> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 665 | class _LIBCPP_VISIBLE allocator<void> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 666 | { | 
 | 667 | public: | 
 | 668 |     typedef void*             pointer; | 
 | 669 |     typedef const void*       const_pointer; | 
 | 670 |     typedef void              value_type; | 
 | 671 |  | 
 | 672 |     template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 
 | 673 | }; | 
 | 674 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 675 | // pointer_traits | 
 | 676 |  | 
 | 677 | template <class _Tp> | 
 | 678 | struct __has_element_type | 
 | 679 | { | 
 | 680 | private: | 
 | 681 |     struct __two {char _; char __;}; | 
 | 682 |     template <class _Up> static __two __test(...); | 
 | 683 |     template <class _Up> static char __test(typename _Up::element_type* = 0); | 
 | 684 | public: | 
 | 685 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 686 | }; | 
 | 687 |  | 
 | 688 | template <class _Ptr, bool = __has_element_type<_Ptr>::value> | 
 | 689 | struct __pointer_traits_element_type; | 
 | 690 |  | 
 | 691 | template <class _Ptr> | 
 | 692 | struct __pointer_traits_element_type<_Ptr, true> | 
 | 693 | { | 
 | 694 |     typedef typename _Ptr::element_type type; | 
 | 695 | }; | 
 | 696 |  | 
 | 697 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 698 |  | 
 | 699 | template <template <class, class...> class _Sp, class _Tp, class ..._Args> | 
 | 700 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> | 
 | 701 | { | 
 | 702 |     typedef typename _Sp<_Tp, _Args...>::element_type type; | 
 | 703 | }; | 
 | 704 |  | 
 | 705 | template <template <class, class...> class _Sp, class _Tp, class ..._Args> | 
 | 706 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> | 
 | 707 | { | 
 | 708 |     typedef _Tp type; | 
 | 709 | }; | 
 | 710 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 711 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 712 |  | 
 | 713 | template <template <class> class _Sp, class _Tp> | 
 | 714 | struct __pointer_traits_element_type<_Sp<_Tp>, true> | 
 | 715 | { | 
 | 716 |     typedef typename _Sp<_Tp>::element_type type; | 
 | 717 | }; | 
 | 718 |  | 
 | 719 | template <template <class> class _Sp, class _Tp> | 
 | 720 | struct __pointer_traits_element_type<_Sp<_Tp>, false> | 
 | 721 | { | 
 | 722 |     typedef _Tp type; | 
 | 723 | }; | 
 | 724 |  | 
 | 725 | template <template <class, class> class _Sp, class _Tp, class _A0> | 
 | 726 | struct __pointer_traits_element_type<_Sp<_Tp, _A0>, true> | 
 | 727 | { | 
 | 728 |     typedef typename _Sp<_Tp, _A0>::element_type type; | 
 | 729 | }; | 
 | 730 |  | 
 | 731 | template <template <class, class> class _Sp, class _Tp, class _A0> | 
 | 732 | struct __pointer_traits_element_type<_Sp<_Tp, _A0>, false> | 
 | 733 | { | 
 | 734 |     typedef _Tp type; | 
 | 735 | }; | 
 | 736 |  | 
 | 737 | template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> | 
 | 738 | struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true> | 
 | 739 | { | 
 | 740 |     typedef typename _Sp<_Tp, _A0, _A1>::element_type type; | 
 | 741 | }; | 
 | 742 |  | 
 | 743 | template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1> | 
 | 744 | struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false> | 
 | 745 | { | 
 | 746 |     typedef _Tp type; | 
 | 747 | }; | 
 | 748 |  | 
 | 749 | template <template <class, class, class, class> class _Sp, class _Tp, class _A0, | 
 | 750 |                                                            class _A1, class _A2> | 
 | 751 | struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true> | 
 | 752 | { | 
 | 753 |     typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type; | 
 | 754 | }; | 
 | 755 |  | 
 | 756 | template <template <class, class, class, class> class _Sp, class _Tp, class _A0, | 
 | 757 |                                                            class _A1, class _A2> | 
 | 758 | struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false> | 
 | 759 | { | 
 | 760 |     typedef _Tp type; | 
 | 761 | }; | 
 | 762 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 763 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 764 |  | 
 | 765 | template <class _Tp> | 
 | 766 | struct __has_difference_type | 
 | 767 | { | 
 | 768 | private: | 
 | 769 |     struct __two {char _; char __;}; | 
 | 770 |     template <class _Up> static __two __test(...); | 
 | 771 |     template <class _Up> static char __test(typename _Up::difference_type* = 0); | 
 | 772 | public: | 
 | 773 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 774 | }; | 
 | 775 |  | 
 | 776 | template <class _Ptr, bool = __has_difference_type<_Ptr>::value> | 
 | 777 | struct __pointer_traits_difference_type | 
 | 778 | { | 
 | 779 |     typedef ptrdiff_t type; | 
 | 780 | }; | 
 | 781 |  | 
 | 782 | template <class _Ptr> | 
 | 783 | struct __pointer_traits_difference_type<_Ptr, true> | 
 | 784 | { | 
 | 785 |     typedef typename _Ptr::difference_type type; | 
 | 786 | }; | 
 | 787 |  | 
 | 788 | template <class _Tp, class _Up> | 
 | 789 | struct __has_rebind | 
 | 790 | { | 
 | 791 | private: | 
 | 792 |     struct __two {char _; char __;}; | 
 | 793 |     template <class _Xp> static __two __test(...); | 
 | 794 |     template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); | 
 | 795 | public: | 
 | 796 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 797 | }; | 
 | 798 |  | 
 | 799 | template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> | 
 | 800 | struct __pointer_traits_rebind | 
 | 801 | { | 
 | 802 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 803 |     typedef typename _Tp::template rebind<_Up> type; | 
 | 804 | #else | 
 | 805 |     typedef typename _Tp::template rebind<_Up>::other type; | 
 | 806 | #endif | 
 | 807 | }; | 
 | 808 |  | 
 | 809 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 810 |  | 
 | 811 | template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> | 
 | 812 | struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> | 
 | 813 | { | 
 | 814 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 815 |     typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; | 
 | 816 | #else | 
 | 817 |     typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; | 
 | 818 | #endif | 
 | 819 | }; | 
 | 820 |  | 
 | 821 | template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> | 
 | 822 | struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> | 
 | 823 | { | 
 | 824 |     typedef _Sp<_Up, _Args...> type; | 
 | 825 | }; | 
 | 826 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 827 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 828 |  | 
 | 829 | template <template <class> class _Sp, class _Tp, class _Up> | 
 | 830 | struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> | 
 | 831 | { | 
 | 832 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 833 |     typedef typename _Sp<_Tp>::template rebind<_Up> type; | 
 | 834 | #else | 
 | 835 |     typedef typename _Sp<_Tp>::template rebind<_Up>::other type; | 
 | 836 | #endif | 
 | 837 | }; | 
 | 838 |  | 
 | 839 | template <template <class> class _Sp, class _Tp, class _Up> | 
 | 840 | struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false> | 
 | 841 | { | 
 | 842 |     typedef _Sp<_Up> type; | 
 | 843 | }; | 
 | 844 |  | 
 | 845 | template <template <class, class> class _Sp, class _Tp, class _A0, class _Up> | 
 | 846 | struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> | 
 | 847 | { | 
 | 848 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 849 |     typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; | 
 | 850 | #else | 
 | 851 |     typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; | 
 | 852 | #endif | 
 | 853 | }; | 
 | 854 |  | 
 | 855 | template <template <class, class> class _Sp, class _Tp, class _A0, class _Up> | 
 | 856 | struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false> | 
 | 857 | { | 
 | 858 |     typedef _Sp<_Up, _A0> type; | 
 | 859 | }; | 
 | 860 |  | 
 | 861 | template <template <class, class, class> class _Sp, class _Tp, class _A0, | 
 | 862 |                                          class _A1, class _Up> | 
 | 863 | struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> | 
 | 864 | { | 
 | 865 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 866 |     typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; | 
 | 867 | #else | 
 | 868 |     typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; | 
 | 869 | #endif | 
 | 870 | }; | 
 | 871 |  | 
 | 872 | template <template <class, class, class> class _Sp, class _Tp, class _A0, | 
 | 873 |                                          class _A1, class _Up> | 
 | 874 | struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false> | 
 | 875 | { | 
 | 876 |     typedef _Sp<_Up, _A0, _A1> type; | 
 | 877 | }; | 
 | 878 |  | 
 | 879 | template <template <class, class, class, class> class _Sp, class _Tp, class _A0, | 
 | 880 |                                                 class _A1, class _A2, class _Up> | 
 | 881 | struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> | 
 | 882 | { | 
 | 883 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 884 |     typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; | 
 | 885 | #else | 
 | 886 |     typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; | 
 | 887 | #endif | 
 | 888 | }; | 
 | 889 |  | 
 | 890 | template <template <class, class, class, class> class _Sp, class _Tp, class _A0, | 
 | 891 |                                                 class _A1, class _A2, class _Up> | 
 | 892 | struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> | 
 | 893 | { | 
 | 894 |     typedef _Sp<_Up, _A0, _A1, _A2> type; | 
 | 895 | }; | 
 | 896 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 897 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 898 |  | 
 | 899 | template <class _Ptr> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 900 | struct _LIBCPP_VISIBLE pointer_traits | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 901 | { | 
 | 902 |     typedef _Ptr                                                     pointer; | 
 | 903 |     typedef typename __pointer_traits_element_type<pointer>::type    element_type; | 
 | 904 |     typedef typename __pointer_traits_difference_type<pointer>::type difference_type; | 
 | 905 |  | 
 | 906 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
| Howard Hinnant | 6b41c60 | 2011-05-11 20:21:19 +0000 | [diff] [blame] | 907 |     template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 908 | #else | 
 | 909 |     template <class _Up> struct rebind | 
 | 910 |         {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 911 | #endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 912 |  | 
 | 913 | private: | 
 | 914 |     struct __nat {}; | 
 | 915 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 916 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 917 |     static pointer pointer_to(typename conditional<is_void<element_type>::value, | 
 | 918 |                                            __nat, element_type>::type& __r) | 
 | 919 |         {return pointer::pointer_to(__r);} | 
 | 920 | }; | 
 | 921 |  | 
 | 922 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 923 | struct _LIBCPP_VISIBLE pointer_traits<_Tp*> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 924 | { | 
 | 925 |     typedef _Tp*      pointer; | 
 | 926 |     typedef _Tp       element_type; | 
 | 927 |     typedef ptrdiff_t difference_type; | 
 | 928 |  | 
 | 929 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 930 |     template <class _Up> using rebind = _Up*; | 
 | 931 | #else | 
 | 932 |     template <class _Up> struct rebind {typedef _Up* other;}; | 
 | 933 | #endif | 
 | 934 |  | 
 | 935 | private: | 
 | 936 |     struct __nat {}; | 
 | 937 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 938 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 939 |     static pointer pointer_to(typename conditional<is_void<element_type>::value, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 940 |                                       __nat, element_type>::type& __r) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 941 |         {return _VSTD::addressof(__r);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 942 | }; | 
 | 943 |  | 
 | 944 | // allocator_traits | 
 | 945 |  | 
 | 946 | namespace __has_pointer_type_imp | 
 | 947 | { | 
 | 948 |     template <class _Up> static __two test(...); | 
 | 949 |     template <class _Up> static char test(typename _Up::pointer* = 0); | 
 | 950 | } | 
 | 951 |  | 
 | 952 | template <class _Tp> | 
 | 953 | struct __has_pointer_type | 
 | 954 |     : public integral_constant<bool, sizeof(__has_pointer_type_imp::test<_Tp>(0)) == 1> | 
 | 955 | { | 
 | 956 | }; | 
 | 957 |  | 
 | 958 | namespace __pointer_type_imp | 
 | 959 | { | 
 | 960 |  | 
 | 961 | template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value> | 
 | 962 | struct __pointer_type | 
 | 963 | { | 
 | 964 |     typedef typename _Dp::pointer type; | 
 | 965 | }; | 
 | 966 |  | 
 | 967 | template <class _Tp, class _Dp> | 
 | 968 | struct __pointer_type<_Tp, _Dp, false> | 
 | 969 | { | 
 | 970 |     typedef _Tp* type; | 
 | 971 | }; | 
 | 972 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame] | 973 | }  // __pointer_type_imp | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 974 |  | 
 | 975 | template <class _Tp, class _Dp> | 
 | 976 | struct __pointer_type | 
 | 977 | { | 
 | 978 |     typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type; | 
 | 979 | }; | 
 | 980 |  | 
 | 981 | template <class _Tp> | 
 | 982 | struct __has_const_pointer | 
 | 983 | { | 
 | 984 | private: | 
 | 985 |     struct __two {char _; char __;}; | 
 | 986 |     template <class _Up> static __two __test(...); | 
 | 987 |     template <class _Up> static char __test(typename _Up::const_pointer* = 0); | 
 | 988 | public: | 
 | 989 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 990 | }; | 
 | 991 |  | 
 | 992 | template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value> | 
 | 993 | struct __const_pointer | 
 | 994 | { | 
 | 995 |     typedef typename _Alloc::const_pointer type; | 
 | 996 | }; | 
 | 997 |  | 
 | 998 | template <class _Tp, class _Ptr, class _Alloc> | 
 | 999 | struct __const_pointer<_Tp, _Ptr, _Alloc, false> | 
 | 1000 | { | 
 | 1001 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 1002 |     typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; | 
 | 1003 | #else | 
 | 1004 |     typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; | 
 | 1005 | #endif | 
 | 1006 | }; | 
 | 1007 |  | 
 | 1008 | template <class _Tp> | 
 | 1009 | struct __has_void_pointer | 
 | 1010 | { | 
 | 1011 | private: | 
 | 1012 |     struct __two {char _; char __;}; | 
 | 1013 |     template <class _Up> static __two __test(...); | 
 | 1014 |     template <class _Up> static char __test(typename _Up::void_pointer* = 0); | 
 | 1015 | public: | 
 | 1016 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1017 | }; | 
 | 1018 |  | 
 | 1019 | template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value> | 
 | 1020 | struct __void_pointer | 
 | 1021 | { | 
 | 1022 |     typedef typename _Alloc::void_pointer type; | 
 | 1023 | }; | 
 | 1024 |  | 
 | 1025 | template <class _Ptr, class _Alloc> | 
 | 1026 | struct __void_pointer<_Ptr, _Alloc, false> | 
 | 1027 | { | 
 | 1028 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 1029 |     typedef typename pointer_traits<_Ptr>::template rebind<void> type; | 
 | 1030 | #else | 
 | 1031 |     typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; | 
 | 1032 | #endif | 
 | 1033 | }; | 
 | 1034 |  | 
 | 1035 | template <class _Tp> | 
 | 1036 | struct __has_const_void_pointer | 
 | 1037 | { | 
 | 1038 | private: | 
 | 1039 |     struct __two {char _; char __;}; | 
 | 1040 |     template <class _Up> static __two __test(...); | 
 | 1041 |     template <class _Up> static char __test(typename _Up::const_void_pointer* = 0); | 
 | 1042 | public: | 
 | 1043 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1044 | }; | 
 | 1045 |  | 
 | 1046 | template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value> | 
 | 1047 | struct __const_void_pointer | 
 | 1048 | { | 
 | 1049 |     typedef typename _Alloc::const_void_pointer type; | 
 | 1050 | }; | 
 | 1051 |  | 
 | 1052 | template <class _Ptr, class _Alloc> | 
 | 1053 | struct __const_void_pointer<_Ptr, _Alloc, false> | 
 | 1054 | { | 
 | 1055 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 1056 |     typedef typename pointer_traits<_Ptr>::template rebind<const void> type; | 
 | 1057 | #else | 
 | 1058 |     typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; | 
 | 1059 | #endif | 
 | 1060 | }; | 
 | 1061 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1062 | template <class _Tp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1063 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1064 | _Tp* | 
 | 1065 | __to_raw_pointer(_Tp* __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1066 | { | 
 | 1067 |     return __p; | 
 | 1068 | } | 
 | 1069 |  | 
 | 1070 | template <class _Pointer> | 
 | 1071 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 1072 | typename pointer_traits<_Pointer>::element_type* | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1073 | __to_raw_pointer(_Pointer __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1074 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1075 |     return _VSTD::__to_raw_pointer(__p.operator->()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1076 | } | 
 | 1077 |  | 
 | 1078 | template <class _Tp> | 
 | 1079 | struct __has_size_type | 
 | 1080 | { | 
 | 1081 | private: | 
 | 1082 |     struct __two {char _; char __;}; | 
 | 1083 |     template <class _Up> static __two __test(...); | 
 | 1084 |     template <class _Up> static char __test(typename _Up::size_type* = 0); | 
 | 1085 | public: | 
 | 1086 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1087 | }; | 
 | 1088 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame] | 1089 | template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1090 | struct __size_type | 
 | 1091 | { | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame] | 1092 |     typedef typename make_unsigned<_DiffType>::type type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1093 | }; | 
 | 1094 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame] | 1095 | template <class _Alloc, class _DiffType> | 
 | 1096 | struct __size_type<_Alloc, _DiffType, true> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1097 | { | 
 | 1098 |     typedef typename _Alloc::size_type type; | 
 | 1099 | }; | 
 | 1100 |  | 
 | 1101 | template <class _Tp> | 
 | 1102 | struct __has_propagate_on_container_copy_assignment | 
 | 1103 | { | 
 | 1104 | private: | 
 | 1105 |     struct __two {char _; char __;}; | 
 | 1106 |     template <class _Up> static __two __test(...); | 
 | 1107 |     template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0); | 
 | 1108 | public: | 
 | 1109 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1110 | }; | 
 | 1111 |  | 
 | 1112 | template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value> | 
 | 1113 | struct __propagate_on_container_copy_assignment | 
 | 1114 | { | 
 | 1115 |     typedef false_type type; | 
 | 1116 | }; | 
 | 1117 |  | 
 | 1118 | template <class _Alloc> | 
 | 1119 | struct __propagate_on_container_copy_assignment<_Alloc, true> | 
 | 1120 | { | 
 | 1121 |     typedef typename _Alloc::propagate_on_container_copy_assignment type; | 
 | 1122 | }; | 
 | 1123 |  | 
 | 1124 | template <class _Tp> | 
 | 1125 | struct __has_propagate_on_container_move_assignment | 
 | 1126 | { | 
 | 1127 | private: | 
 | 1128 |     struct __two {char _; char __;}; | 
 | 1129 |     template <class _Up> static __two __test(...); | 
 | 1130 |     template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0); | 
 | 1131 | public: | 
 | 1132 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1133 | }; | 
 | 1134 |  | 
 | 1135 | template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value> | 
 | 1136 | struct __propagate_on_container_move_assignment | 
 | 1137 | { | 
 | 1138 |     typedef false_type type; | 
 | 1139 | }; | 
 | 1140 |  | 
 | 1141 | template <class _Alloc> | 
 | 1142 | struct __propagate_on_container_move_assignment<_Alloc, true> | 
 | 1143 | { | 
 | 1144 |     typedef typename _Alloc::propagate_on_container_move_assignment type; | 
 | 1145 | }; | 
 | 1146 |  | 
 | 1147 | template <class _Tp> | 
 | 1148 | struct __has_propagate_on_container_swap | 
 | 1149 | { | 
 | 1150 | private: | 
 | 1151 |     struct __two {char _; char __;}; | 
 | 1152 |     template <class _Up> static __two __test(...); | 
 | 1153 |     template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0); | 
 | 1154 | public: | 
 | 1155 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1156 | }; | 
 | 1157 |  | 
 | 1158 | template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> | 
 | 1159 | struct __propagate_on_container_swap | 
 | 1160 | { | 
 | 1161 |     typedef false_type type; | 
 | 1162 | }; | 
 | 1163 |  | 
 | 1164 | template <class _Alloc> | 
 | 1165 | struct __propagate_on_container_swap<_Alloc, true> | 
 | 1166 | { | 
 | 1167 |     typedef typename _Alloc::propagate_on_container_swap type; | 
 | 1168 | }; | 
 | 1169 |  | 
 | 1170 | template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> | 
 | 1171 | struct __has_rebind_other | 
 | 1172 | { | 
 | 1173 | private: | 
 | 1174 |     struct __two {char _; char __;}; | 
 | 1175 |     template <class _Xp> static __two __test(...); | 
 | 1176 |     template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0); | 
 | 1177 | public: | 
 | 1178 |     static const bool value = sizeof(__test<_Tp>(0)) == 1; | 
 | 1179 | }; | 
 | 1180 |  | 
 | 1181 | template <class _Tp, class _Up> | 
 | 1182 | struct __has_rebind_other<_Tp, _Up, false> | 
 | 1183 | { | 
 | 1184 |     static const bool value = false; | 
 | 1185 | }; | 
 | 1186 |  | 
 | 1187 | template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> | 
 | 1188 | struct __allocator_traits_rebind | 
 | 1189 | { | 
 | 1190 |     typedef typename _Tp::template rebind<_Up>::other type; | 
 | 1191 | }; | 
 | 1192 |  | 
 | 1193 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1194 |  | 
 | 1195 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> | 
 | 1196 | struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> | 
 | 1197 | { | 
 | 1198 |     typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type; | 
 | 1199 | }; | 
 | 1200 |  | 
 | 1201 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> | 
 | 1202 | struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> | 
 | 1203 | { | 
 | 1204 |     typedef _Alloc<_Up, _Args...> type; | 
 | 1205 | }; | 
 | 1206 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1207 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1208 |  | 
 | 1209 | template <template <class> class _Alloc, class _Tp, class _Up> | 
 | 1210 | struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true> | 
 | 1211 | { | 
 | 1212 |     typedef typename _Alloc<_Tp>::template rebind<_Up>::other type; | 
 | 1213 | }; | 
 | 1214 |  | 
 | 1215 | template <template <class> class _Alloc, class _Tp, class _Up> | 
 | 1216 | struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false> | 
 | 1217 | { | 
 | 1218 |     typedef _Alloc<_Up> type; | 
 | 1219 | }; | 
 | 1220 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1221 | template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> | 
 | 1222 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true> | 
 | 1223 | { | 
 | 1224 |     typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type; | 
 | 1225 | }; | 
 | 1226 |  | 
 | 1227 | template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up> | 
 | 1228 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false> | 
 | 1229 | { | 
 | 1230 |     typedef _Alloc<_Up, _A0> type; | 
 | 1231 | }; | 
 | 1232 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1233 | template <template <class, class, class> class _Alloc, class _Tp, class _A0, | 
 | 1234 |                                          class _A1, class _Up> | 
 | 1235 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true> | 
 | 1236 | { | 
 | 1237 |     typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type; | 
 | 1238 | }; | 
 | 1239 |  | 
 | 1240 | template <template <class, class, class> class _Alloc, class _Tp, class _A0, | 
 | 1241 |                                          class _A1, class _Up> | 
 | 1242 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false> | 
 | 1243 | { | 
 | 1244 |     typedef _Alloc<_Up, _A0, _A1> type; | 
 | 1245 | }; | 
 | 1246 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1247 | template <template <class, class, class, class> class _Alloc, class _Tp, class _A0, | 
 | 1248 |                                                 class _A1, class _A2, class _Up> | 
 | 1249 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true> | 
 | 1250 | { | 
 | 1251 |     typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; | 
 | 1252 | }; | 
 | 1253 |  | 
 | 1254 | template <template <class, class, class, class> class _Alloc, class _Tp, class _A0, | 
 | 1255 |                                                 class _A1, class _A2, class _Up> | 
 | 1256 | struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> | 
 | 1257 | { | 
 | 1258 |     typedef _Alloc<_Up, _A0, _A1, _A2> type; | 
 | 1259 | }; | 
 | 1260 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1261 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1262 |  | 
 | 1263 | #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
 | 1264 |  | 
 | 1265 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 
 | 1266 | auto | 
 | 1267 | __has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) | 
 | 1268 |     -> decltype(__a.allocate(__sz, __p), true_type()); | 
 | 1269 |  | 
 | 1270 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 
 | 1271 | auto | 
 | 1272 | __has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p) | 
 | 1273 |     -> false_type; | 
 | 1274 |  | 
 | 1275 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 
 | 1276 | struct __has_allocate_hint | 
 | 1277 |     : integral_constant<bool, | 
 | 1278 |         is_same< | 
 | 1279 |             decltype(__has_allocate_hint_test(declval<_Alloc>(), | 
 | 1280 |                                           declval<_SizeType>(), | 
 | 1281 |                                           declval<_ConstVoidPtr>())), | 
 | 1282 |             true_type>::value> | 
 | 1283 | { | 
 | 1284 | }; | 
 | 1285 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1286 | #else  // _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1287 |  | 
 | 1288 | template <class _Alloc, class _SizeType, class _ConstVoidPtr> | 
 | 1289 | struct __has_allocate_hint | 
 | 1290 |     : true_type | 
 | 1291 | { | 
 | 1292 | }; | 
 | 1293 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1294 | #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1295 |  | 
| Howard Hinnant | 23369ee | 2011-07-29 21:35:53 +0000 | [diff] [blame] | 1296 | #if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1297 |  | 
 | 1298 | template <class _Alloc, class _Tp, class ..._Args> | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1299 | decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), | 
 | 1300 |                                            _VSTD::declval<_Args>()...), | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1301 |                                            true_type()) | 
 | 1302 | __has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args); | 
 | 1303 |  | 
 | 1304 | template <class _Alloc, class _Pointer, class ..._Args> | 
 | 1305 | false_type | 
 | 1306 | __has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args); | 
 | 1307 |  | 
 | 1308 | template <class _Alloc, class _Pointer, class ..._Args> | 
 | 1309 | struct __has_construct | 
 | 1310 |     : integral_constant<bool, | 
 | 1311 |         is_same< | 
 | 1312 |             decltype(__has_construct_test(declval<_Alloc>(), | 
 | 1313 |                                           declval<_Pointer>(), | 
 | 1314 |                                           declval<_Args>()...)), | 
 | 1315 |             true_type>::value> | 
 | 1316 | { | 
 | 1317 | }; | 
 | 1318 |  | 
 | 1319 | template <class _Alloc, class _Pointer> | 
 | 1320 | auto | 
 | 1321 | __has_destroy_test(_Alloc&& __a, _Pointer&& __p) | 
 | 1322 |     -> decltype(__a.destroy(__p), true_type()); | 
 | 1323 |  | 
 | 1324 | template <class _Alloc, class _Pointer> | 
 | 1325 | auto | 
 | 1326 | __has_destroy_test(const _Alloc& __a, _Pointer&& __p) | 
 | 1327 |     -> false_type; | 
 | 1328 |  | 
 | 1329 | template <class _Alloc, class _Pointer> | 
 | 1330 | struct __has_destroy | 
 | 1331 |     : integral_constant<bool, | 
 | 1332 |         is_same< | 
 | 1333 |             decltype(__has_destroy_test(declval<_Alloc>(), | 
 | 1334 |                                         declval<_Pointer>())), | 
 | 1335 |             true_type>::value> | 
 | 1336 | { | 
 | 1337 | }; | 
 | 1338 |  | 
 | 1339 | template <class _Alloc> | 
 | 1340 | auto | 
 | 1341 | __has_max_size_test(_Alloc&& __a) | 
 | 1342 |     -> decltype(__a.max_size(), true_type()); | 
 | 1343 |  | 
 | 1344 | template <class _Alloc> | 
 | 1345 | auto | 
 | 1346 | __has_max_size_test(const volatile _Alloc& __a) | 
 | 1347 |     -> false_type; | 
 | 1348 |  | 
 | 1349 | template <class _Alloc> | 
 | 1350 | struct __has_max_size | 
 | 1351 |     : integral_constant<bool, | 
 | 1352 |         is_same< | 
 | 1353 |             decltype(__has_max_size_test(declval<_Alloc&>())), | 
 | 1354 |             true_type>::value> | 
 | 1355 | { | 
 | 1356 | }; | 
 | 1357 |  | 
 | 1358 | template <class _Alloc> | 
 | 1359 | auto | 
 | 1360 | __has_select_on_container_copy_construction_test(_Alloc&& __a) | 
 | 1361 |     -> decltype(__a.select_on_container_copy_construction(), true_type()); | 
 | 1362 |  | 
 | 1363 | template <class _Alloc> | 
 | 1364 | auto | 
 | 1365 | __has_select_on_container_copy_construction_test(const volatile _Alloc& __a) | 
 | 1366 |     -> false_type; | 
 | 1367 |  | 
 | 1368 | template <class _Alloc> | 
 | 1369 | struct __has_select_on_container_copy_construction | 
 | 1370 |     : integral_constant<bool, | 
 | 1371 |         is_same< | 
 | 1372 |             decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())), | 
 | 1373 |             true_type>::value> | 
 | 1374 | { | 
 | 1375 | }; | 
 | 1376 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1377 | #else  // _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1378 |  | 
 | 1379 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1380 |  | 
 | 1381 | template <class _Alloc, class _Pointer, class ..._Args> | 
 | 1382 | struct __has_construct | 
 | 1383 |     : false_type | 
 | 1384 | { | 
 | 1385 | }; | 
 | 1386 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1387 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1388 |  | 
 | 1389 | template <class _Alloc, class _Pointer> | 
 | 1390 | struct __has_destroy | 
 | 1391 |     : false_type | 
 | 1392 | { | 
 | 1393 | }; | 
 | 1394 |  | 
 | 1395 | template <class _Alloc> | 
 | 1396 | struct __has_max_size | 
 | 1397 |     : true_type | 
 | 1398 | { | 
 | 1399 | }; | 
 | 1400 |  | 
 | 1401 | template <class _Alloc> | 
 | 1402 | struct __has_select_on_container_copy_construction | 
 | 1403 |     : false_type | 
 | 1404 | { | 
 | 1405 | }; | 
 | 1406 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1407 | #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1408 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame] | 1409 | template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> | 
 | 1410 | struct __alloc_traits_difference_type | 
 | 1411 | { | 
 | 1412 |     typedef typename pointer_traits<_Ptr>::difference_type type; | 
 | 1413 | }; | 
 | 1414 |  | 
 | 1415 | template <class _Alloc, class _Ptr> | 
 | 1416 | struct __alloc_traits_difference_type<_Alloc, _Ptr, true> | 
 | 1417 | { | 
 | 1418 |     typedef typename _Alloc::difference_type type; | 
 | 1419 | }; | 
 | 1420 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1421 | template <class _Alloc> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1422 | struct _LIBCPP_VISIBLE allocator_traits | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1423 | { | 
 | 1424 |     typedef _Alloc                              allocator_type; | 
 | 1425 |     typedef typename allocator_type::value_type value_type; | 
 | 1426 |  | 
 | 1427 |     typedef typename __pointer_type<value_type, allocator_type>::type pointer; | 
 | 1428 |     typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer; | 
 | 1429 |     typedef typename __void_pointer<pointer, allocator_type>::type void_pointer; | 
 | 1430 |     typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer; | 
 | 1431 |  | 
| Howard Hinnant | 4776107 | 2010-11-18 01:40:00 +0000 | [diff] [blame] | 1432 |     typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type; | 
 | 1433 |     typedef typename __size_type<allocator_type, difference_type>::type size_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1434 |  | 
 | 1435 |     typedef typename __propagate_on_container_copy_assignment<allocator_type>::type | 
 | 1436 |                      propagate_on_container_copy_assignment; | 
 | 1437 |     typedef typename __propagate_on_container_move_assignment<allocator_type>::type | 
 | 1438 |                      propagate_on_container_move_assignment; | 
 | 1439 |     typedef typename __propagate_on_container_swap<allocator_type>::type | 
 | 1440 |                      propagate_on_container_swap; | 
 | 1441 |  | 
 | 1442 | #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
 | 1443 |     template <class _Tp> using rebind_alloc = | 
| Howard Hinnant | 6b41c60 | 2011-05-11 20:21:19 +0000 | [diff] [blame] | 1444 |                   typename __allocator_traits_rebind<allocator_type, _Tp>::type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1445 |     template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1446 | #else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1447 |     template <class _Tp> struct rebind_alloc | 
 | 1448 |         {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;}; | 
 | 1449 |     template <class _Tp> struct rebind_traits | 
 | 1450 |         {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;}; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1451 | #endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1452 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1453 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1454 |     static pointer allocate(allocator_type& __a, size_type __n) | 
 | 1455 |         {return __a.allocate(__n);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1456 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1457 |     static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) | 
 | 1458 |         {return allocate(__a, __n, __hint, | 
 | 1459 |             __has_allocate_hint<allocator_type, size_type, const_void_pointer>());} | 
 | 1460 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1461 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1462 |     static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1463 |         {__a.deallocate(__p, __n);} | 
 | 1464 |  | 
 | 1465 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1466 |     template <class _Tp, class... _Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1467 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1468 |         static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) | 
 | 1469 |             {__construct(__has_construct<allocator_type, pointer, _Args...>(), | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1470 |                          __a, __p, _VSTD::forward<_Args>(__args)...);} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1471 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1472 |     template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1473 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1474 |         static void construct(allocator_type& __a, _Tp* __p) | 
 | 1475 |             { | 
 | 1476 |                 ::new ((void*)__p) _Tp(); | 
 | 1477 |             } | 
 | 1478 |     template <class _Tp, class _A0> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1479 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1480 |         static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0) | 
 | 1481 |             { | 
 | 1482 |                 ::new ((void*)__p) _Tp(__a0); | 
 | 1483 |             } | 
 | 1484 |     template <class _Tp, class _A0, class _A1> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1485 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1486 |         static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, | 
 | 1487 |                               const _A1& __a1) | 
 | 1488 |             { | 
 | 1489 |                 ::new ((void*)__p) _Tp(__a0, __a1); | 
 | 1490 |             } | 
 | 1491 |     template <class _Tp, class _A0, class _A1, class _A2> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1492 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1493 |         static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0, | 
 | 1494 |                               const _A1& __a1, const _A2& __a2) | 
 | 1495 |             { | 
 | 1496 |                 ::new ((void*)__p) _Tp(__a0, __a1, __a2); | 
 | 1497 |             } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1498 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1499 |  | 
 | 1500 |     template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1501 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1502 |         static void destroy(allocator_type& __a, _Tp* __p) | 
 | 1503 |             {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} | 
 | 1504 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1505 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1506 |     static size_type max_size(const allocator_type& __a) | 
 | 1507 |         {return __max_size(__has_max_size<const allocator_type>(), __a);} | 
 | 1508 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1509 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1510 |     static allocator_type | 
 | 1511 |         select_on_container_copy_construction(const allocator_type& __a) | 
 | 1512 |             {return select_on_container_copy_construction( | 
 | 1513 |                 __has_select_on_container_copy_construction<const allocator_type>(), | 
 | 1514 |                 __a);} | 
 | 1515 |  | 
 | 1516 | private: | 
 | 1517 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1518 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1519 |     static pointer allocate(allocator_type& __a, size_type __n, | 
 | 1520 |         const_void_pointer __hint, true_type) | 
 | 1521 |         {return __a.allocate(__n, __hint);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1522 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1523 |     static pointer allocate(allocator_type& __a, size_type __n, | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 1524 |         const_void_pointer, false_type) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1525 |         {return __a.allocate(__n);} | 
 | 1526 |  | 
 | 1527 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1528 |     template <class _Tp, class... _Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1529 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1530 |         static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1531 |             {__a.construct(__p, _VSTD::forward<_Args>(__args)...);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1532 |     template <class _Tp, class... _Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1533 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1534 |         static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args) | 
 | 1535 |             { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1536 |                 ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1537 |             } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1538 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1539 |  | 
 | 1540 |     template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1541 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1542 |         static void __destroy(true_type, allocator_type& __a, _Tp* __p) | 
 | 1543 |             {__a.destroy(__p);} | 
 | 1544 |     template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1545 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1546 |         static void __destroy(false_type, allocator_type&, _Tp* __p) | 
 | 1547 |             { | 
 | 1548 |                 __p->~_Tp(); | 
 | 1549 |             } | 
 | 1550 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1551 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1552 |     static size_type __max_size(true_type, const allocator_type& __a) | 
 | 1553 |             {return __a.max_size();} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1554 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1555 |     static size_type __max_size(false_type, const allocator_type&) | 
 | 1556 |             {return numeric_limits<size_type>::max();} | 
 | 1557 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1558 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1559 |     static allocator_type | 
 | 1560 |         select_on_container_copy_construction(true_type, const allocator_type& __a) | 
 | 1561 |             {return __a.select_on_container_copy_construction();} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1562 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1563 |     static allocator_type | 
 | 1564 |         select_on_container_copy_construction(false_type, const allocator_type& __a) | 
 | 1565 |             {return __a;} | 
 | 1566 | }; | 
 | 1567 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1568 | // allocator | 
 | 1569 |  | 
 | 1570 | template <class _Tp> | 
| Howard Hinnant | 36cdf02 | 2010-09-10 16:42:26 +0000 | [diff] [blame] | 1571 | class _LIBCPP_VISIBLE allocator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1572 | { | 
 | 1573 | public: | 
 | 1574 |     typedef size_t            size_type; | 
 | 1575 |     typedef ptrdiff_t         difference_type; | 
 | 1576 |     typedef _Tp*              pointer; | 
 | 1577 |     typedef const _Tp*        const_pointer; | 
 | 1578 |     typedef _Tp&              reference; | 
 | 1579 |     typedef const _Tp&        const_reference; | 
 | 1580 |     typedef _Tp               value_type; | 
 | 1581 |  | 
| Howard Hinnant | 18884f4 | 2011-06-02 21:38:57 +0000 | [diff] [blame] | 1582 |     typedef true_type propagate_on_container_move_assignment; | 
 | 1583 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1584 |     template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 
 | 1585 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1586 |     _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} | 
 | 1587 |     template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} | 
 | 1588 |     _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1589 |         {return _VSTD::addressof(__x);} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1590 |     _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1591 |         {return _VSTD::addressof(__x);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1592 |     _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) | 
 | 1593 |         {return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1594 |     _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT | 
 | 1595 |         {::operator delete((void*)__p);} | 
 | 1596 |     _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT | 
 | 1597 |         {return size_type(~0) / sizeof(_Tp);} | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1598 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1599 |     template <class _Up, class... _Args> | 
 | 1600 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1601 |         void | 
 | 1602 |         construct(_Up* __p, _Args&&... __args) | 
 | 1603 |         { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1604 |             ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1605 |         } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1606 | #else  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1607 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1608 |         void | 
 | 1609 |         construct(pointer __p) | 
 | 1610 |         { | 
 | 1611 |             ::new((void*)__p) _Tp(); | 
 | 1612 |         } | 
| Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 1613 | # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1614 |     template <class _A0> | 
 | 1615 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1616 |         typename enable_if | 
 | 1617 |         < | 
 | 1618 |             !is_convertible<_A0, __rv<_A0> >::value, | 
 | 1619 |             void | 
 | 1620 |         >::type | 
 | 1621 |         construct(pointer __p, _A0& __a0) | 
 | 1622 |         { | 
 | 1623 |             ::new((void*)__p) _Tp(__a0); | 
 | 1624 |         } | 
 | 1625 |     template <class _A0> | 
 | 1626 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1627 |         typename enable_if | 
 | 1628 |         < | 
 | 1629 |             !is_convertible<_A0, __rv<_A0> >::value, | 
 | 1630 |             void | 
 | 1631 |         >::type | 
 | 1632 |         construct(pointer __p, const _A0& __a0) | 
 | 1633 |         { | 
 | 1634 |             ::new((void*)__p) _Tp(__a0); | 
 | 1635 |         } | 
 | 1636 |     template <class _A0> | 
 | 1637 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1638 |         typename enable_if | 
 | 1639 |         < | 
 | 1640 |             is_convertible<_A0, __rv<_A0> >::value, | 
 | 1641 |             void | 
 | 1642 |         >::type | 
 | 1643 |         construct(pointer __p, _A0 __a0) | 
 | 1644 |         { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1645 |             ::new((void*)__p) _Tp(_VSTD::move(__a0)); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1646 |         } | 
| Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 1647 | # endif  // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1648 |     template <class _A0, class _A1> | 
 | 1649 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1650 |         void | 
 | 1651 |         construct(pointer __p, _A0& __a0, _A1& __a1) | 
 | 1652 |         { | 
 | 1653 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1654 |         } | 
 | 1655 |     template <class _A0, class _A1> | 
 | 1656 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1657 |         void | 
 | 1658 |         construct(pointer __p, const _A0& __a0, _A1& __a1) | 
 | 1659 |         { | 
 | 1660 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1661 |         } | 
 | 1662 |     template <class _A0, class _A1> | 
 | 1663 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1664 |         void | 
 | 1665 |         construct(pointer __p, _A0& __a0, const _A1& __a1) | 
 | 1666 |         { | 
 | 1667 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1668 |         } | 
 | 1669 |     template <class _A0, class _A1> | 
 | 1670 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1671 |         void | 
 | 1672 |         construct(pointer __p, const _A0& __a0, const _A1& __a1) | 
 | 1673 |         { | 
 | 1674 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1675 |         } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1676 | #endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1677 |     _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} | 
 | 1678 | }; | 
 | 1679 |  | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 1680 | template <class _Tp> | 
 | 1681 | class _LIBCPP_VISIBLE allocator<const _Tp> | 
 | 1682 | { | 
 | 1683 | public: | 
 | 1684 |     typedef size_t            size_type; | 
 | 1685 |     typedef ptrdiff_t         difference_type; | 
 | 1686 |     typedef const _Tp*        pointer; | 
 | 1687 |     typedef const _Tp*        const_pointer; | 
 | 1688 |     typedef const _Tp&        reference; | 
 | 1689 |     typedef const _Tp&        const_reference; | 
 | 1690 |     typedef _Tp               value_type; | 
 | 1691 |  | 
 | 1692 |     typedef true_type propagate_on_container_move_assignment; | 
 | 1693 |  | 
 | 1694 |     template <class _Up> struct rebind {typedef allocator<_Up> other;}; | 
 | 1695 |  | 
 | 1696 |     _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {} | 
 | 1697 |     template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {} | 
 | 1698 |     _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT | 
 | 1699 |         {return _VSTD::addressof(__x);} | 
 | 1700 |     _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) | 
 | 1701 |         {return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));} | 
 | 1702 |     _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT | 
 | 1703 |         {::operator delete((void*)__p);} | 
 | 1704 |     _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT | 
 | 1705 |         {return size_type(~0) / sizeof(_Tp);} | 
 | 1706 | #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
 | 1707 |     template <class _Up, class... _Args> | 
 | 1708 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1709 |         void | 
 | 1710 |         construct(_Up* __p, _Args&&... __args) | 
 | 1711 |         { | 
 | 1712 |             ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); | 
 | 1713 |         } | 
 | 1714 | #else  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
 | 1715 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1716 |         void | 
 | 1717 |         construct(pointer __p) | 
 | 1718 |         { | 
 | 1719 |             ::new((void*)__p) _Tp(); | 
 | 1720 |         } | 
 | 1721 | # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | 
 | 1722 |     template <class _A0> | 
 | 1723 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1724 |         typename enable_if | 
 | 1725 |         < | 
 | 1726 |             !is_convertible<_A0, __rv<_A0> >::value, | 
 | 1727 |             void | 
 | 1728 |         >::type | 
 | 1729 |         construct(pointer __p, _A0& __a0) | 
 | 1730 |         { | 
 | 1731 |             ::new((void*)__p) _Tp(__a0); | 
 | 1732 |         } | 
 | 1733 |     template <class _A0> | 
 | 1734 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1735 |         typename enable_if | 
 | 1736 |         < | 
 | 1737 |             !is_convertible<_A0, __rv<_A0> >::value, | 
 | 1738 |             void | 
 | 1739 |         >::type | 
 | 1740 |         construct(pointer __p, const _A0& __a0) | 
 | 1741 |         { | 
 | 1742 |             ::new((void*)__p) _Tp(__a0); | 
 | 1743 |         } | 
 | 1744 |     template <class _A0> | 
 | 1745 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1746 |         typename enable_if | 
 | 1747 |         < | 
 | 1748 |             is_convertible<_A0, __rv<_A0> >::value, | 
 | 1749 |             void | 
 | 1750 |         >::type | 
 | 1751 |         construct(pointer __p, _A0 __a0) | 
 | 1752 |         { | 
 | 1753 |             ::new((void*)__p) _Tp(_VSTD::move(__a0)); | 
 | 1754 |         } | 
 | 1755 | # endif  // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) | 
 | 1756 |     template <class _A0, class _A1> | 
 | 1757 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1758 |         void | 
 | 1759 |         construct(pointer __p, _A0& __a0, _A1& __a1) | 
 | 1760 |         { | 
 | 1761 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1762 |         } | 
 | 1763 |     template <class _A0, class _A1> | 
 | 1764 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1765 |         void | 
 | 1766 |         construct(pointer __p, const _A0& __a0, _A1& __a1) | 
 | 1767 |         { | 
 | 1768 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1769 |         } | 
 | 1770 |     template <class _A0, class _A1> | 
 | 1771 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1772 |         void | 
 | 1773 |         construct(pointer __p, _A0& __a0, const _A1& __a1) | 
 | 1774 |         { | 
 | 1775 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1776 |         } | 
 | 1777 |     template <class _A0, class _A1> | 
 | 1778 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1779 |         void | 
 | 1780 |         construct(pointer __p, const _A0& __a0, const _A1& __a1) | 
 | 1781 |         { | 
 | 1782 |             ::new((void*)__p) _Tp(__a0, __a1); | 
 | 1783 |         } | 
 | 1784 | #endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) | 
 | 1785 |     _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();} | 
 | 1786 | }; | 
 | 1787 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1788 | template <class _Tp, class _Up> | 
 | 1789 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1790 | bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1791 |  | 
 | 1792 | template <class _Tp, class _Up> | 
 | 1793 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1794 | bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1795 |  | 
 | 1796 | template <class _OutputIterator, class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1797 | class _LIBCPP_VISIBLE raw_storage_iterator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1798 |     : public iterator<output_iterator_tag, | 
 | 1799 |                       _Tp,                                         // purposefully not C++03 | 
 | 1800 |                       ptrdiff_t,                                   // purposefully not C++03 | 
 | 1801 |                       _Tp*,                                        // purposefully not C++03 | 
 | 1802 |                       raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03 | 
 | 1803 | { | 
 | 1804 | private: | 
 | 1805 |     _OutputIterator __x_; | 
 | 1806 | public: | 
 | 1807 |     _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} | 
 | 1808 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} | 
 | 1809 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) | 
 | 1810 |         {::new(&*__x_) _Tp(__element); return *this;} | 
 | 1811 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} | 
 | 1812 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator  operator++(int) | 
 | 1813 |         {raw_storage_iterator __t(*this); ++__x_; return __t;} | 
 | 1814 | }; | 
 | 1815 |  | 
 | 1816 | template <class _Tp> | 
 | 1817 | pair<_Tp*, ptrdiff_t> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1818 | get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1819 | { | 
 | 1820 |     pair<_Tp*, ptrdiff_t> __r(0, 0); | 
 | 1821 |     const ptrdiff_t __m = (~ptrdiff_t(0) ^ | 
 | 1822 |                            ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) | 
 | 1823 |                            / sizeof(_Tp); | 
 | 1824 |     if (__n > __m) | 
 | 1825 |         __n = __m; | 
 | 1826 |     while (__n > 0) | 
 | 1827 |     { | 
 | 1828 |         __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); | 
 | 1829 |         if (__r.first) | 
 | 1830 |         { | 
 | 1831 |             __r.second = __n; | 
 | 1832 |             break; | 
 | 1833 |         } | 
 | 1834 |         __n /= 2; | 
 | 1835 |     } | 
 | 1836 |     return __r; | 
 | 1837 | } | 
 | 1838 |  | 
 | 1839 | template <class _Tp> | 
 | 1840 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1841 | void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1842 |  | 
 | 1843 | template <class _Tp> | 
 | 1844 | struct auto_ptr_ref | 
 | 1845 | { | 
 | 1846 |     _Tp* __ptr_; | 
 | 1847 | }; | 
 | 1848 |  | 
 | 1849 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1850 | class _LIBCPP_VISIBLE auto_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1851 | { | 
 | 1852 | private: | 
 | 1853 |     _Tp* __ptr_; | 
 | 1854 | public: | 
 | 1855 |     typedef _Tp element_type; | 
 | 1856 |  | 
 | 1857 |     _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} | 
 | 1858 |     _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} | 
 | 1859 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() | 
 | 1860 |         : __ptr_(__p.release()) {} | 
 | 1861 |     _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() | 
 | 1862 |         {reset(__p.release()); return *this;} | 
 | 1863 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() | 
 | 1864 |         {reset(__p.release()); return *this;} | 
 | 1865 |     _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() | 
 | 1866 |         {reset(__p.__ptr_); return *this;} | 
 | 1867 |     _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} | 
 | 1868 |  | 
 | 1869 |     _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() | 
 | 1870 |         {return *__ptr_;} | 
 | 1871 |     _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} | 
 | 1872 |     _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} | 
 | 1873 |     _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() | 
 | 1874 |     { | 
 | 1875 |         _Tp* __t = __ptr_; | 
 | 1876 |         __ptr_ = 0; | 
 | 1877 |         return __t; | 
 | 1878 |     } | 
 | 1879 |     _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() | 
 | 1880 |     { | 
 | 1881 |         if (__ptr_ != __p) | 
 | 1882 |             delete __ptr_; | 
 | 1883 |         __ptr_ = __p; | 
 | 1884 |     } | 
 | 1885 |  | 
 | 1886 |     _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} | 
 | 1887 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() | 
 | 1888 |         {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} | 
 | 1889 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() | 
 | 1890 |         {return auto_ptr<_Up>(release());} | 
 | 1891 | }; | 
 | 1892 |  | 
 | 1893 | template <> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1894 | class _LIBCPP_VISIBLE auto_ptr<void> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1895 | { | 
 | 1896 | public: | 
 | 1897 |     typedef void element_type; | 
 | 1898 | }; | 
 | 1899 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1900 | template <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, | 
 | 1901 |                                                      typename remove_cv<_T2>::type>::value, | 
| Howard Hinnant | d4cf215 | 2011-12-11 20:31:33 +0000 | [diff] [blame] | 1902 |                                 bool = is_empty<_T1>::value | 
 | 1903 | #if __has_feature(is_final) | 
 | 1904 |                                        && !__is_final(_T1) | 
 | 1905 | #endif | 
 | 1906 |                                 , | 
 | 1907 |                                 bool = is_empty<_T2>::value | 
 | 1908 | #if __has_feature(is_final) | 
 | 1909 |                                        && !__is_final(_T2) | 
 | 1910 | #endif | 
 | 1911 |          > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1912 | struct __libcpp_compressed_pair_switch; | 
 | 1913 |  | 
 | 1914 | template <class _T1, class _T2, bool IsSame> | 
 | 1915 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};}; | 
 | 1916 |  | 
 | 1917 | template <class _T1, class _T2, bool IsSame> | 
 | 1918 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false>  {enum {value = 1};}; | 
 | 1919 |  | 
 | 1920 | template <class _T1, class _T2, bool IsSame> | 
 | 1921 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true>  {enum {value = 2};}; | 
 | 1922 |  | 
 | 1923 | template <class _T1, class _T2> | 
 | 1924 | struct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true>    {enum {value = 3};}; | 
 | 1925 |  | 
 | 1926 | template <class _T1, class _T2> | 
 | 1927 | struct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true>     {enum {value = 1};}; | 
 | 1928 |  | 
 | 1929 | template <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value> | 
 | 1930 | class __libcpp_compressed_pair_imp; | 
 | 1931 |  | 
 | 1932 | template <class _T1, class _T2> | 
 | 1933 | class __libcpp_compressed_pair_imp<_T1, _T2, 0> | 
 | 1934 | { | 
 | 1935 | private: | 
 | 1936 |     _T1 __first_; | 
 | 1937 |     _T2 __second_; | 
 | 1938 | public: | 
 | 1939 |     typedef _T1 _T1_param; | 
 | 1940 |     typedef _T2 _T2_param; | 
 | 1941 |  | 
 | 1942 |     typedef typename remove_reference<_T1>::type& _T1_reference; | 
 | 1943 |     typedef typename remove_reference<_T2>::type& _T2_reference; | 
 | 1944 |  | 
 | 1945 |     typedef const typename remove_reference<_T1>::type& _T1_const_reference; | 
 | 1946 |     typedef const typename remove_reference<_T2>::type& _T2_const_reference; | 
 | 1947 |  | 
 | 1948 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 1949 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1950 |         : __first_(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 1951 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1952 |         : __second_(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1953 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1954 |         : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1955 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1956 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 1957 |  | 
 | 1958 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1959 |     __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) | 
 | 1960 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 1961 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 1962 |         : __first_(__p.first()), | 
 | 1963 |           __second_(__p.second()) {} | 
 | 1964 |  | 
 | 1965 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1966 |     __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) | 
 | 1967 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 1968 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 1969 |         { | 
 | 1970 |             __first_ = __p.first(); | 
 | 1971 |             __second_ = __p.second(); | 
 | 1972 |             return *this; | 
 | 1973 |         } | 
 | 1974 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1975 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1976 |  | 
 | 1977 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1978 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1979 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 1980 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1981 |         : __first_(_VSTD::forward<_T1>(__p.first())), | 
 | 1982 |           __second_(_VSTD::forward<_T2>(__p.second())) {} | 
 | 1983 |  | 
 | 1984 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1985 |     __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) | 
 | 1986 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 1987 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 1988 |         { | 
 | 1989 |             __first_ = _VSTD::forward<_T1>(__p.first()); | 
 | 1990 |             __second_ = _VSTD::forward<_T2>(__p.second()); | 
 | 1991 |             return *this; | 
 | 1992 |         } | 
 | 1993 |  | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 1994 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1995 |  | 
 | 1996 |     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | 
 | 1997 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1998 |         __libcpp_compressed_pair_imp(piecewise_construct_t __pc, | 
 | 1999 |                                      tuple<_Args1...> __first_args, | 
 | 2000 |                                      tuple<_Args2...> __second_args, | 
 | 2001 |                                      __tuple_indices<_I1...>, | 
 | 2002 |                                      __tuple_indices<_I2...>) | 
 | 2003 |             : __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), | 
 | 2004 |               __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) | 
 | 2005 |             {} | 
 | 2006 |  | 
 | 2007 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2008 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2009 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2010 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2011 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2012 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2013 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;} | 
 | 2014 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2015 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2016 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return __second_;} | 
 | 2017 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2018 |  | 
 | 2019 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2020 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2021 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2022 |     { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2023 |         using _VSTD::swap; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2024 |         swap(__first_, __x.__first_); | 
 | 2025 |         swap(__second_, __x.__second_); | 
 | 2026 |     } | 
 | 2027 | }; | 
 | 2028 |  | 
 | 2029 | template <class _T1, class _T2> | 
 | 2030 | class __libcpp_compressed_pair_imp<_T1, _T2, 1> | 
 | 2031 |     : private _T1 | 
 | 2032 | { | 
 | 2033 | private: | 
 | 2034 |     _T2 __second_; | 
 | 2035 | public: | 
 | 2036 |     typedef _T1 _T1_param; | 
 | 2037 |     typedef _T2 _T2_param; | 
 | 2038 |  | 
 | 2039 |     typedef _T1&                                        _T1_reference; | 
 | 2040 |     typedef typename remove_reference<_T2>::type& _T2_reference; | 
 | 2041 |  | 
 | 2042 |     typedef const _T1&                                        _T1_const_reference; | 
 | 2043 |     typedef const typename remove_reference<_T2>::type& _T2_const_reference; | 
 | 2044 |  | 
 | 2045 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2046 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2047 |         : _T1(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2048 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2049 |         : __second_(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2050 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2051 |         : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2052 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2053 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2054 |  | 
 | 2055 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2056 |     __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) | 
 | 2057 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 2058 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 2059 |         : _T1(__p.first()), __second_(__p.second()) {} | 
 | 2060 |  | 
 | 2061 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2062 |     __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) | 
 | 2063 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 2064 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 2065 |         { | 
 | 2066 |             _T1::operator=(__p.first()); | 
 | 2067 |             __second_ = __p.second(); | 
 | 2068 |             return *this; | 
 | 2069 |         } | 
 | 2070 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2071 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2072 |  | 
 | 2073 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2074 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2075 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2076 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2077 |         : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {} | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2078 |  | 
 | 2079 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2080 |     __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) | 
 | 2081 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 2082 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 2083 |         { | 
 | 2084 |             _T1::operator=(_VSTD::move(__p.first())); | 
 | 2085 |             __second_ = _VSTD::forward<_T2>(__p.second()); | 
 | 2086 |             return *this; | 
 | 2087 |         } | 
 | 2088 |  | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 2089 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2090 |  | 
 | 2091 |     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | 
 | 2092 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2093 |         __libcpp_compressed_pair_imp(piecewise_construct_t __pc, | 
 | 2094 |                                      tuple<_Args1...> __first_args, | 
 | 2095 |                                      tuple<_Args2...> __second_args, | 
 | 2096 |                                      __tuple_indices<_I1...>, | 
 | 2097 |                                      __tuple_indices<_I2...>) | 
 | 2098 |             : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), | 
 | 2099 |               __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) | 
 | 2100 |             {} | 
 | 2101 |  | 
 | 2102 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2103 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2104 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2105 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2106 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2107 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2108 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;} | 
 | 2109 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2110 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2111 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return __second_;} | 
 | 2112 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2113 |  | 
 | 2114 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2115 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2116 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2117 |     { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2118 |         using _VSTD::swap; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2119 |         swap(__second_, __x.__second_); | 
 | 2120 |     } | 
 | 2121 | }; | 
 | 2122 |  | 
 | 2123 | template <class _T1, class _T2> | 
 | 2124 | class __libcpp_compressed_pair_imp<_T1, _T2, 2> | 
 | 2125 |     : private _T2 | 
 | 2126 | { | 
 | 2127 | private: | 
 | 2128 |     _T1 __first_; | 
 | 2129 | public: | 
 | 2130 |     typedef _T1 _T1_param; | 
 | 2131 |     typedef _T2 _T2_param; | 
 | 2132 |  | 
 | 2133 |     typedef typename remove_reference<_T1>::type& _T1_reference; | 
 | 2134 |     typedef _T2&                                        _T2_reference; | 
 | 2135 |  | 
 | 2136 |     typedef const typename remove_reference<_T1>::type& _T1_const_reference; | 
 | 2137 |     typedef const _T2&                                        _T2_const_reference; | 
 | 2138 |  | 
 | 2139 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 2140 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2141 |         : __first_(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2142 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2143 |         : _T2(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2144 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2145 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2146 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2147 |         : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2148 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2149 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2150 |  | 
 | 2151 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2152 |     __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) | 
 | 2153 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 2154 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 2155 |         : _T2(__p.second()), __first_(__p.first()) {} | 
 | 2156 |  | 
 | 2157 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2158 |     __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) | 
 | 2159 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 2160 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 2161 |         { | 
 | 2162 |             _T2::operator=(__p.second()); | 
 | 2163 |             __first_ = __p.first(); | 
 | 2164 |             return *this; | 
 | 2165 |         } | 
 | 2166 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2167 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2168 |  | 
 | 2169 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2170 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2171 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2172 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2173 |         : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {} | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2174 |  | 
 | 2175 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2176 |     __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) | 
 | 2177 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 2178 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 2179 |         { | 
 | 2180 |             _T2::operator=(_VSTD::forward<_T2>(__p.second())); | 
 | 2181 |             __first_ = _VSTD::move(__p.first()); | 
 | 2182 |             return *this; | 
 | 2183 |         } | 
 | 2184 |  | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 2185 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2186 |  | 
 | 2187 |     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | 
 | 2188 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2189 |         __libcpp_compressed_pair_imp(piecewise_construct_t __pc, | 
 | 2190 |                                      tuple<_Args1...> __first_args, | 
 | 2191 |                                      tuple<_Args2...> __second_args, | 
 | 2192 |                                      __tuple_indices<_I1...>, | 
 | 2193 |                                      __tuple_indices<_I2...>) | 
 | 2194 |             : _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...), | 
 | 2195 |               __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...) | 
 | 2196 |                | 
 | 2197 |             {} | 
 | 2198 |  | 
 | 2199 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2200 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2201 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2202 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2203 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2204 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2205 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;} | 
 | 2206 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2207 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2208 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return *this;} | 
 | 2209 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2210 |  | 
 | 2211 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2212 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2213 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2214 |     { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2215 |         using _VSTD::swap; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2216 |         swap(__first_, __x.__first_); | 
 | 2217 |     } | 
 | 2218 | }; | 
 | 2219 |  | 
 | 2220 | template <class _T1, class _T2> | 
 | 2221 | class __libcpp_compressed_pair_imp<_T1, _T2, 3> | 
 | 2222 |     : private _T1, | 
 | 2223 |       private _T2 | 
 | 2224 | { | 
 | 2225 | public: | 
 | 2226 |     typedef _T1 _T1_param; | 
 | 2227 |     typedef _T2 _T2_param; | 
 | 2228 |  | 
 | 2229 |     typedef _T1& _T1_reference; | 
 | 2230 |     typedef _T2& _T2_reference; | 
 | 2231 |  | 
 | 2232 |     typedef const _T1& _T1_const_reference; | 
 | 2233 |     typedef const _T2& _T2_const_reference; | 
 | 2234 |  | 
 | 2235 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 2236 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2237 |         : _T1(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2238 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2239 |         : _T2(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2240 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2241 |         : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2242 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2243 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2244 |  | 
 | 2245 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2246 |     __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) | 
 | 2247 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 2248 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 2249 |         : _T1(__p.first()), _T2(__p.second()) {} | 
 | 2250 |  | 
 | 2251 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2252 |     __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) | 
 | 2253 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 2254 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 2255 |         { | 
 | 2256 |             _T1::operator=(__p.first()); | 
 | 2257 |             _T2::operator=(__p.second()); | 
 | 2258 |             return *this; | 
 | 2259 |         } | 
 | 2260 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2261 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2262 |  | 
 | 2263 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2264 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2265 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2266 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2267 |         : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {} | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2268 |  | 
 | 2269 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2270 |     __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) | 
 | 2271 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 2272 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 2273 |         { | 
 | 2274 |             _T1::operator=(_VSTD::move(__p.first())); | 
 | 2275 |             _T2::operator=(_VSTD::move(__p.second())); | 
 | 2276 |             return *this; | 
 | 2277 |         } | 
 | 2278 |  | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 2279 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2280 |  | 
 | 2281 |     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | 
 | 2282 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2283 |         __libcpp_compressed_pair_imp(piecewise_construct_t __pc, | 
 | 2284 |                                      tuple<_Args1...> __first_args, | 
 | 2285 |                                      tuple<_Args2...> __second_args, | 
 | 2286 |                                      __tuple_indices<_I1...>, | 
 | 2287 |                                      __tuple_indices<_I2...>) | 
 | 2288 |             : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), | 
 | 2289 |               _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) | 
 | 2290 |             {} | 
 | 2291 |  | 
 | 2292 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2293 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2294 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2295 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2296 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2297 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2298 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;} | 
 | 2299 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2300 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2301 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return *this;} | 
 | 2302 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2303 |  | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 2304 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2305 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2306 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2307 |     { | 
 | 2308 |     } | 
 | 2309 | }; | 
 | 2310 |  | 
 | 2311 | template <class _T1, class _T2> | 
 | 2312 | class __compressed_pair | 
 | 2313 |     : private __libcpp_compressed_pair_imp<_T1, _T2> | 
 | 2314 | { | 
 | 2315 |     typedef __libcpp_compressed_pair_imp<_T1, _T2> base; | 
 | 2316 | public: | 
 | 2317 |     typedef typename base::_T1_param _T1_param; | 
 | 2318 |     typedef typename base::_T2_param _T2_param; | 
 | 2319 |  | 
 | 2320 |     typedef typename base::_T1_reference _T1_reference; | 
 | 2321 |     typedef typename base::_T2_reference _T2_reference; | 
 | 2322 |  | 
 | 2323 |     typedef typename base::_T1_const_reference _T1_const_reference; | 
 | 2324 |     typedef typename base::_T2_const_reference _T2_const_reference; | 
 | 2325 |  | 
 | 2326 |     _LIBCPP_INLINE_VISIBILITY __compressed_pair() {} | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2327 |     _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2328 |         : base(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2329 |     _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2330 |         : base(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2331 |     _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2332 |         : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2333 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2334 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2335 |  | 
 | 2336 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2337 |     __compressed_pair(const __compressed_pair& __p) | 
 | 2338 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 2339 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 2340 |         : base(__p) {} | 
 | 2341 |  | 
 | 2342 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2343 |     __compressed_pair& operator=(const __compressed_pair& __p) | 
 | 2344 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 2345 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 2346 |         { | 
 | 2347 |             base::operator=(__p); | 
 | 2348 |             return *this; | 
 | 2349 |         } | 
 | 2350 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2351 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2352 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2353 |     __compressed_pair(__compressed_pair&& __p) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2354 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2355 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2356 |         : base(_VSTD::move(__p)) {} | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2357 |  | 
 | 2358 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2359 |     __compressed_pair& operator=(__compressed_pair&& __p) | 
 | 2360 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 2361 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 2362 |         { | 
 | 2363 |             base::operator=(_VSTD::move(__p)); | 
 | 2364 |             return *this; | 
 | 2365 |         } | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 2366 |  | 
 | 2367 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2368 |  | 
 | 2369 |     template <class... _Args1, class... _Args2> | 
 | 2370 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2371 |         __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, | 
 | 2372 |                                                       tuple<_Args2...> __second_args) | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2373 |             : base(__pc, _VSTD::move(__first_args), _VSTD::move(__second_args), | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 2374 |                    typename __make_tuple_indices<sizeof...(_Args1)>::type(), | 
 | 2375 |                    typename __make_tuple_indices<sizeof...(_Args2) >::type()) | 
 | 2376 |             {} | 
 | 2377 |  | 
 | 2378 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2379 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2380 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2381 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2382 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2383 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2384 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return base::first();} | 
 | 2385 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2386 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2387 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return base::second();} | 
 | 2388 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2389 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2390 |     _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) | 
 | 2391 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2392 |                    __is_nothrow_swappable<_T1>::value) | 
 | 2393 |         {base::swap(__x);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2394 | }; | 
 | 2395 |  | 
 | 2396 | template <class _T1, class _T2> | 
 | 2397 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2398 | void | 
 | 2399 | swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2400 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2401 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2402 |     {__x.swap(__y);} | 
 | 2403 |  | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2404 | // __same_or_less_cv_qualified | 
 | 2405 |  | 
 | 2406 | template <class _Ptr1, class _Ptr2, | 
 | 2407 |           bool = is_same<typename remove_cv<typename pointer_traits<_Ptr1>::element_type>::type, | 
 | 2408 |                          typename remove_cv<typename pointer_traits<_Ptr2>::element_type>::type | 
 | 2409 |                         >::value | 
 | 2410 |          > | 
 | 2411 | struct __same_or_less_cv_qualified_imp | 
 | 2412 |     : is_convertible<_Ptr1, _Ptr2> {}; | 
 | 2413 |  | 
 | 2414 | template <class _Ptr1, class _Ptr2> | 
 | 2415 | struct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false> | 
 | 2416 |     : false_type {}; | 
 | 2417 |  | 
 | 2418 | template <class _Ptr1, class _Ptr2, bool = is_scalar<_Ptr1>::value && | 
 | 2419 |                                          !is_pointer<_Ptr1>::value> | 
 | 2420 | struct __same_or_less_cv_qualified | 
 | 2421 |     : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {}; | 
 | 2422 |  | 
 | 2423 | template <class _Ptr1, class _Ptr2> | 
 | 2424 | struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true> | 
 | 2425 |     : false_type {}; | 
 | 2426 |  | 
 | 2427 | // default_delete | 
 | 2428 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2429 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2430 | struct _LIBCPP_VISIBLE default_delete | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2431 | { | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2432 |     _LIBCPP_INLINE_VISIBILITY default_delete() _NOEXCEPT {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2433 |     template <class _Up> | 
 | 2434 |         _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2435 |              typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} | 
 | 2436 |     _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2437 |         { | 
 | 2438 |             static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); | 
 | 2439 |             delete __ptr; | 
 | 2440 |         } | 
 | 2441 | }; | 
 | 2442 |  | 
 | 2443 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2444 | struct _LIBCPP_VISIBLE default_delete<_Tp[]> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2445 | { | 
| Howard Hinnant | 8e84350 | 2011-12-18 21:19:44 +0000 | [diff] [blame] | 2446 | public: | 
 | 2447 |     _LIBCPP_INLINE_VISIBILITY default_delete() _NOEXCEPT {} | 
 | 2448 |     template <class _Up> | 
 | 2449 |         _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&, | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2450 |              typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} | 
| Howard Hinnant | 8e84350 | 2011-12-18 21:19:44 +0000 | [diff] [blame] | 2451 |     template <class _Up> | 
 | 2452 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2453 |         void operator() (_Up* __ptr, | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2454 |                          typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2455 |         { | 
 | 2456 |             static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); | 
 | 2457 |             delete [] __ptr; | 
 | 2458 |         } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2459 | }; | 
 | 2460 |  | 
 | 2461 | template <class _Tp, class _Dp = default_delete<_Tp> > | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2462 | class _LIBCPP_VISIBLE unique_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2463 | { | 
 | 2464 | public: | 
 | 2465 |     typedef _Tp element_type; | 
 | 2466 |     typedef _Dp deleter_type; | 
 | 2467 |     typedef typename __pointer_type<_Tp, deleter_type>::type pointer; | 
 | 2468 | private: | 
 | 2469 |     __compressed_pair<pointer, deleter_type> __ptr_; | 
 | 2470 |  | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2471 | #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2472 |     unique_ptr(unique_ptr&); | 
 | 2473 |     template <class _Up, class _Ep> | 
 | 2474 |         unique_ptr(unique_ptr<_Up, _Ep>&); | 
 | 2475 |     unique_ptr& operator=(unique_ptr&); | 
 | 2476 |     template <class _Up, class _Ep> | 
 | 2477 |         unique_ptr& operator=(unique_ptr<_Up, _Ep>&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2478 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2479 |  | 
 | 2480 |     struct __nat {int __for_bool_;}; | 
 | 2481 |  | 
 | 2482 |     typedef       typename remove_reference<deleter_type>::type& _Dp_reference; | 
 | 2483 |     typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; | 
 | 2484 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2485 |     _LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2486 |         : __ptr_(pointer()) | 
 | 2487 |         { | 
 | 2488 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2489 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2490 |         } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2491 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2492 |         : __ptr_(pointer()) | 
 | 2493 |         { | 
 | 2494 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2495 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2496 |         } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2497 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2498 |         : __ptr_(_VSTD::move(__p)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2499 |         { | 
 | 2500 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2501 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2502 |         } | 
 | 2503 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2504 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2505 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional< | 
 | 2506 |                                         is_reference<deleter_type>::value, | 
 | 2507 |                                         deleter_type, | 
 | 2508 |                                         typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2509 |              _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2510 |         : __ptr_(__p, __d) {} | 
 | 2511 |  | 
 | 2512 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2513 |              _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2514 |         : __ptr_(__p, _VSTD::move(__d)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2515 |         { | 
 | 2516 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2517 |         } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2518 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2519 |         : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2520 |     template <class _Up, class _Ep> | 
 | 2521 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2522 |         unique_ptr(unique_ptr<_Up, _Ep>&& __u, | 
 | 2523 |                    typename enable_if | 
 | 2524 |                       < | 
 | 2525 |                         !is_array<_Up>::value && | 
 | 2526 |                          is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && | 
 | 2527 |                          is_convertible<_Ep, deleter_type>::value && | 
 | 2528 |                          ( | 
 | 2529 |                             !is_reference<deleter_type>::value || | 
 | 2530 |                             is_same<deleter_type, _Ep>::value | 
 | 2531 |                          ), | 
 | 2532 |                          __nat | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2533 |                       >::type = __nat()) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2534 |             : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2535 |  | 
 | 2536 |     template <class _Up> | 
 | 2537 |         _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, | 
 | 2538 |                 typename enable_if< | 
 | 2539 |                                       is_convertible<_Up*, _Tp*>::value && | 
 | 2540 |                                       is_same<_Dp, default_delete<_Tp> >::value, | 
 | 2541 |                                       __nat | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2542 |                                   >::type = __nat()) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2543 |             : __ptr_(__p.release()) | 
 | 2544 |             { | 
 | 2545 |             } | 
 | 2546 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2547 |         _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2548 |             { | 
 | 2549 |                 reset(__u.release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2550 |                 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2551 |                 return *this; | 
 | 2552 |             } | 
 | 2553 |  | 
 | 2554 |         template <class _Up, class _Ep> | 
 | 2555 |             _LIBCPP_INLINE_VISIBILITY | 
 | 2556 |             typename enable_if | 
 | 2557 |             < | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2558 |                 !is_array<_Up>::value && | 
 | 2559 |                 is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && | 
 | 2560 |                 is_assignable<deleter_type&, _Ep&&>::value, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2561 |                 unique_ptr& | 
 | 2562 |             >::type | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2563 |             operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2564 |             { | 
 | 2565 |                 reset(__u.release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2566 |                 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2567 |                 return *this; | 
 | 2568 |             } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2569 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2570 |  | 
 | 2571 |     _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() | 
 | 2572 |     { | 
 | 2573 |         return __rv<unique_ptr>(*this); | 
 | 2574 |     } | 
 | 2575 |  | 
 | 2576 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2577 |         : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2578 |  | 
 | 2579 |     template <class _Up, class _Ep> | 
 | 2580 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) | 
 | 2581 |     { | 
 | 2582 |         reset(__u.release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2583 |         __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2584 |         return *this; | 
 | 2585 |     } | 
 | 2586 |  | 
 | 2587 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2588 |         : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2589 |  | 
 | 2590 |     template <class _Up> | 
 | 2591 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2592 |                 typename enable_if< | 
 | 2593 |                                       is_convertible<_Up*, _Tp*>::value && | 
 | 2594 |                                       is_same<_Dp, default_delete<_Tp> >::value, | 
 | 2595 |                                       unique_ptr& | 
 | 2596 |                                   >::type | 
 | 2597 |         operator=(auto_ptr<_Up> __p) | 
 | 2598 |             {reset(__p.release()); return *this;} | 
 | 2599 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2600 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2601 |     _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} | 
 | 2602 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2603 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2604 |     { | 
 | 2605 |         reset(); | 
 | 2606 |         return *this; | 
 | 2607 |     } | 
 | 2608 |  | 
 | 2609 |     _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const | 
 | 2610 |         {return *__ptr_.first();} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2611 |     _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();} | 
 | 2612 |     _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} | 
 | 2613 |     _LIBCPP_INLINE_VISIBILITY       _Dp_reference get_deleter() _NOEXCEPT | 
 | 2614 |         {return __ptr_.second();} | 
 | 2615 |     _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT | 
 | 2616 |         {return __ptr_.second();} | 
 | 2617 |     _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const | 
 | 2618 |              _NOEXCEPT | 
 | 2619 |         {return __ptr_.first() ? &__nat::__for_bool_ : 0;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2620 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2621 |     _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2622 |     { | 
 | 2623 |         pointer __t = __ptr_.first(); | 
 | 2624 |         __ptr_.first() = pointer(); | 
 | 2625 |         return __t; | 
 | 2626 |     } | 
 | 2627 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2628 |     _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2629 |     { | 
 | 2630 |         pointer __tmp = __ptr_.first(); | 
 | 2631 |         __ptr_.first() = __p; | 
 | 2632 |         if (__tmp) | 
 | 2633 |             __ptr_.second()(__tmp); | 
 | 2634 |     } | 
 | 2635 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2636 |     _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT | 
 | 2637 |         {__ptr_.swap(__u.__ptr_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2638 | }; | 
 | 2639 |  | 
 | 2640 | template <class _Tp, class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2641 | class _LIBCPP_VISIBLE unique_ptr<_Tp[], _Dp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2642 | { | 
 | 2643 | public: | 
 | 2644 |     typedef _Tp element_type; | 
 | 2645 |     typedef _Dp deleter_type; | 
 | 2646 |     typedef typename __pointer_type<_Tp, deleter_type>::type pointer; | 
 | 2647 | private: | 
 | 2648 |     __compressed_pair<pointer, deleter_type> __ptr_; | 
 | 2649 |  | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2650 | #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2651 |     unique_ptr(unique_ptr&); | 
 | 2652 |     template <class _Up> | 
 | 2653 |         unique_ptr(unique_ptr<_Up>&); | 
 | 2654 |     unique_ptr& operator=(unique_ptr&); | 
 | 2655 |     template <class _Up> | 
 | 2656 |         unique_ptr& operator=(unique_ptr<_Up>&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2657 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2658 |  | 
 | 2659 |     struct __nat {int __for_bool_;}; | 
 | 2660 |  | 
 | 2661 |     typedef       typename remove_reference<deleter_type>::type& _Dp_reference; | 
 | 2662 |     typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; | 
 | 2663 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2664 |     _LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2665 |         : __ptr_(pointer()) | 
 | 2666 |         { | 
 | 2667 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2668 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2669 |         } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2670 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2671 |         : __ptr_(pointer()) | 
 | 2672 |         { | 
 | 2673 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2674 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2675 |         } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2676 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2677 |     template <class _Pp, | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2678 |               class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2679 |              > | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2680 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2681 |         : __ptr_(__p) | 
 | 2682 |         { | 
 | 2683 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2684 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2685 |         } | 
 | 2686 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2687 |     template <class _Pp, | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2688 |               class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2689 |              > | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2690 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional< | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2691 |                                        is_reference<deleter_type>::value, | 
 | 2692 |                                        deleter_type, | 
 | 2693 |                                        typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2694 |              _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2695 |         : __ptr_(__p, __d) {} | 
 | 2696 |  | 
 | 2697 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional< | 
 | 2698 |                                        is_reference<deleter_type>::value, | 
 | 2699 |                                        deleter_type, | 
 | 2700 |                                        typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2701 |              _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2702 |         : __ptr_(pointer(), __d) {} | 
 | 2703 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2704 |     template <class _Pp, | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2705 |               class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2706 |              > | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2707 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename remove_reference<deleter_type>::type&& __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2708 |              _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2709 |         : __ptr_(__p, _VSTD::move(__d)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2710 |         { | 
 | 2711 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2712 |         } | 
 | 2713 |  | 
 | 2714 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2715 |              _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2716 |         : __ptr_(pointer(), _VSTD::move(__d)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2717 |         { | 
 | 2718 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2719 |         } | 
 | 2720 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2721 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2722 |         : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2723 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2724 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2725 |         { | 
 | 2726 |             reset(__u.release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2727 |             __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2728 |             return *this; | 
 | 2729 |         } | 
| Howard Hinnant | 8e84350 | 2011-12-18 21:19:44 +0000 | [diff] [blame] | 2730 |  | 
 | 2731 |     template <class _Up, class _Ep> | 
 | 2732 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2733 |         unique_ptr(unique_ptr<_Up, _Ep>&& __u, | 
 | 2734 |                    typename enable_if | 
 | 2735 |                             < | 
 | 2736 |                                 is_array<_Up>::value && | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2737 |                                 __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value | 
| Howard Hinnant | 8e84350 | 2011-12-18 21:19:44 +0000 | [diff] [blame] | 2738 |                                 && is_convertible<_Ep, deleter_type>::value && | 
 | 2739 |                                 ( | 
 | 2740 |                                     !is_reference<deleter_type>::value || | 
 | 2741 |                                     is_same<deleter_type, _Ep>::value | 
 | 2742 |                                 ), | 
 | 2743 |                                 __nat | 
 | 2744 |                             >::type = __nat() | 
 | 2745 |                   ) _NOEXCEPT | 
 | 2746 |         : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} | 
 | 2747 |  | 
 | 2748 |  | 
 | 2749 |         template <class _Up, class _Ep> | 
 | 2750 |             _LIBCPP_INLINE_VISIBILITY | 
 | 2751 |             typename enable_if | 
 | 2752 |             < | 
 | 2753 |                 is_array<_Up>::value && | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2754 |                 __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && | 
 | 2755 |                 is_assignable<deleter_type&, _Ep&&>::value, | 
| Howard Hinnant | 8e84350 | 2011-12-18 21:19:44 +0000 | [diff] [blame] | 2756 |                 unique_ptr& | 
 | 2757 |             >::type | 
 | 2758 |             operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT | 
 | 2759 |             { | 
 | 2760 |                 reset(__u.release()); | 
 | 2761 |                 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); | 
 | 2762 |                 return *this; | 
 | 2763 |             } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2764 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2765 |  | 
 | 2766 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) | 
 | 2767 |         : __ptr_(__p) | 
 | 2768 |         { | 
 | 2769 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2770 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2771 |         } | 
 | 2772 |  | 
 | 2773 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2774 |         : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2775 |  | 
 | 2776 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2777 |         : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2778 |  | 
 | 2779 |     _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() | 
 | 2780 |     { | 
 | 2781 |         return __rv<unique_ptr>(*this); | 
 | 2782 |     } | 
 | 2783 |  | 
 | 2784 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2785 |         : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2786 |  | 
 | 2787 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u) | 
 | 2788 |     { | 
 | 2789 |         reset(__u->release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2790 |         __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2791 |         return *this; | 
 | 2792 |     } | 
 | 2793 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2794 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2795 |     _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} | 
 | 2796 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2797 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2798 |     { | 
 | 2799 |         reset(); | 
 | 2800 |         return *this; | 
 | 2801 |     } | 
 | 2802 |  | 
 | 2803 |     _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const | 
 | 2804 |         {return __ptr_.first()[__i];} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2805 |     _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} | 
 | 2806 |     _LIBCPP_INLINE_VISIBILITY       _Dp_reference get_deleter() _NOEXCEPT | 
 | 2807 |         {return __ptr_.second();} | 
 | 2808 |     _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT | 
 | 2809 |         {return __ptr_.second();} | 
 | 2810 |     _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const _NOEXCEPT | 
 | 2811 |         {return __ptr_.first() ? &__nat::__for_bool_ : 0;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2812 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2813 |     _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2814 |     { | 
 | 2815 |         pointer __t = __ptr_.first(); | 
 | 2816 |         __ptr_.first() = pointer(); | 
 | 2817 |         return __t; | 
 | 2818 |     } | 
 | 2819 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2820 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2821 |     template <class _Pp, | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 2822 |               class = typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value>::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2823 |              > | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2824 |     _LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2825 |     { | 
 | 2826 |         pointer __tmp = __ptr_.first(); | 
 | 2827 |         __ptr_.first() = __p; | 
 | 2828 |         if (__tmp) | 
 | 2829 |             __ptr_.second()(__tmp); | 
 | 2830 |     } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2831 |     _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2832 |     { | 
 | 2833 |         pointer __tmp = __ptr_.first(); | 
 | 2834 |         __ptr_.first() = nullptr; | 
 | 2835 |         if (__tmp) | 
 | 2836 |             __ptr_.second()(__tmp); | 
 | 2837 |     } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2838 |     _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2839 |     { | 
 | 2840 |         pointer __tmp = __ptr_.first(); | 
 | 2841 |         __ptr_.first() = nullptr; | 
 | 2842 |         if (__tmp) | 
 | 2843 |             __ptr_.second()(__tmp); | 
 | 2844 |     } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2845 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2846 |     _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) | 
 | 2847 |     { | 
 | 2848 |         pointer __tmp = __ptr_.first(); | 
 | 2849 |         __ptr_.first() = __p; | 
 | 2850 |         if (__tmp) | 
 | 2851 |             __ptr_.second()(__tmp); | 
 | 2852 |     } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2853 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2854 |  | 
 | 2855 |     _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} | 
 | 2856 | private: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2857 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2858 | #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2859 |     template <class _Up> | 
 | 2860 |         explicit unique_ptr(_Up); | 
 | 2861 |     template <class _Up> | 
 | 2862 |         unique_ptr(_Up __u, | 
 | 2863 |                    typename conditional< | 
 | 2864 |                                        is_reference<deleter_type>::value, | 
 | 2865 |                                        deleter_type, | 
 | 2866 |                                        typename add_lvalue_reference<const deleter_type>::type>::type, | 
 | 2867 |                    typename enable_if | 
 | 2868 |                       < | 
 | 2869 |                          is_convertible<_Up, pointer>::value, | 
 | 2870 |                          __nat | 
 | 2871 |                       >::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2872 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2873 | }; | 
 | 2874 |  | 
 | 2875 | template <class _Tp, class _Dp> | 
 | 2876 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2877 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2878 | swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2879 |  | 
 | 2880 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2881 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2882 | bool | 
 | 2883 | operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();} | 
 | 2884 |  | 
 | 2885 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2886 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2887 | bool | 
 | 2888 | operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);} | 
 | 2889 |  | 
 | 2890 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2891 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2892 | bool | 
 | 2893 | operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() < __y.get();} | 
 | 2894 |  | 
 | 2895 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2896 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2897 | bool | 
 | 2898 | operator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;} | 
 | 2899 |  | 
 | 2900 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2901 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2902 | bool | 
 | 2903 | operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);} | 
 | 2904 |  | 
 | 2905 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2906 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2907 | bool | 
 | 2908 | operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} | 
 | 2909 |  | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 2910 | template <class _Tp> struct hash; | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 2911 |  | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2912 | // We use murmur2 when size_t is 32 bits, and cityhash64 when size_t | 
 | 2913 | // is 64 bits.  This is because cityhash64 uses 64bit x 64bit | 
 | 2914 | // multiplication, which can be very slow on 32-bit systems. | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2915 | template <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__> | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2916 | struct __murmur2_or_cityhash; | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2917 |  | 
 | 2918 | template <class _Size> | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2919 | struct __murmur2_or_cityhash<_Size, 32> | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2920 | { | 
 | 2921 |     _Size operator()(const void* __key, _Size __len); | 
 | 2922 | }; | 
 | 2923 |  | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2924 | // murmur2 | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2925 | template <class _Size> | 
 | 2926 | _Size | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2927 | __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2928 | { | 
 | 2929 |     const _Size __m = 0x5bd1e995; | 
 | 2930 |     const _Size __r = 24; | 
 | 2931 |     _Size __h = __len; | 
 | 2932 |     const unsigned char* __data = static_cast<const unsigned char*>(__key); | 
 | 2933 |     for (; __len >= 4; __data += 4, __len -= 4) | 
 | 2934 |     { | 
 | 2935 |         _Size __k = *(const _Size*)__data; | 
 | 2936 |         __k *= __m; | 
 | 2937 |         __k ^= __k >> __r; | 
 | 2938 |         __k *= __m; | 
 | 2939 |         __h *= __m; | 
 | 2940 |         __h ^= __k; | 
 | 2941 |     } | 
 | 2942 |     switch (__len) | 
 | 2943 |     { | 
 | 2944 |     case 3: | 
 | 2945 |         __h ^= __data[2] << 16; | 
 | 2946 |     case 2: | 
 | 2947 |         __h ^= __data[1] << 8; | 
 | 2948 |     case 1: | 
 | 2949 |         __h ^= __data[0]; | 
 | 2950 |         __h *= __m; | 
 | 2951 |     } | 
 | 2952 |     __h ^= __h >> 13; | 
 | 2953 |     __h *= __m; | 
 | 2954 |     __h ^= __h >> 15; | 
 | 2955 |     return __h; | 
 | 2956 | } | 
 | 2957 |  | 
 | 2958 | template <class _Size> | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2959 | struct __murmur2_or_cityhash<_Size, 64> | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2960 | { | 
 | 2961 |     _Size operator()(const void* __key, _Size __len); | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2962 |  | 
 | 2963 |  private: | 
 | 2964 |   // Some primes between 2^63 and 2^64. | 
 | 2965 |   static const _Size __k0 = 0xc3a5c85c97cb3127ULL; | 
 | 2966 |   static const _Size __k1 = 0xb492b66fbe98f273ULL; | 
 | 2967 |   static const _Size __k2 = 0x9ae16a3b2f90404fULL; | 
 | 2968 |   static const _Size __k3 = 0xc949d7c7509e6557ULL; | 
 | 2969 |  | 
 | 2970 |   static _Size __rotate(_Size __val, int __shift) { | 
 | 2971 |     return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); | 
 | 2972 |   } | 
 | 2973 |  | 
 | 2974 |   static _Size __rotate_by_at_least_1(_Size __val, int __shift) { | 
 | 2975 |     return (__val >> __shift) | (__val << (64 - __shift)); | 
 | 2976 |   } | 
 | 2977 |  | 
 | 2978 |   static _Size __shift_mix(_Size __val) { | 
 | 2979 |     return __val ^ (__val >> 47); | 
 | 2980 |   } | 
 | 2981 |  | 
 | 2982 |   static _Size __hash_len_16(_Size __u, _Size __v) { | 
 | 2983 |     const _Size __mul = 0x9ddfea08eb382d69ULL; | 
 | 2984 |     _Size __a = (__u ^ __v) * __mul; | 
 | 2985 |     __a ^= (__a >> 47); | 
 | 2986 |     _Size __b = (__v ^ __a) * __mul; | 
 | 2987 |     __b ^= (__b >> 47); | 
 | 2988 |     __b *= __mul; | 
 | 2989 |     return __b; | 
 | 2990 |   } | 
 | 2991 |  | 
 | 2992 |   static _Size __hash_len_0_to_16(const char* __s, _Size __len) { | 
 | 2993 |     if (__len > 8) { | 
 | 2994 |       const _Size __a = *(const _Size*)__s; | 
 | 2995 |       const _Size __b = *(const _Size*)(__s + __len - 8); | 
 | 2996 |       return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; | 
 | 2997 |     } | 
 | 2998 |     if (__len >= 4) { | 
 | 2999 |       const uint32_t __a = *(const uint32_t*)(__s); | 
 | 3000 |       const uint32_t __b = *(const uint32_t*)(__s + __len - 4); | 
 | 3001 |       return __hash_len_16(__len + (__a << 3), __b); | 
 | 3002 |     } | 
 | 3003 |     if (__len > 0) { | 
 | 3004 |       const unsigned char __a = __s[0]; | 
 | 3005 |       const unsigned char __b = __s[__len >> 1]; | 
 | 3006 |       const unsigned char __c = __s[__len - 1]; | 
 | 3007 |       const uint32_t __y = static_cast<uint32_t>(__a) + | 
 | 3008 |                            (static_cast<uint32_t>(__b) << 8); | 
 | 3009 |       const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2); | 
 | 3010 |       return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; | 
 | 3011 |     } | 
 | 3012 |     return __k2; | 
 | 3013 |   } | 
 | 3014 |  | 
 | 3015 |   static _Size __hash_len_17_to_32(const char *__s, _Size __len) { | 
 | 3016 |     const _Size __a = *(const _Size*)(__s) * __k1; | 
 | 3017 |     const _Size __b = *(const _Size*)(__s + 8); | 
 | 3018 |     const _Size __c = *(const _Size*)(__s + __len - 8) * __k2; | 
 | 3019 |     const _Size __d = *(const _Size*)(__s + __len - 16) * __k0; | 
 | 3020 |     return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, | 
 | 3021 |                          __a + __rotate(__b ^ __k3, 20) - __c + __len); | 
 | 3022 |   } | 
 | 3023 |  | 
 | 3024 |   // Return a 16-byte hash for 48 bytes.  Quick and dirty. | 
 | 3025 |   // Callers do best to use "random-looking" values for a and b. | 
 | 3026 |   static pair<_Size, _Size> __weak_hash_len_32_with_seeds( | 
 | 3027 |       _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) { | 
 | 3028 |     __a += __w; | 
 | 3029 |     __b = __rotate(__b + __a + __z, 21); | 
 | 3030 |     const _Size __c = __a; | 
 | 3031 |     __a += __x; | 
 | 3032 |     __a += __y; | 
 | 3033 |     __b += __rotate(__a, 44); | 
 | 3034 |     return pair<_Size, _Size>(__a + __z, __b + __c); | 
 | 3035 |   } | 
 | 3036 |  | 
 | 3037 |   // Return a 16-byte hash for s[0] ... s[31], a, and b.  Quick and dirty. | 
 | 3038 |   static pair<_Size, _Size> __weak_hash_len_32_with_seeds( | 
 | 3039 |       const char* __s, _Size __a, _Size __b) { | 
 | 3040 |     return __weak_hash_len_32_with_seeds(*(const _Size*)(__s), | 
 | 3041 |                                          *(const _Size*)(__s + 8), | 
 | 3042 |                                          *(const _Size*)(__s + 16), | 
 | 3043 |                                          *(const _Size*)(__s + 24), | 
 | 3044 |                                          __a, | 
 | 3045 |                                          __b); | 
 | 3046 |   } | 
 | 3047 |  | 
 | 3048 |   // Return an 8-byte hash for 33 to 64 bytes. | 
 | 3049 |   static _Size __hash_len_33_to_64(const char *__s, size_t __len) { | 
 | 3050 |     _Size __z = *(const _Size*)(__s + 24); | 
 | 3051 |     _Size __a = *(const _Size*)(__s) + | 
 | 3052 |                 (__len + *(const _Size*)(__s + __len - 16)) * __k0; | 
 | 3053 |     _Size __b = __rotate(__a + __z, 52); | 
 | 3054 |     _Size __c = __rotate(__a, 37); | 
 | 3055 |     __a += *(const _Size*)(__s + 8); | 
 | 3056 |     __c += __rotate(__a, 7); | 
 | 3057 |     __a += *(const _Size*)(__s + 16); | 
 | 3058 |     _Size __vf = __a + __z; | 
 | 3059 |     _Size __vs = __b + __rotate(__a, 31) + __c; | 
 | 3060 |     __a = *(const _Size*)(__s + 16) + *(const _Size*)(__s + __len - 32); | 
 | 3061 |     __z += *(const _Size*)(__s + __len - 8); | 
 | 3062 |     __b = __rotate(__a + __z, 52); | 
 | 3063 |     __c = __rotate(__a, 37); | 
 | 3064 |     __a += *(const _Size*)(__s + __len - 24); | 
 | 3065 |     __c += __rotate(__a, 7); | 
 | 3066 |     __a += *(const _Size*)(__s + __len - 16); | 
 | 3067 |     _Size __wf = __a + __z; | 
 | 3068 |     _Size __ws = __b + __rotate(__a, 31) + __c; | 
 | 3069 |     _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); | 
 | 3070 |     return __shift_mix(__r * __k0 + __vs) * __k2; | 
 | 3071 |   } | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 3072 | }; | 
 | 3073 |  | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3074 | // cityhash64 | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 3075 | template <class _Size> | 
 | 3076 | _Size | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3077 | __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 3078 | { | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3079 |   const char* __s = static_cast<const char*>(__key); | 
 | 3080 |   if (__len <= 32) { | 
 | 3081 |     if (__len <= 16) { | 
 | 3082 |       return __hash_len_0_to_16(__s, __len); | 
 | 3083 |     } else { | 
 | 3084 |       return __hash_len_17_to_32(__s, __len); | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 3085 |     } | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3086 |   } else if (__len <= 64) { | 
 | 3087 |     return __hash_len_33_to_64(__s, __len); | 
 | 3088 |   } | 
 | 3089 |  | 
 | 3090 |   // For strings over 64 bytes we hash the end first, and then as we | 
 | 3091 |   // loop we keep 56 bytes of state: v, w, x, y, and z. | 
 | 3092 |   _Size __x = *(const _Size*)(__s + __len - 40); | 
 | 3093 |   _Size __y = *(const _Size*)(__s + __len - 16) + | 
 | 3094 |               *(const _Size*)(__s + __len - 56); | 
 | 3095 |   _Size __z = __hash_len_16(*(const _Size*)(__s + __len - 48) + __len, | 
 | 3096 |                           *(const _Size*)(__s + __len - 24)); | 
 | 3097 |   pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); | 
 | 3098 |   pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); | 
 | 3099 |   __x = __x * __k1 + *(const _Size*)(__s); | 
 | 3100 |  | 
 | 3101 |   // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. | 
 | 3102 |   __len = (__len - 1) & ~static_cast<_Size>(63); | 
 | 3103 |   do { | 
 | 3104 |     __x = __rotate(__x + __y + __v.first + *(const _Size*)(__s + 8), 37) * __k1; | 
 | 3105 |     __y = __rotate(__y + __v.second + *(const _Size*)(__s + 48), 42) * __k1; | 
 | 3106 |     __x ^= __w.second; | 
 | 3107 |     __y += __v.first + *(const _Size*)(__s + 40); | 
 | 3108 |     __z = __rotate(__z + __w.first, 33) * __k1; | 
 | 3109 |     __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); | 
 | 3110 |     __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, | 
 | 3111 |                                         __y + *(const _Size*)(__s + 16)); | 
 | 3112 |     std::swap(__z, __x); | 
 | 3113 |     __s += 64; | 
 | 3114 |     __len -= 64; | 
 | 3115 |   } while (__len != 0); | 
 | 3116 |   return __hash_len_16( | 
 | 3117 |       __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, | 
 | 3118 |       __hash_len_16(__v.second, __w.second) + __x); | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 3119 | } | 
 | 3120 |  | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3121 | template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> | 
 | 3122 | struct __scalar_hash; | 
 | 3123 |  | 
 | 3124 | template <class _Tp> | 
 | 3125 | struct __scalar_hash<_Tp, 0> | 
 | 3126 |     : public unary_function<_Tp, size_t> | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3127 | { | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3128 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3129 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3130 |     { | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3131 |         union | 
 | 3132 |         { | 
 | 3133 |             _Tp    __t; | 
 | 3134 |             size_t __a; | 
 | 3135 |         } __u; | 
 | 3136 |         __u.__a = 0; | 
 | 3137 |         __u.__t = __v; | 
 | 3138 |         return __u.__a; | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3139 |     } | 
 | 3140 | }; | 
 | 3141 |  | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3142 | template <class _Tp> | 
 | 3143 | struct __scalar_hash<_Tp, 1> | 
 | 3144 |     : public unary_function<_Tp, size_t> | 
 | 3145 | { | 
 | 3146 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3147 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
 | 3148 |     { | 
 | 3149 |         union | 
 | 3150 |         { | 
 | 3151 |             _Tp    __t; | 
 | 3152 |             size_t __a; | 
 | 3153 |         } __u; | 
 | 3154 |         __u.__t = __v; | 
 | 3155 |         return __u.__a; | 
 | 3156 |     } | 
 | 3157 | }; | 
 | 3158 |  | 
 | 3159 | template <class _Tp> | 
 | 3160 | struct __scalar_hash<_Tp, 2> | 
 | 3161 |     : public unary_function<_Tp, size_t> | 
 | 3162 | { | 
 | 3163 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3164 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
 | 3165 |     { | 
 | 3166 |         union | 
 | 3167 |         { | 
 | 3168 |             _Tp __t; | 
 | 3169 |             struct | 
 | 3170 |             { | 
 | 3171 |                 size_t __a; | 
 | 3172 |                 size_t __b; | 
 | 3173 |             }; | 
 | 3174 |         } __u; | 
 | 3175 |         __u.__t = __v; | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3176 |         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3177 |     } | 
 | 3178 | }; | 
 | 3179 |  | 
 | 3180 | template <class _Tp> | 
 | 3181 | struct __scalar_hash<_Tp, 3> | 
 | 3182 |     : public unary_function<_Tp, size_t> | 
 | 3183 | { | 
 | 3184 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3185 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
 | 3186 |     { | 
 | 3187 |         union | 
 | 3188 |         { | 
 | 3189 |             _Tp __t; | 
 | 3190 |             struct | 
 | 3191 |             { | 
 | 3192 |                 size_t __a; | 
 | 3193 |                 size_t __b; | 
 | 3194 |                 size_t __c; | 
 | 3195 |             }; | 
 | 3196 |         } __u; | 
 | 3197 |         __u.__t = __v; | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3198 |         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3199 |     } | 
 | 3200 | }; | 
 | 3201 |  | 
 | 3202 | template <class _Tp> | 
 | 3203 | struct __scalar_hash<_Tp, 4> | 
 | 3204 |     : public unary_function<_Tp, size_t> | 
 | 3205 | { | 
 | 3206 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3207 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
 | 3208 |     { | 
 | 3209 |         union | 
 | 3210 |         { | 
 | 3211 |             _Tp __t; | 
 | 3212 |             struct | 
 | 3213 |             { | 
 | 3214 |                 size_t __a; | 
 | 3215 |                 size_t __b; | 
 | 3216 |                 size_t __c; | 
 | 3217 |                 size_t __d; | 
 | 3218 |             }; | 
 | 3219 |         } __u; | 
 | 3220 |         __u.__t = __v; | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3221 |         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3222 |     } | 
 | 3223 | }; | 
 | 3224 |  | 
 | 3225 | template<class _Tp> | 
 | 3226 | struct _LIBCPP_VISIBLE hash<_Tp*> | 
 | 3227 |     : public __scalar_hash<_Tp*> | 
 | 3228 | { | 
 | 3229 | }; | 
 | 3230 |  | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3231 | template <class _Tp, class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3232 | struct _LIBCPP_VISIBLE hash<unique_ptr<_Tp, _Dp> > | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3233 | { | 
 | 3234 |     typedef unique_ptr<_Tp, _Dp> argument_type; | 
 | 3235 |     typedef size_t               result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3236 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3237 |     result_type operator()(const argument_type& __ptr) const _NOEXCEPT | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3238 |     { | 
 | 3239 |         typedef typename argument_type::pointer pointer; | 
 | 3240 |         return hash<pointer>()(__ptr.get()); | 
 | 3241 |     } | 
 | 3242 | }; | 
 | 3243 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3244 | struct __destruct_n | 
 | 3245 | { | 
 | 3246 | private: | 
 | 3247 |     size_t size; | 
 | 3248 |  | 
 | 3249 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3250 |     _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3251 |         {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} | 
 | 3252 |  | 
 | 3253 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3254 |     _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3255 |         {} | 
 | 3256 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3257 |     _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3258 |         {++size;} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3259 |     _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3260 |         {} | 
 | 3261 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3262 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3263 |         {size = __s;} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3264 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3265 |         {} | 
 | 3266 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3267 |     _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT | 
 | 3268 |         : size(__s) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3269 |  | 
 | 3270 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3271 |     _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT | 
| Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 3272 |         {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3273 |  | 
 | 3274 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3275 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT | 
| Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 3276 |         {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3277 |  | 
 | 3278 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3279 |     _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT | 
| Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 3280 |         {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3281 | }; | 
 | 3282 |  | 
 | 3283 | template <class _Alloc> | 
 | 3284 | class __allocator_destructor | 
 | 3285 | { | 
 | 3286 |     typedef allocator_traits<_Alloc> __alloc_traits; | 
 | 3287 | public: | 
 | 3288 |     typedef typename __alloc_traits::pointer pointer; | 
 | 3289 |     typedef typename __alloc_traits::size_type size_type; | 
 | 3290 | private: | 
 | 3291 |     _Alloc& __alloc_; | 
 | 3292 |     size_type __s_; | 
 | 3293 | public: | 
 | 3294 |     _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3295 |              _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3296 |         : __alloc_(__a), __s_(__s) {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3297 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3298 |     void operator()(pointer __p) _NOEXCEPT | 
 | 3299 |         {__alloc_traits::deallocate(__alloc_, __p, __s_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3300 | }; | 
 | 3301 |  | 
 | 3302 | template <class _InputIterator, class _ForwardIterator> | 
 | 3303 | _ForwardIterator | 
 | 3304 | uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) | 
 | 3305 | { | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3306 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
| Howard Hinnant | 8292d74 | 2011-12-29 17:45:35 +0000 | [diff] [blame] | 3307 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3308 |     _ForwardIterator __s = __r; | 
 | 3309 |     try | 
 | 3310 |     { | 
 | 3311 | #endif | 
 | 3312 |         for (; __f != __l; ++__f, ++__r) | 
 | 3313 |             ::new(&*__r) value_type(*__f); | 
 | 3314 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3315 |     } | 
 | 3316 |     catch (...) | 
 | 3317 |     { | 
 | 3318 |         for (; __s != __r; ++__s) | 
 | 3319 |             __s->~value_type(); | 
 | 3320 |         throw; | 
 | 3321 |     } | 
 | 3322 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3323 |     return __r; | 
 | 3324 | } | 
 | 3325 |  | 
 | 3326 | template <class _InputIterator, class _Size, class _ForwardIterator> | 
 | 3327 | _ForwardIterator | 
 | 3328 | uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) | 
 | 3329 | { | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3330 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
| Howard Hinnant | 8292d74 | 2011-12-29 17:45:35 +0000 | [diff] [blame] | 3331 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3332 |     _ForwardIterator __s = __r; | 
 | 3333 |     try | 
 | 3334 |     { | 
 | 3335 | #endif | 
 | 3336 |         for (; __n > 0; ++__f, ++__r, --__n) | 
 | 3337 |             ::new(&*__r) value_type(*__f); | 
 | 3338 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3339 |     } | 
 | 3340 |     catch (...) | 
 | 3341 |     { | 
 | 3342 |         for (; __s != __r; ++__s) | 
 | 3343 |             __s->~value_type(); | 
 | 3344 |         throw; | 
 | 3345 |     } | 
 | 3346 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3347 |     return __r; | 
 | 3348 | } | 
 | 3349 |  | 
 | 3350 | template <class _ForwardIterator, class _Tp> | 
 | 3351 | void | 
 | 3352 | uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) | 
 | 3353 | { | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3354 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
| Howard Hinnant | 8292d74 | 2011-12-29 17:45:35 +0000 | [diff] [blame] | 3355 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3356 |     _ForwardIterator __s = __f; | 
 | 3357 |     try | 
 | 3358 |     { | 
 | 3359 | #endif | 
 | 3360 |         for (; __f != __l; ++__f) | 
 | 3361 |             ::new(&*__f) value_type(__x); | 
 | 3362 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3363 |     } | 
 | 3364 |     catch (...) | 
 | 3365 |     { | 
 | 3366 |         for (; __s != __f; ++__s) | 
 | 3367 |             __s->~value_type(); | 
 | 3368 |         throw; | 
 | 3369 |     } | 
 | 3370 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3371 | } | 
 | 3372 |  | 
 | 3373 | template <class _ForwardIterator, class _Size, class _Tp> | 
| Howard Hinnant | 2f6a627 | 2010-11-18 16:13:03 +0000 | [diff] [blame] | 3374 | _ForwardIterator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3375 | uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) | 
 | 3376 | { | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3377 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
| Howard Hinnant | 8292d74 | 2011-12-29 17:45:35 +0000 | [diff] [blame] | 3378 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3379 |     _ForwardIterator __s = __f; | 
 | 3380 |     try | 
 | 3381 |     { | 
 | 3382 | #endif | 
 | 3383 |         for (; __n > 0; ++__f, --__n) | 
 | 3384 |             ::new(&*__f) value_type(__x); | 
 | 3385 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3386 |     } | 
 | 3387 |     catch (...) | 
 | 3388 |     { | 
 | 3389 |         for (; __s != __f; ++__s) | 
 | 3390 |             __s->~value_type(); | 
 | 3391 |         throw; | 
 | 3392 |     } | 
 | 3393 | #endif | 
| Howard Hinnant | 2f6a627 | 2010-11-18 16:13:03 +0000 | [diff] [blame] | 3394 |     return __f; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3395 | } | 
 | 3396 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3397 | class _LIBCPP_EXCEPTION_ABI bad_weak_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3398 |     : public std::exception | 
 | 3399 | { | 
 | 3400 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3401 |     virtual ~bad_weak_ptr() _NOEXCEPT; | 
 | 3402 |     virtual const char* what() const  _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3403 | }; | 
 | 3404 |  | 
 | 3405 | template<class _Tp> class weak_ptr; | 
 | 3406 |  | 
 | 3407 | class __shared_count | 
 | 3408 | { | 
 | 3409 |     __shared_count(const __shared_count&); | 
 | 3410 |     __shared_count& operator=(const __shared_count&); | 
 | 3411 |  | 
 | 3412 | protected: | 
 | 3413 |     long __shared_owners_; | 
 | 3414 |     virtual ~__shared_count(); | 
 | 3415 | private: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3416 |     virtual void __on_zero_shared() _NOEXCEPT = 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3417 |  | 
 | 3418 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3419 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3420 |     explicit __shared_count(long __refs = 0) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3421 |         : __shared_owners_(__refs) {} | 
 | 3422 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3423 |     void __add_shared() _NOEXCEPT; | 
 | 3424 |     bool __release_shared() _NOEXCEPT; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3425 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3426 |     long use_count() const _NOEXCEPT {return __shared_owners_ + 1;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3427 | }; | 
 | 3428 |  | 
 | 3429 | class __shared_weak_count | 
 | 3430 |     : private __shared_count | 
 | 3431 | { | 
 | 3432 |     long __shared_weak_owners_; | 
 | 3433 |  | 
 | 3434 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3435 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3436 |     explicit __shared_weak_count(long __refs = 0) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3437 |         : __shared_count(__refs), | 
 | 3438 |           __shared_weak_owners_(__refs) {} | 
 | 3439 | protected: | 
 | 3440 |     virtual ~__shared_weak_count(); | 
 | 3441 |  | 
 | 3442 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3443 |     void __add_shared() _NOEXCEPT; | 
 | 3444 |     void __add_weak() _NOEXCEPT; | 
 | 3445 |     void __release_shared() _NOEXCEPT; | 
 | 3446 |     void __release_weak() _NOEXCEPT; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3447 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3448 |     long use_count() const _NOEXCEPT {return __shared_count::use_count();} | 
 | 3449 |     __shared_weak_count* lock() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3450 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3451 |     virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3452 | private: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3453 |     virtual void __on_zero_shared_weak() _NOEXCEPT = 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3454 | }; | 
 | 3455 |  | 
 | 3456 | template <class _Tp, class _Dp, class _Alloc> | 
 | 3457 | class __shared_ptr_pointer | 
 | 3458 |     : public __shared_weak_count | 
 | 3459 | { | 
 | 3460 |     __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; | 
 | 3461 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3462 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3463 |     __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3464 |         :  __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3465 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3466 | #ifndef _LIBCPP_NO_RTTI | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3467 |     virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3468 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3469 |  | 
 | 3470 | private: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3471 |     virtual void __on_zero_shared() _NOEXCEPT; | 
 | 3472 |     virtual void __on_zero_shared_weak() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3473 | }; | 
 | 3474 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3475 | #ifndef _LIBCPP_NO_RTTI | 
 | 3476 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3477 | template <class _Tp, class _Dp, class _Alloc> | 
 | 3478 | const void* | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3479 | __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3480 | { | 
 | 3481 |     return __t == typeid(_Dp) ? &__data_.first().second() : 0; | 
 | 3482 | } | 
 | 3483 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3484 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3485 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3486 | template <class _Tp, class _Dp, class _Alloc> | 
 | 3487 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3488 | __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3489 | { | 
 | 3490 |     __data_.first().second()(__data_.first().first()); | 
 | 3491 |     __data_.first().second().~_Dp(); | 
 | 3492 | } | 
 | 3493 |  | 
 | 3494 | template <class _Tp, class _Dp, class _Alloc> | 
 | 3495 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3496 | __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3497 | { | 
 | 3498 |     typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second()); | 
 | 3499 |     __data_.second().~_Alloc(); | 
 | 3500 |     __a.deallocate(this, 1); | 
 | 3501 | } | 
 | 3502 |  | 
 | 3503 | template <class _Tp, class _Alloc> | 
 | 3504 | class __shared_ptr_emplace | 
 | 3505 |     : public __shared_weak_count | 
 | 3506 | { | 
 | 3507 |     __compressed_pair<_Alloc, _Tp> __data_; | 
 | 3508 | public: | 
 | 3509 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 3510 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3511 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3512 |     __shared_ptr_emplace(_Alloc __a) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3513 |         :  __data_(_VSTD::move(__a)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3514 |  | 
 | 3515 |     template <class ..._Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3516 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3517 |         __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 3518 |             :  __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), | 
 | 3519 |                    _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3520 |  | 
 | 3521 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3522 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3523 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3524 |     __shared_ptr_emplace(_Alloc __a) | 
 | 3525 |         :  __data_(__a) {} | 
 | 3526 |  | 
 | 3527 |     template <class _A0> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3528 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3529 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0) | 
 | 3530 |             :  __data_(__a, _Tp(__a0)) {} | 
 | 3531 |  | 
 | 3532 |     template <class _A0, class _A1> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3533 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3534 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1) | 
 | 3535 |             :  __data_(__a, _Tp(__a0, __a1)) {} | 
 | 3536 |  | 
 | 3537 |     template <class _A0, class _A1, class _A2> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3538 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3539 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 3540 |             :  __data_(__a, _Tp(__a0, __a1, __a2)) {} | 
 | 3541 |  | 
 | 3542 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3543 |  | 
 | 3544 | private: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3545 |     virtual void __on_zero_shared() _NOEXCEPT; | 
 | 3546 |     virtual void __on_zero_shared_weak() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3547 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3548 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3549 |     _Tp* get() _NOEXCEPT {return &__data_.second();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3550 | }; | 
 | 3551 |  | 
 | 3552 | template <class _Tp, class _Alloc> | 
 | 3553 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3554 | __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3555 | { | 
 | 3556 |     __data_.second().~_Tp(); | 
 | 3557 | } | 
 | 3558 |  | 
 | 3559 | template <class _Tp, class _Alloc> | 
 | 3560 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3561 | __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3562 | { | 
 | 3563 |     typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first()); | 
 | 3564 |     __data_.first().~_Alloc(); | 
 | 3565 |     __a.deallocate(this, 1); | 
 | 3566 | } | 
 | 3567 |  | 
 | 3568 | template<class _Tp> class enable_shared_from_this; | 
 | 3569 |  | 
 | 3570 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3571 | class _LIBCPP_VISIBLE shared_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3572 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3573 | public: | 
 | 3574 |     typedef _Tp element_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3575 | private: | 
 | 3576 |     element_type*      __ptr_; | 
 | 3577 |     __shared_weak_count* __cntrl_; | 
 | 3578 |  | 
 | 3579 |     struct __nat {int __for_bool_;}; | 
 | 3580 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3581 |     shared_ptr() _NOEXCEPT; | 
 | 3582 |     shared_ptr(nullptr_t) _NOEXCEPT; | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3583 |     template<class _Yp, | 
 | 3584 |              class = typename enable_if | 
 | 3585 |                      < | 
 | 3586 |                         is_convertible<_Yp*, element_type*>::value | 
 | 3587 |                      >::type | 
 | 3588 |             > | 
 | 3589 |         explicit shared_ptr(_Yp* __p); | 
 | 3590 |     template<class _Yp, class _Dp, | 
 | 3591 |              class = typename enable_if | 
 | 3592 |                      < | 
 | 3593 |                         is_convertible<_Yp*, element_type*>::value | 
 | 3594 |                      >::type | 
 | 3595 |             > | 
 | 3596 |         shared_ptr(_Yp* __p, _Dp __d); | 
 | 3597 |     template<class _Yp, class _Dp, class _Alloc, | 
 | 3598 |              class = typename enable_if | 
 | 3599 |                      < | 
 | 3600 |                         is_convertible<_Yp*, element_type*>::value | 
 | 3601 |                      >::type | 
 | 3602 |             > | 
 | 3603 |         shared_ptr(_Yp* __p, _Dp __d, _Alloc __a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3604 |     template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); | 
 | 3605 |     template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3606 |     template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; | 
 | 3607 |     shared_ptr(const shared_ptr& __r) _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3608 |     template<class _Yp> | 
 | 3609 |         shared_ptr(const shared_ptr<_Yp>& __r, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3610 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) | 
 | 3611 |                        _NOEXCEPT; | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3612 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3613 |     shared_ptr(shared_ptr&& __r) _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3614 |     template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3615 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) | 
 | 3616 |                        _NOEXCEPT; | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3617 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3618 |     template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3619 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3620 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3621 |     template<class _Yp, | 
 | 3622 |              class = typename enable_if | 
 | 3623 |                      < | 
 | 3624 |                         is_convertible<_Yp*, element_type*>::value | 
 | 3625 |                      >::type | 
 | 3626 |             > | 
 | 3627 |         shared_ptr(auto_ptr<_Yp>&& __r); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3628 | #else | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3629 |     template<class _Yp, | 
 | 3630 |              class = typename enable_if | 
 | 3631 |                      < | 
 | 3632 |                         is_convertible<_Yp*, element_type*>::value | 
 | 3633 |                      >::type | 
 | 3634 |             > | 
 | 3635 |         shared_ptr(auto_ptr<_Yp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3636 | #endif | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3637 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3638 |     template <class _Yp, class _Dp, | 
 | 3639 |                  class = typename enable_if | 
 | 3640 |                  < | 
 | 3641 |                     !is_array<_Yp>::value && | 
 | 3642 |                     is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value | 
 | 3643 |                  >::type | 
 | 3644 |              > | 
 | 3645 |        shared_ptr(unique_ptr<_Yp, _Dp>&&, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3646 |        typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3647 |     template <class _Yp, class _Dp, | 
 | 3648 |                  class = typename enable_if | 
 | 3649 |                  < | 
 | 3650 |                     !is_array<_Yp>::value && | 
 | 3651 |                     is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value | 
 | 3652 |                  >::type | 
 | 3653 |              > | 
 | 3654 |        shared_ptr(unique_ptr<_Yp, _Dp>&&, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3655 |        typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3656 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3657 |     template <class _Yp, class _Dp, | 
 | 3658 |                  class = typename enable_if | 
 | 3659 |                  < | 
 | 3660 |                     !is_array<_Yp>::value && | 
 | 3661 |                     is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value | 
 | 3662 |                  >::type | 
 | 3663 |              > shared_ptr(unique_ptr<_Yp, _Dp>, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3664 |        typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3665 |     template <class _Yp, class _Dp, | 
 | 3666 |                  class = typename enable_if | 
 | 3667 |                  < | 
 | 3668 |                     !is_array<_Yp>::value && | 
 | 3669 |                     is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value | 
 | 3670 |                  >::type | 
 | 3671 |              > | 
 | 3672 |        shared_ptr(unique_ptr<_Yp, _Dp>, | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3673 |        typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3674 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3675 |  | 
 | 3676 |     ~shared_ptr(); | 
 | 3677 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3678 |     shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3679 |     template<class _Yp> | 
 | 3680 |         typename enable_if | 
 | 3681 |         < | 
 | 3682 |             is_convertible<_Yp*, element_type*>::value, | 
 | 3683 |             shared_ptr& | 
 | 3684 |         >::type | 
 | 3685 |         operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3686 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3687 |     shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3688 |     template<class _Yp> | 
 | 3689 |         typename enable_if | 
 | 3690 |         < | 
 | 3691 |             is_convertible<_Yp*, element_type*>::value, | 
 | 3692 |             shared_ptr<_Tp>& | 
 | 3693 |         >::type | 
 | 3694 |         operator=(shared_ptr<_Yp>&& __r); | 
 | 3695 |     template<class _Yp> | 
 | 3696 |         typename enable_if | 
 | 3697 |         < | 
 | 3698 |             !is_array<_Yp>::value && | 
 | 3699 |             is_convertible<_Yp*, element_type*>::value, | 
 | 3700 |             shared_ptr& | 
 | 3701 |         >::type | 
 | 3702 |         operator=(auto_ptr<_Yp>&& __r); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3703 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3704 |     template<class _Yp> | 
 | 3705 |         typename enable_if | 
 | 3706 |         < | 
 | 3707 |             !is_array<_Yp>::value && | 
 | 3708 |             is_convertible<_Yp*, element_type*>::value, | 
 | 3709 |             shared_ptr& | 
 | 3710 |         >::type | 
 | 3711 |         operator=(auto_ptr<_Yp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3712 | #endif | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3713 |     template <class _Yp, class _Dp> | 
 | 3714 |         typename enable_if | 
 | 3715 |         < | 
 | 3716 |             !is_array<_Yp>::value && | 
 | 3717 |             is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | 
 | 3718 |             shared_ptr& | 
 | 3719 |         >::type | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3720 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3721 |         operator=(unique_ptr<_Yp, _Dp>&& __r); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3722 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3723 |         operator=(unique_ptr<_Yp, _Dp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3724 | #endif | 
 | 3725 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3726 |     void swap(shared_ptr& __r) _NOEXCEPT; | 
 | 3727 |     void reset() _NOEXCEPT; | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3728 |     template<class _Yp> | 
 | 3729 |         typename enable_if | 
 | 3730 |         < | 
 | 3731 |             is_convertible<_Yp*, element_type*>::value, | 
 | 3732 |             void | 
 | 3733 |         >::type | 
 | 3734 |         reset(_Yp* __p); | 
 | 3735 |     template<class _Yp, class _Dp> | 
 | 3736 |         typename enable_if | 
 | 3737 |         < | 
 | 3738 |             is_convertible<_Yp*, element_type*>::value, | 
 | 3739 |             void | 
 | 3740 |         >::type | 
 | 3741 |         reset(_Yp* __p, _Dp __d); | 
 | 3742 |     template<class _Yp, class _Dp, class _Alloc> | 
 | 3743 |         typename enable_if | 
 | 3744 |         < | 
 | 3745 |             is_convertible<_Yp*, element_type*>::value, | 
 | 3746 |             void | 
 | 3747 |         >::type | 
 | 3748 |         reset(_Yp* __p, _Dp __d, _Alloc __a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3749 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3750 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3751 |     element_type* get() const _NOEXCEPT {return __ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3752 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3753 |     typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT | 
 | 3754 |         {return *__ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3755 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3756 |     element_type* operator->() const _NOEXCEPT {return __ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3757 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3758 |     long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3759 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3760 |     bool unique() const _NOEXCEPT {return use_count() == 1;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3761 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3762 |     /*explicit*/ operator bool() const _NOEXCEPT {return get() != 0;} | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3763 |     template <class _Up> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3764 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3765 |         bool owner_before(shared_ptr<_Up> const& __p) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3766 |         {return __cntrl_ < __p.__cntrl_;} | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3767 |     template <class _Up> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3768 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3769 |         bool owner_before(weak_ptr<_Up> const& __p) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3770 |         {return __cntrl_ < __p.__cntrl_;} | 
 | 3771 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3772 | #ifndef _LIBCPP_NO_RTTI | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3773 |     template <class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3774 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3775 |         _Dp* __get_deleter() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3776 |             {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3777 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3778 |  | 
 | 3779 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 3780 |  | 
 | 3781 |     template<class ..._Args> | 
 | 3782 |         static | 
 | 3783 |         shared_ptr<_Tp> | 
 | 3784 |         make_shared(_Args&& ...__args); | 
 | 3785 |  | 
 | 3786 |     template<class _Alloc, class ..._Args> | 
 | 3787 |         static | 
 | 3788 |         shared_ptr<_Tp> | 
 | 3789 |         allocate_shared(const _Alloc& __a, _Args&& ...__args); | 
 | 3790 |  | 
 | 3791 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3792 |  | 
 | 3793 |     static shared_ptr<_Tp> make_shared(); | 
 | 3794 |  | 
 | 3795 |     template<class _A0> | 
 | 3796 |         static shared_ptr<_Tp> make_shared(_A0&); | 
 | 3797 |  | 
 | 3798 |     template<class _A0, class _A1> | 
 | 3799 |         static shared_ptr<_Tp> make_shared(_A0&, _A1&); | 
 | 3800 |  | 
 | 3801 |     template<class _A0, class _A1, class _A2> | 
 | 3802 |         static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&); | 
 | 3803 |  | 
 | 3804 |     template<class _Alloc> | 
 | 3805 |         static shared_ptr<_Tp> | 
 | 3806 |         allocate_shared(const _Alloc& __a); | 
 | 3807 |  | 
 | 3808 |     template<class _Alloc, class _A0> | 
 | 3809 |         static shared_ptr<_Tp> | 
 | 3810 |         allocate_shared(const _Alloc& __a, _A0& __a0); | 
 | 3811 |  | 
 | 3812 |     template<class _Alloc, class _A0, class _A1> | 
 | 3813 |         static shared_ptr<_Tp> | 
 | 3814 |         allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1); | 
 | 3815 |  | 
 | 3816 |     template<class _Alloc, class _A0, class _A1, class _A2> | 
 | 3817 |         static shared_ptr<_Tp> | 
 | 3818 |         allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2); | 
 | 3819 |  | 
 | 3820 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3821 |  | 
 | 3822 | private: | 
 | 3823 |  | 
 | 3824 |     template <class _Yp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3825 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3826 |         void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3827 |         __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3828 |         { | 
 | 3829 |             if (__e) | 
 | 3830 |                 __e->__weak_this_ = *this; | 
 | 3831 |         } | 
 | 3832 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3833 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3834 |     void __enable_weak_this(const void*) _NOEXCEPT {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3835 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3836 |     template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; | 
 | 3837 |     template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3838 | }; | 
 | 3839 |  | 
 | 3840 | template<class _Tp> | 
 | 3841 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3842 | shared_ptr<_Tp>::shared_ptr() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3843 |     : __ptr_(0), | 
 | 3844 |       __cntrl_(0) | 
 | 3845 | { | 
 | 3846 | } | 
 | 3847 |  | 
 | 3848 | template<class _Tp> | 
 | 3849 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3850 | shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3851 |     : __ptr_(0), | 
 | 3852 |       __cntrl_(0) | 
 | 3853 | { | 
 | 3854 | } | 
 | 3855 |  | 
 | 3856 | template<class _Tp> | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3857 | template<class _Yp, class> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3858 | shared_ptr<_Tp>::shared_ptr(_Yp* __p) | 
 | 3859 |     : __ptr_(__p) | 
 | 3860 | { | 
 | 3861 |     unique_ptr<_Yp> __hold(__p); | 
 | 3862 |     typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | 
 | 3863 |     __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); | 
 | 3864 |     __hold.release(); | 
 | 3865 |     __enable_weak_this(__p); | 
 | 3866 | } | 
 | 3867 |  | 
 | 3868 | template<class _Tp> | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3869 | template<class _Yp, class _Dp, class> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3870 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d) | 
 | 3871 |     : __ptr_(__p) | 
 | 3872 | { | 
 | 3873 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3874 |     try | 
 | 3875 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3876 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3877 |         typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; | 
 | 3878 |         __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); | 
 | 3879 |         __enable_weak_this(__p); | 
 | 3880 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3881 |     } | 
 | 3882 |     catch (...) | 
 | 3883 |     { | 
 | 3884 |         __d(__p); | 
 | 3885 |         throw; | 
 | 3886 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3887 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3888 | } | 
 | 3889 |  | 
 | 3890 | template<class _Tp> | 
 | 3891 | template<class _Dp> | 
 | 3892 | shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) | 
 | 3893 |     : __ptr_(0) | 
 | 3894 | { | 
 | 3895 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3896 |     try | 
 | 3897 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3898 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3899 |         typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; | 
 | 3900 |         __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); | 
 | 3901 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3902 |     } | 
 | 3903 |     catch (...) | 
 | 3904 |     { | 
 | 3905 |         __d(__p); | 
 | 3906 |         throw; | 
 | 3907 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3908 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3909 | } | 
 | 3910 |  | 
 | 3911 | template<class _Tp> | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 3912 | template<class _Yp, class _Dp, class _Alloc, class> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3913 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) | 
 | 3914 |     : __ptr_(__p) | 
 | 3915 | { | 
 | 3916 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3917 |     try | 
 | 3918 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3919 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3920 |         typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; | 
 | 3921 |         typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 3922 |         typedef __allocator_destructor<_A2> _D2; | 
 | 3923 |         _A2 __a2(__a); | 
 | 3924 |         unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
 | 3925 |         ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); | 
 | 3926 |         __cntrl_ = __hold2.release(); | 
 | 3927 |         __enable_weak_this(__p); | 
 | 3928 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3929 |     } | 
 | 3930 |     catch (...) | 
 | 3931 |     { | 
 | 3932 |         __d(__p); | 
 | 3933 |         throw; | 
 | 3934 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3935 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3936 | } | 
 | 3937 |  | 
 | 3938 | template<class _Tp> | 
 | 3939 | template<class _Dp, class _Alloc> | 
 | 3940 | shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) | 
 | 3941 |     : __ptr_(0) | 
 | 3942 | { | 
 | 3943 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3944 |     try | 
 | 3945 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3946 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3947 |         typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; | 
 | 3948 |         typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 3949 |         typedef __allocator_destructor<_A2> _D2; | 
 | 3950 |         _A2 __a2(__a); | 
 | 3951 |         unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
 | 3952 |         ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); | 
 | 3953 |         __cntrl_ = __hold2.release(); | 
 | 3954 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3955 |     } | 
 | 3956 |     catch (...) | 
 | 3957 |     { | 
 | 3958 |         __d(__p); | 
 | 3959 |         throw; | 
 | 3960 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3961 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3962 | } | 
 | 3963 |  | 
 | 3964 | template<class _Tp> | 
 | 3965 | template<class _Yp> | 
 | 3966 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3967 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3968 |     : __ptr_(__p), | 
 | 3969 |       __cntrl_(__r.__cntrl_) | 
 | 3970 | { | 
 | 3971 |     if (__cntrl_) | 
 | 3972 |         __cntrl_->__add_shared(); | 
 | 3973 | } | 
 | 3974 |  | 
 | 3975 | template<class _Tp> | 
 | 3976 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3977 | shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3978 |     : __ptr_(__r.__ptr_), | 
 | 3979 |       __cntrl_(__r.__cntrl_) | 
 | 3980 | { | 
 | 3981 |     if (__cntrl_) | 
 | 3982 |         __cntrl_->__add_shared(); | 
 | 3983 | } | 
 | 3984 |  | 
 | 3985 | template<class _Tp> | 
 | 3986 | template<class _Yp> | 
 | 3987 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3988 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, | 
 | 3989 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3990 |          _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3991 |     : __ptr_(__r.__ptr_), | 
 | 3992 |       __cntrl_(__r.__cntrl_) | 
 | 3993 | { | 
 | 3994 |     if (__cntrl_) | 
 | 3995 |         __cntrl_->__add_shared(); | 
 | 3996 | } | 
 | 3997 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3998 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3999 |  | 
 | 4000 | template<class _Tp> | 
 | 4001 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4002 | shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4003 |     : __ptr_(__r.__ptr_), | 
 | 4004 |       __cntrl_(__r.__cntrl_) | 
 | 4005 | { | 
 | 4006 |     __r.__ptr_ = 0; | 
 | 4007 |     __r.__cntrl_ = 0; | 
 | 4008 | } | 
 | 4009 |  | 
 | 4010 | template<class _Tp> | 
 | 4011 | template<class _Yp> | 
 | 4012 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4013 | shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, | 
 | 4014 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4015 |          _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4016 |     : __ptr_(__r.__ptr_), | 
 | 4017 |       __cntrl_(__r.__cntrl_) | 
 | 4018 | { | 
 | 4019 |     __r.__ptr_ = 0; | 
 | 4020 |     __r.__cntrl_ = 0; | 
 | 4021 | } | 
 | 4022 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4023 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4024 |  | 
 | 4025 | template<class _Tp> | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4026 | template<class _Yp, class> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4027 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4028 | shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r) | 
 | 4029 | #else | 
| Howard Hinnant | 92172b8 | 2010-08-21 21:14:53 +0000 | [diff] [blame] | 4030 | shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4031 | #endif | 
 | 4032 |     : __ptr_(__r.get()) | 
 | 4033 | { | 
 | 4034 |     typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | 
 | 4035 |     __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); | 
 | 4036 |     __enable_weak_this(__r.get()); | 
 | 4037 |     __r.release(); | 
 | 4038 | } | 
 | 4039 |  | 
 | 4040 | template<class _Tp> | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4041 | template <class _Yp, class _Dp, class> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4042 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4043 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 
 | 4044 | #else | 
 | 4045 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | 
 | 4046 | #endif | 
 | 4047 |            typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type) | 
 | 4048 |     : __ptr_(__r.get()) | 
 | 4049 | { | 
 | 4050 |     typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; | 
 | 4051 |     __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); | 
 | 4052 |     __enable_weak_this(__r.get()); | 
 | 4053 |     __r.release(); | 
 | 4054 | } | 
 | 4055 |  | 
 | 4056 | template<class _Tp> | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4057 | template <class _Yp, class _Dp, class> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4058 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4059 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 
 | 4060 | #else | 
 | 4061 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | 
 | 4062 | #endif | 
 | 4063 |            typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type) | 
 | 4064 |     : __ptr_(__r.get()) | 
 | 4065 | { | 
 | 4066 |     typedef __shared_ptr_pointer<_Yp*, | 
 | 4067 |                                  reference_wrapper<typename remove_reference<_Dp>::type>, | 
 | 4068 |                                  allocator<_Yp> > _CntrlBlk; | 
 | 4069 |     __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); | 
 | 4070 |     __enable_weak_this(__r.get()); | 
 | 4071 |     __r.release(); | 
 | 4072 | } | 
 | 4073 |  | 
 | 4074 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 4075 |  | 
 | 4076 | template<class _Tp> | 
 | 4077 | template<class ..._Args> | 
 | 4078 | shared_ptr<_Tp> | 
 | 4079 | shared_ptr<_Tp>::make_shared(_Args&& ...__args) | 
 | 4080 | { | 
 | 4081 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 4082 |     typedef allocator<_CntrlBlk> _A2; | 
 | 4083 |     typedef __allocator_destructor<_A2> _D2; | 
 | 4084 |     _A2 __a2; | 
 | 4085 |     unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4086 |     ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4087 |     shared_ptr<_Tp> __r; | 
 | 4088 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4089 |     __r.__cntrl_ = __hold2.release(); | 
 | 4090 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4091 |     return __r; | 
 | 4092 | } | 
 | 4093 |  | 
 | 4094 | template<class _Tp> | 
 | 4095 | template<class _Alloc, class ..._Args> | 
 | 4096 | shared_ptr<_Tp> | 
 | 4097 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) | 
 | 4098 | { | 
 | 4099 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 4100 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 4101 |     typedef __allocator_destructor<_A2> _D2; | 
 | 4102 |     _A2 __a2(__a); | 
 | 4103 |     unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4104 |     ::new(__hold2.get()) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4105 |     shared_ptr<_Tp> __r; | 
 | 4106 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4107 |     __r.__cntrl_ = __hold2.release(); | 
 | 4108 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4109 |     return __r; | 
 | 4110 | } | 
 | 4111 |  | 
 | 4112 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 4113 |  | 
 | 4114 | template<class _Tp> | 
 | 4115 | shared_ptr<_Tp> | 
 | 4116 | shared_ptr<_Tp>::make_shared() | 
 | 4117 | { | 
 | 4118 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 4119 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 4120 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4121 |     _Alloc2 __alloc2; | 
 | 4122 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4123 |     ::new(__hold2.get()) _CntrlBlk(__alloc2); | 
 | 4124 |     shared_ptr<_Tp> __r; | 
 | 4125 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4126 |     __r.__cntrl_ = __hold2.release(); | 
 | 4127 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4128 |     return __r; | 
 | 4129 | } | 
 | 4130 |  | 
 | 4131 | template<class _Tp> | 
 | 4132 | template<class _A0> | 
 | 4133 | shared_ptr<_Tp> | 
 | 4134 | shared_ptr<_Tp>::make_shared(_A0& __a0) | 
 | 4135 | { | 
 | 4136 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 4137 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 4138 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4139 |     _Alloc2 __alloc2; | 
 | 4140 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4141 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); | 
 | 4142 |     shared_ptr<_Tp> __r; | 
 | 4143 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4144 |     __r.__cntrl_ = __hold2.release(); | 
 | 4145 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4146 |     return __r; | 
 | 4147 | } | 
 | 4148 |  | 
 | 4149 | template<class _Tp> | 
 | 4150 | template<class _A0, class _A1> | 
 | 4151 | shared_ptr<_Tp> | 
 | 4152 | shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) | 
 | 4153 | { | 
 | 4154 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 4155 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 4156 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4157 |     _Alloc2 __alloc2; | 
 | 4158 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4159 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); | 
 | 4160 |     shared_ptr<_Tp> __r; | 
 | 4161 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4162 |     __r.__cntrl_ = __hold2.release(); | 
 | 4163 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4164 |     return __r; | 
 | 4165 | } | 
 | 4166 |  | 
 | 4167 | template<class _Tp> | 
 | 4168 | template<class _A0, class _A1, class _A2> | 
 | 4169 | shared_ptr<_Tp> | 
 | 4170 | shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) | 
 | 4171 | { | 
 | 4172 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 4173 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 4174 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4175 |     _Alloc2 __alloc2; | 
 | 4176 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4177 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); | 
 | 4178 |     shared_ptr<_Tp> __r; | 
 | 4179 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4180 |     __r.__cntrl_ = __hold2.release(); | 
 | 4181 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4182 |     return __r; | 
 | 4183 | } | 
 | 4184 |  | 
 | 4185 | template<class _Tp> | 
 | 4186 | template<class _Alloc> | 
 | 4187 | shared_ptr<_Tp> | 
 | 4188 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a) | 
 | 4189 | { | 
 | 4190 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 4191 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 4192 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4193 |     _Alloc2 __alloc2(__a); | 
 | 4194 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4195 |     ::new(__hold2.get()) _CntrlBlk(__a); | 
 | 4196 |     shared_ptr<_Tp> __r; | 
 | 4197 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4198 |     __r.__cntrl_ = __hold2.release(); | 
 | 4199 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4200 |     return __r; | 
 | 4201 | } | 
 | 4202 |  | 
 | 4203 | template<class _Tp> | 
 | 4204 | template<class _Alloc, class _A0> | 
 | 4205 | shared_ptr<_Tp> | 
 | 4206 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) | 
 | 4207 | { | 
 | 4208 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 4209 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 4210 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4211 |     _Alloc2 __alloc2(__a); | 
 | 4212 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4213 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0); | 
 | 4214 |     shared_ptr<_Tp> __r; | 
 | 4215 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4216 |     __r.__cntrl_ = __hold2.release(); | 
 | 4217 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4218 |     return __r; | 
 | 4219 | } | 
 | 4220 |  | 
 | 4221 | template<class _Tp> | 
 | 4222 | template<class _Alloc, class _A0, class _A1> | 
 | 4223 | shared_ptr<_Tp> | 
 | 4224 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) | 
 | 4225 | { | 
 | 4226 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 4227 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 4228 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4229 |     _Alloc2 __alloc2(__a); | 
 | 4230 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4231 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1); | 
 | 4232 |     shared_ptr<_Tp> __r; | 
 | 4233 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4234 |     __r.__cntrl_ = __hold2.release(); | 
 | 4235 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4236 |     return __r; | 
 | 4237 | } | 
 | 4238 |  | 
 | 4239 | template<class _Tp> | 
 | 4240 | template<class _Alloc, class _A0, class _A1, class _A2> | 
 | 4241 | shared_ptr<_Tp> | 
 | 4242 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 4243 | { | 
 | 4244 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 4245 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 4246 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4247 |     _Alloc2 __alloc2(__a); | 
 | 4248 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4249 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2); | 
 | 4250 |     shared_ptr<_Tp> __r; | 
 | 4251 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4252 |     __r.__cntrl_ = __hold2.release(); | 
 | 4253 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4254 |     return __r; | 
 | 4255 | } | 
 | 4256 |  | 
 | 4257 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 4258 |  | 
 | 4259 | template<class _Tp> | 
 | 4260 | shared_ptr<_Tp>::~shared_ptr() | 
 | 4261 | { | 
 | 4262 |     if (__cntrl_) | 
 | 4263 |         __cntrl_->__release_shared(); | 
 | 4264 | } | 
 | 4265 |  | 
 | 4266 | template<class _Tp> | 
 | 4267 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4268 | shared_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4269 | shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4270 | { | 
 | 4271 |     shared_ptr(__r).swap(*this); | 
 | 4272 |     return *this; | 
 | 4273 | } | 
 | 4274 |  | 
 | 4275 | template<class _Tp> | 
 | 4276 | template<class _Yp> | 
 | 4277 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4278 | typename enable_if | 
 | 4279 | < | 
 | 4280 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4281 |     shared_ptr<_Tp>& | 
 | 4282 | >::type | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4283 | shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4284 | { | 
 | 4285 |     shared_ptr(__r).swap(*this); | 
 | 4286 |     return *this; | 
 | 4287 | } | 
 | 4288 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4289 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4290 |  | 
 | 4291 | template<class _Tp> | 
 | 4292 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4293 | shared_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4294 | shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4295 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4296 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4297 |     return *this; | 
 | 4298 | } | 
 | 4299 |  | 
 | 4300 | template<class _Tp> | 
 | 4301 | template<class _Yp> | 
 | 4302 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4303 | typename enable_if | 
 | 4304 | < | 
 | 4305 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4306 |     shared_ptr<_Tp>& | 
 | 4307 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4308 | shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) | 
 | 4309 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4310 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4311 |     return *this; | 
 | 4312 | } | 
 | 4313 |  | 
 | 4314 | template<class _Tp> | 
 | 4315 | template<class _Yp> | 
 | 4316 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4317 | typename enable_if | 
 | 4318 | < | 
 | 4319 |     !is_array<_Yp>::value && | 
 | 4320 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4321 |     shared_ptr<_Tp>& | 
 | 4322 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4323 | shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) | 
 | 4324 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4325 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4326 |     return *this; | 
 | 4327 | } | 
 | 4328 |  | 
 | 4329 | template<class _Tp> | 
 | 4330 | template <class _Yp, class _Dp> | 
 | 4331 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4332 | typename enable_if | 
 | 4333 | < | 
 | 4334 |     !is_array<_Yp>::value && | 
 | 4335 |     is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, | 
 | 4336 |     shared_ptr<_Tp>& | 
 | 4337 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4338 | shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) | 
 | 4339 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4340 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4341 |     return *this; | 
 | 4342 | } | 
 | 4343 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4344 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4345 |  | 
 | 4346 | template<class _Tp> | 
 | 4347 | template<class _Yp> | 
 | 4348 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4349 | typename enable_if | 
 | 4350 | < | 
 | 4351 |     !is_array<_Yp>::value && | 
 | 4352 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4353 |     shared_ptr<_Tp>& | 
 | 4354 | >::type | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4355 | shared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4356 | { | 
 | 4357 |     shared_ptr(__r).swap(*this); | 
 | 4358 |     return *this; | 
 | 4359 | } | 
 | 4360 |  | 
 | 4361 | template<class _Tp> | 
 | 4362 | template <class _Yp, class _Dp> | 
 | 4363 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4364 | typename enable_if | 
 | 4365 | < | 
 | 4366 |     !is_array<_Yp>::value && | 
 | 4367 |     is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value, | 
 | 4368 |     shared_ptr<_Tp>& | 
 | 4369 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4370 | shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) | 
 | 4371 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4372 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4373 |     return *this; | 
 | 4374 | } | 
 | 4375 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4376 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4377 |  | 
 | 4378 | template<class _Tp> | 
 | 4379 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4380 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4381 | shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4382 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4383 |     _VSTD::swap(__ptr_, __r.__ptr_); | 
 | 4384 |     _VSTD::swap(__cntrl_, __r.__cntrl_); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4385 | } | 
 | 4386 |  | 
 | 4387 | template<class _Tp> | 
 | 4388 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4389 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4390 | shared_ptr<_Tp>::reset() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4391 | { | 
 | 4392 |     shared_ptr().swap(*this); | 
 | 4393 | } | 
 | 4394 |  | 
 | 4395 | template<class _Tp> | 
 | 4396 | template<class _Yp> | 
 | 4397 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4398 | typename enable_if | 
 | 4399 | < | 
 | 4400 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4401 |     void | 
 | 4402 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4403 | shared_ptr<_Tp>::reset(_Yp* __p) | 
 | 4404 | { | 
 | 4405 |     shared_ptr(__p).swap(*this); | 
 | 4406 | } | 
 | 4407 |  | 
 | 4408 | template<class _Tp> | 
 | 4409 | template<class _Yp, class _Dp> | 
 | 4410 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4411 | typename enable_if | 
 | 4412 | < | 
 | 4413 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4414 |     void | 
 | 4415 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4416 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) | 
 | 4417 | { | 
 | 4418 |     shared_ptr(__p, __d).swap(*this); | 
 | 4419 | } | 
 | 4420 |  | 
 | 4421 | template<class _Tp> | 
 | 4422 | template<class _Yp, class _Dp, class _Alloc> | 
 | 4423 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4424 | typename enable_if | 
 | 4425 | < | 
 | 4426 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4427 |     void | 
 | 4428 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4429 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) | 
 | 4430 | { | 
 | 4431 |     shared_ptr(__p, __d, __a).swap(*this); | 
 | 4432 | } | 
 | 4433 |  | 
 | 4434 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 4435 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4436 | template<class _Tp, class ..._Args> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4437 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4438 | typename enable_if | 
 | 4439 | < | 
 | 4440 |     !is_array<_Tp>::value, | 
 | 4441 |     shared_ptr<_Tp> | 
 | 4442 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4443 | make_shared(_Args&& ...__args) | 
 | 4444 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4445 |     return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4446 | } | 
 | 4447 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4448 | template<class _Tp, class _Alloc, class ..._Args> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4449 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4450 | typename enable_if | 
 | 4451 | < | 
 | 4452 |     !is_array<_Tp>::value, | 
 | 4453 |     shared_ptr<_Tp> | 
 | 4454 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4455 | allocate_shared(const _Alloc& __a, _Args&& ...__args) | 
 | 4456 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4457 |     return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4458 | } | 
 | 4459 |  | 
 | 4460 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 4461 |  | 
 | 4462 | template<class _Tp> | 
 | 4463 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4464 | shared_ptr<_Tp> | 
 | 4465 | make_shared() | 
 | 4466 | { | 
 | 4467 |     return shared_ptr<_Tp>::make_shared(); | 
 | 4468 | } | 
 | 4469 |  | 
 | 4470 | template<class _Tp, class _A0> | 
 | 4471 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4472 | shared_ptr<_Tp> | 
 | 4473 | make_shared(_A0& __a0) | 
 | 4474 | { | 
 | 4475 |     return shared_ptr<_Tp>::make_shared(__a0); | 
 | 4476 | } | 
 | 4477 |  | 
 | 4478 | template<class _Tp, class _A0, class _A1> | 
 | 4479 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4480 | shared_ptr<_Tp> | 
 | 4481 | make_shared(_A0& __a0, _A1& __a1) | 
 | 4482 | { | 
 | 4483 |     return shared_ptr<_Tp>::make_shared(__a0, __a1); | 
 | 4484 | } | 
 | 4485 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4486 | template<class _Tp, class _A0, class _A1, class _A2> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4487 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4488 | shared_ptr<_Tp> | 
 | 4489 | make_shared(_A0& __a0, _A1& __a1, _A2& __a2) | 
 | 4490 | { | 
 | 4491 |     return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2); | 
 | 4492 | } | 
 | 4493 |  | 
 | 4494 | template<class _Tp, class _Alloc> | 
 | 4495 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4496 | shared_ptr<_Tp> | 
 | 4497 | allocate_shared(const _Alloc& __a) | 
 | 4498 | { | 
 | 4499 |     return shared_ptr<_Tp>::allocate_shared(__a); | 
 | 4500 | } | 
 | 4501 |  | 
 | 4502 | template<class _Tp, class _Alloc, class _A0> | 
 | 4503 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4504 | shared_ptr<_Tp> | 
 | 4505 | allocate_shared(const _Alloc& __a, _A0& __a0) | 
 | 4506 | { | 
 | 4507 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0); | 
 | 4508 | } | 
 | 4509 |  | 
 | 4510 | template<class _Tp, class _Alloc, class _A0, class _A1> | 
 | 4511 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4512 | shared_ptr<_Tp> | 
 | 4513 | allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) | 
 | 4514 | { | 
 | 4515 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1); | 
 | 4516 | } | 
 | 4517 |  | 
 | 4518 | template<class _Tp, class _Alloc, class _A0, class _A1, class _A2> | 
 | 4519 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4520 | shared_ptr<_Tp> | 
 | 4521 | allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 4522 | { | 
 | 4523 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2); | 
 | 4524 | } | 
 | 4525 |  | 
 | 4526 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 4527 |  | 
 | 4528 | template<class _Tp, class _Up> | 
 | 4529 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4530 | bool | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4531 | operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4532 | { | 
 | 4533 |     return __x.get() == __y.get(); | 
 | 4534 | } | 
 | 4535 |  | 
 | 4536 | template<class _Tp, class _Up> | 
 | 4537 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4538 | bool | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4539 | operator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4540 | { | 
 | 4541 |     return !(__x == __y); | 
 | 4542 | } | 
 | 4543 |  | 
 | 4544 | template<class _Tp, class _Up> | 
 | 4545 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4546 | bool | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4547 | operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4548 | { | 
 | 4549 |     return __x.get() < __y.get(); | 
 | 4550 | } | 
 | 4551 |  | 
 | 4552 | template<class _Tp> | 
 | 4553 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4554 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4555 | swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4556 | { | 
 | 4557 |     __x.swap(__y); | 
 | 4558 | } | 
 | 4559 |  | 
 | 4560 | template<class _Tp, class _Up> | 
 | 4561 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4562 | typename enable_if | 
 | 4563 | < | 
 | 4564 |     !is_array<_Tp>::value && !is_array<_Up>::value, | 
 | 4565 |     shared_ptr<_Tp> | 
 | 4566 | >::type | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4567 | static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4568 | { | 
 | 4569 |     return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); | 
 | 4570 | } | 
 | 4571 |  | 
 | 4572 | template<class _Tp, class _Up> | 
 | 4573 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4574 | typename enable_if | 
 | 4575 | < | 
 | 4576 |     !is_array<_Tp>::value && !is_array<_Up>::value, | 
 | 4577 |     shared_ptr<_Tp> | 
 | 4578 | >::type | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4579 | dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4580 | { | 
 | 4581 |     _Tp* __p = dynamic_cast<_Tp*>(__r.get()); | 
 | 4582 |     return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); | 
 | 4583 | } | 
 | 4584 |  | 
 | 4585 | template<class _Tp, class _Up> | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4586 | typename enable_if | 
 | 4587 | < | 
 | 4588 |     is_array<_Tp>::value == is_array<_Up>::value, | 
 | 4589 |     shared_ptr<_Tp> | 
 | 4590 | >::type | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4591 | const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4592 | { | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4593 |     typedef typename remove_extent<_Tp>::type _RTp; | 
 | 4594 |     return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4595 | } | 
 | 4596 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 4597 | #ifndef _LIBCPP_NO_RTTI | 
 | 4598 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4599 | template<class _Dp, class _Tp> | 
 | 4600 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4601 | _Dp* | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4602 | get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4603 | { | 
 | 4604 |     return __p.template __get_deleter<_Dp>(); | 
 | 4605 | } | 
 | 4606 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4607 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 4608 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4609 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4610 | class _LIBCPP_VISIBLE weak_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4611 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4612 | public: | 
 | 4613 |     typedef _Tp element_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4614 | private: | 
 | 4615 |     element_type*        __ptr_; | 
 | 4616 |     __shared_weak_count* __cntrl_; | 
 | 4617 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4618 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4619 |     weak_ptr() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4620 |     template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4621 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) | 
 | 4622 |                         _NOEXCEPT; | 
 | 4623 |     weak_ptr(weak_ptr const& __r) _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4624 |     template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4625 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) | 
 | 4626 |                          _NOEXCEPT; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4627 |  | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4628 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
 | 4629 |     weak_ptr(weak_ptr&& __r) _NOEXCEPT; | 
 | 4630 |     template<class _Yp> weak_ptr(weak_ptr<_Yp>&& __r, | 
 | 4631 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) | 
 | 4632 |                          _NOEXCEPT; | 
 | 4633 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4634 |     ~weak_ptr(); | 
 | 4635 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4636 |     weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4637 |     template<class _Yp> | 
 | 4638 |         typename enable_if | 
 | 4639 |         < | 
 | 4640 |             is_convertible<_Yp*, element_type*>::value, | 
 | 4641 |             weak_ptr& | 
 | 4642 |         >::type | 
 | 4643 |         operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; | 
 | 4644 |  | 
 | 4645 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
 | 4646 |  | 
 | 4647 |     weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT; | 
 | 4648 |     template<class _Yp> | 
 | 4649 |         typename enable_if | 
 | 4650 |         < | 
 | 4651 |             is_convertible<_Yp*, element_type*>::value, | 
 | 4652 |             weak_ptr& | 
 | 4653 |         >::type | 
 | 4654 |         operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT; | 
 | 4655 |  | 
 | 4656 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
 | 4657 |  | 
 | 4658 |     template<class _Yp> | 
 | 4659 |         typename enable_if | 
 | 4660 |         < | 
 | 4661 |             is_convertible<_Yp*, element_type*>::value, | 
 | 4662 |             weak_ptr& | 
 | 4663 |         >::type | 
 | 4664 |         operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4665 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4666 |     void swap(weak_ptr& __r) _NOEXCEPT; | 
 | 4667 |     void reset() _NOEXCEPT; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4668 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4669 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4670 |     long use_count() const _NOEXCEPT | 
 | 4671 |         {return __cntrl_ ? __cntrl_->use_count() : 0;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4672 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4673 |     bool expired() const _NOEXCEPT | 
 | 4674 |         {return __cntrl_ == 0 || __cntrl_->use_count() == 0;} | 
 | 4675 |     shared_ptr<_Tp> lock() const _NOEXCEPT; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4676 |     template<class _Up> | 
 | 4677 |         _LIBCPP_INLINE_VISIBILITY | 
 | 4678 |         bool owner_before(const shared_ptr<_Up>& __r) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4679 |         {return __cntrl_ < __r.__cntrl_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4680 |     template<class _Up> | 
 | 4681 |         _LIBCPP_INLINE_VISIBILITY | 
 | 4682 |         bool owner_before(const weak_ptr<_Up>& __r) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4683 |         {return __cntrl_ < __r.__cntrl_;} | 
 | 4684 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4685 |     template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; | 
 | 4686 |     template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4687 | }; | 
 | 4688 |  | 
 | 4689 | template<class _Tp> | 
 | 4690 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4691 | weak_ptr<_Tp>::weak_ptr() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4692 |     : __ptr_(0), | 
 | 4693 |       __cntrl_(0) | 
 | 4694 | { | 
 | 4695 | } | 
 | 4696 |  | 
 | 4697 | template<class _Tp> | 
 | 4698 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4699 | weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4700 |     : __ptr_(__r.__ptr_), | 
 | 4701 |       __cntrl_(__r.__cntrl_) | 
 | 4702 | { | 
 | 4703 |     if (__cntrl_) | 
 | 4704 |         __cntrl_->__add_weak(); | 
 | 4705 | } | 
 | 4706 |  | 
 | 4707 | template<class _Tp> | 
 | 4708 | template<class _Yp> | 
 | 4709 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4710 | weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, | 
| Howard Hinnant | e003ce4 | 2011-05-22 00:09:02 +0000 | [diff] [blame] | 4711 |                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4712 |                          _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4713 |     : __ptr_(__r.__ptr_), | 
 | 4714 |       __cntrl_(__r.__cntrl_) | 
 | 4715 | { | 
 | 4716 |     if (__cntrl_) | 
 | 4717 |         __cntrl_->__add_weak(); | 
 | 4718 | } | 
 | 4719 |  | 
 | 4720 | template<class _Tp> | 
 | 4721 | template<class _Yp> | 
 | 4722 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4723 | weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, | 
| Howard Hinnant | e003ce4 | 2011-05-22 00:09:02 +0000 | [diff] [blame] | 4724 |                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4725 |          _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4726 |     : __ptr_(__r.__ptr_), | 
 | 4727 |       __cntrl_(__r.__cntrl_) | 
 | 4728 | { | 
 | 4729 |     if (__cntrl_) | 
 | 4730 |         __cntrl_->__add_weak(); | 
 | 4731 | } | 
 | 4732 |  | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4733 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
 | 4734 |  | 
 | 4735 | template<class _Tp> | 
 | 4736 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4737 | weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT | 
 | 4738 |     : __ptr_(__r.__ptr_), | 
 | 4739 |       __cntrl_(__r.__cntrl_) | 
 | 4740 | { | 
 | 4741 |     __r.__ptr_ = 0; | 
 | 4742 |     __r.__cntrl_ = 0; | 
 | 4743 | } | 
 | 4744 |  | 
 | 4745 | template<class _Tp> | 
 | 4746 | template<class _Yp> | 
 | 4747 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4748 | weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, | 
 | 4749 |                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) | 
 | 4750 |          _NOEXCEPT | 
 | 4751 |     : __ptr_(__r.__ptr_), | 
 | 4752 |       __cntrl_(__r.__cntrl_) | 
 | 4753 | { | 
 | 4754 |     __r.__ptr_ = 0; | 
 | 4755 |     __r.__cntrl_ = 0; | 
 | 4756 | } | 
 | 4757 |  | 
 | 4758 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
 | 4759 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4760 | template<class _Tp> | 
 | 4761 | weak_ptr<_Tp>::~weak_ptr() | 
 | 4762 | { | 
 | 4763 |     if (__cntrl_) | 
 | 4764 |         __cntrl_->__release_weak(); | 
 | 4765 | } | 
 | 4766 |  | 
 | 4767 | template<class _Tp> | 
 | 4768 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4769 | weak_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4770 | weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4771 | { | 
 | 4772 |     weak_ptr(__r).swap(*this); | 
 | 4773 |     return *this; | 
 | 4774 | } | 
 | 4775 |  | 
 | 4776 | template<class _Tp> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4777 | template<class _Yp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4778 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4779 | typename enable_if | 
 | 4780 | < | 
 | 4781 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4782 |     weak_ptr<_Tp>& | 
 | 4783 | >::type | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4784 | weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4785 | { | 
 | 4786 |     weak_ptr(__r).swap(*this); | 
 | 4787 |     return *this; | 
 | 4788 | } | 
 | 4789 |  | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4790 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
 | 4791 |  | 
 | 4792 | template<class _Tp> | 
 | 4793 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4794 | weak_ptr<_Tp>& | 
 | 4795 | weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT | 
 | 4796 | { | 
 | 4797 |     weak_ptr(_VSTD::move(__r)).swap(*this); | 
 | 4798 |     return *this; | 
 | 4799 | } | 
 | 4800 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4801 | template<class _Tp> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4802 | template<class _Yp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4803 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 5719940 | 2012-01-02 17:56:02 +0000 | [diff] [blame^] | 4804 | typename enable_if | 
 | 4805 | < | 
 | 4806 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4807 |     weak_ptr<_Tp>& | 
 | 4808 | >::type | 
 | 4809 | weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT | 
 | 4810 | { | 
 | 4811 |     weak_ptr(_VSTD::move(__r)).swap(*this); | 
 | 4812 |     return *this; | 
 | 4813 | } | 
 | 4814 |  | 
 | 4815 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
 | 4816 |  | 
 | 4817 | template<class _Tp> | 
 | 4818 | template<class _Yp> | 
 | 4819 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4820 | typename enable_if | 
 | 4821 | < | 
 | 4822 |     is_convertible<_Yp*, _Tp*>::value, | 
 | 4823 |     weak_ptr<_Tp>& | 
 | 4824 | >::type | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4825 | weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4826 | { | 
 | 4827 |     weak_ptr(__r).swap(*this); | 
 | 4828 |     return *this; | 
 | 4829 | } | 
 | 4830 |  | 
 | 4831 | template<class _Tp> | 
 | 4832 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4833 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4834 | weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4835 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4836 |     _VSTD::swap(__ptr_, __r.__ptr_); | 
 | 4837 |     _VSTD::swap(__cntrl_, __r.__cntrl_); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4838 | } | 
 | 4839 |  | 
 | 4840 | template<class _Tp> | 
 | 4841 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4842 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4843 | swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4844 | { | 
 | 4845 |     __x.swap(__y); | 
 | 4846 | } | 
 | 4847 |  | 
 | 4848 | template<class _Tp> | 
 | 4849 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4850 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4851 | weak_ptr<_Tp>::reset() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4852 | { | 
 | 4853 |     weak_ptr().swap(*this); | 
 | 4854 | } | 
 | 4855 |  | 
 | 4856 | template<class _Tp> | 
 | 4857 | template<class _Yp> | 
 | 4858 | shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, | 
 | 4859 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
 | 4860 |     : __ptr_(__r.__ptr_), | 
 | 4861 |       __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) | 
 | 4862 | { | 
 | 4863 |     if (__cntrl_ == 0) | 
 | 4864 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 4865 |         throw bad_weak_ptr(); | 
 | 4866 | #else | 
 | 4867 |         assert(!"bad_weak_ptr"); | 
 | 4868 | #endif | 
 | 4869 | } | 
 | 4870 |  | 
 | 4871 | template<class _Tp> | 
 | 4872 | shared_ptr<_Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4873 | weak_ptr<_Tp>::lock() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4874 | { | 
 | 4875 |     shared_ptr<_Tp> __r; | 
 | 4876 |     __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_; | 
 | 4877 |     if (__r.__cntrl_) | 
 | 4878 |         __r.__ptr_ = __ptr_; | 
 | 4879 |     return __r; | 
 | 4880 | } | 
 | 4881 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4882 | template <class _Tp> struct owner_less; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4883 |  | 
 | 4884 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4885 | struct _LIBCPP_VISIBLE owner_less<shared_ptr<_Tp> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4886 |     : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4887 | { | 
 | 4888 |     typedef bool result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4889 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4890 |     bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 4891 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4892 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4893 |     bool operator()(shared_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 4894 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4895 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4896 |     bool operator()(  weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 4897 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4898 | }; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4899 |  | 
 | 4900 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4901 | struct _LIBCPP_VISIBLE owner_less<weak_ptr<_Tp> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4902 |     : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> | 
 | 4903 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4904 |     typedef bool result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4905 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4906 |     bool operator()(  weak_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 4907 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4908 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4909 |     bool operator()(shared_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 4910 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4911 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4912 |     bool operator()(  weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 4913 |         {return __x.owner_before(__y);} | 
 | 4914 | }; | 
 | 4915 |  | 
 | 4916 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4917 | class _LIBCPP_VISIBLE enable_shared_from_this | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4918 | { | 
 | 4919 |     mutable weak_ptr<_Tp> __weak_this_; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4920 | protected: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4921 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4922 |     enable_shared_from_this() _NOEXCEPT {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4923 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4924 |     enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4925 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4926 |     enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT | 
 | 4927 |         {return *this;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4928 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4929 |     ~enable_shared_from_this() {} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4930 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4931 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4932 |     shared_ptr<_Tp> shared_from_this() | 
 | 4933 |         {return shared_ptr<_Tp>(__weak_this_);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4934 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4935 |     shared_ptr<_Tp const> shared_from_this() const | 
 | 4936 |         {return shared_ptr<const _Tp>(__weak_this_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4937 |  | 
 | 4938 |     template <class _Up> friend class shared_ptr; | 
 | 4939 | }; | 
 | 4940 |  | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 4941 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4942 | struct _LIBCPP_VISIBLE hash<shared_ptr<_Tp> > | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 4943 | { | 
 | 4944 |     typedef shared_ptr<_Tp>      argument_type; | 
 | 4945 |     typedef size_t               result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4946 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4947 |     result_type operator()(const argument_type& __ptr) const _NOEXCEPT | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 4948 |     { | 
 | 4949 |         return hash<_Tp*>()(__ptr.get()); | 
 | 4950 |     } | 
 | 4951 | }; | 
 | 4952 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 4953 | template<class _CharT, class _Traits, class _Yp> | 
| Howard Hinnant | 464aa5c | 2011-07-18 15:51:59 +0000 | [diff] [blame] | 4954 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4955 | basic_ostream<_CharT, _Traits>& | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 4956 | operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); | 
| Howard Hinnant | 464aa5c | 2011-07-18 15:51:59 +0000 | [diff] [blame] | 4957 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4958 | //enum class | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4959 | struct _LIBCPP_VISIBLE pointer_safety | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4960 | { | 
 | 4961 |     enum _ | 
 | 4962 |     { | 
 | 4963 |         relaxed, | 
 | 4964 |         preferred, | 
 | 4965 |         strict | 
 | 4966 |     }; | 
 | 4967 |  | 
 | 4968 |     _ __v_; | 
 | 4969 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4970 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4971 |     pointer_safety(_ __v) : __v_(__v) {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4972 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4973 |     operator int() const {return __v_;} | 
 | 4974 | }; | 
 | 4975 |  | 
 | 4976 | void declare_reachable(void* __p); | 
 | 4977 | void declare_no_pointers(char* __p, size_t __n); | 
 | 4978 | void undeclare_no_pointers(char* __p, size_t __n); | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4979 | pointer_safety get_pointer_safety() _NOEXCEPT; | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 4980 | void* __undeclare_reachable(void* __p); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4981 |  | 
 | 4982 | template <class _Tp> | 
 | 4983 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4984 | _Tp* | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4985 | undeclare_reachable(_Tp* __p) | 
 | 4986 | { | 
 | 4987 |     return static_cast<_Tp*>(__undeclare_reachable(__p)); | 
 | 4988 | } | 
 | 4989 |  | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 4990 | void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4991 |  | 
 | 4992 | _LIBCPP_END_NAMESPACE_STD | 
 | 4993 |  | 
 | 4994 | #endif  // _LIBCPP_MEMORY |