| 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 |  | 
 | 1680 | template <class _Tp, class _Up> | 
 | 1681 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1682 | bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1683 |  | 
 | 1684 | template <class _Tp, class _Up> | 
 | 1685 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1686 | bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1687 |  | 
 | 1688 | template <class _OutputIterator, class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1689 | class _LIBCPP_VISIBLE raw_storage_iterator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1690 |     : public iterator<output_iterator_tag, | 
 | 1691 |                       _Tp,                                         // purposefully not C++03 | 
 | 1692 |                       ptrdiff_t,                                   // purposefully not C++03 | 
 | 1693 |                       _Tp*,                                        // purposefully not C++03 | 
 | 1694 |                       raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03 | 
 | 1695 | { | 
 | 1696 | private: | 
 | 1697 |     _OutputIterator __x_; | 
 | 1698 | public: | 
 | 1699 |     _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {} | 
 | 1700 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} | 
 | 1701 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) | 
 | 1702 |         {::new(&*__x_) _Tp(__element); return *this;} | 
 | 1703 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} | 
 | 1704 |     _LIBCPP_INLINE_VISIBILITY raw_storage_iterator  operator++(int) | 
 | 1705 |         {raw_storage_iterator __t(*this); ++__x_; return __t;} | 
 | 1706 | }; | 
 | 1707 |  | 
 | 1708 | template <class _Tp> | 
 | 1709 | pair<_Tp*, ptrdiff_t> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1710 | get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1711 | { | 
 | 1712 |     pair<_Tp*, ptrdiff_t> __r(0, 0); | 
 | 1713 |     const ptrdiff_t __m = (~ptrdiff_t(0) ^ | 
 | 1714 |                            ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) | 
 | 1715 |                            / sizeof(_Tp); | 
 | 1716 |     if (__n > __m) | 
 | 1717 |         __n = __m; | 
 | 1718 |     while (__n > 0) | 
 | 1719 |     { | 
 | 1720 |         __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); | 
 | 1721 |         if (__r.first) | 
 | 1722 |         { | 
 | 1723 |             __r.second = __n; | 
 | 1724 |             break; | 
 | 1725 |         } | 
 | 1726 |         __n /= 2; | 
 | 1727 |     } | 
 | 1728 |     return __r; | 
 | 1729 | } | 
 | 1730 |  | 
 | 1731 | template <class _Tp> | 
 | 1732 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1733 | void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1734 |  | 
 | 1735 | template <class _Tp> | 
 | 1736 | struct auto_ptr_ref | 
 | 1737 | { | 
 | 1738 |     _Tp* __ptr_; | 
 | 1739 | }; | 
 | 1740 |  | 
 | 1741 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1742 | class _LIBCPP_VISIBLE auto_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1743 | { | 
 | 1744 | private: | 
 | 1745 |     _Tp* __ptr_; | 
 | 1746 | public: | 
 | 1747 |     typedef _Tp element_type; | 
 | 1748 |  | 
 | 1749 |     _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {} | 
 | 1750 |     _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {} | 
 | 1751 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw() | 
 | 1752 |         : __ptr_(__p.release()) {} | 
 | 1753 |     _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw() | 
 | 1754 |         {reset(__p.release()); return *this;} | 
 | 1755 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw() | 
 | 1756 |         {reset(__p.release()); return *this;} | 
 | 1757 |     _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw() | 
 | 1758 |         {reset(__p.__ptr_); return *this;} | 
 | 1759 |     _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;} | 
 | 1760 |  | 
 | 1761 |     _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw() | 
 | 1762 |         {return *__ptr_;} | 
 | 1763 |     _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;} | 
 | 1764 |     _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;} | 
 | 1765 |     _LIBCPP_INLINE_VISIBILITY _Tp* release() throw() | 
 | 1766 |     { | 
 | 1767 |         _Tp* __t = __ptr_; | 
 | 1768 |         __ptr_ = 0; | 
 | 1769 |         return __t; | 
 | 1770 |     } | 
 | 1771 |     _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw() | 
 | 1772 |     { | 
 | 1773 |         if (__ptr_ != __p) | 
 | 1774 |             delete __ptr_; | 
 | 1775 |         __ptr_ = __p; | 
 | 1776 |     } | 
 | 1777 |  | 
 | 1778 |     _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {} | 
 | 1779 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw() | 
 | 1780 |         {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;} | 
 | 1781 |     template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw() | 
 | 1782 |         {return auto_ptr<_Up>(release());} | 
 | 1783 | }; | 
 | 1784 |  | 
 | 1785 | template <> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1786 | class _LIBCPP_VISIBLE auto_ptr<void> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1787 | { | 
 | 1788 | public: | 
 | 1789 |     typedef void element_type; | 
 | 1790 | }; | 
 | 1791 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1792 | template <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type, | 
 | 1793 |                                                      typename remove_cv<_T2>::type>::value, | 
| Howard Hinnant | d4cf215 | 2011-12-11 20:31:33 +0000 | [diff] [blame] | 1794 |                                 bool = is_empty<_T1>::value | 
 | 1795 | #if __has_feature(is_final) | 
 | 1796 |                                        && !__is_final(_T1) | 
 | 1797 | #endif | 
 | 1798 |                                 , | 
 | 1799 |                                 bool = is_empty<_T2>::value | 
 | 1800 | #if __has_feature(is_final) | 
 | 1801 |                                        && !__is_final(_T2) | 
 | 1802 | #endif | 
 | 1803 |          > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1804 | struct __libcpp_compressed_pair_switch; | 
 | 1805 |  | 
 | 1806 | template <class _T1, class _T2, bool IsSame> | 
 | 1807 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};}; | 
 | 1808 |  | 
 | 1809 | template <class _T1, class _T2, bool IsSame> | 
 | 1810 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false>  {enum {value = 1};}; | 
 | 1811 |  | 
 | 1812 | template <class _T1, class _T2, bool IsSame> | 
 | 1813 | struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true>  {enum {value = 2};}; | 
 | 1814 |  | 
 | 1815 | template <class _T1, class _T2> | 
 | 1816 | struct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true>    {enum {value = 3};}; | 
 | 1817 |  | 
 | 1818 | template <class _T1, class _T2> | 
 | 1819 | struct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true>     {enum {value = 1};}; | 
 | 1820 |  | 
 | 1821 | template <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value> | 
 | 1822 | class __libcpp_compressed_pair_imp; | 
 | 1823 |  | 
 | 1824 | template <class _T1, class _T2> | 
 | 1825 | class __libcpp_compressed_pair_imp<_T1, _T2, 0> | 
 | 1826 | { | 
 | 1827 | private: | 
 | 1828 |     _T1 __first_; | 
 | 1829 |     _T2 __second_; | 
 | 1830 | public: | 
 | 1831 |     typedef _T1 _T1_param; | 
 | 1832 |     typedef _T2 _T2_param; | 
 | 1833 |  | 
 | 1834 |     typedef typename remove_reference<_T1>::type& _T1_reference; | 
 | 1835 |     typedef typename remove_reference<_T2>::type& _T2_reference; | 
 | 1836 |  | 
 | 1837 |     typedef const typename remove_reference<_T1>::type& _T1_const_reference; | 
 | 1838 |     typedef const typename remove_reference<_T2>::type& _T2_const_reference; | 
 | 1839 |  | 
 | 1840 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 1841 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1, int = 0) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1842 |         : __first_(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1843 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2, int* = 0) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1844 |         : __second_(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1845 |     _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] | 1846 |         : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1847 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1848 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 1849 |  | 
 | 1850 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1851 |     __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) | 
 | 1852 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 1853 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 1854 |         : __first_(__p.first()), | 
 | 1855 |           __second_(__p.second()) {} | 
 | 1856 |  | 
 | 1857 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1858 |     __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) | 
 | 1859 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 1860 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 1861 |         { | 
 | 1862 |             __first_ = __p.first(); | 
 | 1863 |             __second_ = __p.second(); | 
 | 1864 |             return *this; | 
 | 1865 |         } | 
 | 1866 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1867 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1868 |  | 
 | 1869 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1870 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1871 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 1872 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1873 |         : __first_(_VSTD::forward<_T1>(__p.first())), | 
 | 1874 |           __second_(_VSTD::forward<_T2>(__p.second())) {} | 
 | 1875 |  | 
 | 1876 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1877 |     __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) | 
 | 1878 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 1879 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 1880 |         { | 
 | 1881 |             __first_ = _VSTD::forward<_T1>(__p.first()); | 
 | 1882 |             __second_ = _VSTD::forward<_T2>(__p.second()); | 
 | 1883 |             return *this; | 
 | 1884 |         } | 
 | 1885 |  | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame^] | 1886 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1887 |  | 
 | 1888 |     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | 
 | 1889 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1890 |         __libcpp_compressed_pair_imp(piecewise_construct_t __pc, | 
 | 1891 |                                      tuple<_Args1...> __first_args, | 
 | 1892 |                                      tuple<_Args2...> __second_args, | 
 | 1893 |                                      __tuple_indices<_I1...>, | 
 | 1894 |                                      __tuple_indices<_I2...>) | 
 | 1895 |             : __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), | 
 | 1896 |               __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) | 
 | 1897 |             {} | 
 | 1898 |  | 
 | 1899 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 1900 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1901 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1902 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1903 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 1904 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1905 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;} | 
 | 1906 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1907 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1908 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return __second_;} | 
 | 1909 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1910 |  | 
 | 1911 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1912 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 1913 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1914 |     { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1915 |         using _VSTD::swap; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1916 |         swap(__first_, __x.__first_); | 
 | 1917 |         swap(__second_, __x.__second_); | 
 | 1918 |     } | 
 | 1919 | }; | 
 | 1920 |  | 
 | 1921 | template <class _T1, class _T2> | 
 | 1922 | class __libcpp_compressed_pair_imp<_T1, _T2, 1> | 
 | 1923 |     : private _T1 | 
 | 1924 | { | 
 | 1925 | private: | 
 | 1926 |     _T2 __second_; | 
 | 1927 | public: | 
 | 1928 |     typedef _T1 _T1_param; | 
 | 1929 |     typedef _T2 _T2_param; | 
 | 1930 |  | 
 | 1931 |     typedef _T1&                                        _T1_reference; | 
 | 1932 |     typedef typename remove_reference<_T2>::type& _T2_reference; | 
 | 1933 |  | 
 | 1934 |     typedef const _T1&                                        _T1_const_reference; | 
 | 1935 |     typedef const typename remove_reference<_T2>::type& _T2_const_reference; | 
 | 1936 |  | 
 | 1937 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 1938 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1, int = 0) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1939 |         : _T1(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1940 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2, int* = 0) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1941 |         : __second_(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1942 |     _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] | 1943 |         : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1944 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1945 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 1946 |  | 
 | 1947 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1948 |     __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) | 
 | 1949 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 1950 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 1951 |         : _T1(__p.first()), __second_(__p.second()) {} | 
 | 1952 |  | 
 | 1953 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1954 |     __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) | 
 | 1955 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 1956 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 1957 |         { | 
 | 1958 |             _T1::operator=(__p.first()); | 
 | 1959 |             __second_ = __p.second(); | 
 | 1960 |             return *this; | 
 | 1961 |         } | 
 | 1962 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1963 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1964 |  | 
 | 1965 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1966 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 1967 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 1968 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1969 |         : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {} | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1970 |  | 
 | 1971 |     _LIBCPP_INLINE_VISIBILITY | 
 | 1972 |     __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) | 
 | 1973 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 1974 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 1975 |         { | 
 | 1976 |             _T1::operator=(_VSTD::move(__p.first())); | 
 | 1977 |             __second_ = _VSTD::forward<_T2>(__p.second()); | 
 | 1978 |             return *this; | 
 | 1979 |         } | 
 | 1980 |  | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame^] | 1981 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 1982 |  | 
 | 1983 |     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | 
 | 1984 |         _LIBCPP_INLINE_VISIBILITY | 
 | 1985 |         __libcpp_compressed_pair_imp(piecewise_construct_t __pc, | 
 | 1986 |                                      tuple<_Args1...> __first_args, | 
 | 1987 |                                      tuple<_Args2...> __second_args, | 
 | 1988 |                                      __tuple_indices<_I1...>, | 
 | 1989 |                                      __tuple_indices<_I2...>) | 
 | 1990 |             : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), | 
 | 1991 |               __second_(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) | 
 | 1992 |             {} | 
 | 1993 |  | 
 | 1994 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 1995 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1996 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1997 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1998 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 1999 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2000 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;} | 
 | 2001 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2002 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2003 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return __second_;} | 
 | 2004 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2005 |  | 
 | 2006 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2007 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2008 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2009 |     { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2010 |         using _VSTD::swap; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2011 |         swap(__second_, __x.__second_); | 
 | 2012 |     } | 
 | 2013 | }; | 
 | 2014 |  | 
 | 2015 | template <class _T1, class _T2> | 
 | 2016 | class __libcpp_compressed_pair_imp<_T1, _T2, 2> | 
 | 2017 |     : private _T2 | 
 | 2018 | { | 
 | 2019 | private: | 
 | 2020 |     _T1 __first_; | 
 | 2021 | public: | 
 | 2022 |     typedef _T1 _T1_param; | 
 | 2023 |     typedef _T2 _T2_param; | 
 | 2024 |  | 
 | 2025 |     typedef typename remove_reference<_T1>::type& _T1_reference; | 
 | 2026 |     typedef _T2&                                        _T2_reference; | 
 | 2027 |  | 
 | 2028 |     typedef const typename remove_reference<_T1>::type& _T1_const_reference; | 
 | 2029 |     typedef const _T2&                                        _T2_const_reference; | 
 | 2030 |  | 
 | 2031 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 2032 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2033 |         : __first_(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2034 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2035 |         : _T2(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2036 |     _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] | 2037 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2038 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2039 |         : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2040 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2041 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2042 |  | 
 | 2043 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2044 |     __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) | 
 | 2045 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 2046 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 2047 |         : _T2(__p.second()), __first_(__p.first()) {} | 
 | 2048 |  | 
 | 2049 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2050 |     __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) | 
 | 2051 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 2052 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 2053 |         { | 
 | 2054 |             _T2::operator=(__p.second()); | 
 | 2055 |             __first_ = __p.first(); | 
 | 2056 |             return *this; | 
 | 2057 |         } | 
 | 2058 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2059 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2060 |  | 
 | 2061 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2062 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2063 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2064 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2065 |         : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {} | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2066 |  | 
 | 2067 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2068 |     __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) | 
 | 2069 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 2070 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 2071 |         { | 
 | 2072 |             _T2::operator=(_VSTD::forward<_T2>(__p.second())); | 
 | 2073 |             __first_ = _VSTD::move(__p.first()); | 
 | 2074 |             return *this; | 
 | 2075 |         } | 
 | 2076 |  | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame^] | 2077 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2078 |  | 
 | 2079 |     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | 
 | 2080 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2081 |         __libcpp_compressed_pair_imp(piecewise_construct_t __pc, | 
 | 2082 |                                      tuple<_Args1...> __first_args, | 
 | 2083 |                                      tuple<_Args2...> __second_args, | 
 | 2084 |                                      __tuple_indices<_I1...>, | 
 | 2085 |                                      __tuple_indices<_I2...>) | 
 | 2086 |             : _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...), | 
 | 2087 |               __first_(_VSTD::forward<_Args1>(get<_I1>(__first_args))...) | 
 | 2088 |                | 
 | 2089 |             {} | 
 | 2090 |  | 
 | 2091 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2092 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2093 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2094 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2095 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2096 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2097 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;} | 
 | 2098 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2099 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2100 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return *this;} | 
 | 2101 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2102 |  | 
 | 2103 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2104 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2105 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2106 |     { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2107 |         using _VSTD::swap; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2108 |         swap(__first_, __x.__first_); | 
 | 2109 |     } | 
 | 2110 | }; | 
 | 2111 |  | 
 | 2112 | template <class _T1, class _T2> | 
 | 2113 | class __libcpp_compressed_pair_imp<_T1, _T2, 3> | 
 | 2114 |     : private _T1, | 
 | 2115 |       private _T2 | 
 | 2116 | { | 
 | 2117 | public: | 
 | 2118 |     typedef _T1 _T1_param; | 
 | 2119 |     typedef _T2 _T2_param; | 
 | 2120 |  | 
 | 2121 |     typedef _T1& _T1_reference; | 
 | 2122 |     typedef _T2& _T2_reference; | 
 | 2123 |  | 
 | 2124 |     typedef const _T1& _T1_const_reference; | 
 | 2125 |     typedef const _T2& _T2_const_reference; | 
 | 2126 |  | 
 | 2127 |     _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} | 
 | 2128 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2129 |         : _T1(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2130 |     _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2131 |         : _T2(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2132 |     _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] | 2133 |         : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2134 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2135 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2136 |  | 
 | 2137 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2138 |     __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) | 
 | 2139 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 2140 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 2141 |         : _T1(__p.first()), _T2(__p.second()) {} | 
 | 2142 |  | 
 | 2143 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2144 |     __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) | 
 | 2145 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 2146 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 2147 |         { | 
 | 2148 |             _T1::operator=(__p.first()); | 
 | 2149 |             _T2::operator=(__p.second()); | 
 | 2150 |             return *this; | 
 | 2151 |         } | 
 | 2152 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2153 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2154 |  | 
 | 2155 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2156 |     __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2157 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2158 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2159 |         : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {} | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2160 |  | 
 | 2161 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2162 |     __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) | 
 | 2163 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 2164 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 2165 |         { | 
 | 2166 |             _T1::operator=(_VSTD::move(__p.first())); | 
 | 2167 |             _T2::operator=(_VSTD::move(__p.second())); | 
 | 2168 |             return *this; | 
 | 2169 |         } | 
 | 2170 |  | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame^] | 2171 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2172 |  | 
 | 2173 |     template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> | 
 | 2174 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2175 |         __libcpp_compressed_pair_imp(piecewise_construct_t __pc, | 
 | 2176 |                                      tuple<_Args1...> __first_args, | 
 | 2177 |                                      tuple<_Args2...> __second_args, | 
 | 2178 |                                      __tuple_indices<_I1...>, | 
 | 2179 |                                      __tuple_indices<_I2...>) | 
 | 2180 |             : _T1(_VSTD::forward<_Args1>(get<_I1>(__first_args))...), | 
 | 2181 |               _T2(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) | 
 | 2182 |             {} | 
 | 2183 |  | 
 | 2184 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2185 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2186 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2187 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2188 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2189 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2190 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;} | 
 | 2191 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2192 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2193 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return *this;} | 
 | 2194 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2195 |  | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 2196 |     _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2197 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2198 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2199 |     { | 
 | 2200 |     } | 
 | 2201 | }; | 
 | 2202 |  | 
 | 2203 | template <class _T1, class _T2> | 
 | 2204 | class __compressed_pair | 
 | 2205 |     : private __libcpp_compressed_pair_imp<_T1, _T2> | 
 | 2206 | { | 
 | 2207 |     typedef __libcpp_compressed_pair_imp<_T1, _T2> base; | 
 | 2208 | public: | 
 | 2209 |     typedef typename base::_T1_param _T1_param; | 
 | 2210 |     typedef typename base::_T2_param _T2_param; | 
 | 2211 |  | 
 | 2212 |     typedef typename base::_T1_reference _T1_reference; | 
 | 2213 |     typedef typename base::_T2_reference _T2_reference; | 
 | 2214 |  | 
 | 2215 |     typedef typename base::_T1_const_reference _T1_const_reference; | 
 | 2216 |     typedef typename base::_T2_const_reference _T2_const_reference; | 
 | 2217 |  | 
 | 2218 |     _LIBCPP_INLINE_VISIBILITY __compressed_pair() {} | 
 | 2219 |     _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1, int = 0) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2220 |         : base(_VSTD::forward<_T1_param>(__t1)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2221 |     _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2, int* = 0) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2222 |         : base(_VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2223 |     _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2224 |         : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2225 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2226 | #ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2227 |  | 
 | 2228 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2229 |     __compressed_pair(const __compressed_pair& __p) | 
 | 2230 |         _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && | 
 | 2231 |                    is_nothrow_copy_constructible<_T2>::value) | 
 | 2232 |         : base(__p) {} | 
 | 2233 |  | 
 | 2234 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2235 |     __compressed_pair& operator=(const __compressed_pair& __p) | 
 | 2236 |         _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && | 
 | 2237 |                    is_nothrow_copy_assignable<_T2>::value) | 
 | 2238 |         { | 
 | 2239 |             base::operator=(__p); | 
 | 2240 |             return *this; | 
 | 2241 |         } | 
 | 2242 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2243 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2244 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2245 |     __compressed_pair(__compressed_pair&& __p) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2246 |         _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && | 
 | 2247 |                    is_nothrow_move_constructible<_T2>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2248 |         : base(_VSTD::move(__p)) {} | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2249 |  | 
 | 2250 |     _LIBCPP_INLINE_VISIBILITY | 
 | 2251 |     __compressed_pair& operator=(__compressed_pair&& __p) | 
 | 2252 |         _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && | 
 | 2253 |                    is_nothrow_move_assignable<_T2>::value) | 
 | 2254 |         { | 
 | 2255 |             base::operator=(_VSTD::move(__p)); | 
 | 2256 |             return *this; | 
 | 2257 |         } | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame^] | 2258 |  | 
 | 2259 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 2260 |  | 
 | 2261 |     template <class... _Args1, class... _Args2> | 
 | 2262 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2263 |         __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, | 
 | 2264 |                                                       tuple<_Args2...> __second_args) | 
 | 2265 |             : base(__pc, __first_args, __second_args, | 
 | 2266 |                    typename __make_tuple_indices<sizeof...(_Args1)>::type(), | 
 | 2267 |                    typename __make_tuple_indices<sizeof...(_Args2) >::type()) | 
 | 2268 |             {} | 
 | 2269 |  | 
 | 2270 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 2271 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2272 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2273 |  | 
| Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 2274 | #endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS | 
 | 2275 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2276 |     _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return base::first();} | 
 | 2277 |     _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2278 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2279 |     _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return base::second();} | 
 | 2280 |     _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2281 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2282 |     _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x) | 
 | 2283 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2284 |                    __is_nothrow_swappable<_T1>::value) | 
 | 2285 |         {base::swap(__x);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2286 | }; | 
 | 2287 |  | 
 | 2288 | template <class _T1, class _T2> | 
 | 2289 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2290 | void | 
 | 2291 | swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2292 |         _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | 
 | 2293 |                    __is_nothrow_swappable<_T1>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2294 |     {__x.swap(__y);} | 
 | 2295 |  | 
 | 2296 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2297 | struct _LIBCPP_VISIBLE default_delete | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2298 | { | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2299 |     _LIBCPP_INLINE_VISIBILITY default_delete() _NOEXCEPT {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2300 |     template <class _Up> | 
 | 2301 |         _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2302 |              typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} | 
 | 2303 |     _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2304 |         { | 
 | 2305 |             static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); | 
 | 2306 |             delete __ptr; | 
 | 2307 |         } | 
 | 2308 | }; | 
 | 2309 |  | 
 | 2310 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2311 | struct _LIBCPP_VISIBLE default_delete<_Tp[]> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2312 | { | 
| Howard Hinnant | 8e84350 | 2011-12-18 21:19:44 +0000 | [diff] [blame] | 2313 | private: | 
 | 2314 |     template <class _P1, | 
 | 2315 |               bool = is_same<typename remove_cv<typename pointer_traits<_P1>::element_type>::type, | 
 | 2316 |                              typename remove_cv<_Tp>::type>::value> | 
 | 2317 |     struct __same_or_less_cv_qualified_imp | 
 | 2318 |         : is_convertible<_P1, _Tp*> {}; | 
 | 2319 |     template <class _P1> | 
 | 2320 |     struct __same_or_less_cv_qualified_imp<_P1, false> | 
 | 2321 |         : false_type {}; | 
 | 2322 |      | 
 | 2323 |     template <class _P1, bool = is_scalar<_P1>::value && !is_pointer<_P1>::value> | 
 | 2324 |     struct __same_or_less_cv_qualified | 
 | 2325 |         : __same_or_less_cv_qualified_imp<_P1> {}; | 
 | 2326 |      | 
 | 2327 |     template <class _P1> | 
 | 2328 |     struct __same_or_less_cv_qualified<_P1, true> | 
 | 2329 |         : false_type {}; | 
 | 2330 |  | 
 | 2331 | public: | 
 | 2332 |     _LIBCPP_INLINE_VISIBILITY default_delete() _NOEXCEPT {} | 
 | 2333 |     template <class _Up> | 
 | 2334 |         _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&, | 
 | 2335 |              typename enable_if<__same_or_less_cv_qualified<_Up*>::value>::type* = 0) _NOEXCEPT {} | 
 | 2336 |     template <class _Up> | 
 | 2337 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2338 |         void operator() (_Up* __ptr, | 
 | 2339 |                          typename enable_if<__same_or_less_cv_qualified<_Up*>::value>::type* = 0) const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2340 |         { | 
 | 2341 |             static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); | 
 | 2342 |             delete [] __ptr; | 
 | 2343 |         } | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2344 | }; | 
 | 2345 |  | 
 | 2346 | template <class _Tp, class _Dp = default_delete<_Tp> > | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2347 | class _LIBCPP_VISIBLE unique_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2348 | { | 
 | 2349 | public: | 
 | 2350 |     typedef _Tp element_type; | 
 | 2351 |     typedef _Dp deleter_type; | 
 | 2352 |     typedef typename __pointer_type<_Tp, deleter_type>::type pointer; | 
 | 2353 | private: | 
 | 2354 |     __compressed_pair<pointer, deleter_type> __ptr_; | 
 | 2355 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2356 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2357 |     unique_ptr(const unique_ptr&); | 
 | 2358 |     unique_ptr& operator=(const unique_ptr&); | 
 | 2359 |     template <class _Up, class _Ep> | 
 | 2360 |         unique_ptr(const unique_ptr<_Up, _Ep>&); | 
 | 2361 |     template <class _Up, class _Ep> | 
 | 2362 |         unique_ptr& operator=(const unique_ptr<_Up, _Ep>&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2363 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2364 |     unique_ptr(unique_ptr&); | 
 | 2365 |     template <class _Up, class _Ep> | 
 | 2366 |         unique_ptr(unique_ptr<_Up, _Ep>&); | 
 | 2367 |     unique_ptr& operator=(unique_ptr&); | 
 | 2368 |     template <class _Up, class _Ep> | 
 | 2369 |         unique_ptr& operator=(unique_ptr<_Up, _Ep>&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2370 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2371 |  | 
 | 2372 |     struct __nat {int __for_bool_;}; | 
 | 2373 |  | 
 | 2374 |     typedef       typename remove_reference<deleter_type>::type& _Dp_reference; | 
 | 2375 |     typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; | 
 | 2376 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2377 |     _LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2378 |         : __ptr_(pointer()) | 
 | 2379 |         { | 
 | 2380 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2381 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2382 |         } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2383 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2384 |         : __ptr_(pointer()) | 
 | 2385 |         { | 
 | 2386 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2387 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2388 |         } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2389 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2390 |         : __ptr_(_VSTD::move(__p)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2391 |         { | 
 | 2392 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2393 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2394 |         } | 
 | 2395 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2396 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2397 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional< | 
 | 2398 |                                         is_reference<deleter_type>::value, | 
 | 2399 |                                         deleter_type, | 
 | 2400 |                                         typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2401 |              _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2402 |         : __ptr_(__p, __d) {} | 
 | 2403 |  | 
 | 2404 |     _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] | 2405 |              _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2406 |         : __ptr_(__p, _VSTD::move(__d)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2407 |         { | 
 | 2408 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2409 |         } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2410 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2411 |         : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2412 |     template <class _Up, class _Ep> | 
 | 2413 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2414 |         unique_ptr(unique_ptr<_Up, _Ep>&& __u, | 
 | 2415 |                    typename enable_if | 
 | 2416 |                       < | 
 | 2417 |                         !is_array<_Up>::value && | 
 | 2418 |                          is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value && | 
 | 2419 |                          is_convertible<_Ep, deleter_type>::value && | 
 | 2420 |                          ( | 
 | 2421 |                             !is_reference<deleter_type>::value || | 
 | 2422 |                             is_same<deleter_type, _Ep>::value | 
 | 2423 |                          ), | 
 | 2424 |                          __nat | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2425 |                       >::type = __nat()) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2426 |             : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2427 |  | 
 | 2428 |     template <class _Up> | 
 | 2429 |         _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p, | 
 | 2430 |                 typename enable_if< | 
 | 2431 |                                       is_convertible<_Up*, _Tp*>::value && | 
 | 2432 |                                       is_same<_Dp, default_delete<_Tp> >::value, | 
 | 2433 |                                       __nat | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2434 |                                   >::type = __nat()) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2435 |             : __ptr_(__p.release()) | 
 | 2436 |             { | 
 | 2437 |             } | 
 | 2438 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2439 |         _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2440 |             { | 
 | 2441 |                 reset(__u.release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2442 |                 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2443 |                 return *this; | 
 | 2444 |             } | 
 | 2445 |  | 
 | 2446 |         template <class _Up, class _Ep> | 
 | 2447 |             _LIBCPP_INLINE_VISIBILITY | 
 | 2448 |             typename enable_if | 
 | 2449 |             < | 
 | 2450 |                 !is_array<_Up>::value, | 
 | 2451 |                 unique_ptr& | 
 | 2452 |             >::type | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2453 |             operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2454 |             { | 
 | 2455 |                 reset(__u.release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2456 |                 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2457 |                 return *this; | 
 | 2458 |             } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2459 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2460 |  | 
 | 2461 |     _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() | 
 | 2462 |     { | 
 | 2463 |         return __rv<unique_ptr>(*this); | 
 | 2464 |     } | 
 | 2465 |  | 
 | 2466 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2467 |         : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2468 |  | 
 | 2469 |     template <class _Up, class _Ep> | 
 | 2470 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) | 
 | 2471 |     { | 
 | 2472 |         reset(__u.release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2473 |         __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2474 |         return *this; | 
 | 2475 |     } | 
 | 2476 |  | 
 | 2477 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2478 |         : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2479 |  | 
 | 2480 |     template <class _Up> | 
 | 2481 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2482 |                 typename enable_if< | 
 | 2483 |                                       is_convertible<_Up*, _Tp*>::value && | 
 | 2484 |                                       is_same<_Dp, default_delete<_Tp> >::value, | 
 | 2485 |                                       unique_ptr& | 
 | 2486 |                                   >::type | 
 | 2487 |         operator=(auto_ptr<_Up> __p) | 
 | 2488 |             {reset(__p.release()); return *this;} | 
 | 2489 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2490 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2491 |     _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} | 
 | 2492 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2493 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2494 |     { | 
 | 2495 |         reset(); | 
 | 2496 |         return *this; | 
 | 2497 |     } | 
 | 2498 |  | 
 | 2499 |     _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const | 
 | 2500 |         {return *__ptr_.first();} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2501 |     _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();} | 
 | 2502 |     _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} | 
 | 2503 |     _LIBCPP_INLINE_VISIBILITY       _Dp_reference get_deleter() _NOEXCEPT | 
 | 2504 |         {return __ptr_.second();} | 
 | 2505 |     _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT | 
 | 2506 |         {return __ptr_.second();} | 
 | 2507 |     _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const | 
 | 2508 |              _NOEXCEPT | 
 | 2509 |         {return __ptr_.first() ? &__nat::__for_bool_ : 0;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2510 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2511 |     _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2512 |     { | 
 | 2513 |         pointer __t = __ptr_.first(); | 
 | 2514 |         __ptr_.first() = pointer(); | 
 | 2515 |         return __t; | 
 | 2516 |     } | 
 | 2517 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2518 |     _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2519 |     { | 
 | 2520 |         pointer __tmp = __ptr_.first(); | 
 | 2521 |         __ptr_.first() = __p; | 
 | 2522 |         if (__tmp) | 
 | 2523 |             __ptr_.second()(__tmp); | 
 | 2524 |     } | 
 | 2525 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2526 |     _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT | 
 | 2527 |         {__ptr_.swap(__u.__ptr_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2528 | }; | 
 | 2529 |  | 
 | 2530 | template <class _Tp, class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2531 | class _LIBCPP_VISIBLE unique_ptr<_Tp[], _Dp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2532 | { | 
 | 2533 | public: | 
 | 2534 |     typedef _Tp element_type; | 
 | 2535 |     typedef _Dp deleter_type; | 
 | 2536 |     typedef typename __pointer_type<_Tp, deleter_type>::type pointer; | 
 | 2537 | private: | 
 | 2538 |     __compressed_pair<pointer, deleter_type> __ptr_; | 
 | 2539 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2540 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2541 |     unique_ptr(const unique_ptr&); | 
 | 2542 |     unique_ptr& operator=(const unique_ptr&); | 
| Howard Hinnant | 0a63119 | 2011-12-16 15:37:23 +0000 | [diff] [blame] | 2543 |  | 
| Howard Hinnant | 8e84350 | 2011-12-18 21:19:44 +0000 | [diff] [blame] | 2544 |     template <class _P1, | 
 | 2545 |               bool = is_same<typename remove_cv<typename pointer_traits<_P1>::element_type>::type, | 
 | 2546 |                              typename remove_cv<element_type>::type>::value> | 
 | 2547 |     struct __same_or_less_cv_qualified_imp | 
 | 2548 |         : is_convertible<_P1, pointer> {}; | 
 | 2549 |     template <class _P1> | 
 | 2550 |     struct __same_or_less_cv_qualified_imp<_P1, false> | 
 | 2551 |         : false_type {}; | 
 | 2552 |      | 
 | 2553 |     template <class _P1, bool = is_scalar<_P1>::value && !is_pointer<_P1>::value> | 
 | 2554 |     struct __same_or_less_cv_qualified | 
 | 2555 |         : __same_or_less_cv_qualified_imp<_P1> {}; | 
 | 2556 |      | 
 | 2557 |     template <class _P1> | 
 | 2558 |     struct __same_or_less_cv_qualified<_P1, true> | 
 | 2559 |         : false_type {}; | 
| Howard Hinnant | 0a63119 | 2011-12-16 15:37:23 +0000 | [diff] [blame] | 2560 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2561 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2562 |     unique_ptr(unique_ptr&); | 
 | 2563 |     template <class _Up> | 
 | 2564 |         unique_ptr(unique_ptr<_Up>&); | 
 | 2565 |     unique_ptr& operator=(unique_ptr&); | 
 | 2566 |     template <class _Up> | 
 | 2567 |         unique_ptr& operator=(unique_ptr<_Up>&); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2568 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2569 |  | 
 | 2570 |     struct __nat {int __for_bool_;}; | 
 | 2571 |  | 
 | 2572 |     typedef       typename remove_reference<deleter_type>::type& _Dp_reference; | 
 | 2573 |     typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference; | 
 | 2574 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2575 |     _LIBCPP_INLINE_VISIBILITY unique_ptr() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2576 |         : __ptr_(pointer()) | 
 | 2577 |         { | 
 | 2578 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2579 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2580 |         } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2581 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2582 |         : __ptr_(pointer()) | 
 | 2583 |         { | 
 | 2584 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2585 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2586 |         } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2587 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2588 |     template <class _Pp, | 
| Howard Hinnant | 0a63119 | 2011-12-16 15:37:23 +0000 | [diff] [blame] | 2589 |               class = typename enable_if<__same_or_less_cv_qualified<_Pp>::value>::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2590 |              > | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2591 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2592 |         : __ptr_(__p) | 
 | 2593 |         { | 
 | 2594 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2595 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2596 |         } | 
 | 2597 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2598 |     template <class _Pp, | 
| Howard Hinnant | 0a63119 | 2011-12-16 15:37:23 +0000 | [diff] [blame] | 2599 |               class = typename enable_if<__same_or_less_cv_qualified<_Pp>::value>::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2600 |              > | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2601 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional< | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2602 |                                        is_reference<deleter_type>::value, | 
 | 2603 |                                        deleter_type, | 
 | 2604 |                                        typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2605 |              _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2606 |         : __ptr_(__p, __d) {} | 
 | 2607 |  | 
 | 2608 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional< | 
 | 2609 |                                        is_reference<deleter_type>::value, | 
 | 2610 |                                        deleter_type, | 
 | 2611 |                                        typename add_lvalue_reference<const deleter_type>::type>::type __d) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2612 |              _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2613 |         : __ptr_(pointer(), __d) {} | 
 | 2614 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2615 |     template <class _Pp, | 
| Howard Hinnant | 0a63119 | 2011-12-16 15:37:23 +0000 | [diff] [blame] | 2616 |               class = typename enable_if<__same_or_less_cv_qualified<_Pp>::value || | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2617 |                                          is_same<_Pp, nullptr_t>::value>::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2618 |              > | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2619 |     _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] | 2620 |              _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2621 |         : __ptr_(__p, _VSTD::move(__d)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2622 |         { | 
 | 2623 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2624 |         } | 
 | 2625 |  | 
 | 2626 |     _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] | 2627 |              _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2628 |         : __ptr_(pointer(), _VSTD::move(__d)) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2629 |         { | 
 | 2630 |             static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); | 
 | 2631 |         } | 
 | 2632 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2633 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2634 |         : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2635 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2636 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2637 |         { | 
 | 2638 |             reset(__u.release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2639 |             __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2640 |             return *this; | 
 | 2641 |         } | 
| Howard Hinnant | 8e84350 | 2011-12-18 21:19:44 +0000 | [diff] [blame] | 2642 |  | 
 | 2643 |     template <class _Up, class _Ep> | 
 | 2644 |         _LIBCPP_INLINE_VISIBILITY | 
 | 2645 |         unique_ptr(unique_ptr<_Up, _Ep>&& __u, | 
 | 2646 |                    typename enable_if | 
 | 2647 |                             < | 
 | 2648 |                                 is_array<_Up>::value && | 
 | 2649 |                                 __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer>::value | 
 | 2650 |                                 && is_convertible<_Ep, deleter_type>::value && | 
 | 2651 |                                 ( | 
 | 2652 |                                     !is_reference<deleter_type>::value || | 
 | 2653 |                                     is_same<deleter_type, _Ep>::value | 
 | 2654 |                                 ), | 
 | 2655 |                                 __nat | 
 | 2656 |                             >::type = __nat() | 
 | 2657 |                   ) _NOEXCEPT | 
 | 2658 |         : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {} | 
 | 2659 |  | 
 | 2660 |  | 
 | 2661 |         template <class _Up, class _Ep> | 
 | 2662 |             _LIBCPP_INLINE_VISIBILITY | 
 | 2663 |             typename enable_if | 
 | 2664 |             < | 
 | 2665 |                 is_array<_Up>::value && | 
 | 2666 |                 __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer>::value && | 
 | 2667 |                 is_assignable<deleter_type, _Ep>::value, | 
 | 2668 |                 unique_ptr& | 
 | 2669 |             >::type | 
 | 2670 |             operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT | 
 | 2671 |             { | 
 | 2672 |                 reset(__u.release()); | 
 | 2673 |                 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); | 
 | 2674 |                 return *this; | 
 | 2675 |             } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2676 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2677 |  | 
 | 2678 |     _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) | 
 | 2679 |         : __ptr_(__p) | 
 | 2680 |         { | 
 | 2681 |             static_assert(!is_pointer<deleter_type>::value, | 
 | 2682 |                 "unique_ptr constructed with null function pointer deleter"); | 
 | 2683 |         } | 
 | 2684 |  | 
 | 2685 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2686 |         : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2687 |  | 
 | 2688 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2689 |         : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2690 |  | 
 | 2691 |     _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>() | 
 | 2692 |     { | 
 | 2693 |         return __rv<unique_ptr>(*this); | 
 | 2694 |     } | 
 | 2695 |  | 
 | 2696 |     _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2697 |         : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2698 |  | 
 | 2699 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u) | 
 | 2700 |     { | 
 | 2701 |         reset(__u->release()); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2702 |         __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter()); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2703 |         return *this; | 
 | 2704 |     } | 
 | 2705 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2706 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2707 |     _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();} | 
 | 2708 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2709 |     _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2710 |     { | 
 | 2711 |         reset(); | 
 | 2712 |         return *this; | 
 | 2713 |     } | 
 | 2714 |  | 
 | 2715 |     _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const | 
 | 2716 |         {return __ptr_.first()[__i];} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2717 |     _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();} | 
 | 2718 |     _LIBCPP_INLINE_VISIBILITY       _Dp_reference get_deleter() _NOEXCEPT | 
 | 2719 |         {return __ptr_.second();} | 
 | 2720 |     _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT | 
 | 2721 |         {return __ptr_.second();} | 
 | 2722 |     _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const _NOEXCEPT | 
 | 2723 |         {return __ptr_.first() ? &__nat::__for_bool_ : 0;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2724 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2725 |     _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2726 |     { | 
 | 2727 |         pointer __t = __ptr_.first(); | 
 | 2728 |         __ptr_.first() = pointer(); | 
 | 2729 |         return __t; | 
 | 2730 |     } | 
 | 2731 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2732 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2733 |     template <class _Pp, | 
| Howard Hinnant | 0a63119 | 2011-12-16 15:37:23 +0000 | [diff] [blame] | 2734 |               class = typename enable_if<__same_or_less_cv_qualified<_Pp>::value>::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2735 |              > | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2736 |     _LIBCPP_INLINE_VISIBILITY void reset(_Pp __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2737 |     { | 
 | 2738 |         pointer __tmp = __ptr_.first(); | 
 | 2739 |         __ptr_.first() = __p; | 
 | 2740 |         if (__tmp) | 
 | 2741 |             __ptr_.second()(__tmp); | 
 | 2742 |     } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2743 |     _LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2744 |     { | 
 | 2745 |         pointer __tmp = __ptr_.first(); | 
 | 2746 |         __ptr_.first() = nullptr; | 
 | 2747 |         if (__tmp) | 
 | 2748 |             __ptr_.second()(__tmp); | 
 | 2749 |     } | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2750 |     _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2751 |     { | 
 | 2752 |         pointer __tmp = __ptr_.first(); | 
 | 2753 |         __ptr_.first() = nullptr; | 
 | 2754 |         if (__tmp) | 
 | 2755 |             __ptr_.second()(__tmp); | 
 | 2756 |     } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2757 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2758 |     _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) | 
 | 2759 |     { | 
 | 2760 |         pointer __tmp = __ptr_.first(); | 
 | 2761 |         __ptr_.first() = __p; | 
 | 2762 |         if (__tmp) | 
 | 2763 |             __ptr_.second()(__tmp); | 
 | 2764 |     } | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2765 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2766 |  | 
 | 2767 |     _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} | 
 | 2768 | private: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 2769 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2770 | #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2771 |     template <class _Up> | 
 | 2772 |         explicit unique_ptr(_Up); | 
 | 2773 |     template <class _Up> | 
 | 2774 |         unique_ptr(_Up __u, | 
 | 2775 |                    typename conditional< | 
 | 2776 |                                        is_reference<deleter_type>::value, | 
 | 2777 |                                        deleter_type, | 
 | 2778 |                                        typename add_lvalue_reference<const deleter_type>::type>::type, | 
 | 2779 |                    typename enable_if | 
 | 2780 |                       < | 
 | 2781 |                          is_convertible<_Up, pointer>::value, | 
 | 2782 |                          __nat | 
 | 2783 |                       >::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2784 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2785 | }; | 
 | 2786 |  | 
 | 2787 | template <class _Tp, class _Dp> | 
 | 2788 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2789 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 2790 | 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] | 2791 |  | 
 | 2792 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2793 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2794 | bool | 
 | 2795 | operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();} | 
 | 2796 |  | 
 | 2797 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2798 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2799 | bool | 
 | 2800 | operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);} | 
 | 2801 |  | 
 | 2802 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2803 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2804 | bool | 
 | 2805 | operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() < __y.get();} | 
 | 2806 |  | 
 | 2807 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2808 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2809 | bool | 
 | 2810 | operator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;} | 
 | 2811 |  | 
 | 2812 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2813 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2814 | bool | 
 | 2815 | operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);} | 
 | 2816 |  | 
 | 2817 | template <class _T1, class _D1, class _T2, class _D2> | 
 | 2818 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 2819 | bool | 
 | 2820 | operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} | 
 | 2821 |  | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 2822 | template <class _Tp> struct hash; | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 2823 |  | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2824 | // We use murmur2 when size_t is 32 bits, and cityhash64 when size_t | 
 | 2825 | // is 64 bits.  This is because cityhash64 uses 64bit x 64bit | 
 | 2826 | // multiplication, which can be very slow on 32-bit systems. | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2827 | template <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__> | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2828 | struct __murmur2_or_cityhash; | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2829 |  | 
 | 2830 | template <class _Size> | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2831 | struct __murmur2_or_cityhash<_Size, 32> | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2832 | { | 
 | 2833 |     _Size operator()(const void* __key, _Size __len); | 
 | 2834 | }; | 
 | 2835 |  | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2836 | // murmur2 | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2837 | template <class _Size> | 
 | 2838 | _Size | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2839 | __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2840 | { | 
 | 2841 |     const _Size __m = 0x5bd1e995; | 
 | 2842 |     const _Size __r = 24; | 
 | 2843 |     _Size __h = __len; | 
 | 2844 |     const unsigned char* __data = static_cast<const unsigned char*>(__key); | 
 | 2845 |     for (; __len >= 4; __data += 4, __len -= 4) | 
 | 2846 |     { | 
 | 2847 |         _Size __k = *(const _Size*)__data; | 
 | 2848 |         __k *= __m; | 
 | 2849 |         __k ^= __k >> __r; | 
 | 2850 |         __k *= __m; | 
 | 2851 |         __h *= __m; | 
 | 2852 |         __h ^= __k; | 
 | 2853 |     } | 
 | 2854 |     switch (__len) | 
 | 2855 |     { | 
 | 2856 |     case 3: | 
 | 2857 |         __h ^= __data[2] << 16; | 
 | 2858 |     case 2: | 
 | 2859 |         __h ^= __data[1] << 8; | 
 | 2860 |     case 1: | 
 | 2861 |         __h ^= __data[0]; | 
 | 2862 |         __h *= __m; | 
 | 2863 |     } | 
 | 2864 |     __h ^= __h >> 13; | 
 | 2865 |     __h *= __m; | 
 | 2866 |     __h ^= __h >> 15; | 
 | 2867 |     return __h; | 
 | 2868 | } | 
 | 2869 |  | 
 | 2870 | template <class _Size> | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2871 | struct __murmur2_or_cityhash<_Size, 64> | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2872 | { | 
 | 2873 |     _Size operator()(const void* __key, _Size __len); | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2874 |  | 
 | 2875 |  private: | 
 | 2876 |   // Some primes between 2^63 and 2^64. | 
 | 2877 |   static const _Size __k0 = 0xc3a5c85c97cb3127ULL; | 
 | 2878 |   static const _Size __k1 = 0xb492b66fbe98f273ULL; | 
 | 2879 |   static const _Size __k2 = 0x9ae16a3b2f90404fULL; | 
 | 2880 |   static const _Size __k3 = 0xc949d7c7509e6557ULL; | 
 | 2881 |  | 
 | 2882 |   static _Size __rotate(_Size __val, int __shift) { | 
 | 2883 |     return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); | 
 | 2884 |   } | 
 | 2885 |  | 
 | 2886 |   static _Size __rotate_by_at_least_1(_Size __val, int __shift) { | 
 | 2887 |     return (__val >> __shift) | (__val << (64 - __shift)); | 
 | 2888 |   } | 
 | 2889 |  | 
 | 2890 |   static _Size __shift_mix(_Size __val) { | 
 | 2891 |     return __val ^ (__val >> 47); | 
 | 2892 |   } | 
 | 2893 |  | 
 | 2894 |   static _Size __hash_len_16(_Size __u, _Size __v) { | 
 | 2895 |     const _Size __mul = 0x9ddfea08eb382d69ULL; | 
 | 2896 |     _Size __a = (__u ^ __v) * __mul; | 
 | 2897 |     __a ^= (__a >> 47); | 
 | 2898 |     _Size __b = (__v ^ __a) * __mul; | 
 | 2899 |     __b ^= (__b >> 47); | 
 | 2900 |     __b *= __mul; | 
 | 2901 |     return __b; | 
 | 2902 |   } | 
 | 2903 |  | 
 | 2904 |   static _Size __hash_len_0_to_16(const char* __s, _Size __len) { | 
 | 2905 |     if (__len > 8) { | 
 | 2906 |       const _Size __a = *(const _Size*)__s; | 
 | 2907 |       const _Size __b = *(const _Size*)(__s + __len - 8); | 
 | 2908 |       return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; | 
 | 2909 |     } | 
 | 2910 |     if (__len >= 4) { | 
 | 2911 |       const uint32_t __a = *(const uint32_t*)(__s); | 
 | 2912 |       const uint32_t __b = *(const uint32_t*)(__s + __len - 4); | 
 | 2913 |       return __hash_len_16(__len + (__a << 3), __b); | 
 | 2914 |     } | 
 | 2915 |     if (__len > 0) { | 
 | 2916 |       const unsigned char __a = __s[0]; | 
 | 2917 |       const unsigned char __b = __s[__len >> 1]; | 
 | 2918 |       const unsigned char __c = __s[__len - 1]; | 
 | 2919 |       const uint32_t __y = static_cast<uint32_t>(__a) + | 
 | 2920 |                            (static_cast<uint32_t>(__b) << 8); | 
 | 2921 |       const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2); | 
 | 2922 |       return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; | 
 | 2923 |     } | 
 | 2924 |     return __k2; | 
 | 2925 |   } | 
 | 2926 |  | 
 | 2927 |   static _Size __hash_len_17_to_32(const char *__s, _Size __len) { | 
 | 2928 |     const _Size __a = *(const _Size*)(__s) * __k1; | 
 | 2929 |     const _Size __b = *(const _Size*)(__s + 8); | 
 | 2930 |     const _Size __c = *(const _Size*)(__s + __len - 8) * __k2; | 
 | 2931 |     const _Size __d = *(const _Size*)(__s + __len - 16) * __k0; | 
 | 2932 |     return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, | 
 | 2933 |                          __a + __rotate(__b ^ __k3, 20) - __c + __len); | 
 | 2934 |   } | 
 | 2935 |  | 
 | 2936 |   // Return a 16-byte hash for 48 bytes.  Quick and dirty. | 
 | 2937 |   // Callers do best to use "random-looking" values for a and b. | 
 | 2938 |   static pair<_Size, _Size> __weak_hash_len_32_with_seeds( | 
 | 2939 |       _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) { | 
 | 2940 |     __a += __w; | 
 | 2941 |     __b = __rotate(__b + __a + __z, 21); | 
 | 2942 |     const _Size __c = __a; | 
 | 2943 |     __a += __x; | 
 | 2944 |     __a += __y; | 
 | 2945 |     __b += __rotate(__a, 44); | 
 | 2946 |     return pair<_Size, _Size>(__a + __z, __b + __c); | 
 | 2947 |   } | 
 | 2948 |  | 
 | 2949 |   // Return a 16-byte hash for s[0] ... s[31], a, and b.  Quick and dirty. | 
 | 2950 |   static pair<_Size, _Size> __weak_hash_len_32_with_seeds( | 
 | 2951 |       const char* __s, _Size __a, _Size __b) { | 
 | 2952 |     return __weak_hash_len_32_with_seeds(*(const _Size*)(__s), | 
 | 2953 |                                          *(const _Size*)(__s + 8), | 
 | 2954 |                                          *(const _Size*)(__s + 16), | 
 | 2955 |                                          *(const _Size*)(__s + 24), | 
 | 2956 |                                          __a, | 
 | 2957 |                                          __b); | 
 | 2958 |   } | 
 | 2959 |  | 
 | 2960 |   // Return an 8-byte hash for 33 to 64 bytes. | 
 | 2961 |   static _Size __hash_len_33_to_64(const char *__s, size_t __len) { | 
 | 2962 |     _Size __z = *(const _Size*)(__s + 24); | 
 | 2963 |     _Size __a = *(const _Size*)(__s) + | 
 | 2964 |                 (__len + *(const _Size*)(__s + __len - 16)) * __k0; | 
 | 2965 |     _Size __b = __rotate(__a + __z, 52); | 
 | 2966 |     _Size __c = __rotate(__a, 37); | 
 | 2967 |     __a += *(const _Size*)(__s + 8); | 
 | 2968 |     __c += __rotate(__a, 7); | 
 | 2969 |     __a += *(const _Size*)(__s + 16); | 
 | 2970 |     _Size __vf = __a + __z; | 
 | 2971 |     _Size __vs = __b + __rotate(__a, 31) + __c; | 
 | 2972 |     __a = *(const _Size*)(__s + 16) + *(const _Size*)(__s + __len - 32); | 
 | 2973 |     __z += *(const _Size*)(__s + __len - 8); | 
 | 2974 |     __b = __rotate(__a + __z, 52); | 
 | 2975 |     __c = __rotate(__a, 37); | 
 | 2976 |     __a += *(const _Size*)(__s + __len - 24); | 
 | 2977 |     __c += __rotate(__a, 7); | 
 | 2978 |     __a += *(const _Size*)(__s + __len - 16); | 
 | 2979 |     _Size __wf = __a + __z; | 
 | 2980 |     _Size __ws = __b + __rotate(__a, 31) + __c; | 
 | 2981 |     _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); | 
 | 2982 |     return __shift_mix(__r * __k0 + __vs) * __k2; | 
 | 2983 |   } | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2984 | }; | 
 | 2985 |  | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2986 | // cityhash64 | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2987 | template <class _Size> | 
 | 2988 | _Size | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2989 | __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2990 | { | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2991 |   const char* __s = static_cast<const char*>(__key); | 
 | 2992 |   if (__len <= 32) { | 
 | 2993 |     if (__len <= 16) { | 
 | 2994 |       return __hash_len_0_to_16(__s, __len); | 
 | 2995 |     } else { | 
 | 2996 |       return __hash_len_17_to_32(__s, __len); | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 2997 |     } | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 2998 |   } else if (__len <= 64) { | 
 | 2999 |     return __hash_len_33_to_64(__s, __len); | 
 | 3000 |   } | 
 | 3001 |  | 
 | 3002 |   // For strings over 64 bytes we hash the end first, and then as we | 
 | 3003 |   // loop we keep 56 bytes of state: v, w, x, y, and z. | 
 | 3004 |   _Size __x = *(const _Size*)(__s + __len - 40); | 
 | 3005 |   _Size __y = *(const _Size*)(__s + __len - 16) + | 
 | 3006 |               *(const _Size*)(__s + __len - 56); | 
 | 3007 |   _Size __z = __hash_len_16(*(const _Size*)(__s + __len - 48) + __len, | 
 | 3008 |                           *(const _Size*)(__s + __len - 24)); | 
 | 3009 |   pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); | 
 | 3010 |   pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); | 
 | 3011 |   __x = __x * __k1 + *(const _Size*)(__s); | 
 | 3012 |  | 
 | 3013 |   // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. | 
 | 3014 |   __len = (__len - 1) & ~static_cast<_Size>(63); | 
 | 3015 |   do { | 
 | 3016 |     __x = __rotate(__x + __y + __v.first + *(const _Size*)(__s + 8), 37) * __k1; | 
 | 3017 |     __y = __rotate(__y + __v.second + *(const _Size*)(__s + 48), 42) * __k1; | 
 | 3018 |     __x ^= __w.second; | 
 | 3019 |     __y += __v.first + *(const _Size*)(__s + 40); | 
 | 3020 |     __z = __rotate(__z + __w.first, 33) * __k1; | 
 | 3021 |     __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); | 
 | 3022 |     __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, | 
 | 3023 |                                         __y + *(const _Size*)(__s + 16)); | 
 | 3024 |     std::swap(__z, __x); | 
 | 3025 |     __s += 64; | 
 | 3026 |     __len -= 64; | 
 | 3027 |   } while (__len != 0); | 
 | 3028 |   return __hash_len_16( | 
 | 3029 |       __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, | 
 | 3030 |       __hash_len_16(__v.second, __w.second) + __x); | 
| Howard Hinnant | 40c13d3 | 2011-12-05 00:08:45 +0000 | [diff] [blame] | 3031 | } | 
 | 3032 |  | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3033 | template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> | 
 | 3034 | struct __scalar_hash; | 
 | 3035 |  | 
 | 3036 | template <class _Tp> | 
 | 3037 | struct __scalar_hash<_Tp, 0> | 
 | 3038 |     : public unary_function<_Tp, size_t> | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3039 | { | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3040 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3041 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3042 |     { | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3043 |         union | 
 | 3044 |         { | 
 | 3045 |             _Tp    __t; | 
 | 3046 |             size_t __a; | 
 | 3047 |         } __u; | 
 | 3048 |         __u.__a = 0; | 
 | 3049 |         __u.__t = __v; | 
 | 3050 |         return __u.__a; | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3051 |     } | 
 | 3052 | }; | 
 | 3053 |  | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3054 | template <class _Tp> | 
 | 3055 | struct __scalar_hash<_Tp, 1> | 
 | 3056 |     : public unary_function<_Tp, size_t> | 
 | 3057 | { | 
 | 3058 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3059 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
 | 3060 |     { | 
 | 3061 |         union | 
 | 3062 |         { | 
 | 3063 |             _Tp    __t; | 
 | 3064 |             size_t __a; | 
 | 3065 |         } __u; | 
 | 3066 |         __u.__t = __v; | 
 | 3067 |         return __u.__a; | 
 | 3068 |     } | 
 | 3069 | }; | 
 | 3070 |  | 
 | 3071 | template <class _Tp> | 
 | 3072 | struct __scalar_hash<_Tp, 2> | 
 | 3073 |     : public unary_function<_Tp, size_t> | 
 | 3074 | { | 
 | 3075 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3076 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
 | 3077 |     { | 
 | 3078 |         union | 
 | 3079 |         { | 
 | 3080 |             _Tp __t; | 
 | 3081 |             struct | 
 | 3082 |             { | 
 | 3083 |                 size_t __a; | 
 | 3084 |                 size_t __b; | 
 | 3085 |             }; | 
 | 3086 |         } __u; | 
 | 3087 |         __u.__t = __v; | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3088 |         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3089 |     } | 
 | 3090 | }; | 
 | 3091 |  | 
 | 3092 | template <class _Tp> | 
 | 3093 | struct __scalar_hash<_Tp, 3> | 
 | 3094 |     : public unary_function<_Tp, size_t> | 
 | 3095 | { | 
 | 3096 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3097 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
 | 3098 |     { | 
 | 3099 |         union | 
 | 3100 |         { | 
 | 3101 |             _Tp __t; | 
 | 3102 |             struct | 
 | 3103 |             { | 
 | 3104 |                 size_t __a; | 
 | 3105 |                 size_t __b; | 
 | 3106 |                 size_t __c; | 
 | 3107 |             }; | 
 | 3108 |         } __u; | 
 | 3109 |         __u.__t = __v; | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3110 |         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3111 |     } | 
 | 3112 | }; | 
 | 3113 |  | 
 | 3114 | template <class _Tp> | 
 | 3115 | struct __scalar_hash<_Tp, 4> | 
 | 3116 |     : public unary_function<_Tp, size_t> | 
 | 3117 | { | 
 | 3118 |     _LIBCPP_INLINE_VISIBILITY | 
 | 3119 |     size_t operator()(_Tp __v) const _NOEXCEPT | 
 | 3120 |     { | 
 | 3121 |         union | 
 | 3122 |         { | 
 | 3123 |             _Tp __t; | 
 | 3124 |             struct | 
 | 3125 |             { | 
 | 3126 |                 size_t __a; | 
 | 3127 |                 size_t __b; | 
 | 3128 |                 size_t __c; | 
 | 3129 |                 size_t __d; | 
 | 3130 |             }; | 
 | 3131 |         } __u; | 
 | 3132 |         __u.__t = __v; | 
| Howard Hinnant | c00f75d | 2011-12-10 20:28:56 +0000 | [diff] [blame] | 3133 |         return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); | 
| Howard Hinnant | cf2654b | 2011-12-03 21:11:36 +0000 | [diff] [blame] | 3134 |     } | 
 | 3135 | }; | 
 | 3136 |  | 
 | 3137 | template<class _Tp> | 
 | 3138 | struct _LIBCPP_VISIBLE hash<_Tp*> | 
 | 3139 |     : public __scalar_hash<_Tp*> | 
 | 3140 | { | 
 | 3141 | }; | 
 | 3142 |  | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3143 | template <class _Tp, class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3144 | struct _LIBCPP_VISIBLE hash<unique_ptr<_Tp, _Dp> > | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3145 | { | 
 | 3146 |     typedef unique_ptr<_Tp, _Dp> argument_type; | 
 | 3147 |     typedef size_t               result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3148 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3149 |     result_type operator()(const argument_type& __ptr) const _NOEXCEPT | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 3150 |     { | 
 | 3151 |         typedef typename argument_type::pointer pointer; | 
 | 3152 |         return hash<pointer>()(__ptr.get()); | 
 | 3153 |     } | 
 | 3154 | }; | 
 | 3155 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3156 | struct __destruct_n | 
 | 3157 | { | 
 | 3158 | private: | 
 | 3159 |     size_t size; | 
 | 3160 |  | 
 | 3161 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3162 |     _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3163 |         {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();} | 
 | 3164 |  | 
 | 3165 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3166 |     _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3167 |         {} | 
 | 3168 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3169 |     _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3170 |         {++size;} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3171 |     _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3172 |         {} | 
 | 3173 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3174 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3175 |         {size = __s;} | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3176 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3177 |         {} | 
 | 3178 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3179 |     _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT | 
 | 3180 |         : size(__s) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3181 |  | 
 | 3182 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3183 |     _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT | 
| Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 3184 |         {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3185 |  | 
 | 3186 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3187 |     _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT | 
| Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 3188 |         {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3189 |  | 
 | 3190 |     template <class _Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3191 |     _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT | 
| Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 3192 |         {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3193 | }; | 
 | 3194 |  | 
 | 3195 | template <class _Alloc> | 
 | 3196 | class __allocator_destructor | 
 | 3197 | { | 
 | 3198 |     typedef allocator_traits<_Alloc> __alloc_traits; | 
 | 3199 | public: | 
 | 3200 |     typedef typename __alloc_traits::pointer pointer; | 
 | 3201 |     typedef typename __alloc_traits::size_type size_type; | 
 | 3202 | private: | 
 | 3203 |     _Alloc& __alloc_; | 
 | 3204 |     size_type __s_; | 
 | 3205 | public: | 
 | 3206 |     _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3207 |              _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3208 |         : __alloc_(__a), __s_(__s) {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3209 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3210 |     void operator()(pointer __p) _NOEXCEPT | 
 | 3211 |         {__alloc_traits::deallocate(__alloc_, __p, __s_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3212 | }; | 
 | 3213 |  | 
 | 3214 | template <class _InputIterator, class _ForwardIterator> | 
 | 3215 | _ForwardIterator | 
 | 3216 | uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) | 
 | 3217 | { | 
 | 3218 |     __destruct_n __d(0); | 
 | 3219 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
 | 3220 |     unique_ptr<value_type, __destruct_n&> __h(&*__r, __d); | 
 | 3221 |     for (; __f != __l; ++__f, ++__r, __d.__incr((value_type*)0)) | 
 | 3222 |         ::new(&*__r) value_type(*__f); | 
 | 3223 |     __h.release(); | 
 | 3224 |     return __r; | 
 | 3225 | } | 
 | 3226 |  | 
 | 3227 | template <class _InputIterator, class _Size, class _ForwardIterator> | 
 | 3228 | _ForwardIterator | 
 | 3229 | uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) | 
 | 3230 | { | 
 | 3231 |     __destruct_n __d(0); | 
 | 3232 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
 | 3233 |     unique_ptr<value_type, __destruct_n&> __h(&*__r, __d); | 
 | 3234 |     for (; __n > 0; ++__f, ++__r, __d.__incr((value_type*)0), --__n) | 
 | 3235 |         ::new(&*__r) value_type(*__f); | 
 | 3236 |     __h.release(); | 
 | 3237 |     return __r; | 
 | 3238 | } | 
 | 3239 |  | 
 | 3240 | template <class _ForwardIterator, class _Tp> | 
 | 3241 | void | 
 | 3242 | uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) | 
 | 3243 | { | 
 | 3244 |     __destruct_n __d(0); | 
 | 3245 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
 | 3246 |     unique_ptr<value_type, __destruct_n&> __h(&*__f, __d); | 
 | 3247 |     for (; __f != __l; ++__f, __d.__incr((value_type*)0)) | 
 | 3248 |         ::new(&*__f) value_type(__x); | 
 | 3249 |     __h.release(); | 
 | 3250 | } | 
 | 3251 |  | 
 | 3252 | template <class _ForwardIterator, class _Size, class _Tp> | 
| Howard Hinnant | 2f6a627 | 2010-11-18 16:13:03 +0000 | [diff] [blame] | 3253 | _ForwardIterator | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3254 | uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) | 
 | 3255 | { | 
 | 3256 |     __destruct_n __d(0); | 
 | 3257 |     typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 
 | 3258 |     unique_ptr<value_type, __destruct_n&> __h(&*__f, __d); | 
 | 3259 |     for (; __n > 0; ++__f, --__n, __d.__incr((value_type*)0)) | 
 | 3260 |         ::new(&*__f) value_type(__x); | 
 | 3261 |     __h.release(); | 
| Howard Hinnant | 2f6a627 | 2010-11-18 16:13:03 +0000 | [diff] [blame] | 3262 |     return __f; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3263 | } | 
 | 3264 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3265 | class _LIBCPP_EXCEPTION_ABI bad_weak_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3266 |     : public std::exception | 
 | 3267 | { | 
 | 3268 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3269 |     virtual ~bad_weak_ptr() _NOEXCEPT; | 
 | 3270 |     virtual const char* what() const  _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3271 | }; | 
 | 3272 |  | 
 | 3273 | template<class _Tp> class weak_ptr; | 
 | 3274 |  | 
 | 3275 | class __shared_count | 
 | 3276 | { | 
 | 3277 |     __shared_count(const __shared_count&); | 
 | 3278 |     __shared_count& operator=(const __shared_count&); | 
 | 3279 |  | 
 | 3280 | protected: | 
 | 3281 |     long __shared_owners_; | 
 | 3282 |     virtual ~__shared_count(); | 
 | 3283 | private: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3284 |     virtual void __on_zero_shared() _NOEXCEPT = 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3285 |  | 
 | 3286 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3287 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3288 |     explicit __shared_count(long __refs = 0) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3289 |         : __shared_owners_(__refs) {} | 
 | 3290 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3291 |     void __add_shared() _NOEXCEPT; | 
 | 3292 |     bool __release_shared() _NOEXCEPT; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3293 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3294 |     long use_count() const _NOEXCEPT {return __shared_owners_ + 1;} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3295 | }; | 
 | 3296 |  | 
 | 3297 | class __shared_weak_count | 
 | 3298 |     : private __shared_count | 
 | 3299 | { | 
 | 3300 |     long __shared_weak_owners_; | 
 | 3301 |  | 
 | 3302 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3303 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3304 |     explicit __shared_weak_count(long __refs = 0) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3305 |         : __shared_count(__refs), | 
 | 3306 |           __shared_weak_owners_(__refs) {} | 
 | 3307 | protected: | 
 | 3308 |     virtual ~__shared_weak_count(); | 
 | 3309 |  | 
 | 3310 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3311 |     void __add_shared() _NOEXCEPT; | 
 | 3312 |     void __add_weak() _NOEXCEPT; | 
 | 3313 |     void __release_shared() _NOEXCEPT; | 
 | 3314 |     void __release_weak() _NOEXCEPT; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3315 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3316 |     long use_count() const _NOEXCEPT {return __shared_count::use_count();} | 
 | 3317 |     __shared_weak_count* lock() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3318 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3319 |     virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3320 | private: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3321 |     virtual void __on_zero_shared_weak() _NOEXCEPT = 0; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3322 | }; | 
 | 3323 |  | 
 | 3324 | template <class _Tp, class _Dp, class _Alloc> | 
 | 3325 | class __shared_ptr_pointer | 
 | 3326 |     : public __shared_weak_count | 
 | 3327 | { | 
 | 3328 |     __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; | 
 | 3329 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3330 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3331 |     __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3332 |         :  __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3333 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3334 | #ifndef _LIBCPP_NO_RTTI | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3335 |     virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3336 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3337 |  | 
 | 3338 | private: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3339 |     virtual void __on_zero_shared() _NOEXCEPT; | 
 | 3340 |     virtual void __on_zero_shared_weak() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3341 | }; | 
 | 3342 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3343 | #ifndef _LIBCPP_NO_RTTI | 
 | 3344 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3345 | template <class _Tp, class _Dp, class _Alloc> | 
 | 3346 | const void* | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3347 | __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] | 3348 | { | 
 | 3349 |     return __t == typeid(_Dp) ? &__data_.first().second() : 0; | 
 | 3350 | } | 
 | 3351 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3352 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3353 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3354 | template <class _Tp, class _Dp, class _Alloc> | 
 | 3355 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3356 | __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3357 | { | 
 | 3358 |     __data_.first().second()(__data_.first().first()); | 
 | 3359 |     __data_.first().second().~_Dp(); | 
 | 3360 | } | 
 | 3361 |  | 
 | 3362 | template <class _Tp, class _Dp, class _Alloc> | 
 | 3363 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3364 | __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3365 | { | 
 | 3366 |     typename _Alloc::template rebind<__shared_ptr_pointer>::other __a(__data_.second()); | 
 | 3367 |     __data_.second().~_Alloc(); | 
 | 3368 |     __a.deallocate(this, 1); | 
 | 3369 | } | 
 | 3370 |  | 
 | 3371 | template <class _Tp, class _Alloc> | 
 | 3372 | class __shared_ptr_emplace | 
 | 3373 |     : public __shared_weak_count | 
 | 3374 | { | 
 | 3375 |     __compressed_pair<_Alloc, _Tp> __data_; | 
 | 3376 | public: | 
 | 3377 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 3378 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3379 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3380 |     __shared_ptr_emplace(_Alloc __a) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3381 |         :  __data_(_VSTD::move(__a)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3382 |  | 
 | 3383 |     template <class ..._Args> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3384 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3385 |         __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) | 
| Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame^] | 3386 |             :  __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), | 
 | 3387 |                    _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3388 |  | 
 | 3389 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3390 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3391 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3392 |     __shared_ptr_emplace(_Alloc __a) | 
 | 3393 |         :  __data_(__a) {} | 
 | 3394 |  | 
 | 3395 |     template <class _A0> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3396 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3397 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0) | 
 | 3398 |             :  __data_(__a, _Tp(__a0)) {} | 
 | 3399 |  | 
 | 3400 |     template <class _A0, class _A1> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3401 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3402 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1) | 
 | 3403 |             :  __data_(__a, _Tp(__a0, __a1)) {} | 
 | 3404 |  | 
 | 3405 |     template <class _A0, class _A1, class _A2> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3406 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3407 |         __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 3408 |             :  __data_(__a, _Tp(__a0, __a1, __a2)) {} | 
 | 3409 |  | 
 | 3410 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3411 |  | 
 | 3412 | private: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3413 |     virtual void __on_zero_shared() _NOEXCEPT; | 
 | 3414 |     virtual void __on_zero_shared_weak() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3415 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3416 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3417 |     _Tp* get() _NOEXCEPT {return &__data_.second();} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3418 | }; | 
 | 3419 |  | 
 | 3420 | template <class _Tp, class _Alloc> | 
 | 3421 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3422 | __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3423 | { | 
 | 3424 |     __data_.second().~_Tp(); | 
 | 3425 | } | 
 | 3426 |  | 
 | 3427 | template <class _Tp, class _Alloc> | 
 | 3428 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3429 | __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3430 | { | 
 | 3431 |     typename _Alloc::template rebind<__shared_ptr_emplace>::other __a(__data_.first()); | 
 | 3432 |     __data_.first().~_Alloc(); | 
 | 3433 |     __a.deallocate(this, 1); | 
 | 3434 | } | 
 | 3435 |  | 
 | 3436 | template<class _Tp> class enable_shared_from_this; | 
 | 3437 |  | 
 | 3438 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3439 | class _LIBCPP_VISIBLE shared_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3440 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3441 | public: | 
 | 3442 |     typedef _Tp element_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3443 | private: | 
 | 3444 |     element_type*      __ptr_; | 
 | 3445 |     __shared_weak_count* __cntrl_; | 
 | 3446 |  | 
 | 3447 |     struct __nat {int __for_bool_;}; | 
 | 3448 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3449 |     shared_ptr() _NOEXCEPT; | 
 | 3450 |     shared_ptr(nullptr_t) _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3451 |     template<class _Yp> explicit shared_ptr(_Yp* __p); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3452 |     template<class _Yp, class _Dp> shared_ptr(_Yp* __p, _Dp __d); | 
 | 3453 |     template<class _Yp, class _Dp, class _Alloc> shared_ptr(_Yp* __p, _Dp __d, _Alloc __a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3454 |     template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); | 
 | 3455 |     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] | 3456 |     template<class _Yp> shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; | 
 | 3457 |     shared_ptr(const shared_ptr& __r) _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3458 |     template<class _Yp> | 
 | 3459 |         shared_ptr(const shared_ptr<_Yp>& __r, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3460 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) | 
 | 3461 |                        _NOEXCEPT; | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3462 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3463 |     shared_ptr(shared_ptr&& __r) _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3464 |     template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3465 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat()) | 
 | 3466 |                        _NOEXCEPT; | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3467 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3468 |     template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3469 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3470 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3471 |     template<class _Yp> shared_ptr(auto_ptr<_Yp>&& __r); | 
 | 3472 | #else | 
 | 3473 |     template<class _Yp> shared_ptr(auto_ptr<_Yp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3474 | #endif | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3475 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3476 | private: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3477 |     template <class _Yp, class _Dp> shared_ptr(const unique_ptr<_Yp, _Dp>& __r);// = delete; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3478 | public: | 
 | 3479 |     template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>&&, | 
 | 3480 |        typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
 | 3481 |     template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>&&, | 
 | 3482 |        typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3483 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3484 |     template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>, | 
 | 3485 |        typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
 | 3486 |     template <class _Yp, class _Dp> shared_ptr(unique_ptr<_Yp, _Dp>, | 
 | 3487 |        typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type = __nat()); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3488 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3489 |  | 
 | 3490 |     ~shared_ptr(); | 
 | 3491 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3492 |     shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; | 
 | 3493 |     template<class _Yp> shared_ptr& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3494 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3495 |     shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3496 |     template<class _Yp> shared_ptr& operator=(shared_ptr<_Yp>&& __r); | 
 | 3497 |     template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp>&& __r); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3498 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3499 |     template<class _Yp> shared_ptr& operator=(auto_ptr<_Yp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3500 | #endif | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3501 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3502 | private: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3503 |     template <class _Yp, class _Dp> shared_ptr& operator=(const unique_ptr<_Yp, _Dp>& __r);// = delete; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3504 | public: | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3505 |     template <class _Yp, class _Dp> shared_ptr& operator=(unique_ptr<_Yp, _Dp>&& __r); | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3506 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3507 |     template <class _Yp, class _Dp> shared_ptr& operator=(unique_ptr<_Yp, _Dp> __r); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3508 | #endif | 
 | 3509 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3510 |     void swap(shared_ptr& __r) _NOEXCEPT; | 
 | 3511 |     void reset() _NOEXCEPT; | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 3512 |     template<class _Yp> void reset(_Yp* __p); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3513 |     template<class _Yp, class _Dp> void reset(_Yp* __p, _Dp __d); | 
 | 3514 |     template<class _Yp, class _Dp, class _Alloc> void reset(_Yp* __p, _Dp __d, _Alloc __a); | 
 | 3515 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3516 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3517 |     element_type* get() const _NOEXCEPT {return __ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3518 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3519 |     typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT | 
 | 3520 |         {return *__ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3521 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3522 |     element_type* operator->() const _NOEXCEPT {return __ptr_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3523 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3524 |     long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3525 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3526 |     bool unique() const _NOEXCEPT {return use_count() == 1;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3527 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3528 |     /*explicit*/ operator bool() const _NOEXCEPT {return get() != 0;} | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3529 |     template <class _Up> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3530 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3531 |         bool owner_before(shared_ptr<_Up> const& __p) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3532 |         {return __cntrl_ < __p.__cntrl_;} | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3533 |     template <class _Up> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3534 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 3535 |         bool owner_before(weak_ptr<_Up> const& __p) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3536 |         {return __cntrl_ < __p.__cntrl_;} | 
 | 3537 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 3538 | #ifndef _LIBCPP_NO_RTTI | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3539 |     template <class _Dp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3540 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3541 |         _Dp* __get_deleter() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3542 |             {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3543 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3544 |  | 
 | 3545 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 3546 |  | 
 | 3547 |     template<class ..._Args> | 
 | 3548 |         static | 
 | 3549 |         shared_ptr<_Tp> | 
 | 3550 |         make_shared(_Args&& ...__args); | 
 | 3551 |  | 
 | 3552 |     template<class _Alloc, class ..._Args> | 
 | 3553 |         static | 
 | 3554 |         shared_ptr<_Tp> | 
 | 3555 |         allocate_shared(const _Alloc& __a, _Args&& ...__args); | 
 | 3556 |  | 
 | 3557 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3558 |  | 
 | 3559 |     static shared_ptr<_Tp> make_shared(); | 
 | 3560 |  | 
 | 3561 |     template<class _A0> | 
 | 3562 |         static shared_ptr<_Tp> make_shared(_A0&); | 
 | 3563 |  | 
 | 3564 |     template<class _A0, class _A1> | 
 | 3565 |         static shared_ptr<_Tp> make_shared(_A0&, _A1&); | 
 | 3566 |  | 
 | 3567 |     template<class _A0, class _A1, class _A2> | 
 | 3568 |         static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&); | 
 | 3569 |  | 
 | 3570 |     template<class _Alloc> | 
 | 3571 |         static shared_ptr<_Tp> | 
 | 3572 |         allocate_shared(const _Alloc& __a); | 
 | 3573 |  | 
 | 3574 |     template<class _Alloc, class _A0> | 
 | 3575 |         static shared_ptr<_Tp> | 
 | 3576 |         allocate_shared(const _Alloc& __a, _A0& __a0); | 
 | 3577 |  | 
 | 3578 |     template<class _Alloc, class _A0, class _A1> | 
 | 3579 |         static shared_ptr<_Tp> | 
 | 3580 |         allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1); | 
 | 3581 |  | 
 | 3582 |     template<class _Alloc, class _A0, class _A1, class _A2> | 
 | 3583 |         static shared_ptr<_Tp> | 
 | 3584 |         allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2); | 
 | 3585 |  | 
 | 3586 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3587 |  | 
 | 3588 | private: | 
 | 3589 |  | 
 | 3590 |     template <class _Yp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3591 |         _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3592 |         void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3593 |         __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3594 |         { | 
 | 3595 |             if (__e) | 
 | 3596 |                 __e->__weak_this_ = *this; | 
 | 3597 |         } | 
 | 3598 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3599 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3600 |     void __enable_weak_this(const void*) _NOEXCEPT {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3601 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 3602 |     template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; | 
 | 3603 |     template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3604 | }; | 
 | 3605 |  | 
 | 3606 | template<class _Tp> | 
 | 3607 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3608 | shared_ptr<_Tp>::shared_ptr() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3609 |     : __ptr_(0), | 
 | 3610 |       __cntrl_(0) | 
 | 3611 | { | 
 | 3612 | } | 
 | 3613 |  | 
 | 3614 | template<class _Tp> | 
 | 3615 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3616 | shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3617 |     : __ptr_(0), | 
 | 3618 |       __cntrl_(0) | 
 | 3619 | { | 
 | 3620 | } | 
 | 3621 |  | 
 | 3622 | template<class _Tp> | 
 | 3623 | template<class _Yp> | 
 | 3624 | shared_ptr<_Tp>::shared_ptr(_Yp* __p) | 
 | 3625 |     : __ptr_(__p) | 
 | 3626 | { | 
 | 3627 |     unique_ptr<_Yp> __hold(__p); | 
 | 3628 |     typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | 
 | 3629 |     __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); | 
 | 3630 |     __hold.release(); | 
 | 3631 |     __enable_weak_this(__p); | 
 | 3632 | } | 
 | 3633 |  | 
 | 3634 | template<class _Tp> | 
 | 3635 | template<class _Yp, class _Dp> | 
 | 3636 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d) | 
 | 3637 |     : __ptr_(__p) | 
 | 3638 | { | 
 | 3639 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3640 |     try | 
 | 3641 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3642 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3643 |         typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; | 
 | 3644 |         __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); | 
 | 3645 |         __enable_weak_this(__p); | 
 | 3646 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3647 |     } | 
 | 3648 |     catch (...) | 
 | 3649 |     { | 
 | 3650 |         __d(__p); | 
 | 3651 |         throw; | 
 | 3652 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3653 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3654 | } | 
 | 3655 |  | 
 | 3656 | template<class _Tp> | 
 | 3657 | template<class _Dp> | 
 | 3658 | shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) | 
 | 3659 |     : __ptr_(0) | 
 | 3660 | { | 
 | 3661 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3662 |     try | 
 | 3663 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3664 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3665 |         typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk; | 
 | 3666 |         __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); | 
 | 3667 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3668 |     } | 
 | 3669 |     catch (...) | 
 | 3670 |     { | 
 | 3671 |         __d(__p); | 
 | 3672 |         throw; | 
 | 3673 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3674 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3675 | } | 
 | 3676 |  | 
 | 3677 | template<class _Tp> | 
 | 3678 | template<class _Yp, class _Dp, class _Alloc> | 
 | 3679 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) | 
 | 3680 |     : __ptr_(__p) | 
 | 3681 | { | 
 | 3682 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3683 |     try | 
 | 3684 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3685 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3686 |         typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; | 
 | 3687 |         typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 3688 |         typedef __allocator_destructor<_A2> _D2; | 
 | 3689 |         _A2 __a2(__a); | 
 | 3690 |         unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
 | 3691 |         ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); | 
 | 3692 |         __cntrl_ = __hold2.release(); | 
 | 3693 |         __enable_weak_this(__p); | 
 | 3694 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3695 |     } | 
 | 3696 |     catch (...) | 
 | 3697 |     { | 
 | 3698 |         __d(__p); | 
 | 3699 |         throw; | 
 | 3700 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3701 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3702 | } | 
 | 3703 |  | 
 | 3704 | template<class _Tp> | 
 | 3705 | template<class _Dp, class _Alloc> | 
 | 3706 | shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) | 
 | 3707 |     : __ptr_(0) | 
 | 3708 | { | 
 | 3709 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3710 |     try | 
 | 3711 |     { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3712 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3713 |         typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; | 
 | 3714 |         typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 3715 |         typedef __allocator_destructor<_A2> _D2; | 
 | 3716 |         _A2 __a2(__a); | 
 | 3717 |         unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
 | 3718 |         ::new(__hold2.get()) _CntrlBlk(__p, __d, __a); | 
 | 3719 |         __cntrl_ = __hold2.release(); | 
 | 3720 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 3721 |     } | 
 | 3722 |     catch (...) | 
 | 3723 |     { | 
 | 3724 |         __d(__p); | 
 | 3725 |         throw; | 
 | 3726 |     } | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 3727 | #endif  // _LIBCPP_NO_EXCEPTIONS | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3728 | } | 
 | 3729 |  | 
 | 3730 | template<class _Tp> | 
 | 3731 | template<class _Yp> | 
 | 3732 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3733 | 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] | 3734 |     : __ptr_(__p), | 
 | 3735 |       __cntrl_(__r.__cntrl_) | 
 | 3736 | { | 
 | 3737 |     if (__cntrl_) | 
 | 3738 |         __cntrl_->__add_shared(); | 
 | 3739 | } | 
 | 3740 |  | 
 | 3741 | template<class _Tp> | 
 | 3742 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3743 | shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3744 |     : __ptr_(__r.__ptr_), | 
 | 3745 |       __cntrl_(__r.__cntrl_) | 
 | 3746 | { | 
 | 3747 |     if (__cntrl_) | 
 | 3748 |         __cntrl_->__add_shared(); | 
 | 3749 | } | 
 | 3750 |  | 
 | 3751 | template<class _Tp> | 
 | 3752 | template<class _Yp> | 
 | 3753 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3754 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, | 
 | 3755 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3756 |          _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3757 |     : __ptr_(__r.__ptr_), | 
 | 3758 |       __cntrl_(__r.__cntrl_) | 
 | 3759 | { | 
 | 3760 |     if (__cntrl_) | 
 | 3761 |         __cntrl_->__add_shared(); | 
 | 3762 | } | 
 | 3763 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3764 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3765 |  | 
 | 3766 | template<class _Tp> | 
 | 3767 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3768 | shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3769 |     : __ptr_(__r.__ptr_), | 
 | 3770 |       __cntrl_(__r.__cntrl_) | 
 | 3771 | { | 
 | 3772 |     __r.__ptr_ = 0; | 
 | 3773 |     __r.__cntrl_ = 0; | 
 | 3774 | } | 
 | 3775 |  | 
 | 3776 | template<class _Tp> | 
 | 3777 | template<class _Yp> | 
 | 3778 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 3779 | shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, | 
 | 3780 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 3781 |          _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3782 |     : __ptr_(__r.__ptr_), | 
 | 3783 |       __cntrl_(__r.__cntrl_) | 
 | 3784 | { | 
 | 3785 |     __r.__ptr_ = 0; | 
 | 3786 |     __r.__cntrl_ = 0; | 
 | 3787 | } | 
 | 3788 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3789 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3790 |  | 
 | 3791 | template<class _Tp> | 
 | 3792 | template<class _Yp> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3793 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3794 | shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r) | 
 | 3795 | #else | 
| Howard Hinnant | 92172b8 | 2010-08-21 21:14:53 +0000 | [diff] [blame] | 3796 | shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3797 | #endif | 
 | 3798 |     : __ptr_(__r.get()) | 
 | 3799 | { | 
 | 3800 |     typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | 
 | 3801 |     __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); | 
 | 3802 |     __enable_weak_this(__r.get()); | 
 | 3803 |     __r.release(); | 
 | 3804 | } | 
 | 3805 |  | 
 | 3806 | template<class _Tp> | 
 | 3807 | template <class _Yp, class _Dp> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3808 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3809 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 
 | 3810 | #else | 
 | 3811 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | 
 | 3812 | #endif | 
 | 3813 |            typename enable_if<!is_lvalue_reference<_Dp>::value, __nat>::type) | 
 | 3814 |     : __ptr_(__r.get()) | 
 | 3815 | { | 
 | 3816 |     typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; | 
 | 3817 |     __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); | 
 | 3818 |     __enable_weak_this(__r.get()); | 
 | 3819 |     __r.release(); | 
 | 3820 | } | 
 | 3821 |  | 
 | 3822 | template<class _Tp> | 
 | 3823 | template <class _Yp, class _Dp> | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 3824 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3825 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | 
 | 3826 | #else | 
 | 3827 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r, | 
 | 3828 | #endif | 
 | 3829 |            typename enable_if<is_lvalue_reference<_Dp>::value, __nat>::type) | 
 | 3830 |     : __ptr_(__r.get()) | 
 | 3831 | { | 
 | 3832 |     typedef __shared_ptr_pointer<_Yp*, | 
 | 3833 |                                  reference_wrapper<typename remove_reference<_Dp>::type>, | 
 | 3834 |                                  allocator<_Yp> > _CntrlBlk; | 
 | 3835 |     __cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); | 
 | 3836 |     __enable_weak_this(__r.get()); | 
 | 3837 |     __r.release(); | 
 | 3838 | } | 
 | 3839 |  | 
 | 3840 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 3841 |  | 
 | 3842 | template<class _Tp> | 
 | 3843 | template<class ..._Args> | 
 | 3844 | shared_ptr<_Tp> | 
 | 3845 | shared_ptr<_Tp>::make_shared(_Args&& ...__args) | 
 | 3846 | { | 
 | 3847 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3848 |     typedef allocator<_CntrlBlk> _A2; | 
 | 3849 |     typedef __allocator_destructor<_A2> _D2; | 
 | 3850 |     _A2 __a2; | 
 | 3851 |     unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3852 |     ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3853 |     shared_ptr<_Tp> __r; | 
 | 3854 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3855 |     __r.__cntrl_ = __hold2.release(); | 
 | 3856 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3857 |     return __r; | 
 | 3858 | } | 
 | 3859 |  | 
 | 3860 | template<class _Tp> | 
 | 3861 | template<class _Alloc, class ..._Args> | 
 | 3862 | shared_ptr<_Tp> | 
 | 3863 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) | 
 | 3864 | { | 
 | 3865 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3866 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _A2; | 
 | 3867 |     typedef __allocator_destructor<_A2> _D2; | 
 | 3868 |     _A2 __a2(__a); | 
 | 3869 |     unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 3870 |     ::new(__hold2.get()) _CntrlBlk(__a, _VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3871 |     shared_ptr<_Tp> __r; | 
 | 3872 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3873 |     __r.__cntrl_ = __hold2.release(); | 
 | 3874 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3875 |     return __r; | 
 | 3876 | } | 
 | 3877 |  | 
 | 3878 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 3879 |  | 
 | 3880 | template<class _Tp> | 
 | 3881 | shared_ptr<_Tp> | 
 | 3882 | shared_ptr<_Tp>::make_shared() | 
 | 3883 | { | 
 | 3884 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3885 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 3886 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3887 |     _Alloc2 __alloc2; | 
 | 3888 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3889 |     ::new(__hold2.get()) _CntrlBlk(__alloc2); | 
 | 3890 |     shared_ptr<_Tp> __r; | 
 | 3891 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3892 |     __r.__cntrl_ = __hold2.release(); | 
 | 3893 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3894 |     return __r; | 
 | 3895 | } | 
 | 3896 |  | 
 | 3897 | template<class _Tp> | 
 | 3898 | template<class _A0> | 
 | 3899 | shared_ptr<_Tp> | 
 | 3900 | shared_ptr<_Tp>::make_shared(_A0& __a0) | 
 | 3901 | { | 
 | 3902 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3903 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 3904 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3905 |     _Alloc2 __alloc2; | 
 | 3906 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3907 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0); | 
 | 3908 |     shared_ptr<_Tp> __r; | 
 | 3909 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3910 |     __r.__cntrl_ = __hold2.release(); | 
 | 3911 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3912 |     return __r; | 
 | 3913 | } | 
 | 3914 |  | 
 | 3915 | template<class _Tp> | 
 | 3916 | template<class _A0, class _A1> | 
 | 3917 | shared_ptr<_Tp> | 
 | 3918 | shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1) | 
 | 3919 | { | 
 | 3920 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3921 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 3922 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3923 |     _Alloc2 __alloc2; | 
 | 3924 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3925 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1); | 
 | 3926 |     shared_ptr<_Tp> __r; | 
 | 3927 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3928 |     __r.__cntrl_ = __hold2.release(); | 
 | 3929 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3930 |     return __r; | 
 | 3931 | } | 
 | 3932 |  | 
 | 3933 | template<class _Tp> | 
 | 3934 | template<class _A0, class _A1, class _A2> | 
 | 3935 | shared_ptr<_Tp> | 
 | 3936 | shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2) | 
 | 3937 | { | 
 | 3938 |     typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; | 
 | 3939 |     typedef allocator<_CntrlBlk> _Alloc2; | 
 | 3940 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3941 |     _Alloc2 __alloc2; | 
 | 3942 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3943 |     ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2); | 
 | 3944 |     shared_ptr<_Tp> __r; | 
 | 3945 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3946 |     __r.__cntrl_ = __hold2.release(); | 
 | 3947 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3948 |     return __r; | 
 | 3949 | } | 
 | 3950 |  | 
 | 3951 | template<class _Tp> | 
 | 3952 | template<class _Alloc> | 
 | 3953 | shared_ptr<_Tp> | 
 | 3954 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a) | 
 | 3955 | { | 
 | 3956 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3957 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 3958 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3959 |     _Alloc2 __alloc2(__a); | 
 | 3960 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3961 |     ::new(__hold2.get()) _CntrlBlk(__a); | 
 | 3962 |     shared_ptr<_Tp> __r; | 
 | 3963 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3964 |     __r.__cntrl_ = __hold2.release(); | 
 | 3965 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3966 |     return __r; | 
 | 3967 | } | 
 | 3968 |  | 
 | 3969 | template<class _Tp> | 
 | 3970 | template<class _Alloc, class _A0> | 
 | 3971 | shared_ptr<_Tp> | 
 | 3972 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0) | 
 | 3973 | { | 
 | 3974 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3975 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 3976 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3977 |     _Alloc2 __alloc2(__a); | 
 | 3978 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3979 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0); | 
 | 3980 |     shared_ptr<_Tp> __r; | 
 | 3981 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 3982 |     __r.__cntrl_ = __hold2.release(); | 
 | 3983 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 3984 |     return __r; | 
 | 3985 | } | 
 | 3986 |  | 
 | 3987 | template<class _Tp> | 
 | 3988 | template<class _Alloc, class _A0, class _A1> | 
 | 3989 | shared_ptr<_Tp> | 
 | 3990 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) | 
 | 3991 | { | 
 | 3992 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 3993 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 3994 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 3995 |     _Alloc2 __alloc2(__a); | 
 | 3996 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 3997 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1); | 
 | 3998 |     shared_ptr<_Tp> __r; | 
 | 3999 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4000 |     __r.__cntrl_ = __hold2.release(); | 
 | 4001 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4002 |     return __r; | 
 | 4003 | } | 
 | 4004 |  | 
 | 4005 | template<class _Tp> | 
 | 4006 | template<class _Alloc, class _A0, class _A1, class _A2> | 
 | 4007 | shared_ptr<_Tp> | 
 | 4008 | shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 4009 | { | 
 | 4010 |     typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk; | 
 | 4011 |     typedef typename _Alloc::template rebind<_CntrlBlk>::other _Alloc2; | 
 | 4012 |     typedef __allocator_destructor<_Alloc2> _D2; | 
 | 4013 |     _Alloc2 __alloc2(__a); | 
 | 4014 |     unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1)); | 
 | 4015 |     ::new(__hold2.get()) _CntrlBlk(__a, __a0, __a1, __a2); | 
 | 4016 |     shared_ptr<_Tp> __r; | 
 | 4017 |     __r.__ptr_ = __hold2.get()->get(); | 
 | 4018 |     __r.__cntrl_ = __hold2.release(); | 
 | 4019 |     __r.__enable_weak_this(__r.__ptr_); | 
 | 4020 |     return __r; | 
 | 4021 | } | 
 | 4022 |  | 
 | 4023 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 4024 |  | 
 | 4025 | template<class _Tp> | 
 | 4026 | shared_ptr<_Tp>::~shared_ptr() | 
 | 4027 | { | 
 | 4028 |     if (__cntrl_) | 
 | 4029 |         __cntrl_->__release_shared(); | 
 | 4030 | } | 
 | 4031 |  | 
 | 4032 | template<class _Tp> | 
 | 4033 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4034 | shared_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4035 | shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4036 | { | 
 | 4037 |     shared_ptr(__r).swap(*this); | 
 | 4038 |     return *this; | 
 | 4039 | } | 
 | 4040 |  | 
 | 4041 | template<class _Tp> | 
 | 4042 | template<class _Yp> | 
 | 4043 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4044 | shared_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4045 | shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4046 | { | 
 | 4047 |     shared_ptr(__r).swap(*this); | 
 | 4048 |     return *this; | 
 | 4049 | } | 
 | 4050 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4051 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4052 |  | 
 | 4053 | template<class _Tp> | 
 | 4054 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4055 | shared_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4056 | shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4057 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4058 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4059 |     return *this; | 
 | 4060 | } | 
 | 4061 |  | 
 | 4062 | template<class _Tp> | 
 | 4063 | template<class _Yp> | 
 | 4064 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4065 | shared_ptr<_Tp>& | 
 | 4066 | shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) | 
 | 4067 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4068 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4069 |     return *this; | 
 | 4070 | } | 
 | 4071 |  | 
 | 4072 | template<class _Tp> | 
 | 4073 | template<class _Yp> | 
 | 4074 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4075 | shared_ptr<_Tp>& | 
 | 4076 | shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) | 
 | 4077 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4078 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4079 |     return *this; | 
 | 4080 | } | 
 | 4081 |  | 
 | 4082 | template<class _Tp> | 
 | 4083 | template <class _Yp, class _Dp> | 
 | 4084 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4085 | shared_ptr<_Tp>& | 
 | 4086 | shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) | 
 | 4087 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4088 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4089 |     return *this; | 
 | 4090 | } | 
 | 4091 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4092 | #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4093 |  | 
 | 4094 | template<class _Tp> | 
 | 4095 | template<class _Yp> | 
 | 4096 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4097 | shared_ptr<_Tp>& | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4098 | shared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4099 | { | 
 | 4100 |     shared_ptr(__r).swap(*this); | 
 | 4101 |     return *this; | 
 | 4102 | } | 
 | 4103 |  | 
 | 4104 | template<class _Tp> | 
 | 4105 | template <class _Yp, class _Dp> | 
 | 4106 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4107 | shared_ptr<_Tp>& | 
 | 4108 | shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) | 
 | 4109 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4110 |     shared_ptr(_VSTD::move(__r)).swap(*this); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4111 |     return *this; | 
 | 4112 | } | 
 | 4113 |  | 
| Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 4114 | #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4115 |  | 
 | 4116 | template<class _Tp> | 
 | 4117 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4118 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4119 | shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4120 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4121 |     _VSTD::swap(__ptr_, __r.__ptr_); | 
 | 4122 |     _VSTD::swap(__cntrl_, __r.__cntrl_); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4123 | } | 
 | 4124 |  | 
 | 4125 | template<class _Tp> | 
 | 4126 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4127 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4128 | shared_ptr<_Tp>::reset() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4129 | { | 
 | 4130 |     shared_ptr().swap(*this); | 
 | 4131 | } | 
 | 4132 |  | 
 | 4133 | template<class _Tp> | 
 | 4134 | template<class _Yp> | 
 | 4135 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4136 | void | 
 | 4137 | shared_ptr<_Tp>::reset(_Yp* __p) | 
 | 4138 | { | 
 | 4139 |     shared_ptr(__p).swap(*this); | 
 | 4140 | } | 
 | 4141 |  | 
 | 4142 | template<class _Tp> | 
 | 4143 | template<class _Yp, class _Dp> | 
 | 4144 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4145 | void | 
 | 4146 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) | 
 | 4147 | { | 
 | 4148 |     shared_ptr(__p, __d).swap(*this); | 
 | 4149 | } | 
 | 4150 |  | 
 | 4151 | template<class _Tp> | 
 | 4152 | template<class _Yp, class _Dp, class _Alloc> | 
 | 4153 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4154 | void | 
 | 4155 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) | 
 | 4156 | { | 
 | 4157 |     shared_ptr(__p, __d, __a).swap(*this); | 
 | 4158 | } | 
 | 4159 |  | 
 | 4160 | #ifndef _LIBCPP_HAS_NO_VARIADICS | 
 | 4161 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4162 | template<class _Tp, class ..._Args> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4163 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4164 | shared_ptr<_Tp> | 
 | 4165 | make_shared(_Args&& ...__args) | 
 | 4166 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4167 |     return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4168 | } | 
 | 4169 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4170 | template<class _Tp, class _Alloc, class ..._Args> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4171 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4172 | shared_ptr<_Tp> | 
 | 4173 | allocate_shared(const _Alloc& __a, _Args&& ...__args) | 
 | 4174 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4175 |     return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4176 | } | 
 | 4177 |  | 
 | 4178 | #else  // _LIBCPP_HAS_NO_VARIADICS | 
 | 4179 |  | 
 | 4180 | template<class _Tp> | 
 | 4181 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4182 | shared_ptr<_Tp> | 
 | 4183 | make_shared() | 
 | 4184 | { | 
 | 4185 |     return shared_ptr<_Tp>::make_shared(); | 
 | 4186 | } | 
 | 4187 |  | 
 | 4188 | template<class _Tp, class _A0> | 
 | 4189 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4190 | shared_ptr<_Tp> | 
 | 4191 | make_shared(_A0& __a0) | 
 | 4192 | { | 
 | 4193 |     return shared_ptr<_Tp>::make_shared(__a0); | 
 | 4194 | } | 
 | 4195 |  | 
 | 4196 | template<class _Tp, class _A0, class _A1> | 
 | 4197 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4198 | shared_ptr<_Tp> | 
 | 4199 | make_shared(_A0& __a0, _A1& __a1) | 
 | 4200 | { | 
 | 4201 |     return shared_ptr<_Tp>::make_shared(__a0, __a1); | 
 | 4202 | } | 
 | 4203 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4204 | template<class _Tp, class _A0, class _A1, class _A2> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4205 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4206 | shared_ptr<_Tp> | 
 | 4207 | make_shared(_A0& __a0, _A1& __a1, _A2& __a2) | 
 | 4208 | { | 
 | 4209 |     return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2); | 
 | 4210 | } | 
 | 4211 |  | 
 | 4212 | template<class _Tp, class _Alloc> | 
 | 4213 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4214 | shared_ptr<_Tp> | 
 | 4215 | allocate_shared(const _Alloc& __a) | 
 | 4216 | { | 
 | 4217 |     return shared_ptr<_Tp>::allocate_shared(__a); | 
 | 4218 | } | 
 | 4219 |  | 
 | 4220 | template<class _Tp, class _Alloc, class _A0> | 
 | 4221 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4222 | shared_ptr<_Tp> | 
 | 4223 | allocate_shared(const _Alloc& __a, _A0& __a0) | 
 | 4224 | { | 
 | 4225 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0); | 
 | 4226 | } | 
 | 4227 |  | 
 | 4228 | template<class _Tp, class _Alloc, class _A0, class _A1> | 
 | 4229 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4230 | shared_ptr<_Tp> | 
 | 4231 | allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1) | 
 | 4232 | { | 
 | 4233 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1); | 
 | 4234 | } | 
 | 4235 |  | 
 | 4236 | template<class _Tp, class _Alloc, class _A0, class _A1, class _A2> | 
 | 4237 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4238 | shared_ptr<_Tp> | 
 | 4239 | allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2) | 
 | 4240 | { | 
 | 4241 |     return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2); | 
 | 4242 | } | 
 | 4243 |  | 
 | 4244 | #endif  // _LIBCPP_HAS_NO_VARIADICS | 
 | 4245 |  | 
 | 4246 | template<class _Tp, class _Up> | 
 | 4247 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4248 | bool | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4249 | operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4250 | { | 
 | 4251 |     return __x.get() == __y.get(); | 
 | 4252 | } | 
 | 4253 |  | 
 | 4254 | template<class _Tp, class _Up> | 
 | 4255 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4256 | bool | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4257 | operator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4258 | { | 
 | 4259 |     return !(__x == __y); | 
 | 4260 | } | 
 | 4261 |  | 
 | 4262 | template<class _Tp, class _Up> | 
 | 4263 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4264 | bool | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4265 | operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4266 | { | 
 | 4267 |     return __x.get() < __y.get(); | 
 | 4268 | } | 
 | 4269 |  | 
 | 4270 | template<class _Tp> | 
 | 4271 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4272 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4273 | swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4274 | { | 
 | 4275 |     __x.swap(__y); | 
 | 4276 | } | 
 | 4277 |  | 
 | 4278 | template<class _Tp, class _Up> | 
 | 4279 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4280 | shared_ptr<_Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4281 | static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4282 | { | 
 | 4283 |     return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); | 
 | 4284 | } | 
 | 4285 |  | 
 | 4286 | template<class _Tp, class _Up> | 
 | 4287 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4288 | shared_ptr<_Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4289 | dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4290 | { | 
 | 4291 |     _Tp* __p = dynamic_cast<_Tp*>(__r.get()); | 
 | 4292 |     return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); | 
 | 4293 | } | 
 | 4294 |  | 
 | 4295 | template<class _Tp, class _Up> | 
 | 4296 | shared_ptr<_Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4297 | const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4298 | { | 
 | 4299 |     return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get())); | 
 | 4300 | } | 
 | 4301 |  | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 4302 | #ifndef _LIBCPP_NO_RTTI | 
 | 4303 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4304 | template<class _Dp, class _Tp> | 
 | 4305 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4306 | _Dp* | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4307 | get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4308 | { | 
 | 4309 |     return __p.template __get_deleter<_Dp>(); | 
 | 4310 | } | 
 | 4311 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4312 | #endif  // _LIBCPP_NO_RTTI | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 4313 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4314 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4315 | class _LIBCPP_VISIBLE weak_ptr | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4316 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4317 | public: | 
 | 4318 |     typedef _Tp element_type; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4319 | private: | 
 | 4320 |     element_type*        __ptr_; | 
 | 4321 |     __shared_weak_count* __cntrl_; | 
 | 4322 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4323 | public: | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4324 |     weak_ptr() _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4325 |     template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4326 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) | 
 | 4327 |                         _NOEXCEPT; | 
 | 4328 |     weak_ptr(weak_ptr const& __r) _NOEXCEPT; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4329 |     template<class _Yp> weak_ptr(weak_ptr<_Yp> const& __r, | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4330 |                    typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) | 
 | 4331 |                          _NOEXCEPT; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4332 |  | 
 | 4333 |     ~weak_ptr(); | 
 | 4334 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4335 |     weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; | 
 | 4336 |     template<class _Yp> weak_ptr& operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; | 
 | 4337 |     template<class _Yp> weak_ptr& operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4338 |  | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4339 |     void swap(weak_ptr& __r) _NOEXCEPT; | 
 | 4340 |     void reset() _NOEXCEPT; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4341 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4342 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4343 |     long use_count() const _NOEXCEPT | 
 | 4344 |         {return __cntrl_ ? __cntrl_->use_count() : 0;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4345 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4346 |     bool expired() const _NOEXCEPT | 
 | 4347 |         {return __cntrl_ == 0 || __cntrl_->use_count() == 0;} | 
 | 4348 |     shared_ptr<_Tp> lock() const _NOEXCEPT; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4349 |     template<class _Up> | 
 | 4350 |         _LIBCPP_INLINE_VISIBILITY | 
 | 4351 |         bool owner_before(const shared_ptr<_Up>& __r) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4352 |         {return __cntrl_ < __r.__cntrl_;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4353 |     template<class _Up> | 
 | 4354 |         _LIBCPP_INLINE_VISIBILITY | 
 | 4355 |         bool owner_before(const weak_ptr<_Up>& __r) const | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4356 |         {return __cntrl_ < __r.__cntrl_;} | 
 | 4357 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4358 |     template <class _Up> friend class _LIBCPP_VISIBLE weak_ptr; | 
 | 4359 |     template <class _Up> friend class _LIBCPP_VISIBLE shared_ptr; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4360 | }; | 
 | 4361 |  | 
 | 4362 | template<class _Tp> | 
 | 4363 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4364 | weak_ptr<_Tp>::weak_ptr() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4365 |     : __ptr_(0), | 
 | 4366 |       __cntrl_(0) | 
 | 4367 | { | 
 | 4368 | } | 
 | 4369 |  | 
 | 4370 | template<class _Tp> | 
 | 4371 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4372 | weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4373 |     : __ptr_(__r.__ptr_), | 
 | 4374 |       __cntrl_(__r.__cntrl_) | 
 | 4375 | { | 
 | 4376 |     if (__cntrl_) | 
 | 4377 |         __cntrl_->__add_weak(); | 
 | 4378 | } | 
 | 4379 |  | 
 | 4380 | template<class _Tp> | 
 | 4381 | template<class _Yp> | 
 | 4382 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4383 | weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, | 
| Howard Hinnant | e003ce4 | 2011-05-22 00:09:02 +0000 | [diff] [blame] | 4384 |                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4385 |                          _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4386 |     : __ptr_(__r.__ptr_), | 
 | 4387 |       __cntrl_(__r.__cntrl_) | 
 | 4388 | { | 
 | 4389 |     if (__cntrl_) | 
 | 4390 |         __cntrl_->__add_weak(); | 
 | 4391 | } | 
 | 4392 |  | 
 | 4393 | template<class _Tp> | 
 | 4394 | template<class _Yp> | 
 | 4395 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4396 | weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, | 
| Howard Hinnant | e003ce4 | 2011-05-22 00:09:02 +0000 | [diff] [blame] | 4397 |                         typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4398 |          _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4399 |     : __ptr_(__r.__ptr_), | 
 | 4400 |       __cntrl_(__r.__cntrl_) | 
 | 4401 | { | 
 | 4402 |     if (__cntrl_) | 
 | 4403 |         __cntrl_->__add_weak(); | 
 | 4404 | } | 
 | 4405 |  | 
 | 4406 | template<class _Tp> | 
 | 4407 | weak_ptr<_Tp>::~weak_ptr() | 
 | 4408 | { | 
 | 4409 |     if (__cntrl_) | 
 | 4410 |         __cntrl_->__release_weak(); | 
 | 4411 | } | 
 | 4412 |  | 
 | 4413 | template<class _Tp> | 
 | 4414 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4415 | weak_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4416 | weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4417 | { | 
 | 4418 |     weak_ptr(__r).swap(*this); | 
 | 4419 |     return *this; | 
 | 4420 | } | 
 | 4421 |  | 
 | 4422 | template<class _Tp> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4423 | template<class _Yp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4424 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4425 | weak_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4426 | weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4427 | { | 
 | 4428 |     weak_ptr(__r).swap(*this); | 
 | 4429 |     return *this; | 
 | 4430 | } | 
 | 4431 |  | 
 | 4432 | template<class _Tp> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4433 | template<class _Yp> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4434 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4435 | weak_ptr<_Tp>& | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4436 | weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4437 | { | 
 | 4438 |     weak_ptr(__r).swap(*this); | 
 | 4439 |     return *this; | 
 | 4440 | } | 
 | 4441 |  | 
 | 4442 | template<class _Tp> | 
 | 4443 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4444 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4445 | weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4446 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 4447 |     _VSTD::swap(__ptr_, __r.__ptr_); | 
 | 4448 |     _VSTD::swap(__cntrl_, __r.__cntrl_); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4449 | } | 
 | 4450 |  | 
 | 4451 | template<class _Tp> | 
 | 4452 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4453 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4454 | swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4455 | { | 
 | 4456 |     __x.swap(__y); | 
 | 4457 | } | 
 | 4458 |  | 
 | 4459 | template<class _Tp> | 
 | 4460 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4461 | void | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4462 | weak_ptr<_Tp>::reset() _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4463 | { | 
 | 4464 |     weak_ptr().swap(*this); | 
 | 4465 | } | 
 | 4466 |  | 
 | 4467 | template<class _Tp> | 
 | 4468 | template<class _Yp> | 
 | 4469 | shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, | 
 | 4470 |                             typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type) | 
 | 4471 |     : __ptr_(__r.__ptr_), | 
 | 4472 |       __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) | 
 | 4473 | { | 
 | 4474 |     if (__cntrl_ == 0) | 
 | 4475 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
 | 4476 |         throw bad_weak_ptr(); | 
 | 4477 | #else | 
 | 4478 |         assert(!"bad_weak_ptr"); | 
 | 4479 | #endif | 
 | 4480 | } | 
 | 4481 |  | 
 | 4482 | template<class _Tp> | 
 | 4483 | shared_ptr<_Tp> | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4484 | weak_ptr<_Tp>::lock() const _NOEXCEPT | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4485 | { | 
 | 4486 |     shared_ptr<_Tp> __r; | 
 | 4487 |     __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_; | 
 | 4488 |     if (__r.__cntrl_) | 
 | 4489 |         __r.__ptr_ = __ptr_; | 
 | 4490 |     return __r; | 
 | 4491 | } | 
 | 4492 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4493 | template <class _Tp> struct owner_less; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4494 |  | 
 | 4495 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4496 | struct _LIBCPP_VISIBLE owner_less<shared_ptr<_Tp> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4497 |     : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4498 | { | 
 | 4499 |     typedef bool result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4500 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4501 |     bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 4502 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4503 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4504 |     bool operator()(shared_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 4505 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4506 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4507 |     bool operator()(  weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 4508 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4509 | }; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4510 |  | 
 | 4511 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4512 | struct _LIBCPP_VISIBLE owner_less<weak_ptr<_Tp> > | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4513 |     : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> | 
 | 4514 | { | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4515 |     typedef bool result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4516 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4517 |     bool operator()(  weak_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 4518 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4519 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4520 |     bool operator()(shared_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const | 
 | 4521 |         {return __x.owner_before(__y);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4522 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4523 |     bool operator()(  weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const | 
 | 4524 |         {return __x.owner_before(__y);} | 
 | 4525 | }; | 
 | 4526 |  | 
 | 4527 | template<class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4528 | class _LIBCPP_VISIBLE enable_shared_from_this | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4529 | { | 
 | 4530 |     mutable weak_ptr<_Tp> __weak_this_; | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4531 | protected: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4532 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4533 |     enable_shared_from_this() _NOEXCEPT {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4534 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4535 |     enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4536 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4537 |     enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT | 
 | 4538 |         {return *this;} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4539 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4540 |     ~enable_shared_from_this() {} | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4541 | public: | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4542 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4543 |     shared_ptr<_Tp> shared_from_this() | 
 | 4544 |         {return shared_ptr<_Tp>(__weak_this_);} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4545 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4546 |     shared_ptr<_Tp const> shared_from_this() const | 
 | 4547 |         {return shared_ptr<const _Tp>(__weak_this_);} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4548 |  | 
 | 4549 |     template <class _Up> friend class shared_ptr; | 
 | 4550 | }; | 
 | 4551 |  | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 4552 | template <class _Tp> | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4553 | struct _LIBCPP_VISIBLE hash<shared_ptr<_Tp> > | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 4554 | { | 
 | 4555 |     typedef shared_ptr<_Tp>      argument_type; | 
 | 4556 |     typedef size_t               result_type; | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4557 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4558 |     result_type operator()(const argument_type& __ptr) const _NOEXCEPT | 
| Howard Hinnant | 21aefc3 | 2010-06-03 16:42:57 +0000 | [diff] [blame] | 4559 |     { | 
 | 4560 |         return hash<_Tp*>()(__ptr.get()); | 
 | 4561 |     } | 
 | 4562 | }; | 
 | 4563 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 4564 | template<class _CharT, class _Traits, class _Yp> | 
| Howard Hinnant | 464aa5c | 2011-07-18 15:51:59 +0000 | [diff] [blame] | 4565 | inline _LIBCPP_INLINE_VISIBILITY | 
 | 4566 | basic_ostream<_CharT, _Traits>& | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 4567 | operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); | 
| Howard Hinnant | 464aa5c | 2011-07-18 15:51:59 +0000 | [diff] [blame] | 4568 |  | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4569 | //enum class | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4570 | struct _LIBCPP_VISIBLE pointer_safety | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4571 | { | 
 | 4572 |     enum _ | 
 | 4573 |     { | 
 | 4574 |         relaxed, | 
 | 4575 |         preferred, | 
 | 4576 |         strict | 
 | 4577 |     }; | 
 | 4578 |  | 
 | 4579 |     _ __v_; | 
 | 4580 |  | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4581 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4582 |     pointer_safety(_ __v) : __v_(__v) {} | 
| Howard Hinnant | 8289481 | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 4583 |     _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4584 |     operator int() const {return __v_;} | 
 | 4585 | }; | 
 | 4586 |  | 
 | 4587 | void declare_reachable(void* __p); | 
 | 4588 | void declare_no_pointers(char* __p, size_t __n); | 
 | 4589 | void undeclare_no_pointers(char* __p, size_t __n); | 
| Howard Hinnant | 1694d23 | 2011-05-28 14:41:13 +0000 | [diff] [blame] | 4590 | pointer_safety get_pointer_safety() _NOEXCEPT; | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 4591 | void* __undeclare_reachable(void* __p); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4592 |  | 
 | 4593 | template <class _Tp> | 
 | 4594 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 4595 | _Tp* | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4596 | undeclare_reachable(_Tp* __p) | 
 | 4597 | { | 
 | 4598 |     return static_cast<_Tp*>(__undeclare_reachable(__p)); | 
 | 4599 | } | 
 | 4600 |  | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 4601 | 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] | 4602 |  | 
 | 4603 | _LIBCPP_END_NAMESPACE_STD | 
 | 4604 |  | 
 | 4605 | #endif  // _LIBCPP_MEMORY |