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