Mercurial > hg > CbC > CbC_llvm
comparison libcxx/include/vector @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | 5f17cb93ff66 |
children | 1f2b6ac9f198 |
comparison
equal
deleted
inserted
replaced
232:70dce7da266c | 236:c4bab56944e8 |
---|---|
1 // -*- C++ -*- | 1 // -*- C++ -*- |
2 //===------------------------------ vector --------------------------------===// | 2 //===----------------------------------------------------------------------===// |
3 // | 3 // |
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 // See https://llvm.org/LICENSE.txt for license information. | 5 // See https://llvm.org/LICENSE.txt for license information. |
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 // | 7 // |
243 bool __invariants() const; | 243 bool __invariants() const; |
244 }; | 244 }; |
245 | 245 |
246 template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> | 246 template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> |
247 vector(InputIterator, InputIterator, Allocator = Allocator()) | 247 vector(InputIterator, InputIterator, Allocator = Allocator()) |
248 -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; | 248 -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17 |
249 | 249 |
250 template <class Allocator> struct hash<std::vector<bool, Allocator>>; | 250 template <class Allocator> struct hash<std::vector<bool, Allocator>>; |
251 | 251 |
252 template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y); | 252 template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y); |
253 template <class T, class Allocator> bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y); | 253 template <class T, class Allocator> bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y); |
269 | 269 |
270 } // std | 270 } // std |
271 | 271 |
272 */ | 272 */ |
273 | 273 |
274 #include <__algorithm/copy.h> | |
275 #include <__algorithm/equal.h> | |
276 #include <__algorithm/fill_n.h> | |
277 #include <__algorithm/lexicographical_compare.h> | |
278 #include <__algorithm/remove.h> | |
279 #include <__algorithm/remove_if.h> | |
280 #include <__algorithm/rotate.h> | |
281 #include <__algorithm/unwrap_iter.h> | |
282 #include <__assert> // all public C++ headers provide the assertion handler | |
283 #include <__bit_reference> | |
274 #include <__config> | 284 #include <__config> |
275 #include <__bit_reference> | |
276 #include <__debug> | 285 #include <__debug> |
277 #include <__functional_base> | 286 #include <__format/enable_insertable.h> |
287 #include <__functional/hash.h> | |
288 #include <__functional/unary_function.h> | |
289 #include <__iterator/advance.h> | |
290 #include <__iterator/iterator_traits.h> | |
291 #include <__iterator/reverse_iterator.h> | |
278 #include <__iterator/wrap_iter.h> | 292 #include <__iterator/wrap_iter.h> |
293 #include <__memory/allocate_at_least.h> | |
294 #include <__memory/pointer_traits.h> | |
295 #include <__memory/swap_allocator.h> | |
296 #include <__memory/temp_value.h> | |
297 #include <__memory/uninitialized_algorithms.h> | |
298 #include <__memory_resource/polymorphic_allocator.h> | |
279 #include <__split_buffer> | 299 #include <__split_buffer> |
300 #include <__type_traits/is_allocator.h> | |
301 #include <__type_traits/noexcept_move_assign_container.h> | |
280 #include <__utility/forward.h> | 302 #include <__utility/forward.h> |
281 #include <algorithm> | 303 #include <__utility/move.h> |
304 #include <__utility/swap.h> | |
282 #include <climits> | 305 #include <climits> |
283 #include <compare> | 306 #include <cstdlib> |
284 #include <cstring> | 307 #include <cstring> |
285 #include <initializer_list> | |
286 #include <iosfwd> // for forward declaration of vector | 308 #include <iosfwd> // for forward declaration of vector |
287 #include <limits> | 309 #include <limits> |
288 #include <memory> | |
289 #include <stdexcept> | 310 #include <stdexcept> |
290 #include <type_traits> | 311 #include <type_traits> |
291 #include <version> | 312 #include <version> |
292 | 313 |
314 // standard-mandated includes | |
315 | |
316 // [iterator.range] | |
317 #include <__iterator/access.h> | |
318 #include <__iterator/data.h> | |
319 #include <__iterator/empty.h> | |
320 #include <__iterator/reverse_access.h> | |
321 #include <__iterator/size.h> | |
322 | |
323 // [vector.syn] | |
324 #include <compare> | |
325 #include <initializer_list> | |
326 | |
293 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 327 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
294 #pragma GCC system_header | 328 # pragma GCC system_header |
295 #endif | 329 #endif |
296 | 330 |
297 _LIBCPP_PUSH_MACROS | 331 _LIBCPP_PUSH_MACROS |
298 #include <__undef_macros> | 332 #include <__undef_macros> |
299 | 333 |
300 | 334 |
301 _LIBCPP_BEGIN_NAMESPACE_STD | 335 _LIBCPP_BEGIN_NAMESPACE_STD |
302 | 336 |
303 template <bool> | |
304 class _LIBCPP_TEMPLATE_VIS __vector_base_common | |
305 { | |
306 protected: | |
307 _LIBCPP_INLINE_VISIBILITY __vector_base_common() {} | |
308 _LIBCPP_NORETURN void __throw_length_error() const; | |
309 _LIBCPP_NORETURN void __throw_out_of_range() const; | |
310 }; | |
311 | |
312 template <bool __b> | |
313 void | |
314 __vector_base_common<__b>::__throw_length_error() const | |
315 { | |
316 _VSTD::__throw_length_error("vector"); | |
317 } | |
318 | |
319 template <bool __b> | |
320 void | |
321 __vector_base_common<__b>::__throw_out_of_range() const | |
322 { | |
323 _VSTD::__throw_out_of_range("vector"); | |
324 } | |
325 | |
326 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __vector_base_common<true>) | |
327 | |
328 template <class _Tp, class _Allocator> | |
329 class __vector_base | |
330 : protected __vector_base_common<true> | |
331 { | |
332 public: | |
333 typedef _Allocator allocator_type; | |
334 typedef allocator_traits<allocator_type> __alloc_traits; | |
335 typedef typename __alloc_traits::size_type size_type; | |
336 protected: | |
337 typedef _Tp value_type; | |
338 typedef value_type& reference; | |
339 typedef const value_type& const_reference; | |
340 typedef typename __alloc_traits::difference_type difference_type; | |
341 typedef typename __alloc_traits::pointer pointer; | |
342 typedef typename __alloc_traits::const_pointer const_pointer; | |
343 typedef pointer iterator; | |
344 typedef const_pointer const_iterator; | |
345 | |
346 pointer __begin_; | |
347 pointer __end_; | |
348 __compressed_pair<pointer, allocator_type> __end_cap_; | |
349 | |
350 _LIBCPP_INLINE_VISIBILITY | |
351 allocator_type& __alloc() _NOEXCEPT | |
352 {return __end_cap_.second();} | |
353 _LIBCPP_INLINE_VISIBILITY | |
354 const allocator_type& __alloc() const _NOEXCEPT | |
355 {return __end_cap_.second();} | |
356 _LIBCPP_INLINE_VISIBILITY | |
357 pointer& __end_cap() _NOEXCEPT | |
358 {return __end_cap_.first();} | |
359 _LIBCPP_INLINE_VISIBILITY | |
360 const pointer& __end_cap() const _NOEXCEPT | |
361 {return __end_cap_.first();} | |
362 | |
363 _LIBCPP_INLINE_VISIBILITY | |
364 __vector_base() | |
365 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | |
366 _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); | |
367 #ifndef _LIBCPP_CXX03_LANG | |
368 _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT; | |
369 #endif | |
370 ~__vector_base(); | |
371 | |
372 _LIBCPP_INLINE_VISIBILITY | |
373 void clear() _NOEXCEPT {__destruct_at_end(__begin_);} | |
374 _LIBCPP_INLINE_VISIBILITY | |
375 size_type capacity() const _NOEXCEPT | |
376 {return static_cast<size_type>(__end_cap() - __begin_);} | |
377 | |
378 _LIBCPP_INLINE_VISIBILITY | |
379 void __destruct_at_end(pointer __new_last) _NOEXCEPT; | |
380 | |
381 _LIBCPP_INLINE_VISIBILITY | |
382 void __copy_assign_alloc(const __vector_base& __c) | |
383 {__copy_assign_alloc(__c, integral_constant<bool, | |
384 __alloc_traits::propagate_on_container_copy_assignment::value>());} | |
385 | |
386 _LIBCPP_INLINE_VISIBILITY | |
387 void __move_assign_alloc(__vector_base& __c) | |
388 _NOEXCEPT_( | |
389 !__alloc_traits::propagate_on_container_move_assignment::value || | |
390 is_nothrow_move_assignable<allocator_type>::value) | |
391 {__move_assign_alloc(__c, integral_constant<bool, | |
392 __alloc_traits::propagate_on_container_move_assignment::value>());} | |
393 private: | |
394 _LIBCPP_INLINE_VISIBILITY | |
395 void __copy_assign_alloc(const __vector_base& __c, true_type) | |
396 { | |
397 if (__alloc() != __c.__alloc()) | |
398 { | |
399 clear(); | |
400 __alloc_traits::deallocate(__alloc(), __begin_, capacity()); | |
401 __begin_ = __end_ = __end_cap() = nullptr; | |
402 } | |
403 __alloc() = __c.__alloc(); | |
404 } | |
405 | |
406 _LIBCPP_INLINE_VISIBILITY | |
407 void __copy_assign_alloc(const __vector_base&, false_type) | |
408 {} | |
409 | |
410 _LIBCPP_INLINE_VISIBILITY | |
411 void __move_assign_alloc(__vector_base& __c, true_type) | |
412 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | |
413 { | |
414 __alloc() = _VSTD::move(__c.__alloc()); | |
415 } | |
416 | |
417 _LIBCPP_INLINE_VISIBILITY | |
418 void __move_assign_alloc(__vector_base&, false_type) | |
419 _NOEXCEPT | |
420 {} | |
421 }; | |
422 | |
423 template <class _Tp, class _Allocator> | |
424 inline _LIBCPP_INLINE_VISIBILITY | |
425 void | |
426 __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT | |
427 { | |
428 pointer __soon_to_be_end = __end_; | |
429 while (__new_last != __soon_to_be_end) | |
430 __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end)); | |
431 __end_ = __new_last; | |
432 } | |
433 | |
434 template <class _Tp, class _Allocator> | |
435 inline _LIBCPP_INLINE_VISIBILITY | |
436 __vector_base<_Tp, _Allocator>::__vector_base() | |
437 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | |
438 : __begin_(nullptr), | |
439 __end_(nullptr), | |
440 __end_cap_(nullptr, __default_init_tag()) | |
441 { | |
442 } | |
443 | |
444 template <class _Tp, class _Allocator> | |
445 inline _LIBCPP_INLINE_VISIBILITY | |
446 __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) | |
447 : __begin_(nullptr), | |
448 __end_(nullptr), | |
449 __end_cap_(nullptr, __a) | |
450 { | |
451 } | |
452 | |
453 #ifndef _LIBCPP_CXX03_LANG | |
454 template <class _Tp, class _Allocator> | |
455 inline _LIBCPP_INLINE_VISIBILITY | |
456 __vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT | |
457 : __begin_(nullptr), | |
458 __end_(nullptr), | |
459 __end_cap_(nullptr, _VSTD::move(__a)) {} | |
460 #endif | |
461 | |
462 template <class _Tp, class _Allocator> | |
463 __vector_base<_Tp, _Allocator>::~__vector_base() | |
464 { | |
465 if (__begin_ != nullptr) | |
466 { | |
467 clear(); | |
468 __alloc_traits::deallocate(__alloc(), __begin_, capacity()); | |
469 } | |
470 } | |
471 | |
472 template <class _Tp, class _Allocator /* = allocator<_Tp> */> | 337 template <class _Tp, class _Allocator /* = allocator<_Tp> */> |
473 class _LIBCPP_TEMPLATE_VIS vector | 338 class _LIBCPP_TEMPLATE_VIS vector |
474 : private __vector_base<_Tp, _Allocator> | |
475 { | 339 { |
476 private: | 340 private: |
477 typedef __vector_base<_Tp, _Allocator> __base; | 341 typedef allocator<_Tp> __default_allocator_type; |
478 typedef allocator<_Tp> __default_allocator_type; | |
479 public: | 342 public: |
480 typedef vector __self; | 343 typedef vector __self; |
481 typedef _Tp value_type; | 344 typedef _Tp value_type; |
482 typedef _Allocator allocator_type; | 345 typedef _Allocator allocator_type; |
483 typedef typename __base::__alloc_traits __alloc_traits; | 346 typedef allocator_traits<allocator_type> __alloc_traits; |
484 typedef typename __base::reference reference; | 347 typedef value_type& reference; |
485 typedef typename __base::const_reference const_reference; | 348 typedef const value_type& const_reference; |
486 typedef typename __base::size_type size_type; | 349 typedef typename __alloc_traits::size_type size_type; |
487 typedef typename __base::difference_type difference_type; | 350 typedef typename __alloc_traits::difference_type difference_type; |
488 typedef typename __base::pointer pointer; | 351 typedef typename __alloc_traits::pointer pointer; |
489 typedef typename __base::const_pointer const_pointer; | 352 typedef typename __alloc_traits::const_pointer const_pointer; |
490 typedef __wrap_iter<pointer> iterator; | 353 typedef __wrap_iter<pointer> iterator; |
491 typedef __wrap_iter<const_pointer> const_iterator; | 354 typedef __wrap_iter<const_pointer> const_iterator; |
492 typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | 355 typedef std::reverse_iterator<iterator> reverse_iterator; |
493 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | 356 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
494 | 357 |
495 static_assert((is_same<typename allocator_type::value_type, value_type>::value), | 358 static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
496 "Allocator::value_type must be same type as value_type"); | 359 "Allocator::value_type must be same type as value_type"); |
497 | 360 |
498 _LIBCPP_INLINE_VISIBILITY | 361 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value, |
362 "[allocator.requirements] states that rebinding an allocator to the same type should result in the " | |
363 "original allocator"); | |
364 | |
365 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
499 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | 366 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
500 { | 367 { |
501 #if _LIBCPP_DEBUG_LEVEL == 2 | 368 std::__debug_db_insert_c(this); |
502 __get_db()->__insert_c(this); | 369 } |
503 #endif | 370 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a) |
504 } | |
505 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) | |
506 #if _LIBCPP_STD_VER <= 14 | 371 #if _LIBCPP_STD_VER <= 14 |
507 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | 372 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) |
508 #else | 373 #else |
509 _NOEXCEPT | 374 _NOEXCEPT |
510 #endif | 375 #endif |
511 : __base(__a) | 376 : __end_cap_(nullptr, __a) |
512 { | 377 { |
513 #if _LIBCPP_DEBUG_LEVEL == 2 | 378 std::__debug_db_insert_c(this); |
514 __get_db()->__insert_c(this); | 379 } |
515 #endif | 380 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n); |
516 } | |
517 explicit vector(size_type __n); | |
518 #if _LIBCPP_STD_VER > 11 | 381 #if _LIBCPP_STD_VER > 11 |
519 explicit vector(size_type __n, const allocator_type& __a); | 382 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a); |
520 #endif | 383 #endif |
521 vector(size_type __n, const value_type& __x); | 384 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x); |
522 vector(size_type __n, const value_type& __x, const allocator_type& __a); | 385 |
523 template <class _InputIterator> | 386 template <class = __enable_if_t<__is_allocator<_Allocator>::value> > |
524 vector(_InputIterator __first, | 387 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
525 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | 388 vector(size_type __n, const value_type& __x, const allocator_type& __a) |
526 !__is_cpp17_forward_iterator<_InputIterator>::value && | 389 : __end_cap_(nullptr, __a) |
527 is_constructible< | 390 { |
528 value_type, | 391 std::__debug_db_insert_c(this); |
529 typename iterator_traits<_InputIterator>::reference>::value, | 392 if (__n > 0) |
530 _InputIterator>::type __last); | 393 { |
531 template <class _InputIterator> | 394 __vallocate(__n); |
532 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | 395 __construct_at_end(__n, __x); |
533 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | 396 } |
534 !__is_cpp17_forward_iterator<_InputIterator>::value && | 397 } |
535 is_constructible< | 398 |
536 value_type, | 399 template <class _InputIterator, |
537 typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); | 400 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value && |
538 template <class _ForwardIterator> | 401 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, |
539 vector(_ForwardIterator __first, | 402 int> = 0> |
540 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && | 403 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last); |
541 is_constructible< | 404 template <class _InputIterator, |
542 value_type, | 405 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value && |
543 typename iterator_traits<_ForwardIterator>::reference>::value, | 406 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, |
544 _ForwardIterator>::type __last); | 407 int> = 0> |
545 template <class _ForwardIterator> | 408 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
546 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | 409 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a); |
547 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && | 410 |
548 is_constructible< | 411 template < |
549 value_type, | 412 class _ForwardIterator, |
550 typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); | 413 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
551 | 414 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, |
552 _LIBCPP_INLINE_VISIBILITY | 415 int> = 0> |
416 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last); | |
417 | |
418 template <class _ForwardIterator, | |
419 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value && | |
420 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
421 int> = 0> | |
422 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
423 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a); | |
424 | |
425 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
553 ~vector() | 426 ~vector() |
554 { | 427 { |
555 __annotate_delete(); | 428 __annotate_delete(); |
556 #if _LIBCPP_DEBUG_LEVEL == 2 | 429 std::__debug_db_erase_c(this); |
557 __get_db()->__erase_c(this); | 430 |
558 #endif | 431 if (this->__begin_ != nullptr) |
559 } | 432 { |
560 | 433 __clear(); |
561 vector(const vector& __x); | 434 __alloc_traits::deallocate(__alloc(), this->__begin_, capacity()); |
562 vector(const vector& __x, const __identity_t<allocator_type>& __a); | 435 } |
563 _LIBCPP_INLINE_VISIBILITY | 436 } |
437 | |
438 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x); | |
439 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x, const __type_identity_t<allocator_type>& __a); | |
440 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
564 vector& operator=(const vector& __x); | 441 vector& operator=(const vector& __x); |
565 | 442 |
566 #ifndef _LIBCPP_CXX03_LANG | 443 #ifndef _LIBCPP_CXX03_LANG |
567 _LIBCPP_INLINE_VISIBILITY | 444 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
568 vector(initializer_list<value_type> __il); | 445 vector(initializer_list<value_type> __il); |
569 | 446 |
570 _LIBCPP_INLINE_VISIBILITY | 447 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
571 vector(initializer_list<value_type> __il, const allocator_type& __a); | 448 vector(initializer_list<value_type> __il, const allocator_type& __a); |
572 | 449 |
573 _LIBCPP_INLINE_VISIBILITY | 450 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
451 vector& operator=(initializer_list<value_type> __il) | |
452 {assign(__il.begin(), __il.end()); return *this;} | |
453 #endif // !_LIBCPP_CXX03_LANG | |
454 | |
455 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
574 vector(vector&& __x) | 456 vector(vector&& __x) |
575 #if _LIBCPP_STD_VER > 14 | 457 #if _LIBCPP_STD_VER > 14 |
576 _NOEXCEPT; | 458 noexcept; |
577 #else | 459 #else |
578 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | 460 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); |
579 #endif | 461 #endif |
580 | 462 |
581 _LIBCPP_INLINE_VISIBILITY | 463 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
582 vector(vector&& __x, const __identity_t<allocator_type>& __a); | 464 vector(vector&& __x, const __type_identity_t<allocator_type>& __a); |
583 _LIBCPP_INLINE_VISIBILITY | 465 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
584 vector& operator=(vector&& __x) | 466 vector& operator=(vector&& __x) |
585 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); | 467 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); |
586 | 468 |
587 _LIBCPP_INLINE_VISIBILITY | 469 template <class _InputIterator, |
588 vector& operator=(initializer_list<value_type> __il) | 470 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value && |
589 {assign(__il.begin(), __il.end()); return *this;} | 471 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, |
590 | 472 int> = 0> |
591 #endif // !_LIBCPP_CXX03_LANG | 473 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last); |
592 | 474 template < |
593 template <class _InputIterator> | 475 class _ForwardIterator, |
594 typename enable_if | 476 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
595 < | 477 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, |
596 __is_cpp17_input_iterator <_InputIterator>::value && | 478 int> = 0> |
597 !__is_cpp17_forward_iterator<_InputIterator>::value && | 479 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last); |
598 is_constructible< | 480 |
599 value_type, | 481 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u); |
600 typename iterator_traits<_InputIterator>::reference>::value, | |
601 void | |
602 >::type | |
603 assign(_InputIterator __first, _InputIterator __last); | |
604 template <class _ForwardIterator> | |
605 typename enable_if | |
606 < | |
607 __is_cpp17_forward_iterator<_ForwardIterator>::value && | |
608 is_constructible< | |
609 value_type, | |
610 typename iterator_traits<_ForwardIterator>::reference>::value, | |
611 void | |
612 >::type | |
613 assign(_ForwardIterator __first, _ForwardIterator __last); | |
614 | |
615 void assign(size_type __n, const_reference __u); | |
616 | 482 |
617 #ifndef _LIBCPP_CXX03_LANG | 483 #ifndef _LIBCPP_CXX03_LANG |
618 _LIBCPP_INLINE_VISIBILITY | 484 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
619 void assign(initializer_list<value_type> __il) | 485 void assign(initializer_list<value_type> __il) |
620 {assign(__il.begin(), __il.end());} | 486 {assign(__il.begin(), __il.end());} |
621 #endif | 487 #endif |
622 | 488 |
623 _LIBCPP_INLINE_VISIBILITY | 489 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
624 allocator_type get_allocator() const _NOEXCEPT | 490 allocator_type get_allocator() const _NOEXCEPT |
625 {return this->__alloc();} | 491 {return this->__alloc();} |
626 | 492 |
627 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; | 493 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT; |
628 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; | 494 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT; |
629 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; | 495 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT; |
630 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; | 496 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT; |
631 | 497 |
632 _LIBCPP_INLINE_VISIBILITY | 498 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
633 reverse_iterator rbegin() _NOEXCEPT | 499 reverse_iterator rbegin() _NOEXCEPT |
634 {return reverse_iterator(end());} | 500 {return reverse_iterator(end());} |
635 _LIBCPP_INLINE_VISIBILITY | 501 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
636 const_reverse_iterator rbegin() const _NOEXCEPT | 502 const_reverse_iterator rbegin() const _NOEXCEPT |
637 {return const_reverse_iterator(end());} | 503 {return const_reverse_iterator(end());} |
638 _LIBCPP_INLINE_VISIBILITY | 504 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
639 reverse_iterator rend() _NOEXCEPT | 505 reverse_iterator rend() _NOEXCEPT |
640 {return reverse_iterator(begin());} | 506 {return reverse_iterator(begin());} |
641 _LIBCPP_INLINE_VISIBILITY | 507 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
642 const_reverse_iterator rend() const _NOEXCEPT | 508 const_reverse_iterator rend() const _NOEXCEPT |
643 {return const_reverse_iterator(begin());} | 509 {return const_reverse_iterator(begin());} |
644 | 510 |
645 _LIBCPP_INLINE_VISIBILITY | 511 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
646 const_iterator cbegin() const _NOEXCEPT | 512 const_iterator cbegin() const _NOEXCEPT |
647 {return begin();} | 513 {return begin();} |
648 _LIBCPP_INLINE_VISIBILITY | 514 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
649 const_iterator cend() const _NOEXCEPT | 515 const_iterator cend() const _NOEXCEPT |
650 {return end();} | 516 {return end();} |
651 _LIBCPP_INLINE_VISIBILITY | 517 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
652 const_reverse_iterator crbegin() const _NOEXCEPT | 518 const_reverse_iterator crbegin() const _NOEXCEPT |
653 {return rbegin();} | 519 {return rbegin();} |
654 _LIBCPP_INLINE_VISIBILITY | 520 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
655 const_reverse_iterator crend() const _NOEXCEPT | 521 const_reverse_iterator crend() const _NOEXCEPT |
656 {return rend();} | 522 {return rend();} |
657 | 523 |
658 _LIBCPP_INLINE_VISIBILITY | 524 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
659 size_type size() const _NOEXCEPT | 525 size_type size() const _NOEXCEPT |
660 {return static_cast<size_type>(this->__end_ - this->__begin_);} | 526 {return static_cast<size_type>(this->__end_ - this->__begin_);} |
661 _LIBCPP_INLINE_VISIBILITY | 527 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
662 size_type capacity() const _NOEXCEPT | 528 size_type capacity() const _NOEXCEPT |
663 {return __base::capacity();} | 529 {return static_cast<size_type>(__end_cap() - this->__begin_);} |
664 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | 530 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
665 bool empty() const _NOEXCEPT | 531 bool empty() const _NOEXCEPT |
666 {return this->__begin_ == this->__end_;} | 532 {return this->__begin_ == this->__end_;} |
667 size_type max_size() const _NOEXCEPT; | 533 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT; |
668 void reserve(size_type __n); | 534 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n); |
669 void shrink_to_fit() _NOEXCEPT; | 535 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; |
670 | 536 |
671 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT; | 537 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT; |
672 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT; | 538 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT; |
673 reference at(size_type __n); | 539 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n); |
674 const_reference at(size_type __n) const; | 540 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const; |
675 | 541 |
676 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT | 542 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT |
677 { | 543 { |
678 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector"); | 544 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector"); |
679 return *this->__begin_; | 545 return *this->__begin_; |
680 } | 546 } |
681 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT | 547 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT |
682 { | 548 { |
683 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector"); | 549 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector"); |
684 return *this->__begin_; | 550 return *this->__begin_; |
685 } | 551 } |
686 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT | 552 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT |
687 { | 553 { |
688 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector"); | 554 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector"); |
689 return *(this->__end_ - 1); | 555 return *(this->__end_ - 1); |
690 } | 556 } |
691 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT | 557 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT |
692 { | 558 { |
693 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector"); | 559 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector"); |
694 return *(this->__end_ - 1); | 560 return *(this->__end_ - 1); |
695 } | 561 } |
696 | 562 |
697 _LIBCPP_INLINE_VISIBILITY | 563 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
698 value_type* data() _NOEXCEPT | 564 value_type* data() _NOEXCEPT |
699 {return _VSTD::__to_address(this->__begin_);} | 565 {return std::__to_address(this->__begin_);} |
700 _LIBCPP_INLINE_VISIBILITY | 566 |
567 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
701 const value_type* data() const _NOEXCEPT | 568 const value_type* data() const _NOEXCEPT |
702 {return _VSTD::__to_address(this->__begin_);} | 569 {return std::__to_address(this->__begin_);} |
703 | 570 |
704 #ifdef _LIBCPP_CXX03_LANG | 571 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x); |
705 _LIBCPP_INLINE_VISIBILITY | 572 |
706 void __emplace_back(const value_type& __x) { push_back(__x); } | 573 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); |
707 #else | |
708 template <class _Arg> | |
709 _LIBCPP_INLINE_VISIBILITY | |
710 void __emplace_back(_Arg&& __arg) { | |
711 emplace_back(_VSTD::forward<_Arg>(__arg)); | |
712 } | |
713 #endif | |
714 | |
715 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); | |
716 | |
717 #ifndef _LIBCPP_CXX03_LANG | |
718 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); | |
719 | 574 |
720 template <class... _Args> | 575 template <class... _Args> |
721 _LIBCPP_INLINE_VISIBILITY | 576 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
722 #if _LIBCPP_STD_VER > 14 | 577 #if _LIBCPP_STD_VER > 14 |
723 reference emplace_back(_Args&&... __args); | 578 reference emplace_back(_Args&&... __args); |
724 #else | 579 #else |
725 void emplace_back(_Args&&... __args); | 580 void emplace_back(_Args&&... __args); |
726 #endif | 581 #endif |
727 #endif // !_LIBCPP_CXX03_LANG | 582 |
728 | 583 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
729 _LIBCPP_INLINE_VISIBILITY | |
730 void pop_back(); | 584 void pop_back(); |
731 | 585 |
732 iterator insert(const_iterator __position, const_reference __x); | 586 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x); |
587 | |
588 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x); | |
589 template <class... _Args> | |
590 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args); | |
591 | |
592 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
593 iterator insert(const_iterator __position, size_type __n, const_reference __x); | |
594 | |
595 template <class _InputIterator, | |
596 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
597 is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
598 int> = 0> | |
599 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
600 insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | |
601 | |
602 template < | |
603 class _ForwardIterator, | |
604 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value && | |
605 is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
606 int> = 0> | |
607 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
608 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | |
733 | 609 |
734 #ifndef _LIBCPP_CXX03_LANG | 610 #ifndef _LIBCPP_CXX03_LANG |
735 iterator insert(const_iterator __position, value_type&& __x); | 611 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
736 template <class... _Args> | |
737 iterator emplace(const_iterator __position, _Args&&... __args); | |
738 #endif // !_LIBCPP_CXX03_LANG | |
739 | |
740 iterator insert(const_iterator __position, size_type __n, const_reference __x); | |
741 template <class _InputIterator> | |
742 typename enable_if | |
743 < | |
744 __is_cpp17_input_iterator <_InputIterator>::value && | |
745 !__is_cpp17_forward_iterator<_InputIterator>::value && | |
746 is_constructible< | |
747 value_type, | |
748 typename iterator_traits<_InputIterator>::reference>::value, | |
749 iterator | |
750 >::type | |
751 insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | |
752 template <class _ForwardIterator> | |
753 typename enable_if | |
754 < | |
755 __is_cpp17_forward_iterator<_ForwardIterator>::value && | |
756 is_constructible< | |
757 value_type, | |
758 typename iterator_traits<_ForwardIterator>::reference>::value, | |
759 iterator | |
760 >::type | |
761 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | |
762 | |
763 #ifndef _LIBCPP_CXX03_LANG | |
764 _LIBCPP_INLINE_VISIBILITY | |
765 iterator insert(const_iterator __position, initializer_list<value_type> __il) | 612 iterator insert(const_iterator __position, initializer_list<value_type> __il) |
766 {return insert(__position, __il.begin(), __il.end());} | 613 {return insert(__position, __il.begin(), __il.end());} |
767 #endif | 614 #endif |
768 | 615 |
769 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); | 616 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position); |
770 iterator erase(const_iterator __first, const_iterator __last); | 617 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last); |
771 | 618 |
772 _LIBCPP_INLINE_VISIBILITY | 619 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
773 void clear() _NOEXCEPT | 620 void clear() _NOEXCEPT |
774 { | 621 { |
775 size_type __old_size = size(); | 622 size_type __old_size = size(); |
776 __base::clear(); | 623 __clear(); |
777 __annotate_shrink(__old_size); | 624 __annotate_shrink(__old_size); |
778 __invalidate_all_iterators(); | 625 std::__debug_db_invalidate_all(this); |
779 } | 626 } |
780 | 627 |
781 void resize(size_type __sz); | 628 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz); |
782 void resize(size_type __sz, const_reference __x); | 629 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x); |
783 | 630 |
784 void swap(vector&) | 631 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&) |
785 #if _LIBCPP_STD_VER >= 14 | 632 #if _LIBCPP_STD_VER >= 14 |
786 _NOEXCEPT; | 633 _NOEXCEPT; |
787 #else | 634 #else |
788 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || | 635 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || |
789 __is_nothrow_swappable<allocator_type>::value); | 636 __is_nothrow_swappable<allocator_type>::value); |
790 #endif | 637 #endif |
791 | 638 |
792 bool __invariants() const; | 639 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; |
793 | 640 |
794 #if _LIBCPP_DEBUG_LEVEL == 2 | 641 #ifdef _LIBCPP_ENABLE_DEBUG_MODE |
795 | 642 |
796 bool __dereferenceable(const const_iterator* __i) const; | 643 bool __dereferenceable(const const_iterator* __i) const; |
797 bool __decrementable(const const_iterator* __i) const; | 644 bool __decrementable(const const_iterator* __i) const; |
798 bool __addable(const const_iterator* __i, ptrdiff_t __n) const; | 645 bool __addable(const const_iterator* __i, ptrdiff_t __n) const; |
799 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; | 646 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; |
800 | 647 |
801 #endif // _LIBCPP_DEBUG_LEVEL == 2 | 648 #endif // _LIBCPP_ENABLE_DEBUG_MODE |
802 | 649 |
803 private: | 650 private: |
804 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | 651 pointer __begin_ = nullptr; |
805 _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); | 652 pointer __end_ = nullptr; |
806 void __vallocate(size_type __n); | 653 __compressed_pair<pointer, allocator_type> __end_cap_ = |
807 void __vdeallocate() _NOEXCEPT; | 654 __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag()); |
808 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; | 655 |
809 void __construct_at_end(size_type __n); | 656 _LIBCPP_HIDE_FROM_ABI void __invalidate_iterators_past(pointer __new_last); |
810 _LIBCPP_INLINE_VISIBILITY | 657 |
658 // Allocate space for __n objects | |
659 // throws length_error if __n > max_size() | |
660 // throws (probably bad_alloc) if memory run out | |
661 // Precondition: __begin_ == __end_ == __end_cap() == 0 | |
662 // Precondition: __n > 0 | |
663 // Postcondition: capacity() >= __n | |
664 // Postcondition: size() == 0 | |
665 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { | |
666 if (__n > max_size()) | |
667 __throw_length_error(); | |
668 auto __allocation = std::__allocate_at_least(__alloc(), __n); | |
669 __begin_ = __allocation.ptr; | |
670 __end_ = __allocation.ptr; | |
671 __end_cap() = __begin_ + __allocation.count; | |
672 __annotate_new(0); | |
673 } | |
674 | |
675 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT; | |
676 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const; | |
677 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); | |
678 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
811 void __construct_at_end(size_type __n, const_reference __x); | 679 void __construct_at_end(size_type __n, const_reference __x); |
812 template <class _ForwardIterator> | 680 |
813 typename enable_if | 681 template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value, int> = 0> |
814 < | 682 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
815 __is_cpp17_forward_iterator<_ForwardIterator>::value, | 683 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n); |
816 void | 684 |
817 >::type | 685 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); |
818 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n); | 686 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); |
819 void __append(size_type __n); | 687 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
820 void __append(size_type __n, const_reference __x); | |
821 _LIBCPP_INLINE_VISIBILITY | |
822 iterator __make_iter(pointer __p) _NOEXCEPT; | 688 iterator __make_iter(pointer __p) _NOEXCEPT; |
823 _LIBCPP_INLINE_VISIBILITY | 689 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
824 const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; | 690 const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; |
825 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); | 691 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); |
826 pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); | 692 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); |
827 void __move_range(pointer __from_s, pointer __from_e, pointer __to); | 693 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_range(pointer __from_s, pointer __from_e, pointer __to); |
828 void __move_assign(vector& __c, true_type) | 694 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type) |
829 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | 695 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); |
830 void __move_assign(vector& __c, false_type) | 696 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type) |
831 _NOEXCEPT_(__alloc_traits::is_always_equal::value); | 697 _NOEXCEPT_(__alloc_traits::is_always_equal::value); |
832 _LIBCPP_INLINE_VISIBILITY | 698 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
833 void __destruct_at_end(pointer __new_last) _NOEXCEPT | 699 void __destruct_at_end(pointer __new_last) _NOEXCEPT |
834 { | 700 { |
835 __invalidate_iterators_past(__new_last); | 701 if (!__libcpp_is_constant_evaluated()) |
702 __invalidate_iterators_past(__new_last); | |
836 size_type __old_size = size(); | 703 size_type __old_size = size(); |
837 __base::__destruct_at_end(__new_last); | 704 __base_destruct_at_end(__new_last); |
838 __annotate_shrink(__old_size); | 705 __annotate_shrink(__old_size); |
839 } | 706 } |
840 | 707 |
841 #ifndef _LIBCPP_CXX03_LANG | |
842 template <class _Up> | 708 template <class _Up> |
843 _LIBCPP_INLINE_VISIBILITY | 709 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
844 inline void __push_back_slow_path(_Up&& __x); | 710 inline void __push_back_slow_path(_Up&& __x); |
845 | 711 |
846 template <class... _Args> | 712 template <class... _Args> |
847 _LIBCPP_INLINE_VISIBILITY | 713 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
848 inline void __emplace_back_slow_path(_Args&&... __args); | 714 inline void __emplace_back_slow_path(_Args&&... __args); |
849 #else | |
850 template <class _Up> | |
851 _LIBCPP_INLINE_VISIBILITY | |
852 inline void __push_back_slow_path(_Up& __x); | |
853 #endif | |
854 | 715 |
855 // The following functions are no-ops outside of AddressSanitizer mode. | 716 // The following functions are no-ops outside of AddressSanitizer mode. |
856 // We call annotatations only for the default Allocator because other allocators | 717 // We call annotatations only for the default Allocator because other allocators |
857 // may not meet the AddressSanitizer alignment constraints. | 718 // may not meet the AddressSanitizer alignment constraints. |
858 // See the documentation for __sanitizer_annotate_contiguous_container for more details. | 719 // See the documentation for __sanitizer_annotate_contiguous_container for more details. |
859 #ifndef _LIBCPP_HAS_NO_ASAN | 720 #ifndef _LIBCPP_HAS_NO_ASAN |
721 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
860 void __annotate_contiguous_container(const void *__beg, const void *__end, | 722 void __annotate_contiguous_container(const void *__beg, const void *__end, |
861 const void *__old_mid, | 723 const void *__old_mid, |
862 const void *__new_mid) const | 724 const void *__new_mid) const |
863 { | 725 { |
864 | 726 |
865 if (__beg && is_same<allocator_type, __default_allocator_type>::value) | 727 if (!__libcpp_is_constant_evaluated() && __beg && is_same<allocator_type, __default_allocator_type>::value) |
866 __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid); | 728 __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid); |
867 } | 729 } |
868 #else | 730 #else |
869 _LIBCPP_INLINE_VISIBILITY | 731 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
870 void __annotate_contiguous_container(const void*, const void*, const void*, | 732 void __annotate_contiguous_container(const void*, const void*, const void*, |
871 const void*) const _NOEXCEPT {} | 733 const void*) const _NOEXCEPT {} |
872 #endif | 734 #endif |
873 _LIBCPP_INLINE_VISIBILITY | 735 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
874 void __annotate_new(size_type __current_size) const _NOEXCEPT { | 736 void __annotate_new(size_type __current_size) const _NOEXCEPT { |
875 __annotate_contiguous_container(data(), data() + capacity(), | 737 __annotate_contiguous_container(data(), data() + capacity(), |
876 data() + capacity(), data() + __current_size); | 738 data() + capacity(), data() + __current_size); |
877 } | 739 } |
878 | 740 |
879 _LIBCPP_INLINE_VISIBILITY | 741 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
880 void __annotate_delete() const _NOEXCEPT { | 742 void __annotate_delete() const _NOEXCEPT { |
881 __annotate_contiguous_container(data(), data() + capacity(), | 743 __annotate_contiguous_container(data(), data() + capacity(), |
882 data() + size(), data() + capacity()); | 744 data() + size(), data() + capacity()); |
883 } | 745 } |
884 | 746 |
885 _LIBCPP_INLINE_VISIBILITY | 747 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
886 void __annotate_increase(size_type __n) const _NOEXCEPT | 748 void __annotate_increase(size_type __n) const _NOEXCEPT |
887 { | 749 { |
888 __annotate_contiguous_container(data(), data() + capacity(), | 750 __annotate_contiguous_container(data(), data() + capacity(), |
889 data() + size(), data() + size() + __n); | 751 data() + size(), data() + size() + __n); |
890 } | 752 } |
891 | 753 |
892 _LIBCPP_INLINE_VISIBILITY | 754 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
893 void __annotate_shrink(size_type __old_size) const _NOEXCEPT | 755 void __annotate_shrink(size_type __old_size) const _NOEXCEPT |
894 { | 756 { |
895 __annotate_contiguous_container(data(), data() + capacity(), | 757 __annotate_contiguous_container(data(), data() + capacity(), |
896 data() + __old_size, data() + size()); | 758 data() + __old_size, data() + size()); |
897 } | 759 } |
898 | 760 |
899 struct _ConstructTransaction { | 761 struct _ConstructTransaction { |
762 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
900 explicit _ConstructTransaction(vector &__v, size_type __n) | 763 explicit _ConstructTransaction(vector &__v, size_type __n) |
901 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { | 764 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { |
902 #ifndef _LIBCPP_HAS_NO_ASAN | 765 #ifndef _LIBCPP_HAS_NO_ASAN |
903 __v_.__annotate_increase(__n); | 766 __v_.__annotate_increase(__n); |
904 #endif | 767 #endif |
905 } | 768 } |
906 ~_ConstructTransaction() { | 769 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { |
907 __v_.__end_ = __pos_; | 770 __v_.__end_ = __pos_; |
908 #ifndef _LIBCPP_HAS_NO_ASAN | 771 #ifndef _LIBCPP_HAS_NO_ASAN |
909 if (__pos_ != __new_end_) { | 772 if (__pos_ != __new_end_) { |
910 __v_.__annotate_shrink(__new_end_ - __v_.__begin_); | 773 __v_.__annotate_shrink(__new_end_ - __v_.__begin_); |
911 } | 774 } |
920 _ConstructTransaction(_ConstructTransaction const&) = delete; | 783 _ConstructTransaction(_ConstructTransaction const&) = delete; |
921 _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; | 784 _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; |
922 }; | 785 }; |
923 | 786 |
924 template <class ..._Args> | 787 template <class ..._Args> |
925 _LIBCPP_INLINE_VISIBILITY | 788 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
926 void __construct_one_at_end(_Args&& ...__args) { | 789 void __construct_one_at_end(_Args&& ...__args) { |
927 _ConstructTransaction __tx(*this, 1); | 790 _ConstructTransaction __tx(*this, 1); |
928 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_), | 791 __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_), |
929 _VSTD::forward<_Args>(__args)...); | 792 std::forward<_Args>(__args)...); |
930 ++__tx.__pos_; | 793 ++__tx.__pos_; |
931 } | 794 } |
795 | |
796 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
797 allocator_type& __alloc() _NOEXCEPT | |
798 {return this->__end_cap_.second();} | |
799 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
800 const allocator_type& __alloc() const _NOEXCEPT | |
801 {return this->__end_cap_.second();} | |
802 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
803 pointer& __end_cap() _NOEXCEPT | |
804 {return this->__end_cap_.first();} | |
805 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
806 const pointer& __end_cap() const _NOEXCEPT | |
807 {return this->__end_cap_.first();} | |
808 | |
809 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
810 void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);} | |
811 | |
812 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
813 void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { | |
814 pointer __soon_to_be_end = this->__end_; | |
815 while (__new_last != __soon_to_be_end) | |
816 __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end)); | |
817 this->__end_ = __new_last; | |
818 } | |
819 | |
820 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
821 void __copy_assign_alloc(const vector& __c) | |
822 {__copy_assign_alloc(__c, integral_constant<bool, | |
823 __alloc_traits::propagate_on_container_copy_assignment::value>());} | |
824 | |
825 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
826 void __move_assign_alloc(vector& __c) | |
827 _NOEXCEPT_( | |
828 !__alloc_traits::propagate_on_container_move_assignment::value || | |
829 is_nothrow_move_assignable<allocator_type>::value) | |
830 {__move_assign_alloc(__c, integral_constant<bool, | |
831 __alloc_traits::propagate_on_container_move_assignment::value>());} | |
832 | |
833 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
834 void __throw_length_error() const { | |
835 std::__throw_length_error("vector"); | |
836 } | |
837 | |
838 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
839 void __throw_out_of_range() const { | |
840 std::__throw_out_of_range("vector"); | |
841 } | |
842 | |
843 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
844 void __copy_assign_alloc(const vector& __c, true_type) | |
845 { | |
846 if (__alloc() != __c.__alloc()) | |
847 { | |
848 __clear(); | |
849 __alloc_traits::deallocate(__alloc(), this->__begin_, capacity()); | |
850 this->__begin_ = this->__end_ = __end_cap() = nullptr; | |
851 } | |
852 __alloc() = __c.__alloc(); | |
853 } | |
854 | |
855 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
856 void __copy_assign_alloc(const vector&, false_type) | |
857 {} | |
858 | |
859 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
860 void __move_assign_alloc(vector& __c, true_type) | |
861 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | |
862 { | |
863 __alloc() = std::move(__c.__alloc()); | |
864 } | |
865 | |
866 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
867 void __move_assign_alloc(vector&, false_type) | |
868 _NOEXCEPT | |
869 {} | |
932 }; | 870 }; |
933 | 871 |
934 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | 872 #if _LIBCPP_STD_VER >= 17 |
935 template<class _InputIterator, | 873 template<class _InputIterator, |
936 class _Alloc = allocator<__iter_value_type<_InputIterator>>, | 874 class _Alloc = allocator<__iter_value_type<_InputIterator>>, |
937 class = _EnableIf<__is_allocator<_Alloc>::value> | 875 class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, |
876 class = enable_if_t<__is_allocator<_Alloc>::value> | |
938 > | 877 > |
939 vector(_InputIterator, _InputIterator) | 878 vector(_InputIterator, _InputIterator) |
940 -> vector<__iter_value_type<_InputIterator>, _Alloc>; | 879 -> vector<__iter_value_type<_InputIterator>, _Alloc>; |
941 | 880 |
942 template<class _InputIterator, | 881 template<class _InputIterator, |
943 class _Alloc, | 882 class _Alloc, |
944 class = _EnableIf<__is_allocator<_Alloc>::value> | 883 class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, |
884 class = enable_if_t<__is_allocator<_Alloc>::value> | |
945 > | 885 > |
946 vector(_InputIterator, _InputIterator, _Alloc) | 886 vector(_InputIterator, _InputIterator, _Alloc) |
947 -> vector<__iter_value_type<_InputIterator>, _Alloc>; | 887 -> vector<__iter_value_type<_InputIterator>, _Alloc>; |
948 #endif | 888 #endif |
949 | 889 |
950 template <class _Tp, class _Allocator> | 890 template <class _Tp, class _Allocator> |
891 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
951 void | 892 void |
952 vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) | 893 vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) |
953 { | 894 { |
954 | |
955 __annotate_delete(); | 895 __annotate_delete(); |
956 _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_); | 896 using _RevIter = std::reverse_iterator<pointer>; |
957 _VSTD::swap(this->__begin_, __v.__begin_); | 897 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept( |
958 _VSTD::swap(this->__end_, __v.__end_); | 898 __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_)) |
959 _VSTD::swap(this->__end_cap(), __v.__end_cap()); | 899 .base(); |
900 std::swap(this->__begin_, __v.__begin_); | |
901 std::swap(this->__end_, __v.__end_); | |
902 std::swap(this->__end_cap(), __v.__end_cap()); | |
960 __v.__first_ = __v.__begin_; | 903 __v.__first_ = __v.__begin_; |
961 __annotate_new(size()); | 904 __annotate_new(size()); |
962 __invalidate_all_iterators(); | 905 std::__debug_db_invalidate_all(this); |
963 } | 906 } |
964 | 907 |
965 template <class _Tp, class _Allocator> | 908 template <class _Tp, class _Allocator> |
909 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
966 typename vector<_Tp, _Allocator>::pointer | 910 typename vector<_Tp, _Allocator>::pointer |
967 vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) | 911 vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) |
968 { | 912 { |
969 __annotate_delete(); | 913 __annotate_delete(); |
970 pointer __r = __v.__begin_; | 914 pointer __r = __v.__begin_; |
971 _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_); | 915 using _RevIter = std::reverse_iterator<pointer>; |
972 _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_); | 916 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept( |
973 _VSTD::swap(this->__begin_, __v.__begin_); | 917 __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_)) |
974 _VSTD::swap(this->__end_, __v.__end_); | 918 .base(); |
975 _VSTD::swap(this->__end_cap(), __v.__end_cap()); | 919 __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_); |
920 std::swap(this->__begin_, __v.__begin_); | |
921 std::swap(this->__end_, __v.__end_); | |
922 std::swap(this->__end_cap(), __v.__end_cap()); | |
976 __v.__first_ = __v.__begin_; | 923 __v.__first_ = __v.__begin_; |
977 __annotate_new(size()); | 924 __annotate_new(size()); |
978 __invalidate_all_iterators(); | 925 std::__debug_db_invalidate_all(this); |
979 return __r; | 926 return __r; |
980 } | 927 } |
981 | 928 |
982 // Allocate space for __n objects | 929 template <class _Tp, class _Allocator> |
983 // throws length_error if __n > max_size() | 930 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
984 // throws (probably bad_alloc) if memory run out | |
985 // Precondition: __begin_ == __end_ == __end_cap() == 0 | |
986 // Precondition: __n > 0 | |
987 // Postcondition: capacity() == __n | |
988 // Postcondition: size() == 0 | |
989 template <class _Tp, class _Allocator> | |
990 void | |
991 vector<_Tp, _Allocator>::__vallocate(size_type __n) | |
992 { | |
993 if (__n > max_size()) | |
994 this->__throw_length_error(); | |
995 this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n); | |
996 this->__end_cap() = this->__begin_ + __n; | |
997 __annotate_new(0); | |
998 } | |
999 | |
1000 template <class _Tp, class _Allocator> | |
1001 void | 931 void |
1002 vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT | 932 vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT |
1003 { | 933 { |
1004 if (this->__begin_ != nullptr) | 934 if (this->__begin_ != nullptr) |
1005 { | 935 { |
1008 this->__begin_ = this->__end_ = this->__end_cap() = nullptr; | 938 this->__begin_ = this->__end_ = this->__end_cap() = nullptr; |
1009 } | 939 } |
1010 } | 940 } |
1011 | 941 |
1012 template <class _Tp, class _Allocator> | 942 template <class _Tp, class _Allocator> |
943 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1013 typename vector<_Tp, _Allocator>::size_type | 944 typename vector<_Tp, _Allocator>::size_type |
1014 vector<_Tp, _Allocator>::max_size() const _NOEXCEPT | 945 vector<_Tp, _Allocator>::max_size() const _NOEXCEPT |
1015 { | 946 { |
1016 return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), | 947 return std::min<size_type>(__alloc_traits::max_size(this->__alloc()), |
1017 numeric_limits<difference_type>::max()); | 948 numeric_limits<difference_type>::max()); |
1018 } | 949 } |
1019 | 950 |
1020 // Precondition: __new_size > capacity() | 951 // Precondition: __new_size > capacity() |
1021 template <class _Tp, class _Allocator> | 952 template <class _Tp, class _Allocator> |
1022 inline _LIBCPP_INLINE_VISIBILITY | 953 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
954 inline _LIBCPP_HIDE_FROM_ABI | |
1023 typename vector<_Tp, _Allocator>::size_type | 955 typename vector<_Tp, _Allocator>::size_type |
1024 vector<_Tp, _Allocator>::__recommend(size_type __new_size) const | 956 vector<_Tp, _Allocator>::__recommend(size_type __new_size) const |
1025 { | 957 { |
1026 const size_type __ms = max_size(); | 958 const size_type __ms = max_size(); |
1027 if (__new_size > __ms) | 959 if (__new_size > __ms) |
1028 this->__throw_length_error(); | 960 this->__throw_length_error(); |
1029 const size_type __cap = capacity(); | 961 const size_type __cap = capacity(); |
1030 if (__cap >= __ms / 2) | 962 if (__cap >= __ms / 2) |
1031 return __ms; | 963 return __ms; |
1032 return _VSTD::max<size_type>(2*__cap, __new_size); | 964 return std::max<size_type>(2 * __cap, __new_size); |
1033 } | 965 } |
1034 | 966 |
1035 // Default constructs __n objects starting at __end_ | 967 // Default constructs __n objects starting at __end_ |
1036 // throws if construction throws | 968 // throws if construction throws |
1037 // Precondition: __n > 0 | 969 // Precondition: __n > 0 |
1038 // Precondition: size() + __n <= capacity() | 970 // Precondition: size() + __n <= capacity() |
1039 // Postcondition: size() == size() + __n | 971 // Postcondition: size() == size() + __n |
1040 template <class _Tp, class _Allocator> | 972 template <class _Tp, class _Allocator> |
973 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1041 void | 974 void |
1042 vector<_Tp, _Allocator>::__construct_at_end(size_type __n) | 975 vector<_Tp, _Allocator>::__construct_at_end(size_type __n) |
1043 { | 976 { |
1044 _ConstructTransaction __tx(*this, __n); | 977 _ConstructTransaction __tx(*this, __n); |
1045 const_pointer __new_end = __tx.__new_end_; | 978 const_pointer __new_end = __tx.__new_end_; |
1046 for (pointer __pos = __tx.__pos_; __pos != __new_end; ++__pos, __tx.__pos_ = __pos) { | 979 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) { |
1047 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos)); | 980 __alloc_traits::construct(this->__alloc(), std::__to_address(__pos)); |
1048 } | 981 } |
1049 } | 982 } |
1050 | 983 |
1051 // Copy constructs __n objects starting at __end_ from __x | 984 // Copy constructs __n objects starting at __end_ from __x |
1052 // throws if construction throws | 985 // throws if construction throws |
1053 // Precondition: __n > 0 | 986 // Precondition: __n > 0 |
1054 // Precondition: size() + __n <= capacity() | 987 // Precondition: size() + __n <= capacity() |
1055 // Postcondition: size() == old size() + __n | 988 // Postcondition: size() == old size() + __n |
1056 // Postcondition: [i] == __x for all i in [size() - __n, __n) | 989 // Postcondition: [i] == __x for all i in [size() - __n, __n) |
1057 template <class _Tp, class _Allocator> | 990 template <class _Tp, class _Allocator> |
991 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1058 inline | 992 inline |
1059 void | 993 void |
1060 vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) | 994 vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) |
1061 { | 995 { |
1062 _ConstructTransaction __tx(*this, __n); | 996 _ConstructTransaction __tx(*this, __n); |
1063 const_pointer __new_end = __tx.__new_end_; | 997 const_pointer __new_end = __tx.__new_end_; |
1064 for (pointer __pos = __tx.__pos_; __pos != __new_end; ++__pos, __tx.__pos_ = __pos) { | 998 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) { |
1065 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos), __x); | 999 __alloc_traits::construct(this->__alloc(), std::__to_address(__pos), __x); |
1066 } | 1000 } |
1067 } | 1001 } |
1068 | 1002 |
1069 template <class _Tp, class _Allocator> | 1003 template <class _Tp, class _Allocator> |
1070 template <class _ForwardIterator> | 1004 template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value, int> > |
1071 typename enable_if | 1005 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
1072 < | |
1073 __is_cpp17_forward_iterator<_ForwardIterator>::value, | |
1074 void | |
1075 >::type | |
1076 vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n) | 1006 vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n) |
1077 { | 1007 { |
1078 _ConstructTransaction __tx(*this, __n); | 1008 _ConstructTransaction __tx(*this, __n); |
1079 _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_); | 1009 __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_); |
1080 } | 1010 } |
1081 | 1011 |
1082 // Default constructs __n objects starting at __end_ | 1012 // Default constructs __n objects starting at __end_ |
1083 // throws if construction throws | 1013 // throws if construction throws |
1084 // Postcondition: size() == size() + __n | 1014 // Postcondition: size() == size() + __n |
1085 // Exception safety: strong. | 1015 // Exception safety: strong. |
1086 template <class _Tp, class _Allocator> | 1016 template <class _Tp, class _Allocator> |
1017 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1087 void | 1018 void |
1088 vector<_Tp, _Allocator>::__append(size_type __n) | 1019 vector<_Tp, _Allocator>::__append(size_type __n) |
1089 { | 1020 { |
1090 if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) | 1021 if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) |
1091 this->__construct_at_end(__n); | 1022 this->__construct_at_end(__n); |
1101 // Default constructs __n objects starting at __end_ | 1032 // Default constructs __n objects starting at __end_ |
1102 // throws if construction throws | 1033 // throws if construction throws |
1103 // Postcondition: size() == size() + __n | 1034 // Postcondition: size() == size() + __n |
1104 // Exception safety: strong. | 1035 // Exception safety: strong. |
1105 template <class _Tp, class _Allocator> | 1036 template <class _Tp, class _Allocator> |
1037 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1106 void | 1038 void |
1107 vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) | 1039 vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) |
1108 { | 1040 { |
1109 if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) | 1041 if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) |
1110 this->__construct_at_end(__n, __x); | 1042 this->__construct_at_end(__n, __x); |
1116 __swap_out_circular_buffer(__v); | 1048 __swap_out_circular_buffer(__v); |
1117 } | 1049 } |
1118 } | 1050 } |
1119 | 1051 |
1120 template <class _Tp, class _Allocator> | 1052 template <class _Tp, class _Allocator> |
1053 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1121 vector<_Tp, _Allocator>::vector(size_type __n) | 1054 vector<_Tp, _Allocator>::vector(size_type __n) |
1122 { | 1055 { |
1123 #if _LIBCPP_DEBUG_LEVEL == 2 | 1056 std::__debug_db_insert_c(this); |
1124 __get_db()->__insert_c(this); | |
1125 #endif | |
1126 if (__n > 0) | 1057 if (__n > 0) |
1127 { | 1058 { |
1128 __vallocate(__n); | 1059 __vallocate(__n); |
1129 __construct_at_end(__n); | 1060 __construct_at_end(__n); |
1130 } | 1061 } |
1131 } | 1062 } |
1132 | 1063 |
1133 #if _LIBCPP_STD_VER > 11 | 1064 #if _LIBCPP_STD_VER > 11 |
1134 template <class _Tp, class _Allocator> | 1065 template <class _Tp, class _Allocator> |
1066 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1135 vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) | 1067 vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) |
1136 : __base(__a) | 1068 : __end_cap_(nullptr, __a) |
1137 { | 1069 { |
1138 #if _LIBCPP_DEBUG_LEVEL == 2 | 1070 std::__debug_db_insert_c(this); |
1139 __get_db()->__insert_c(this); | |
1140 #endif | |
1141 if (__n > 0) | 1071 if (__n > 0) |
1142 { | 1072 { |
1143 __vallocate(__n); | 1073 __vallocate(__n); |
1144 __construct_at_end(__n); | 1074 __construct_at_end(__n); |
1145 } | 1075 } |
1146 } | 1076 } |
1147 #endif | 1077 #endif |
1148 | 1078 |
1149 template <class _Tp, class _Allocator> | 1079 template <class _Tp, class _Allocator> |
1080 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1150 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) | 1081 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) |
1151 { | 1082 { |
1152 #if _LIBCPP_DEBUG_LEVEL == 2 | 1083 std::__debug_db_insert_c(this); |
1153 __get_db()->__insert_c(this); | |
1154 #endif | |
1155 if (__n > 0) | 1084 if (__n > 0) |
1156 { | 1085 { |
1157 __vallocate(__n); | 1086 __vallocate(__n); |
1158 __construct_at_end(__n, __x); | 1087 __construct_at_end(__n, __x); |
1159 } | 1088 } |
1160 } | 1089 } |
1161 | 1090 |
1162 template <class _Tp, class _Allocator> | 1091 template <class _Tp, class _Allocator> |
1163 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) | 1092 template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value && |
1164 : __base(__a) | 1093 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value, |
1165 { | 1094 int> > |
1166 #if _LIBCPP_DEBUG_LEVEL == 2 | 1095 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1167 __get_db()->__insert_c(this); | 1096 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last) |
1168 #endif | 1097 { |
1169 if (__n > 0) | 1098 std::__debug_db_insert_c(this); |
1170 { | |
1171 __vallocate(__n); | |
1172 __construct_at_end(__n, __x); | |
1173 } | |
1174 } | |
1175 | |
1176 template <class _Tp, class _Allocator> | |
1177 template <class _InputIterator> | |
1178 vector<_Tp, _Allocator>::vector(_InputIterator __first, | |
1179 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
1180 !__is_cpp17_forward_iterator<_InputIterator>::value && | |
1181 is_constructible< | |
1182 value_type, | |
1183 typename iterator_traits<_InputIterator>::reference>::value, | |
1184 _InputIterator>::type __last) | |
1185 { | |
1186 #if _LIBCPP_DEBUG_LEVEL == 2 | |
1187 __get_db()->__insert_c(this); | |
1188 #endif | |
1189 for (; __first != __last; ++__first) | 1099 for (; __first != __last; ++__first) |
1190 __emplace_back(*__first); | 1100 emplace_back(*__first); |
1191 } | 1101 } |
1192 | 1102 |
1193 template <class _Tp, class _Allocator> | 1103 template <class _Tp, class _Allocator> |
1194 template <class _InputIterator> | 1104 template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value && |
1195 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | 1105 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value, |
1196 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | 1106 int> > |
1197 !__is_cpp17_forward_iterator<_InputIterator>::value && | 1107 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1198 is_constructible< | 1108 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a) |
1199 value_type, | 1109 : __end_cap_(nullptr, __a) |
1200 typename iterator_traits<_InputIterator>::reference>::value>::type*) | 1110 { |
1201 : __base(__a) | 1111 std::__debug_db_insert_c(this); |
1202 { | |
1203 #if _LIBCPP_DEBUG_LEVEL == 2 | |
1204 __get_db()->__insert_c(this); | |
1205 #endif | |
1206 for (; __first != __last; ++__first) | 1112 for (; __first != __last; ++__first) |
1207 __emplace_back(*__first); | 1113 emplace_back(*__first); |
1208 } | 1114 } |
1209 | 1115 |
1210 template <class _Tp, class _Allocator> | 1116 template <class _Tp, class _Allocator> |
1211 template <class _ForwardIterator> | 1117 template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
1212 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, | 1118 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value, |
1213 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && | 1119 int> > |
1214 is_constructible< | 1120 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1215 value_type, | 1121 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last) |
1216 typename iterator_traits<_ForwardIterator>::reference>::value, | 1122 { |
1217 _ForwardIterator>::type __last) | 1123 std::__debug_db_insert_c(this); |
1218 { | 1124 size_type __n = static_cast<size_type>(std::distance(__first, __last)); |
1219 #if _LIBCPP_DEBUG_LEVEL == 2 | |
1220 __get_db()->__insert_c(this); | |
1221 #endif | |
1222 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | |
1223 if (__n > 0) | 1125 if (__n > 0) |
1224 { | 1126 { |
1225 __vallocate(__n); | 1127 __vallocate(__n); |
1226 __construct_at_end(__first, __last, __n); | 1128 __construct_at_end(__first, __last, __n); |
1227 } | 1129 } |
1228 } | 1130 } |
1229 | 1131 |
1230 template <class _Tp, class _Allocator> | 1132 template <class _Tp, class _Allocator> |
1231 template <class _ForwardIterator> | 1133 template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
1232 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | 1134 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value, |
1233 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && | 1135 int> > |
1234 is_constructible< | 1136 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1235 value_type, | 1137 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a) |
1236 typename iterator_traits<_ForwardIterator>::reference>::value>::type*) | 1138 : __end_cap_(nullptr, __a) |
1237 : __base(__a) | 1139 { |
1238 { | 1140 std::__debug_db_insert_c(this); |
1239 #if _LIBCPP_DEBUG_LEVEL == 2 | 1141 size_type __n = static_cast<size_type>(std::distance(__first, __last)); |
1240 __get_db()->__insert_c(this); | |
1241 #endif | |
1242 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | |
1243 if (__n > 0) | 1142 if (__n > 0) |
1244 { | 1143 { |
1245 __vallocate(__n); | 1144 __vallocate(__n); |
1246 __construct_at_end(__first, __last, __n); | 1145 __construct_at_end(__first, __last, __n); |
1247 } | 1146 } |
1248 } | 1147 } |
1249 | 1148 |
1250 template <class _Tp, class _Allocator> | 1149 template <class _Tp, class _Allocator> |
1150 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1251 vector<_Tp, _Allocator>::vector(const vector& __x) | 1151 vector<_Tp, _Allocator>::vector(const vector& __x) |
1252 : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) | 1152 : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) |
1253 { | 1153 { |
1254 #if _LIBCPP_DEBUG_LEVEL == 2 | 1154 std::__debug_db_insert_c(this); |
1255 __get_db()->__insert_c(this); | |
1256 #endif | |
1257 size_type __n = __x.size(); | 1155 size_type __n = __x.size(); |
1258 if (__n > 0) | 1156 if (__n > 0) |
1259 { | 1157 { |
1260 __vallocate(__n); | 1158 __vallocate(__n); |
1261 __construct_at_end(__x.__begin_, __x.__end_, __n); | 1159 __construct_at_end(__x.__begin_, __x.__end_, __n); |
1262 } | 1160 } |
1263 } | 1161 } |
1264 | 1162 |
1265 template <class _Tp, class _Allocator> | 1163 template <class _Tp, class _Allocator> |
1266 vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_type>& __a) | 1164 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1267 : __base(__a) | 1165 vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a) |
1268 { | 1166 : __end_cap_(nullptr, __a) |
1269 #if _LIBCPP_DEBUG_LEVEL == 2 | 1167 { |
1270 __get_db()->__insert_c(this); | 1168 std::__debug_db_insert_c(this); |
1271 #endif | |
1272 size_type __n = __x.size(); | 1169 size_type __n = __x.size(); |
1273 if (__n > 0) | 1170 if (__n > 0) |
1274 { | 1171 { |
1275 __vallocate(__n); | 1172 __vallocate(__n); |
1276 __construct_at_end(__x.__begin_, __x.__end_, __n); | 1173 __construct_at_end(__x.__begin_, __x.__end_, __n); |
1277 } | 1174 } |
1278 } | 1175 } |
1279 | 1176 |
1280 #ifndef _LIBCPP_CXX03_LANG | 1177 template <class _Tp, class _Allocator> |
1281 | 1178 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1282 template <class _Tp, class _Allocator> | 1179 inline _LIBCPP_HIDE_FROM_ABI |
1283 inline _LIBCPP_INLINE_VISIBILITY | |
1284 vector<_Tp, _Allocator>::vector(vector&& __x) | 1180 vector<_Tp, _Allocator>::vector(vector&& __x) |
1285 #if _LIBCPP_STD_VER > 14 | 1181 #if _LIBCPP_STD_VER > 14 |
1286 _NOEXCEPT | 1182 noexcept |
1287 #else | 1183 #else |
1288 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | 1184 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
1289 #endif | 1185 #endif |
1290 : __base(_VSTD::move(__x.__alloc())) | 1186 : __end_cap_(nullptr, std::move(__x.__alloc())) |
1291 { | 1187 { |
1292 #if _LIBCPP_DEBUG_LEVEL == 2 | 1188 std::__debug_db_insert_c(this); |
1293 __get_db()->__insert_c(this); | 1189 std::__debug_db_swap(this, std::addressof(__x)); |
1294 __get_db()->swap(this, &__x); | |
1295 #endif | |
1296 this->__begin_ = __x.__begin_; | 1190 this->__begin_ = __x.__begin_; |
1297 this->__end_ = __x.__end_; | 1191 this->__end_ = __x.__end_; |
1298 this->__end_cap() = __x.__end_cap(); | 1192 this->__end_cap() = __x.__end_cap(); |
1299 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; | 1193 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; |
1300 } | 1194 } |
1301 | 1195 |
1302 template <class _Tp, class _Allocator> | 1196 template <class _Tp, class _Allocator> |
1303 inline _LIBCPP_INLINE_VISIBILITY | 1197 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1304 vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>& __a) | 1198 inline _LIBCPP_HIDE_FROM_ABI |
1305 : __base(__a) | 1199 vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a) |
1306 { | 1200 : __end_cap_(nullptr, __a) |
1307 #if _LIBCPP_DEBUG_LEVEL == 2 | 1201 { |
1308 __get_db()->__insert_c(this); | 1202 std::__debug_db_insert_c(this); |
1309 #endif | |
1310 if (__a == __x.__alloc()) | 1203 if (__a == __x.__alloc()) |
1311 { | 1204 { |
1312 this->__begin_ = __x.__begin_; | 1205 this->__begin_ = __x.__begin_; |
1313 this->__end_ = __x.__end_; | 1206 this->__end_ = __x.__end_; |
1314 this->__end_cap() = __x.__end_cap(); | 1207 this->__end_cap() = __x.__end_cap(); |
1315 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; | 1208 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; |
1316 #if _LIBCPP_DEBUG_LEVEL == 2 | 1209 std::__debug_db_swap(this, std::addressof(__x)); |
1317 __get_db()->swap(this, &__x); | |
1318 #endif | |
1319 } | 1210 } |
1320 else | 1211 else |
1321 { | 1212 { |
1322 typedef move_iterator<iterator> _Ip; | 1213 typedef move_iterator<iterator> _Ip; |
1323 assign(_Ip(__x.begin()), _Ip(__x.end())); | 1214 assign(_Ip(__x.begin()), _Ip(__x.end())); |
1324 } | 1215 } |
1325 } | 1216 } |
1326 | 1217 |
1327 template <class _Tp, class _Allocator> | 1218 #ifndef _LIBCPP_CXX03_LANG |
1328 inline _LIBCPP_INLINE_VISIBILITY | 1219 |
1220 template <class _Tp, class _Allocator> | |
1221 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1222 inline _LIBCPP_HIDE_FROM_ABI | |
1329 vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) | 1223 vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) |
1330 { | 1224 { |
1331 #if _LIBCPP_DEBUG_LEVEL == 2 | 1225 std::__debug_db_insert_c(this); |
1332 __get_db()->__insert_c(this); | |
1333 #endif | |
1334 if (__il.size() > 0) | 1226 if (__il.size() > 0) |
1335 { | 1227 { |
1336 __vallocate(__il.size()); | 1228 __vallocate(__il.size()); |
1337 __construct_at_end(__il.begin(), __il.end(), __il.size()); | 1229 __construct_at_end(__il.begin(), __il.end(), __il.size()); |
1338 } | 1230 } |
1339 } | 1231 } |
1340 | 1232 |
1341 template <class _Tp, class _Allocator> | 1233 template <class _Tp, class _Allocator> |
1342 inline _LIBCPP_INLINE_VISIBILITY | 1234 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1235 inline _LIBCPP_HIDE_FROM_ABI | |
1343 vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) | 1236 vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) |
1344 : __base(__a) | 1237 : __end_cap_(nullptr, __a) |
1345 { | 1238 { |
1346 #if _LIBCPP_DEBUG_LEVEL == 2 | 1239 std::__debug_db_insert_c(this); |
1347 __get_db()->__insert_c(this); | |
1348 #endif | |
1349 if (__il.size() > 0) | 1240 if (__il.size() > 0) |
1350 { | 1241 { |
1351 __vallocate(__il.size()); | 1242 __vallocate(__il.size()); |
1352 __construct_at_end(__il.begin(), __il.end(), __il.size()); | 1243 __construct_at_end(__il.begin(), __il.end(), __il.size()); |
1353 } | 1244 } |
1354 } | 1245 } |
1355 | 1246 |
1356 template <class _Tp, class _Allocator> | 1247 #endif // _LIBCPP_CXX03_LANG |
1357 inline _LIBCPP_INLINE_VISIBILITY | 1248 |
1249 template <class _Tp, class _Allocator> | |
1250 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1251 inline _LIBCPP_HIDE_FROM_ABI | |
1358 vector<_Tp, _Allocator>& | 1252 vector<_Tp, _Allocator>& |
1359 vector<_Tp, _Allocator>::operator=(vector&& __x) | 1253 vector<_Tp, _Allocator>::operator=(vector&& __x) |
1360 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) | 1254 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) |
1361 { | 1255 { |
1362 __move_assign(__x, integral_constant<bool, | 1256 __move_assign(__x, integral_constant<bool, |
1363 __alloc_traits::propagate_on_container_move_assignment::value>()); | 1257 __alloc_traits::propagate_on_container_move_assignment::value>()); |
1364 return *this; | 1258 return *this; |
1365 } | 1259 } |
1366 | 1260 |
1367 template <class _Tp, class _Allocator> | 1261 template <class _Tp, class _Allocator> |
1262 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1368 void | 1263 void |
1369 vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) | 1264 vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) |
1370 _NOEXCEPT_(__alloc_traits::is_always_equal::value) | 1265 _NOEXCEPT_(__alloc_traits::is_always_equal::value) |
1371 { | 1266 { |
1372 if (__base::__alloc() != __c.__alloc()) | 1267 if (__alloc() != __c.__alloc()) |
1373 { | 1268 { |
1374 typedef move_iterator<iterator> _Ip; | 1269 typedef move_iterator<iterator> _Ip; |
1375 assign(_Ip(__c.begin()), _Ip(__c.end())); | 1270 assign(_Ip(__c.begin()), _Ip(__c.end())); |
1376 } | 1271 } |
1377 else | 1272 else |
1378 __move_assign(__c, true_type()); | 1273 __move_assign(__c, true_type()); |
1379 } | 1274 } |
1380 | 1275 |
1381 template <class _Tp, class _Allocator> | 1276 template <class _Tp, class _Allocator> |
1277 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1382 void | 1278 void |
1383 vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) | 1279 vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) |
1384 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 1280 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
1385 { | 1281 { |
1386 __vdeallocate(); | 1282 __vdeallocate(); |
1387 __base::__move_assign_alloc(__c); // this can throw | 1283 __move_assign_alloc(__c); // this can throw |
1388 this->__begin_ = __c.__begin_; | 1284 this->__begin_ = __c.__begin_; |
1389 this->__end_ = __c.__end_; | 1285 this->__end_ = __c.__end_; |
1390 this->__end_cap() = __c.__end_cap(); | 1286 this->__end_cap() = __c.__end_cap(); |
1391 __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; | 1287 __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; |
1392 #if _LIBCPP_DEBUG_LEVEL == 2 | 1288 std::__debug_db_swap(this, std::addressof(__c)); |
1393 __get_db()->swap(this, &__c); | 1289 } |
1394 #endif | 1290 |
1395 } | 1291 template <class _Tp, class _Allocator> |
1396 | 1292 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1397 #endif // !_LIBCPP_CXX03_LANG | 1293 inline _LIBCPP_HIDE_FROM_ABI |
1398 | |
1399 template <class _Tp, class _Allocator> | |
1400 inline _LIBCPP_INLINE_VISIBILITY | |
1401 vector<_Tp, _Allocator>& | 1294 vector<_Tp, _Allocator>& |
1402 vector<_Tp, _Allocator>::operator=(const vector& __x) | 1295 vector<_Tp, _Allocator>::operator=(const vector& __x) |
1403 { | 1296 { |
1404 if (this != &__x) | 1297 if (this != std::addressof(__x)) |
1405 { | 1298 { |
1406 __base::__copy_assign_alloc(__x); | 1299 __copy_assign_alloc(__x); |
1407 assign(__x.__begin_, __x.__end_); | 1300 assign(__x.__begin_, __x.__end_); |
1408 } | 1301 } |
1409 return *this; | 1302 return *this; |
1410 } | 1303 } |
1411 | 1304 |
1412 template <class _Tp, class _Allocator> | 1305 template <class _Tp, class _Allocator> |
1413 template <class _InputIterator> | 1306 template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value && |
1414 typename enable_if | 1307 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value, |
1415 < | 1308 int> > |
1416 __is_cpp17_input_iterator <_InputIterator>::value && | 1309 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
1417 !__is_cpp17_forward_iterator<_InputIterator>::value && | |
1418 is_constructible< | |
1419 _Tp, | |
1420 typename iterator_traits<_InputIterator>::reference>::value, | |
1421 void | |
1422 >::type | |
1423 vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) | 1310 vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) |
1424 { | 1311 { |
1425 clear(); | 1312 clear(); |
1426 for (; __first != __last; ++__first) | 1313 for (; __first != __last; ++__first) |
1427 __emplace_back(*__first); | 1314 emplace_back(*__first); |
1428 } | 1315 } |
1429 | 1316 |
1430 template <class _Tp, class _Allocator> | 1317 template <class _Tp, class _Allocator> |
1431 template <class _ForwardIterator> | 1318 template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
1432 typename enable_if | 1319 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value, |
1433 < | 1320 int> > |
1434 __is_cpp17_forward_iterator<_ForwardIterator>::value && | 1321 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
1435 is_constructible< | |
1436 _Tp, | |
1437 typename iterator_traits<_ForwardIterator>::reference>::value, | |
1438 void | |
1439 >::type | |
1440 vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) | 1322 vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) |
1441 { | 1323 { |
1442 size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last)); | 1324 size_type __new_size = static_cast<size_type>(std::distance(__first, __last)); |
1443 if (__new_size <= capacity()) | 1325 if (__new_size <= capacity()) |
1444 { | 1326 { |
1445 _ForwardIterator __mid = __last; | 1327 _ForwardIterator __mid = __last; |
1446 bool __growing = false; | 1328 bool __growing = false; |
1447 if (__new_size > size()) | 1329 if (__new_size > size()) |
1448 { | 1330 { |
1449 __growing = true; | 1331 __growing = true; |
1450 __mid = __first; | 1332 __mid = __first; |
1451 _VSTD::advance(__mid, size()); | 1333 std::advance(__mid, size()); |
1452 } | 1334 } |
1453 pointer __m = _VSTD::copy(__first, __mid, this->__begin_); | 1335 pointer __m = std::copy(__first, __mid, this->__begin_); |
1454 if (__growing) | 1336 if (__growing) |
1455 __construct_at_end(__mid, __last, __new_size - size()); | 1337 __construct_at_end(__mid, __last, __new_size - size()); |
1456 else | 1338 else |
1457 this->__destruct_at_end(__m); | 1339 this->__destruct_at_end(__m); |
1458 } | 1340 } |
1460 { | 1342 { |
1461 __vdeallocate(); | 1343 __vdeallocate(); |
1462 __vallocate(__recommend(__new_size)); | 1344 __vallocate(__recommend(__new_size)); |
1463 __construct_at_end(__first, __last, __new_size); | 1345 __construct_at_end(__first, __last, __new_size); |
1464 } | 1346 } |
1465 __invalidate_all_iterators(); | 1347 std::__debug_db_invalidate_all(this); |
1466 } | 1348 } |
1467 | 1349 |
1468 template <class _Tp, class _Allocator> | 1350 template <class _Tp, class _Allocator> |
1351 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1469 void | 1352 void |
1470 vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) | 1353 vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) |
1471 { | 1354 { |
1472 if (__n <= capacity()) | 1355 if (__n <= capacity()) |
1473 { | 1356 { |
1474 size_type __s = size(); | 1357 size_type __s = size(); |
1475 _VSTD::fill_n(this->__begin_, _VSTD::min(__n, __s), __u); | 1358 std::fill_n(this->__begin_, std::min(__n, __s), __u); |
1476 if (__n > __s) | 1359 if (__n > __s) |
1477 __construct_at_end(__n - __s, __u); | 1360 __construct_at_end(__n - __s, __u); |
1478 else | 1361 else |
1479 this->__destruct_at_end(this->__begin_ + __n); | 1362 this->__destruct_at_end(this->__begin_ + __n); |
1480 } | 1363 } |
1482 { | 1365 { |
1483 __vdeallocate(); | 1366 __vdeallocate(); |
1484 __vallocate(__recommend(static_cast<size_type>(__n))); | 1367 __vallocate(__recommend(static_cast<size_type>(__n))); |
1485 __construct_at_end(__n, __u); | 1368 __construct_at_end(__n, __u); |
1486 } | 1369 } |
1487 __invalidate_all_iterators(); | 1370 std::__debug_db_invalidate_all(this); |
1488 } | 1371 } |
1489 | 1372 |
1490 template <class _Tp, class _Allocator> | 1373 template <class _Tp, class _Allocator> |
1491 inline _LIBCPP_INLINE_VISIBILITY | 1374 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1492 typename vector<_Tp, _Allocator>::iterator | 1375 inline _LIBCPP_HIDE_FROM_ABI |
1493 vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT | |
1494 { | |
1495 #if _LIBCPP_DEBUG_LEVEL == 2 | |
1496 return iterator(this, __p); | |
1497 #else | |
1498 return iterator(__p); | |
1499 #endif | |
1500 } | |
1501 | |
1502 template <class _Tp, class _Allocator> | |
1503 inline _LIBCPP_INLINE_VISIBILITY | |
1504 typename vector<_Tp, _Allocator>::const_iterator | |
1505 vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT | |
1506 { | |
1507 #if _LIBCPP_DEBUG_LEVEL == 2 | |
1508 return const_iterator(this, __p); | |
1509 #else | |
1510 return const_iterator(__p); | |
1511 #endif | |
1512 } | |
1513 | |
1514 template <class _Tp, class _Allocator> | |
1515 inline _LIBCPP_INLINE_VISIBILITY | |
1516 typename vector<_Tp, _Allocator>::iterator | 1376 typename vector<_Tp, _Allocator>::iterator |
1517 vector<_Tp, _Allocator>::begin() _NOEXCEPT | 1377 vector<_Tp, _Allocator>::begin() _NOEXCEPT |
1518 { | 1378 { |
1519 return __make_iter(this->__begin_); | 1379 return iterator(this, this->__begin_); |
1520 } | 1380 } |
1521 | 1381 |
1522 template <class _Tp, class _Allocator> | 1382 template <class _Tp, class _Allocator> |
1523 inline _LIBCPP_INLINE_VISIBILITY | 1383 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1384 inline _LIBCPP_HIDE_FROM_ABI | |
1524 typename vector<_Tp, _Allocator>::const_iterator | 1385 typename vector<_Tp, _Allocator>::const_iterator |
1525 vector<_Tp, _Allocator>::begin() const _NOEXCEPT | 1386 vector<_Tp, _Allocator>::begin() const _NOEXCEPT |
1526 { | 1387 { |
1527 return __make_iter(this->__begin_); | 1388 return const_iterator(this, this->__begin_); |
1528 } | 1389 } |
1529 | 1390 |
1530 template <class _Tp, class _Allocator> | 1391 template <class _Tp, class _Allocator> |
1531 inline _LIBCPP_INLINE_VISIBILITY | 1392 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1393 inline _LIBCPP_HIDE_FROM_ABI | |
1532 typename vector<_Tp, _Allocator>::iterator | 1394 typename vector<_Tp, _Allocator>::iterator |
1533 vector<_Tp, _Allocator>::end() _NOEXCEPT | 1395 vector<_Tp, _Allocator>::end() _NOEXCEPT |
1534 { | 1396 { |
1535 return __make_iter(this->__end_); | 1397 return iterator(this, this->__end_); |
1536 } | 1398 } |
1537 | 1399 |
1538 template <class _Tp, class _Allocator> | 1400 template <class _Tp, class _Allocator> |
1539 inline _LIBCPP_INLINE_VISIBILITY | 1401 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1402 inline _LIBCPP_HIDE_FROM_ABI | |
1540 typename vector<_Tp, _Allocator>::const_iterator | 1403 typename vector<_Tp, _Allocator>::const_iterator |
1541 vector<_Tp, _Allocator>::end() const _NOEXCEPT | 1404 vector<_Tp, _Allocator>::end() const _NOEXCEPT |
1542 { | 1405 { |
1543 return __make_iter(this->__end_); | 1406 return const_iterator(this, this->__end_); |
1544 } | 1407 } |
1545 | 1408 |
1546 template <class _Tp, class _Allocator> | 1409 template <class _Tp, class _Allocator> |
1547 inline _LIBCPP_INLINE_VISIBILITY | 1410 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1411 inline _LIBCPP_HIDE_FROM_ABI | |
1548 typename vector<_Tp, _Allocator>::reference | 1412 typename vector<_Tp, _Allocator>::reference |
1549 vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT | 1413 vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT |
1550 { | 1414 { |
1551 _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); | 1415 _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); |
1552 return this->__begin_[__n]; | 1416 return this->__begin_[__n]; |
1553 } | 1417 } |
1554 | 1418 |
1555 template <class _Tp, class _Allocator> | 1419 template <class _Tp, class _Allocator> |
1556 inline _LIBCPP_INLINE_VISIBILITY | 1420 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1421 inline _LIBCPP_HIDE_FROM_ABI | |
1557 typename vector<_Tp, _Allocator>::const_reference | 1422 typename vector<_Tp, _Allocator>::const_reference |
1558 vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT | 1423 vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT |
1559 { | 1424 { |
1560 _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); | 1425 _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds"); |
1561 return this->__begin_[__n]; | 1426 return this->__begin_[__n]; |
1562 } | 1427 } |
1563 | 1428 |
1564 template <class _Tp, class _Allocator> | 1429 template <class _Tp, class _Allocator> |
1430 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1565 typename vector<_Tp, _Allocator>::reference | 1431 typename vector<_Tp, _Allocator>::reference |
1566 vector<_Tp, _Allocator>::at(size_type __n) | 1432 vector<_Tp, _Allocator>::at(size_type __n) |
1567 { | 1433 { |
1568 if (__n >= size()) | 1434 if (__n >= size()) |
1569 this->__throw_out_of_range(); | 1435 this->__throw_out_of_range(); |
1570 return this->__begin_[__n]; | 1436 return this->__begin_[__n]; |
1571 } | 1437 } |
1572 | 1438 |
1573 template <class _Tp, class _Allocator> | 1439 template <class _Tp, class _Allocator> |
1440 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1574 typename vector<_Tp, _Allocator>::const_reference | 1441 typename vector<_Tp, _Allocator>::const_reference |
1575 vector<_Tp, _Allocator>::at(size_type __n) const | 1442 vector<_Tp, _Allocator>::at(size_type __n) const |
1576 { | 1443 { |
1577 if (__n >= size()) | 1444 if (__n >= size()) |
1578 this->__throw_out_of_range(); | 1445 this->__throw_out_of_range(); |
1579 return this->__begin_[__n]; | 1446 return this->__begin_[__n]; |
1580 } | 1447 } |
1581 | 1448 |
1582 template <class _Tp, class _Allocator> | 1449 template <class _Tp, class _Allocator> |
1450 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1583 void | 1451 void |
1584 vector<_Tp, _Allocator>::reserve(size_type __n) | 1452 vector<_Tp, _Allocator>::reserve(size_type __n) |
1585 { | 1453 { |
1586 if (__n > capacity()) | 1454 if (__n > capacity()) |
1587 { | 1455 { |
1456 if (__n > max_size()) | |
1457 this->__throw_length_error(); | |
1588 allocator_type& __a = this->__alloc(); | 1458 allocator_type& __a = this->__alloc(); |
1589 __split_buffer<value_type, allocator_type&> __v(__n, size(), __a); | 1459 __split_buffer<value_type, allocator_type&> __v(__n, size(), __a); |
1590 __swap_out_circular_buffer(__v); | 1460 __swap_out_circular_buffer(__v); |
1591 } | 1461 } |
1592 } | 1462 } |
1593 | 1463 |
1594 template <class _Tp, class _Allocator> | 1464 template <class _Tp, class _Allocator> |
1465 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1595 void | 1466 void |
1596 vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT | 1467 vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT |
1597 { | 1468 { |
1598 if (capacity() > size()) | 1469 if (capacity() > size()) |
1599 { | 1470 { |
1613 } | 1484 } |
1614 } | 1485 } |
1615 | 1486 |
1616 template <class _Tp, class _Allocator> | 1487 template <class _Tp, class _Allocator> |
1617 template <class _Up> | 1488 template <class _Up> |
1489 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1618 void | 1490 void |
1619 #ifndef _LIBCPP_CXX03_LANG | |
1620 vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) | 1491 vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) |
1621 #else | |
1622 vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) | |
1623 #endif | |
1624 { | 1492 { |
1625 allocator_type& __a = this->__alloc(); | 1493 allocator_type& __a = this->__alloc(); |
1626 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); | 1494 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); |
1627 // __v.push_back(_VSTD::forward<_Up>(__x)); | 1495 // __v.push_back(std::forward<_Up>(__x)); |
1628 __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Up>(__x)); | 1496 __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Up>(__x)); |
1629 __v.__end_++; | 1497 __v.__end_++; |
1630 __swap_out_circular_buffer(__v); | 1498 __swap_out_circular_buffer(__v); |
1631 } | 1499 } |
1632 | 1500 |
1633 template <class _Tp, class _Allocator> | 1501 template <class _Tp, class _Allocator> |
1634 inline _LIBCPP_INLINE_VISIBILITY | 1502 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1503 inline _LIBCPP_HIDE_FROM_ABI | |
1635 void | 1504 void |
1636 vector<_Tp, _Allocator>::push_back(const_reference __x) | 1505 vector<_Tp, _Allocator>::push_back(const_reference __x) |
1637 { | 1506 { |
1638 if (this->__end_ != this->__end_cap()) | 1507 if (this->__end_ != this->__end_cap()) |
1639 { | 1508 { |
1641 } | 1510 } |
1642 else | 1511 else |
1643 __push_back_slow_path(__x); | 1512 __push_back_slow_path(__x); |
1644 } | 1513 } |
1645 | 1514 |
1646 #ifndef _LIBCPP_CXX03_LANG | 1515 template <class _Tp, class _Allocator> |
1647 | 1516 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1648 template <class _Tp, class _Allocator> | 1517 inline _LIBCPP_HIDE_FROM_ABI |
1649 inline _LIBCPP_INLINE_VISIBILITY | |
1650 void | 1518 void |
1651 vector<_Tp, _Allocator>::push_back(value_type&& __x) | 1519 vector<_Tp, _Allocator>::push_back(value_type&& __x) |
1652 { | 1520 { |
1653 if (this->__end_ < this->__end_cap()) | 1521 if (this->__end_ < this->__end_cap()) |
1654 { | 1522 { |
1655 __construct_one_at_end(_VSTD::move(__x)); | 1523 __construct_one_at_end(std::move(__x)); |
1656 } | 1524 } |
1657 else | 1525 else |
1658 __push_back_slow_path(_VSTD::move(__x)); | 1526 __push_back_slow_path(std::move(__x)); |
1659 } | 1527 } |
1660 | 1528 |
1661 template <class _Tp, class _Allocator> | 1529 template <class _Tp, class _Allocator> |
1662 template <class... _Args> | 1530 template <class... _Args> |
1531 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1663 void | 1532 void |
1664 vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) | 1533 vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) |
1665 { | 1534 { |
1666 allocator_type& __a = this->__alloc(); | 1535 allocator_type& __a = this->__alloc(); |
1667 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); | 1536 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); |
1668 // __v.emplace_back(_VSTD::forward<_Args>(__args)...); | 1537 // __v.emplace_back(std::forward<_Args>(__args)...); |
1669 __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Args>(__args)...); | 1538 __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Args>(__args)...); |
1670 __v.__end_++; | 1539 __v.__end_++; |
1671 __swap_out_circular_buffer(__v); | 1540 __swap_out_circular_buffer(__v); |
1672 } | 1541 } |
1673 | 1542 |
1674 template <class _Tp, class _Allocator> | 1543 template <class _Tp, class _Allocator> |
1675 template <class... _Args> | 1544 template <class... _Args> |
1545 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1676 inline | 1546 inline |
1677 #if _LIBCPP_STD_VER > 14 | 1547 #if _LIBCPP_STD_VER > 14 |
1678 typename vector<_Tp, _Allocator>::reference | 1548 typename vector<_Tp, _Allocator>::reference |
1679 #else | 1549 #else |
1680 void | 1550 void |
1681 #endif | 1551 #endif |
1682 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) | 1552 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) |
1683 { | 1553 { |
1684 if (this->__end_ < this->__end_cap()) | 1554 if (this->__end_ < this->__end_cap()) |
1685 { | 1555 { |
1686 __construct_one_at_end(_VSTD::forward<_Args>(__args)...); | 1556 __construct_one_at_end(std::forward<_Args>(__args)...); |
1687 } | 1557 } |
1688 else | 1558 else |
1689 __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...); | 1559 __emplace_back_slow_path(std::forward<_Args>(__args)...); |
1690 #if _LIBCPP_STD_VER > 14 | 1560 #if _LIBCPP_STD_VER > 14 |
1691 return this->back(); | 1561 return this->back(); |
1692 #endif | 1562 #endif |
1693 } | 1563 } |
1694 | 1564 |
1695 #endif // !_LIBCPP_CXX03_LANG | 1565 template <class _Tp, class _Allocator> |
1696 | 1566 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1697 template <class _Tp, class _Allocator> | |
1698 inline | 1567 inline |
1699 void | 1568 void |
1700 vector<_Tp, _Allocator>::pop_back() | 1569 vector<_Tp, _Allocator>::pop_back() |
1701 { | 1570 { |
1702 _LIBCPP_ASSERT(!empty(), "vector::pop_back called on an empty vector"); | 1571 _LIBCPP_ASSERT(!empty(), "vector::pop_back called on an empty vector"); |
1703 this->__destruct_at_end(this->__end_ - 1); | 1572 this->__destruct_at_end(this->__end_ - 1); |
1704 } | 1573 } |
1705 | 1574 |
1706 template <class _Tp, class _Allocator> | 1575 template <class _Tp, class _Allocator> |
1707 inline _LIBCPP_INLINE_VISIBILITY | 1576 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1577 inline _LIBCPP_HIDE_FROM_ABI | |
1708 typename vector<_Tp, _Allocator>::iterator | 1578 typename vector<_Tp, _Allocator>::iterator |
1709 vector<_Tp, _Allocator>::erase(const_iterator __position) | 1579 vector<_Tp, _Allocator>::erase(const_iterator __position) |
1710 { | 1580 { |
1711 #if _LIBCPP_DEBUG_LEVEL == 2 | 1581 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this, |
1712 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 1582 "vector::erase(iterator) called with an iterator not referring to this vector"); |
1713 "vector::erase(iterator) called with an iterator not" | |
1714 " referring to this vector"); | |
1715 #endif | |
1716 _LIBCPP_ASSERT(__position != end(), | 1583 _LIBCPP_ASSERT(__position != end(), |
1717 "vector::erase(iterator) called with a non-dereferenceable iterator"); | 1584 "vector::erase(iterator) called with a non-dereferenceable iterator"); |
1718 difference_type __ps = __position - cbegin(); | 1585 difference_type __ps = __position - cbegin(); |
1719 pointer __p = this->__begin_ + __ps; | 1586 pointer __p = this->__begin_ + __ps; |
1720 this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p)); | 1587 this->__destruct_at_end(std::move(__p + 1, this->__end_, __p)); |
1721 this->__invalidate_iterators_past(__p-1); | 1588 if (!__libcpp_is_constant_evaluated()) |
1722 iterator __r = __make_iter(__p); | 1589 this->__invalidate_iterators_past(__p - 1); |
1590 iterator __r = iterator(this, __p); | |
1723 return __r; | 1591 return __r; |
1724 } | 1592 } |
1725 | 1593 |
1726 template <class _Tp, class _Allocator> | 1594 template <class _Tp, class _Allocator> |
1595 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1727 typename vector<_Tp, _Allocator>::iterator | 1596 typename vector<_Tp, _Allocator>::iterator |
1728 vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) | 1597 vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) |
1729 { | 1598 { |
1730 #if _LIBCPP_DEBUG_LEVEL == 2 | 1599 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__first)) == this, |
1731 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, | 1600 "vector::erase(iterator, iterator) called with an iterator not referring to this vector"); |
1732 "vector::erase(iterator, iterator) called with an iterator not" | 1601 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__last)) == this, |
1733 " referring to this vector"); | 1602 "vector::erase(iterator, iterator) called with an iterator not referring to this vector"); |
1734 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, | 1603 |
1735 "vector::erase(iterator, iterator) called with an iterator not" | |
1736 " referring to this vector"); | |
1737 #endif | |
1738 _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range"); | 1604 _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range"); |
1739 pointer __p = this->__begin_ + (__first - begin()); | 1605 pointer __p = this->__begin_ + (__first - begin()); |
1740 if (__first != __last) { | 1606 if (__first != __last) { |
1741 this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p)); | 1607 this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p)); |
1742 this->__invalidate_iterators_past(__p - 1); | 1608 if (!__libcpp_is_constant_evaluated()) |
1743 } | 1609 this->__invalidate_iterators_past(__p - 1); |
1744 iterator __r = __make_iter(__p); | 1610 } |
1611 iterator __r = iterator(this, __p); | |
1745 return __r; | 1612 return __r; |
1746 } | 1613 } |
1747 | 1614 |
1748 template <class _Tp, class _Allocator> | 1615 template <class _Tp, class _Allocator> |
1616 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1749 void | 1617 void |
1750 vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) | 1618 vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) |
1751 { | 1619 { |
1752 pointer __old_last = this->__end_; | 1620 pointer __old_last = this->__end_; |
1753 difference_type __n = __old_last - __to; | 1621 difference_type __n = __old_last - __to; |
1754 { | 1622 { |
1755 pointer __i = __from_s + __n; | 1623 pointer __i = __from_s + __n; |
1756 _ConstructTransaction __tx(*this, __from_e - __i); | 1624 _ConstructTransaction __tx(*this, __from_e - __i); |
1757 for (pointer __pos = __tx.__pos_; __i < __from_e; | 1625 for (pointer __pos = __tx.__pos_; __i < __from_e; |
1758 ++__i, ++__pos, __tx.__pos_ = __pos) { | 1626 ++__i, (void) ++__pos, __tx.__pos_ = __pos) { |
1759 __alloc_traits::construct(this->__alloc(), | 1627 __alloc_traits::construct(this->__alloc(), |
1760 _VSTD::__to_address(__pos), | 1628 std::__to_address(__pos), |
1761 _VSTD::move(*__i)); | 1629 std::move(*__i)); |
1762 } | 1630 } |
1763 } | 1631 } |
1764 _VSTD::move_backward(__from_s, __from_s + __n, __old_last); | 1632 std::move_backward(__from_s, __from_s + __n, __old_last); |
1765 } | 1633 } |
1766 | 1634 |
1767 template <class _Tp, class _Allocator> | 1635 template <class _Tp, class _Allocator> |
1636 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1768 typename vector<_Tp, _Allocator>::iterator | 1637 typename vector<_Tp, _Allocator>::iterator |
1769 vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) | 1638 vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) |
1770 { | 1639 { |
1771 #if _LIBCPP_DEBUG_LEVEL == 2 | 1640 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this, |
1772 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 1641 "vector::insert(iterator, x) called with an iterator not referring to this vector"); |
1773 "vector::insert(iterator, x) called with an iterator not" | |
1774 " referring to this vector"); | |
1775 #endif | |
1776 pointer __p = this->__begin_ + (__position - begin()); | 1642 pointer __p = this->__begin_ + (__position - begin()); |
1777 if (this->__end_ < this->__end_cap()) | 1643 // We can't compare unrelated pointers inside constant expressions |
1644 if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap()) | |
1778 { | 1645 { |
1779 if (__p == this->__end_) | 1646 if (__p == this->__end_) |
1780 { | 1647 { |
1781 __construct_one_at_end(__x); | 1648 __construct_one_at_end(__x); |
1782 } | 1649 } |
1794 allocator_type& __a = this->__alloc(); | 1661 allocator_type& __a = this->__alloc(); |
1795 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | 1662 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); |
1796 __v.push_back(__x); | 1663 __v.push_back(__x); |
1797 __p = __swap_out_circular_buffer(__v, __p); | 1664 __p = __swap_out_circular_buffer(__v, __p); |
1798 } | 1665 } |
1799 return __make_iter(__p); | 1666 return iterator(this, __p); |
1800 } | 1667 } |
1801 | 1668 |
1802 #ifndef _LIBCPP_CXX03_LANG | 1669 template <class _Tp, class _Allocator> |
1803 | 1670 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1804 template <class _Tp, class _Allocator> | |
1805 typename vector<_Tp, _Allocator>::iterator | 1671 typename vector<_Tp, _Allocator>::iterator |
1806 vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) | 1672 vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) |
1807 { | 1673 { |
1808 #if _LIBCPP_DEBUG_LEVEL == 2 | 1674 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this, |
1809 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 1675 "vector::insert(iterator, x) called with an iterator not referring to this vector"); |
1810 "vector::insert(iterator, x) called with an iterator not" | |
1811 " referring to this vector"); | |
1812 #endif | |
1813 pointer __p = this->__begin_ + (__position - begin()); | 1676 pointer __p = this->__begin_ + (__position - begin()); |
1814 if (this->__end_ < this->__end_cap()) | 1677 if (this->__end_ < this->__end_cap()) |
1815 { | 1678 { |
1816 if (__p == this->__end_) | 1679 if (__p == this->__end_) |
1817 { | 1680 { |
1818 __construct_one_at_end(_VSTD::move(__x)); | 1681 __construct_one_at_end(std::move(__x)); |
1819 } | 1682 } |
1820 else | 1683 else |
1821 { | 1684 { |
1822 __move_range(__p, this->__end_, __p + 1); | 1685 __move_range(__p, this->__end_, __p + 1); |
1823 *__p = _VSTD::move(__x); | 1686 *__p = std::move(__x); |
1824 } | 1687 } |
1825 } | 1688 } |
1826 else | 1689 else |
1827 { | 1690 { |
1828 allocator_type& __a = this->__alloc(); | 1691 allocator_type& __a = this->__alloc(); |
1829 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | 1692 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); |
1830 __v.push_back(_VSTD::move(__x)); | 1693 __v.push_back(std::move(__x)); |
1831 __p = __swap_out_circular_buffer(__v, __p); | 1694 __p = __swap_out_circular_buffer(__v, __p); |
1832 } | 1695 } |
1833 return __make_iter(__p); | 1696 return iterator(this, __p); |
1834 } | 1697 } |
1835 | 1698 |
1836 template <class _Tp, class _Allocator> | 1699 template <class _Tp, class _Allocator> |
1837 template <class... _Args> | 1700 template <class... _Args> |
1701 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
1838 typename vector<_Tp, _Allocator>::iterator | 1702 typename vector<_Tp, _Allocator>::iterator |
1839 vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) | 1703 vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) |
1840 { | 1704 { |
1841 #if _LIBCPP_DEBUG_LEVEL == 2 | 1705 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this, |
1842 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 1706 "vector::emplace(iterator, x) called with an iterator not referring to this vector"); |
1843 "vector::emplace(iterator, x) called with an iterator not" | |
1844 " referring to this vector"); | |
1845 #endif | |
1846 pointer __p = this->__begin_ + (__position - begin()); | 1707 pointer __p = this->__begin_ + (__position - begin()); |
1847 if (this->__end_ < this->__end_cap()) | 1708 if (this->__end_ < this->__end_cap()) |
1848 { | 1709 { |
1849 if (__p == this->__end_) | 1710 if (__p == this->__end_) |
1850 { | 1711 { |
1851 __construct_one_at_end(_VSTD::forward<_Args>(__args)...); | 1712 __construct_one_at_end(std::forward<_Args>(__args)...); |
1852 } | 1713 } |
1853 else | 1714 else |
1854 { | 1715 { |
1855 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...); | 1716 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), std::forward<_Args>(__args)...); |
1856 __move_range(__p, this->__end_, __p + 1); | 1717 __move_range(__p, this->__end_, __p + 1); |
1857 *__p = _VSTD::move(__tmp.get()); | 1718 *__p = std::move(__tmp.get()); |
1858 } | 1719 } |
1859 } | 1720 } |
1860 else | 1721 else |
1861 { | 1722 { |
1862 allocator_type& __a = this->__alloc(); | 1723 allocator_type& __a = this->__alloc(); |
1863 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | 1724 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); |
1864 __v.emplace_back(_VSTD::forward<_Args>(__args)...); | 1725 __v.emplace_back(std::forward<_Args>(__args)...); |
1865 __p = __swap_out_circular_buffer(__v, __p); | 1726 __p = __swap_out_circular_buffer(__v, __p); |
1866 } | 1727 } |
1867 return __make_iter(__p); | 1728 return iterator(this, __p); |
1868 } | 1729 } |
1869 | 1730 |
1870 #endif // !_LIBCPP_CXX03_LANG | 1731 template <class _Tp, class _Allocator> |
1871 | 1732 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
1872 template <class _Tp, class _Allocator> | |
1873 typename vector<_Tp, _Allocator>::iterator | 1733 typename vector<_Tp, _Allocator>::iterator |
1874 vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) | 1734 vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) |
1875 { | 1735 { |
1876 #if _LIBCPP_DEBUG_LEVEL == 2 | 1736 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this, |
1877 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 1737 "vector::insert(iterator, n, x) called with an iterator not referring to this vector"); |
1878 "vector::insert(iterator, n, x) called with an iterator not" | |
1879 " referring to this vector"); | |
1880 #endif | |
1881 pointer __p = this->__begin_ + (__position - begin()); | 1738 pointer __p = this->__begin_ + (__position - begin()); |
1882 if (__n > 0) | 1739 if (__n > 0) |
1883 { | 1740 { |
1884 if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_)) | 1741 // We can't compare unrelated pointers inside constant expressions |
1742 if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_)) | |
1885 { | 1743 { |
1886 size_type __old_n = __n; | 1744 size_type __old_n = __n; |
1887 pointer __old_last = this->__end_; | 1745 pointer __old_last = this->__end_; |
1888 if (__n > static_cast<size_type>(this->__end_ - __p)) | 1746 if (__n > static_cast<size_type>(this->__end_ - __p)) |
1889 { | 1747 { |
1895 { | 1753 { |
1896 __move_range(__p, __old_last, __p + __old_n); | 1754 __move_range(__p, __old_last, __p + __old_n); |
1897 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | 1755 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); |
1898 if (__p <= __xr && __xr < this->__end_) | 1756 if (__p <= __xr && __xr < this->__end_) |
1899 __xr += __old_n; | 1757 __xr += __old_n; |
1900 _VSTD::fill_n(__p, __n, *__xr); | 1758 std::fill_n(__p, __n, *__xr); |
1901 } | 1759 } |
1902 } | 1760 } |
1903 else | 1761 else |
1904 { | 1762 { |
1905 allocator_type& __a = this->__alloc(); | 1763 allocator_type& __a = this->__alloc(); |
1906 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); | 1764 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); |
1907 __v.__construct_at_end(__n, __x); | 1765 __v.__construct_at_end(__n, __x); |
1908 __p = __swap_out_circular_buffer(__v, __p); | 1766 __p = __swap_out_circular_buffer(__v, __p); |
1909 } | 1767 } |
1910 } | 1768 } |
1911 return __make_iter(__p); | 1769 return iterator(this, __p); |
1912 } | 1770 } |
1913 | 1771 |
1914 template <class _Tp, class _Allocator> | 1772 template <class _Tp, class _Allocator> |
1915 template <class _InputIterator> | 1773 template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value && |
1916 typename enable_if | 1774 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value, |
1917 < | 1775 int> > |
1918 __is_cpp17_input_iterator <_InputIterator>::value && | 1776 _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator |
1919 !__is_cpp17_forward_iterator<_InputIterator>::value && | |
1920 is_constructible< | |
1921 _Tp, | |
1922 typename iterator_traits<_InputIterator>::reference>::value, | |
1923 typename vector<_Tp, _Allocator>::iterator | |
1924 >::type | |
1925 vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) | 1777 vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) |
1926 { | 1778 { |
1927 #if _LIBCPP_DEBUG_LEVEL == 2 | 1779 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this, |
1928 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 1780 "vector::insert(iterator, range) called with an iterator not referring to this vector"); |
1929 "vector::insert(iterator, range) called with an iterator not" | |
1930 " referring to this vector"); | |
1931 #endif | |
1932 difference_type __off = __position - begin(); | 1781 difference_type __off = __position - begin(); |
1933 pointer __p = this->__begin_ + __off; | 1782 pointer __p = this->__begin_ + __off; |
1934 allocator_type& __a = this->__alloc(); | 1783 allocator_type& __a = this->__alloc(); |
1935 pointer __old_last = this->__end_; | 1784 pointer __old_last = this->__end_; |
1936 for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) | 1785 for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) |
1952 __old_last = this->__begin_ + __old_size; | 1801 __old_last = this->__begin_ + __old_size; |
1953 #ifndef _LIBCPP_NO_EXCEPTIONS | 1802 #ifndef _LIBCPP_NO_EXCEPTIONS |
1954 } | 1803 } |
1955 catch (...) | 1804 catch (...) |
1956 { | 1805 { |
1957 erase(__make_iter(__old_last), end()); | 1806 erase(iterator(this, __old_last), end()); |
1958 throw; | 1807 throw; |
1959 } | 1808 } |
1960 #endif // _LIBCPP_NO_EXCEPTIONS | 1809 #endif // _LIBCPP_NO_EXCEPTIONS |
1961 } | 1810 } |
1962 __p = _VSTD::rotate(__p, __old_last, this->__end_); | 1811 __p = std::rotate(__p, __old_last, this->__end_); |
1963 insert(__make_iter(__p), _VSTD::make_move_iterator(__v.begin()), | 1812 insert(iterator(this, __p), std::make_move_iterator(__v.begin()), |
1964 _VSTD::make_move_iterator(__v.end())); | 1813 std::make_move_iterator(__v.end())); |
1965 return begin() + __off; | 1814 return begin() + __off; |
1966 } | 1815 } |
1967 | 1816 |
1968 template <class _Tp, class _Allocator> | 1817 template <class _Tp, class _Allocator> |
1969 template <class _ForwardIterator> | 1818 template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
1970 typename enable_if | 1819 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value, |
1971 < | 1820 int> > |
1972 __is_cpp17_forward_iterator<_ForwardIterator>::value && | 1821 _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator |
1973 is_constructible< | |
1974 _Tp, | |
1975 typename iterator_traits<_ForwardIterator>::reference>::value, | |
1976 typename vector<_Tp, _Allocator>::iterator | |
1977 >::type | |
1978 vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) | 1822 vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) |
1979 { | 1823 { |
1980 #if _LIBCPP_DEBUG_LEVEL == 2 | 1824 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this, |
1981 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | 1825 "vector::insert(iterator, range) called with an iterator not referring to this vector"); |
1982 "vector::insert(iterator, range) called with an iterator not" | |
1983 " referring to this vector"); | |
1984 #endif | |
1985 pointer __p = this->__begin_ + (__position - begin()); | 1826 pointer __p = this->__begin_ + (__position - begin()); |
1986 difference_type __n = _VSTD::distance(__first, __last); | 1827 difference_type __n = std::distance(__first, __last); |
1987 if (__n > 0) | 1828 if (__n > 0) |
1988 { | 1829 { |
1989 if (__n <= this->__end_cap() - this->__end_) | 1830 if (__n <= this->__end_cap() - this->__end_) |
1990 { | 1831 { |
1991 size_type __old_n = __n; | 1832 size_type __old_n = __n; |
1994 difference_type __dx = this->__end_ - __p; | 1835 difference_type __dx = this->__end_ - __p; |
1995 if (__n > __dx) | 1836 if (__n > __dx) |
1996 { | 1837 { |
1997 __m = __first; | 1838 __m = __first; |
1998 difference_type __diff = this->__end_ - __p; | 1839 difference_type __diff = this->__end_ - __p; |
1999 _VSTD::advance(__m, __diff); | 1840 std::advance(__m, __diff); |
2000 __construct_at_end(__m, __last, __n - __diff); | 1841 __construct_at_end(__m, __last, __n - __diff); |
2001 __n = __dx; | 1842 __n = __dx; |
2002 } | 1843 } |
2003 if (__n > 0) | 1844 if (__n > 0) |
2004 { | 1845 { |
2005 __move_range(__p, __old_last, __p + __old_n); | 1846 __move_range(__p, __old_last, __p + __old_n); |
2006 _VSTD::copy(__first, __m, __p); | 1847 std::copy(__first, __m, __p); |
2007 } | 1848 } |
2008 } | 1849 } |
2009 else | 1850 else |
2010 { | 1851 { |
2011 allocator_type& __a = this->__alloc(); | 1852 allocator_type& __a = this->__alloc(); |
2012 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); | 1853 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); |
2013 __v.__construct_at_end(__first, __last); | 1854 __v.__construct_at_end(__first, __last); |
2014 __p = __swap_out_circular_buffer(__v, __p); | 1855 __p = __swap_out_circular_buffer(__v, __p); |
2015 } | 1856 } |
2016 } | 1857 } |
2017 return __make_iter(__p); | 1858 return iterator(this, __p); |
2018 } | 1859 } |
2019 | 1860 |
2020 template <class _Tp, class _Allocator> | 1861 template <class _Tp, class _Allocator> |
1862 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2021 void | 1863 void |
2022 vector<_Tp, _Allocator>::resize(size_type __sz) | 1864 vector<_Tp, _Allocator>::resize(size_type __sz) |
2023 { | 1865 { |
2024 size_type __cs = size(); | 1866 size_type __cs = size(); |
2025 if (__cs < __sz) | 1867 if (__cs < __sz) |
2027 else if (__cs > __sz) | 1869 else if (__cs > __sz) |
2028 this->__destruct_at_end(this->__begin_ + __sz); | 1870 this->__destruct_at_end(this->__begin_ + __sz); |
2029 } | 1871 } |
2030 | 1872 |
2031 template <class _Tp, class _Allocator> | 1873 template <class _Tp, class _Allocator> |
1874 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2032 void | 1875 void |
2033 vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) | 1876 vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) |
2034 { | 1877 { |
2035 size_type __cs = size(); | 1878 size_type __cs = size(); |
2036 if (__cs < __sz) | 1879 if (__cs < __sz) |
2038 else if (__cs > __sz) | 1881 else if (__cs > __sz) |
2039 this->__destruct_at_end(this->__begin_ + __sz); | 1882 this->__destruct_at_end(this->__begin_ + __sz); |
2040 } | 1883 } |
2041 | 1884 |
2042 template <class _Tp, class _Allocator> | 1885 template <class _Tp, class _Allocator> |
1886 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2043 void | 1887 void |
2044 vector<_Tp, _Allocator>::swap(vector& __x) | 1888 vector<_Tp, _Allocator>::swap(vector& __x) |
2045 #if _LIBCPP_STD_VER >= 14 | 1889 #if _LIBCPP_STD_VER >= 14 |
2046 _NOEXCEPT | 1890 _NOEXCEPT |
2047 #else | 1891 #else |
2051 { | 1895 { |
2052 _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value || | 1896 _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value || |
2053 this->__alloc() == __x.__alloc(), | 1897 this->__alloc() == __x.__alloc(), |
2054 "vector::swap: Either propagate_on_container_swap must be true" | 1898 "vector::swap: Either propagate_on_container_swap must be true" |
2055 " or the allocators must compare equal"); | 1899 " or the allocators must compare equal"); |
2056 _VSTD::swap(this->__begin_, __x.__begin_); | 1900 std::swap(this->__begin_, __x.__begin_); |
2057 _VSTD::swap(this->__end_, __x.__end_); | 1901 std::swap(this->__end_, __x.__end_); |
2058 _VSTD::swap(this->__end_cap(), __x.__end_cap()); | 1902 std::swap(this->__end_cap(), __x.__end_cap()); |
2059 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(), | 1903 std::__swap_allocator(this->__alloc(), __x.__alloc(), |
2060 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>()); | 1904 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>()); |
2061 #if _LIBCPP_DEBUG_LEVEL == 2 | 1905 std::__debug_db_swap(this, std::addressof(__x)); |
2062 __get_db()->swap(this, &__x); | 1906 } |
2063 #endif | 1907 |
2064 } | 1908 template <class _Tp, class _Allocator> |
2065 | 1909 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2066 template <class _Tp, class _Allocator> | |
2067 bool | 1910 bool |
2068 vector<_Tp, _Allocator>::__invariants() const | 1911 vector<_Tp, _Allocator>::__invariants() const |
2069 { | 1912 { |
2070 if (this->__begin_ == nullptr) | 1913 if (this->__begin_ == nullptr) |
2071 { | 1914 { |
2082 return false; | 1925 return false; |
2083 } | 1926 } |
2084 return true; | 1927 return true; |
2085 } | 1928 } |
2086 | 1929 |
2087 #if _LIBCPP_DEBUG_LEVEL == 2 | 1930 #ifdef _LIBCPP_ENABLE_DEBUG_MODE |
2088 | 1931 |
2089 template <class _Tp, class _Allocator> | 1932 template <class _Tp, class _Allocator> |
2090 bool | 1933 bool |
2091 vector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const | 1934 vector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const |
2092 { | 1935 { |
2114 { | 1957 { |
2115 const_pointer __p = __i->base() + __n; | 1958 const_pointer __p = __i->base() + __n; |
2116 return this->__begin_ <= __p && __p < this->__end_; | 1959 return this->__begin_ <= __p && __p < this->__end_; |
2117 } | 1960 } |
2118 | 1961 |
2119 #endif // _LIBCPP_DEBUG_LEVEL == 2 | 1962 #endif // _LIBCPP_ENABLE_DEBUG_MODE |
2120 | 1963 |
2121 template <class _Tp, class _Allocator> | 1964 template <class _Tp, class _Allocator> |
2122 inline _LIBCPP_INLINE_VISIBILITY | 1965 inline _LIBCPP_HIDE_FROM_ABI |
2123 void | |
2124 vector<_Tp, _Allocator>::__invalidate_all_iterators() | |
2125 { | |
2126 #if _LIBCPP_DEBUG_LEVEL == 2 | |
2127 __get_db()->__invalidate_all(this); | |
2128 #endif | |
2129 } | |
2130 | |
2131 | |
2132 template <class _Tp, class _Allocator> | |
2133 inline _LIBCPP_INLINE_VISIBILITY | |
2134 void | 1966 void |
2135 vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) { | 1967 vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) { |
2136 #if _LIBCPP_DEBUG_LEVEL == 2 | 1968 #ifdef _LIBCPP_ENABLE_DEBUG_MODE |
2137 __c_node* __c = __get_db()->__find_c_and_lock(this); | 1969 __c_node* __c = __get_db()->__find_c_and_lock(this); |
2138 for (__i_node** __p = __c->end_; __p != __c->beg_; ) { | 1970 for (__i_node** __p = __c->end_; __p != __c->beg_; ) { |
2139 --__p; | 1971 --__p; |
2140 const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); | 1972 const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); |
2141 if (__i->base() > __new_last) { | 1973 if (__i->base() > __new_last) { |
2142 (*__p)->__c_ = nullptr; | 1974 (*__p)->__c_ = nullptr; |
2143 if (--__c->end_ != __p) | 1975 if (--__c->end_ != __p) |
2144 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); | 1976 std::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); |
2145 } | 1977 } |
2146 } | 1978 } |
2147 __get_db()->unlock(); | 1979 __get_db()->unlock(); |
2148 #else | 1980 #else |
2149 ((void)__new_last); | 1981 ((void)__new_last); |
2162 static const bool value = true; | 1994 static const bool value = true; |
2163 }; | 1995 }; |
2164 | 1996 |
2165 template <class _Allocator> | 1997 template <class _Allocator> |
2166 class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> | 1998 class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> |
2167 : private __vector_base_common<true> | |
2168 { | 1999 { |
2169 public: | 2000 public: |
2170 typedef vector __self; | 2001 typedef vector __self; |
2171 typedef bool value_type; | 2002 typedef bool value_type; |
2172 typedef _Allocator allocator_type; | 2003 typedef _Allocator allocator_type; |
2176 typedef size_type __storage_type; | 2007 typedef size_type __storage_type; |
2177 typedef __bit_iterator<vector, false> pointer; | 2008 typedef __bit_iterator<vector, false> pointer; |
2178 typedef __bit_iterator<vector, true> const_pointer; | 2009 typedef __bit_iterator<vector, true> const_pointer; |
2179 typedef pointer iterator; | 2010 typedef pointer iterator; |
2180 typedef const_pointer const_iterator; | 2011 typedef const_pointer const_iterator; |
2181 typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | 2012 typedef std::reverse_iterator<iterator> reverse_iterator; |
2182 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | 2013 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
2183 | 2014 |
2184 private: | 2015 private: |
2185 typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator; | 2016 typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator; |
2186 typedef allocator_traits<__storage_allocator> __storage_traits; | 2017 typedef allocator_traits<__storage_allocator> __storage_traits; |
2187 typedef typename __storage_traits::pointer __storage_pointer; | 2018 typedef typename __storage_traits::pointer __storage_pointer; |
2188 typedef typename __storage_traits::const_pointer __const_storage_pointer; | 2019 typedef typename __storage_traits::const_pointer __const_storage_pointer; |
2189 | 2020 |
2190 __storage_pointer __begin_; | 2021 __storage_pointer __begin_; |
2191 size_type __size_; | 2022 size_type __size_; |
2192 __compressed_pair<size_type, __storage_allocator> __cap_alloc_; | 2023 __compressed_pair<size_type, __storage_allocator> __cap_alloc_; |
2193 public: | 2024 public: |
2194 typedef __bit_reference<vector> reference; | 2025 typedef __bit_reference<vector> reference; |
2026 #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
2027 using const_reference = bool; | |
2028 #else | |
2195 typedef __bit_const_reference<vector> const_reference; | 2029 typedef __bit_const_reference<vector> const_reference; |
2030 #endif | |
2196 private: | 2031 private: |
2197 _LIBCPP_INLINE_VISIBILITY | 2032 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2198 size_type& __cap() _NOEXCEPT | 2033 size_type& __cap() _NOEXCEPT |
2199 {return __cap_alloc_.first();} | 2034 {return __cap_alloc_.first();} |
2200 _LIBCPP_INLINE_VISIBILITY | 2035 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2201 const size_type& __cap() const _NOEXCEPT | 2036 const size_type& __cap() const _NOEXCEPT |
2202 {return __cap_alloc_.first();} | 2037 {return __cap_alloc_.first();} |
2203 _LIBCPP_INLINE_VISIBILITY | 2038 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2204 __storage_allocator& __alloc() _NOEXCEPT | 2039 __storage_allocator& __alloc() _NOEXCEPT |
2205 {return __cap_alloc_.second();} | 2040 {return __cap_alloc_.second();} |
2206 _LIBCPP_INLINE_VISIBILITY | 2041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2207 const __storage_allocator& __alloc() const _NOEXCEPT | 2042 const __storage_allocator& __alloc() const _NOEXCEPT |
2208 {return __cap_alloc_.second();} | 2043 {return __cap_alloc_.second();} |
2209 | 2044 |
2210 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); | 2045 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); |
2211 | 2046 |
2212 _LIBCPP_INLINE_VISIBILITY | 2047 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2213 static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT | 2048 static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT |
2214 {return __n * __bits_per_word;} | 2049 {return __n * __bits_per_word;} |
2215 _LIBCPP_INLINE_VISIBILITY | 2050 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2216 static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT | 2051 static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT |
2217 {return (__n - 1) / __bits_per_word + 1;} | 2052 {return (__n - 1) / __bits_per_word + 1;} |
2218 | 2053 |
2219 public: | 2054 public: |
2220 _LIBCPP_INLINE_VISIBILITY | 2055 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2221 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | 2056 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); |
2222 | 2057 |
2223 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) | 2058 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(const allocator_type& __a) |
2224 #if _LIBCPP_STD_VER <= 14 | 2059 #if _LIBCPP_STD_VER <= 14 |
2225 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); | 2060 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); |
2226 #else | 2061 #else |
2227 _NOEXCEPT; | 2062 _NOEXCEPT; |
2228 #endif | 2063 #endif |
2229 ~vector(); | 2064 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector(); |
2230 explicit vector(size_type __n); | 2065 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n); |
2231 #if _LIBCPP_STD_VER > 11 | 2066 #if _LIBCPP_STD_VER > 11 |
2232 explicit vector(size_type __n, const allocator_type& __a); | 2067 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a); |
2233 #endif | 2068 #endif |
2234 vector(size_type __n, const value_type& __v); | 2069 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v); |
2235 vector(size_type __n, const value_type& __v, const allocator_type& __a); | 2070 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v, const allocator_type& __a); |
2236 template <class _InputIterator> | 2071 template <class _InputIterator> |
2237 vector(_InputIterator __first, _InputIterator __last, | 2072 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, |
2238 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | 2073 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0); |
2239 !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0); | |
2240 template <class _InputIterator> | 2074 template <class _InputIterator> |
2241 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | 2075 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, |
2242 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | 2076 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0); |
2243 !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0); | |
2244 template <class _ForwardIterator> | 2077 template <class _ForwardIterator> |
2245 vector(_ForwardIterator __first, _ForwardIterator __last, | 2078 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last, |
2246 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); | 2079 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); |
2247 template <class _ForwardIterator> | 2080 template <class _ForwardIterator> |
2248 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | 2081 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, |
2249 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); | 2082 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); |
2250 | 2083 |
2251 vector(const vector& __v); | 2084 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v); |
2252 vector(const vector& __v, const allocator_type& __a); | 2085 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a); |
2253 vector& operator=(const vector& __v); | 2086 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(const vector& __v); |
2254 | 2087 |
2255 #ifndef _LIBCPP_CXX03_LANG | 2088 #ifndef _LIBCPP_CXX03_LANG |
2256 vector(initializer_list<value_type> __il); | 2089 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il); |
2257 vector(initializer_list<value_type> __il, const allocator_type& __a); | 2090 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il, const allocator_type& __a); |
2258 | 2091 |
2259 _LIBCPP_INLINE_VISIBILITY | 2092 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2093 vector& operator=(initializer_list<value_type> __il) | |
2094 {assign(__il.begin(), __il.end()); return *this;} | |
2095 | |
2096 #endif // !_LIBCPP_CXX03_LANG | |
2097 | |
2098 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2260 vector(vector&& __v) | 2099 vector(vector&& __v) |
2261 #if _LIBCPP_STD_VER > 14 | 2100 #if _LIBCPP_STD_VER > 14 |
2262 _NOEXCEPT; | 2101 noexcept; |
2263 #else | 2102 #else |
2264 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | 2103 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); |
2265 #endif | 2104 #endif |
2266 vector(vector&& __v, const __identity_t<allocator_type>& __a); | 2105 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v, const __type_identity_t<allocator_type>& __a); |
2267 _LIBCPP_INLINE_VISIBILITY | 2106 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2268 vector& operator=(vector&& __v) | 2107 vector& operator=(vector&& __v) |
2269 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); | 2108 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); |
2270 | 2109 |
2271 _LIBCPP_INLINE_VISIBILITY | |
2272 vector& operator=(initializer_list<value_type> __il) | |
2273 {assign(__il.begin(), __il.end()); return *this;} | |
2274 | |
2275 #endif // !_LIBCPP_CXX03_LANG | |
2276 | |
2277 template <class _InputIterator> | 2110 template <class _InputIterator> |
2278 typename enable_if | 2111 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, |
2279 < | |
2280 __is_cpp17_input_iterator<_InputIterator>::value && | |
2281 !__is_cpp17_forward_iterator<_InputIterator>::value, | |
2282 void | 2112 void |
2283 >::type | 2113 >::type |
2284 assign(_InputIterator __first, _InputIterator __last); | 2114 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last); |
2285 template <class _ForwardIterator> | 2115 template <class _ForwardIterator> |
2286 typename enable_if | 2116 typename enable_if |
2287 < | 2117 < |
2288 __is_cpp17_forward_iterator<_ForwardIterator>::value, | 2118 __is_cpp17_forward_iterator<_ForwardIterator>::value, |
2289 void | 2119 void |
2290 >::type | 2120 >::type |
2291 assign(_ForwardIterator __first, _ForwardIterator __last); | 2121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last); |
2292 | 2122 |
2293 void assign(size_type __n, const value_type& __x); | 2123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(size_type __n, const value_type& __x); |
2294 | 2124 |
2295 #ifndef _LIBCPP_CXX03_LANG | 2125 #ifndef _LIBCPP_CXX03_LANG |
2296 _LIBCPP_INLINE_VISIBILITY | 2126 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2297 void assign(initializer_list<value_type> __il) | 2127 void assign(initializer_list<value_type> __il) |
2298 {assign(__il.begin(), __il.end());} | 2128 {assign(__il.begin(), __il.end());} |
2299 #endif | 2129 #endif |
2300 | 2130 |
2301 _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT | 2131 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT |
2302 {return allocator_type(this->__alloc());} | 2132 {return allocator_type(this->__alloc());} |
2303 | 2133 |
2304 size_type max_size() const _NOEXCEPT; | 2134 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT; |
2305 _LIBCPP_INLINE_VISIBILITY | 2135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2306 size_type capacity() const _NOEXCEPT | 2136 size_type capacity() const _NOEXCEPT |
2307 {return __internal_cap_to_external(__cap());} | 2137 {return __internal_cap_to_external(__cap());} |
2308 _LIBCPP_INLINE_VISIBILITY | 2138 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2309 size_type size() const _NOEXCEPT | 2139 size_type size() const _NOEXCEPT |
2310 {return __size_;} | 2140 {return __size_;} |
2311 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | 2141 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2312 bool empty() const _NOEXCEPT | 2142 bool empty() const _NOEXCEPT |
2313 {return __size_ == 0;} | 2143 {return __size_ == 0;} |
2314 void reserve(size_type __n); | 2144 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n); |
2315 void shrink_to_fit() _NOEXCEPT; | 2145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; |
2316 | 2146 |
2317 _LIBCPP_INLINE_VISIBILITY | 2147 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2318 iterator begin() _NOEXCEPT | 2148 iterator begin() _NOEXCEPT |
2319 {return __make_iter(0);} | 2149 {return __make_iter(0);} |
2320 _LIBCPP_INLINE_VISIBILITY | 2150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2321 const_iterator begin() const _NOEXCEPT | 2151 const_iterator begin() const _NOEXCEPT |
2322 {return __make_iter(0);} | 2152 {return __make_iter(0);} |
2323 _LIBCPP_INLINE_VISIBILITY | 2153 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2324 iterator end() _NOEXCEPT | 2154 iterator end() _NOEXCEPT |
2325 {return __make_iter(__size_);} | 2155 {return __make_iter(__size_);} |
2326 _LIBCPP_INLINE_VISIBILITY | 2156 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2327 const_iterator end() const _NOEXCEPT | 2157 const_iterator end() const _NOEXCEPT |
2328 {return __make_iter(__size_);} | 2158 {return __make_iter(__size_);} |
2329 | 2159 |
2330 _LIBCPP_INLINE_VISIBILITY | 2160 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2331 reverse_iterator rbegin() _NOEXCEPT | 2161 reverse_iterator rbegin() _NOEXCEPT |
2332 {return reverse_iterator(end());} | 2162 {return reverse_iterator(end());} |
2333 _LIBCPP_INLINE_VISIBILITY | 2163 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2334 const_reverse_iterator rbegin() const _NOEXCEPT | 2164 const_reverse_iterator rbegin() const _NOEXCEPT |
2335 {return const_reverse_iterator(end());} | 2165 {return const_reverse_iterator(end());} |
2336 _LIBCPP_INLINE_VISIBILITY | 2166 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2337 reverse_iterator rend() _NOEXCEPT | 2167 reverse_iterator rend() _NOEXCEPT |
2338 {return reverse_iterator(begin());} | 2168 {return reverse_iterator(begin());} |
2339 _LIBCPP_INLINE_VISIBILITY | 2169 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2340 const_reverse_iterator rend() const _NOEXCEPT | 2170 const_reverse_iterator rend() const _NOEXCEPT |
2341 {return const_reverse_iterator(begin());} | 2171 {return const_reverse_iterator(begin());} |
2342 | 2172 |
2343 _LIBCPP_INLINE_VISIBILITY | 2173 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2344 const_iterator cbegin() const _NOEXCEPT | 2174 const_iterator cbegin() const _NOEXCEPT |
2345 {return __make_iter(0);} | 2175 {return __make_iter(0);} |
2346 _LIBCPP_INLINE_VISIBILITY | 2176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2347 const_iterator cend() const _NOEXCEPT | 2177 const_iterator cend() const _NOEXCEPT |
2348 {return __make_iter(__size_);} | 2178 {return __make_iter(__size_);} |
2349 _LIBCPP_INLINE_VISIBILITY | 2179 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2350 const_reverse_iterator crbegin() const _NOEXCEPT | 2180 const_reverse_iterator crbegin() const _NOEXCEPT |
2351 {return rbegin();} | 2181 {return rbegin();} |
2352 _LIBCPP_INLINE_VISIBILITY | 2182 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2353 const_reverse_iterator crend() const _NOEXCEPT | 2183 const_reverse_iterator crend() const _NOEXCEPT |
2354 {return rend();} | 2184 {return rend();} |
2355 | 2185 |
2356 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);} | 2186 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) {return __make_ref(__n);} |
2357 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);} | 2187 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const {return __make_ref(__n);} |
2358 reference at(size_type __n); | 2188 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n); |
2359 const_reference at(size_type __n) const; | 2189 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const; |
2360 | 2190 |
2361 _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);} | 2191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() {return __make_ref(0);} |
2362 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);} | 2192 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const {return __make_ref(0);} |
2363 _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);} | 2193 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() {return __make_ref(__size_ - 1);} |
2364 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);} | 2194 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const {return __make_ref(__size_ - 1);} |
2365 | 2195 |
2366 void push_back(const value_type& __x); | 2196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(const value_type& __x); |
2367 #if _LIBCPP_STD_VER > 11 | 2197 #if _LIBCPP_STD_VER > 11 |
2368 template <class... _Args> | 2198 template <class... _Args> |
2369 #if _LIBCPP_STD_VER > 14 | 2199 #if _LIBCPP_STD_VER > 14 |
2370 _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args) | 2200 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference emplace_back(_Args&&... __args) |
2371 #else | 2201 #else |
2372 _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) | 2202 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args) |
2373 #endif | 2203 #endif |
2374 { | 2204 { |
2375 push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); | 2205 push_back ( value_type ( std::forward<_Args>(__args)... )); |
2376 #if _LIBCPP_STD_VER > 14 | 2206 #if _LIBCPP_STD_VER > 14 |
2377 return this->back(); | 2207 return this->back(); |
2378 #endif | 2208 #endif |
2379 } | 2209 } |
2380 #endif | 2210 #endif |
2381 | 2211 |
2382 _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;} | 2212 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back() {--__size_;} |
2383 | 2213 |
2384 #if _LIBCPP_STD_VER > 11 | 2214 #if _LIBCPP_STD_VER > 11 |
2385 template <class... _Args> | 2215 template <class... _Args> |
2386 _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args) | 2216 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args) |
2387 { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); } | 2217 { return insert ( __position, value_type ( std::forward<_Args>(__args)... )); } |
2388 #endif | 2218 #endif |
2389 | 2219 |
2390 iterator insert(const_iterator __position, const value_type& __x); | 2220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x); |
2391 iterator insert(const_iterator __position, size_type __n, const value_type& __x); | 2221 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, size_type __n, const value_type& __x); |
2392 iterator insert(const_iterator __position, size_type __n, const_reference __x); | |
2393 template <class _InputIterator> | 2222 template <class _InputIterator> |
2394 typename enable_if | 2223 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, |
2395 < | |
2396 __is_cpp17_input_iterator <_InputIterator>::value && | |
2397 !__is_cpp17_forward_iterator<_InputIterator>::value, | |
2398 iterator | 2224 iterator |
2399 >::type | 2225 >::type |
2400 insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | 2226 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert(const_iterator __position, _InputIterator __first, _InputIterator __last); |
2401 template <class _ForwardIterator> | 2227 template <class _ForwardIterator> |
2402 typename enable_if | 2228 typename enable_if |
2403 < | 2229 < |
2404 __is_cpp17_forward_iterator<_ForwardIterator>::value, | 2230 __is_cpp17_forward_iterator<_ForwardIterator>::value, |
2405 iterator | 2231 iterator |
2406 >::type | 2232 >::type |
2407 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | 2233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); |
2408 | 2234 |
2409 #ifndef _LIBCPP_CXX03_LANG | 2235 #ifndef _LIBCPP_CXX03_LANG |
2410 _LIBCPP_INLINE_VISIBILITY | 2236 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2411 iterator insert(const_iterator __position, initializer_list<value_type> __il) | 2237 iterator insert(const_iterator __position, initializer_list<value_type> __il) |
2412 {return insert(__position, __il.begin(), __il.end());} | 2238 {return insert(__position, __il.begin(), __il.end());} |
2413 #endif | 2239 #endif |
2414 | 2240 |
2415 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); | 2241 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position); |
2416 iterator erase(const_iterator __first, const_iterator __last); | 2242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last); |
2417 | 2243 |
2418 _LIBCPP_INLINE_VISIBILITY | 2244 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2419 void clear() _NOEXCEPT {__size_ = 0;} | 2245 void clear() _NOEXCEPT {__size_ = 0;} |
2420 | 2246 |
2421 void swap(vector&) | 2247 _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&) |
2422 #if _LIBCPP_STD_VER >= 14 | 2248 #if _LIBCPP_STD_VER >= 14 |
2423 _NOEXCEPT; | 2249 _NOEXCEPT; |
2424 #else | 2250 #else |
2425 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || | 2251 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || |
2426 __is_nothrow_swappable<allocator_type>::value); | 2252 __is_nothrow_swappable<allocator_type>::value); |
2427 #endif | 2253 #endif |
2428 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); } | 2254 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT { std::swap(__x, __y); } |
2429 | 2255 |
2430 void resize(size_type __sz, value_type __x = false); | 2256 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false); |
2431 void flip() _NOEXCEPT; | 2257 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT; |
2432 | 2258 |
2433 bool __invariants() const; | 2259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const; |
2434 | 2260 |
2435 private: | 2261 private: |
2436 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | 2262 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI |
2437 void __vallocate(size_type __n); | 2263 void __throw_length_error() const { |
2438 void __vdeallocate() _NOEXCEPT; | 2264 std::__throw_length_error("vector"); |
2439 _LIBCPP_INLINE_VISIBILITY | 2265 } |
2266 | |
2267 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
2268 void __throw_out_of_range() const { | |
2269 std::__throw_out_of_range("vector"); | |
2270 } | |
2271 | |
2272 // Allocate space for __n objects | |
2273 // throws length_error if __n > max_size() | |
2274 // throws (probably bad_alloc) if memory run out | |
2275 // Precondition: __begin_ == __end_ == __cap() == 0 | |
2276 // Precondition: __n > 0 | |
2277 // Postcondition: capacity() >= __n | |
2278 // Postcondition: size() == 0 | |
2279 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) { | |
2280 if (__n > max_size()) | |
2281 __throw_length_error(); | |
2282 auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n)); | |
2283 __begin_ = __allocation.ptr; | |
2284 __size_ = 0; | |
2285 __cap() = __allocation.count; | |
2286 if (__libcpp_is_constant_evaluated()) { | |
2287 for (size_type __i = 0; __i != __cap(); ++__i) | |
2288 std::__construct_at(std::__to_address(__begin_) + __i); | |
2289 } | |
2290 } | |
2291 | |
2292 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT; | |
2293 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2440 static size_type __align_it(size_type __new_size) _NOEXCEPT | 2294 static size_type __align_it(size_type __new_size) _NOEXCEPT |
2441 {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);} | 2295 {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);} |
2442 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; | 2296 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const; |
2443 _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); | 2297 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x); |
2444 template <class _ForwardIterator> | 2298 template <class _ForwardIterator> |
2445 typename enable_if | 2299 typename enable_if |
2446 < | 2300 < |
2447 __is_cpp17_forward_iterator<_ForwardIterator>::value, | 2301 __is_cpp17_forward_iterator<_ForwardIterator>::value, |
2448 void | 2302 void |
2449 >::type | 2303 >::type |
2450 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); | 2304 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); |
2451 void __append(size_type __n, const_reference __x); | 2305 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append(size_type __n, const_reference __x); |
2452 _LIBCPP_INLINE_VISIBILITY | 2306 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2453 reference __make_ref(size_type __pos) _NOEXCEPT | 2307 reference __make_ref(size_type __pos) _NOEXCEPT |
2454 {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} | 2308 {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} |
2455 _LIBCPP_INLINE_VISIBILITY | 2309 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2456 const_reference __make_ref(size_type __pos) const _NOEXCEPT | 2310 const_reference __make_ref(size_type __pos) const _NOEXCEPT { |
2457 {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} | 2311 return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word, |
2458 _LIBCPP_INLINE_VISIBILITY | 2312 __storage_type(1) << __pos % __bits_per_word); |
2313 } | |
2314 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2459 iterator __make_iter(size_type __pos) _NOEXCEPT | 2315 iterator __make_iter(size_type __pos) _NOEXCEPT |
2460 {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} | 2316 {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} |
2461 _LIBCPP_INLINE_VISIBILITY | 2317 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2462 const_iterator __make_iter(size_type __pos) const _NOEXCEPT | 2318 const_iterator __make_iter(size_type __pos) const _NOEXCEPT |
2463 {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} | 2319 {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} |
2464 _LIBCPP_INLINE_VISIBILITY | 2320 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2465 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT | 2321 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT |
2466 {return begin() + (__p - cbegin());} | 2322 {return begin() + (__p - cbegin());} |
2467 | 2323 |
2468 _LIBCPP_INLINE_VISIBILITY | 2324 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2469 void __copy_assign_alloc(const vector& __v) | 2325 void __copy_assign_alloc(const vector& __v) |
2470 {__copy_assign_alloc(__v, integral_constant<bool, | 2326 {__copy_assign_alloc(__v, integral_constant<bool, |
2471 __storage_traits::propagate_on_container_copy_assignment::value>());} | 2327 __storage_traits::propagate_on_container_copy_assignment::value>());} |
2472 _LIBCPP_INLINE_VISIBILITY | 2328 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2473 void __copy_assign_alloc(const vector& __c, true_type) | 2329 void __copy_assign_alloc(const vector& __c, true_type) |
2474 { | 2330 { |
2475 if (__alloc() != __c.__alloc()) | 2331 if (__alloc() != __c.__alloc()) |
2476 __vdeallocate(); | 2332 __vdeallocate(); |
2477 __alloc() = __c.__alloc(); | 2333 __alloc() = __c.__alloc(); |
2478 } | 2334 } |
2479 | 2335 |
2480 _LIBCPP_INLINE_VISIBILITY | 2336 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2481 void __copy_assign_alloc(const vector&, false_type) | 2337 void __copy_assign_alloc(const vector&, false_type) |
2482 {} | 2338 {} |
2483 | 2339 |
2484 void __move_assign(vector& __c, false_type); | 2340 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type); |
2485 void __move_assign(vector& __c, true_type) | 2341 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type) |
2486 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | 2342 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); |
2487 _LIBCPP_INLINE_VISIBILITY | 2343 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2488 void __move_assign_alloc(vector& __c) | 2344 void __move_assign_alloc(vector& __c) |
2489 _NOEXCEPT_( | 2345 _NOEXCEPT_( |
2490 !__storage_traits::propagate_on_container_move_assignment::value || | 2346 !__storage_traits::propagate_on_container_move_assignment::value || |
2491 is_nothrow_move_assignable<allocator_type>::value) | 2347 is_nothrow_move_assignable<allocator_type>::value) |
2492 {__move_assign_alloc(__c, integral_constant<bool, | 2348 {__move_assign_alloc(__c, integral_constant<bool, |
2493 __storage_traits::propagate_on_container_move_assignment::value>());} | 2349 __storage_traits::propagate_on_container_move_assignment::value>());} |
2494 _LIBCPP_INLINE_VISIBILITY | 2350 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2495 void __move_assign_alloc(vector& __c, true_type) | 2351 void __move_assign_alloc(vector& __c, true_type) |
2496 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 2352 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
2497 { | 2353 { |
2498 __alloc() = _VSTD::move(__c.__alloc()); | 2354 __alloc() = std::move(__c.__alloc()); |
2499 } | 2355 } |
2500 | 2356 |
2501 _LIBCPP_INLINE_VISIBILITY | 2357 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2502 void __move_assign_alloc(vector&, false_type) | 2358 void __move_assign_alloc(vector&, false_type) |
2503 _NOEXCEPT | 2359 _NOEXCEPT |
2504 {} | 2360 {} |
2505 | 2361 |
2506 size_t __hash_code() const _NOEXCEPT; | 2362 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT; |
2507 | 2363 |
2508 friend class __bit_reference<vector>; | 2364 friend class __bit_reference<vector>; |
2509 friend class __bit_const_reference<vector>; | 2365 friend class __bit_const_reference<vector>; |
2510 friend class __bit_iterator<vector, false>; | 2366 friend class __bit_iterator<vector, false>; |
2511 friend class __bit_iterator<vector, true>; | 2367 friend class __bit_iterator<vector, true>; |
2512 friend struct __bit_array<vector>; | 2368 friend struct __bit_array<vector>; |
2513 friend struct _LIBCPP_TEMPLATE_VIS hash<vector>; | 2369 friend struct _LIBCPP_TEMPLATE_VIS hash<vector>; |
2514 }; | 2370 }; |
2515 | 2371 |
2516 template <class _Allocator> | 2372 template <class _Allocator> |
2517 inline _LIBCPP_INLINE_VISIBILITY | 2373 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
2518 void | |
2519 vector<bool, _Allocator>::__invalidate_all_iterators() | |
2520 { | |
2521 } | |
2522 | |
2523 // Allocate space for __n objects | |
2524 // throws length_error if __n > max_size() | |
2525 // throws (probably bad_alloc) if memory run out | |
2526 // Precondition: __begin_ == __end_ == __cap() == 0 | |
2527 // Precondition: __n > 0 | |
2528 // Postcondition: capacity() == __n | |
2529 // Postcondition: size() == 0 | |
2530 template <class _Allocator> | |
2531 void | |
2532 vector<bool, _Allocator>::__vallocate(size_type __n) | |
2533 { | |
2534 if (__n > max_size()) | |
2535 this->__throw_length_error(); | |
2536 __n = __external_cap_to_internal(__n); | |
2537 this->__begin_ = __storage_traits::allocate(this->__alloc(), __n); | |
2538 this->__size_ = 0; | |
2539 this->__cap() = __n; | |
2540 } | |
2541 | |
2542 template <class _Allocator> | |
2543 void | |
2544 vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT | 2374 vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT |
2545 { | 2375 { |
2546 if (this->__begin_ != nullptr) | 2376 if (this->__begin_ != nullptr) |
2547 { | 2377 { |
2548 __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); | 2378 __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); |
2549 __invalidate_all_iterators(); | 2379 std::__debug_db_invalidate_all(this); |
2550 this->__begin_ = nullptr; | 2380 this->__begin_ = nullptr; |
2551 this->__size_ = this->__cap() = 0; | 2381 this->__size_ = this->__cap() = 0; |
2552 } | 2382 } |
2553 } | 2383 } |
2554 | 2384 |
2555 template <class _Allocator> | 2385 template <class _Allocator> |
2386 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2556 typename vector<bool, _Allocator>::size_type | 2387 typename vector<bool, _Allocator>::size_type |
2557 vector<bool, _Allocator>::max_size() const _NOEXCEPT | 2388 vector<bool, _Allocator>::max_size() const _NOEXCEPT |
2558 { | 2389 { |
2559 size_type __amax = __storage_traits::max_size(__alloc()); | 2390 size_type __amax = __storage_traits::max_size(__alloc()); |
2560 size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always | 2391 size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always |
2563 return __internal_cap_to_external(__amax); | 2394 return __internal_cap_to_external(__amax); |
2564 } | 2395 } |
2565 | 2396 |
2566 // Precondition: __new_size > capacity() | 2397 // Precondition: __new_size > capacity() |
2567 template <class _Allocator> | 2398 template <class _Allocator> |
2568 inline _LIBCPP_INLINE_VISIBILITY | 2399 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2569 typename vector<bool, _Allocator>::size_type | 2400 typename vector<bool, _Allocator>::size_type |
2570 vector<bool, _Allocator>::__recommend(size_type __new_size) const | 2401 vector<bool, _Allocator>::__recommend(size_type __new_size) const |
2571 { | 2402 { |
2572 const size_type __ms = max_size(); | 2403 const size_type __ms = max_size(); |
2573 if (__new_size > __ms) | 2404 if (__new_size > __ms) |
2574 this->__throw_length_error(); | 2405 this->__throw_length_error(); |
2575 const size_type __cap = capacity(); | 2406 const size_type __cap = capacity(); |
2576 if (__cap >= __ms / 2) | 2407 if (__cap >= __ms / 2) |
2577 return __ms; | 2408 return __ms; |
2578 return _VSTD::max(2*__cap, __align_it(__new_size)); | 2409 return std::max(2 * __cap, __align_it(__new_size)); |
2579 } | 2410 } |
2580 | 2411 |
2581 // Default constructs __n objects starting at __end_ | 2412 // Default constructs __n objects starting at __end_ |
2582 // Precondition: __n > 0 | 2413 // Precondition: __n > 0 |
2583 // Precondition: size() + __n <= capacity() | 2414 // Precondition: size() + __n <= capacity() |
2584 // Postcondition: size() == size() + __n | 2415 // Postcondition: size() == size() + __n |
2585 template <class _Allocator> | 2416 template <class _Allocator> |
2586 inline _LIBCPP_INLINE_VISIBILITY | 2417 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2587 void | 2418 void |
2588 vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) | 2419 vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) |
2589 { | 2420 { |
2590 size_type __old_size = this->__size_; | 2421 size_type __old_size = this->__size_; |
2591 this->__size_ += __n; | 2422 this->__size_ += __n; |
2594 if (this->__size_ <= __bits_per_word) | 2425 if (this->__size_ <= __bits_per_word) |
2595 this->__begin_[0] = __storage_type(0); | 2426 this->__begin_[0] = __storage_type(0); |
2596 else | 2427 else |
2597 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); | 2428 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); |
2598 } | 2429 } |
2599 _VSTD::fill_n(__make_iter(__old_size), __n, __x); | 2430 std::fill_n(__make_iter(__old_size), __n, __x); |
2600 } | 2431 } |
2601 | 2432 |
2602 template <class _Allocator> | 2433 template <class _Allocator> |
2603 template <class _ForwardIterator> | 2434 template <class _ForwardIterator> |
2435 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2604 typename enable_if | 2436 typename enable_if |
2605 < | 2437 < |
2606 __is_cpp17_forward_iterator<_ForwardIterator>::value, | 2438 __is_cpp17_forward_iterator<_ForwardIterator>::value, |
2607 void | 2439 void |
2608 >::type | 2440 >::type |
2609 vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) | 2441 vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) |
2610 { | 2442 { |
2611 size_type __old_size = this->__size_; | 2443 size_type __old_size = this->__size_; |
2612 this->__size_ += _VSTD::distance(__first, __last); | 2444 this->__size_ += std::distance(__first, __last); |
2613 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) | 2445 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) |
2614 { | 2446 { |
2615 if (this->__size_ <= __bits_per_word) | 2447 if (this->__size_ <= __bits_per_word) |
2616 this->__begin_[0] = __storage_type(0); | 2448 this->__begin_[0] = __storage_type(0); |
2617 else | 2449 else |
2618 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); | 2450 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); |
2619 } | 2451 } |
2620 _VSTD::copy(__first, __last, __make_iter(__old_size)); | 2452 std::copy(__first, __last, __make_iter(__old_size)); |
2621 } | 2453 } |
2622 | 2454 |
2623 template <class _Allocator> | 2455 template <class _Allocator> |
2624 inline _LIBCPP_INLINE_VISIBILITY | 2456 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2625 vector<bool, _Allocator>::vector() | 2457 vector<bool, _Allocator>::vector() |
2626 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | 2458 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
2627 : __begin_(nullptr), | 2459 : __begin_(nullptr), |
2628 __size_(0), | 2460 __size_(0), |
2629 __cap_alloc_(0, __default_init_tag()) | 2461 __cap_alloc_(0, __default_init_tag()) |
2630 { | 2462 { |
2631 } | 2463 } |
2632 | 2464 |
2633 template <class _Allocator> | 2465 template <class _Allocator> |
2634 inline _LIBCPP_INLINE_VISIBILITY | 2466 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2635 vector<bool, _Allocator>::vector(const allocator_type& __a) | 2467 vector<bool, _Allocator>::vector(const allocator_type& __a) |
2636 #if _LIBCPP_STD_VER <= 14 | 2468 #if _LIBCPP_STD_VER <= 14 |
2637 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | 2469 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) |
2638 #else | 2470 #else |
2639 _NOEXCEPT | 2471 _NOEXCEPT |
2643 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 2475 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) |
2644 { | 2476 { |
2645 } | 2477 } |
2646 | 2478 |
2647 template <class _Allocator> | 2479 template <class _Allocator> |
2480 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2648 vector<bool, _Allocator>::vector(size_type __n) | 2481 vector<bool, _Allocator>::vector(size_type __n) |
2649 : __begin_(nullptr), | 2482 : __begin_(nullptr), |
2650 __size_(0), | 2483 __size_(0), |
2651 __cap_alloc_(0, __default_init_tag()) | 2484 __cap_alloc_(0, __default_init_tag()) |
2652 { | 2485 { |
2657 } | 2490 } |
2658 } | 2491 } |
2659 | 2492 |
2660 #if _LIBCPP_STD_VER > 11 | 2493 #if _LIBCPP_STD_VER > 11 |
2661 template <class _Allocator> | 2494 template <class _Allocator> |
2495 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2662 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) | 2496 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) |
2663 : __begin_(nullptr), | 2497 : __begin_(nullptr), |
2664 __size_(0), | 2498 __size_(0), |
2665 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 2499 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) |
2666 { | 2500 { |
2671 } | 2505 } |
2672 } | 2506 } |
2673 #endif | 2507 #endif |
2674 | 2508 |
2675 template <class _Allocator> | 2509 template <class _Allocator> |
2510 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2676 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) | 2511 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) |
2677 : __begin_(nullptr), | 2512 : __begin_(nullptr), |
2678 __size_(0), | 2513 __size_(0), |
2679 __cap_alloc_(0, __default_init_tag()) | 2514 __cap_alloc_(0, __default_init_tag()) |
2680 { | 2515 { |
2684 __construct_at_end(__n, __x); | 2519 __construct_at_end(__n, __x); |
2685 } | 2520 } |
2686 } | 2521 } |
2687 | 2522 |
2688 template <class _Allocator> | 2523 template <class _Allocator> |
2524 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2689 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) | 2525 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) |
2690 : __begin_(nullptr), | 2526 : __begin_(nullptr), |
2691 __size_(0), | 2527 __size_(0), |
2692 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 2528 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) |
2693 { | 2529 { |
2698 } | 2534 } |
2699 } | 2535 } |
2700 | 2536 |
2701 template <class _Allocator> | 2537 template <class _Allocator> |
2702 template <class _InputIterator> | 2538 template <class _InputIterator> |
2539 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2703 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, | 2540 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, |
2704 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | 2541 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*) |
2705 !__is_cpp17_forward_iterator<_InputIterator>::value>::type*) | |
2706 : __begin_(nullptr), | 2542 : __begin_(nullptr), |
2707 __size_(0), | 2543 __size_(0), |
2708 __cap_alloc_(0, __default_init_tag()) | 2544 __cap_alloc_(0, __default_init_tag()) |
2709 { | 2545 { |
2710 #ifndef _LIBCPP_NO_EXCEPTIONS | 2546 #ifndef _LIBCPP_NO_EXCEPTIONS |
2717 } | 2553 } |
2718 catch (...) | 2554 catch (...) |
2719 { | 2555 { |
2720 if (__begin_ != nullptr) | 2556 if (__begin_ != nullptr) |
2721 __storage_traits::deallocate(__alloc(), __begin_, __cap()); | 2557 __storage_traits::deallocate(__alloc(), __begin_, __cap()); |
2722 __invalidate_all_iterators(); | 2558 std::__debug_db_invalidate_all(this); |
2723 throw; | 2559 throw; |
2724 } | 2560 } |
2725 #endif // _LIBCPP_NO_EXCEPTIONS | 2561 #endif // _LIBCPP_NO_EXCEPTIONS |
2726 } | 2562 } |
2727 | 2563 |
2728 template <class _Allocator> | 2564 template <class _Allocator> |
2729 template <class _InputIterator> | 2565 template <class _InputIterator> |
2566 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2730 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | 2567 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, |
2731 typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | 2568 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*) |
2732 !__is_cpp17_forward_iterator<_InputIterator>::value>::type*) | |
2733 : __begin_(nullptr), | 2569 : __begin_(nullptr), |
2734 __size_(0), | 2570 __size_(0), |
2735 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 2571 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) |
2736 { | 2572 { |
2737 #ifndef _LIBCPP_NO_EXCEPTIONS | 2573 #ifndef _LIBCPP_NO_EXCEPTIONS |
2744 } | 2580 } |
2745 catch (...) | 2581 catch (...) |
2746 { | 2582 { |
2747 if (__begin_ != nullptr) | 2583 if (__begin_ != nullptr) |
2748 __storage_traits::deallocate(__alloc(), __begin_, __cap()); | 2584 __storage_traits::deallocate(__alloc(), __begin_, __cap()); |
2749 __invalidate_all_iterators(); | 2585 std::__debug_db_invalidate_all(this); |
2750 throw; | 2586 throw; |
2751 } | 2587 } |
2752 #endif // _LIBCPP_NO_EXCEPTIONS | 2588 #endif // _LIBCPP_NO_EXCEPTIONS |
2753 } | 2589 } |
2754 | 2590 |
2755 template <class _Allocator> | 2591 template <class _Allocator> |
2756 template <class _ForwardIterator> | 2592 template <class _ForwardIterator> |
2593 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2757 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, | 2594 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, |
2758 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) | 2595 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) |
2759 : __begin_(nullptr), | 2596 : __begin_(nullptr), |
2760 __size_(0), | 2597 __size_(0), |
2761 __cap_alloc_(0, __default_init_tag()) | 2598 __cap_alloc_(0, __default_init_tag()) |
2762 { | 2599 { |
2763 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 2600 size_type __n = static_cast<size_type>(std::distance(__first, __last)); |
2764 if (__n > 0) | 2601 if (__n > 0) |
2765 { | 2602 { |
2766 __vallocate(__n); | 2603 __vallocate(__n); |
2767 __construct_at_end(__first, __last); | 2604 __construct_at_end(__first, __last); |
2768 } | 2605 } |
2769 } | 2606 } |
2770 | 2607 |
2771 template <class _Allocator> | 2608 template <class _Allocator> |
2772 template <class _ForwardIterator> | 2609 template <class _ForwardIterator> |
2610 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2773 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | 2611 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, |
2774 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) | 2612 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) |
2775 : __begin_(nullptr), | 2613 : __begin_(nullptr), |
2776 __size_(0), | 2614 __size_(0), |
2777 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 2615 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) |
2778 { | 2616 { |
2779 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | 2617 size_type __n = static_cast<size_type>(std::distance(__first, __last)); |
2780 if (__n > 0) | 2618 if (__n > 0) |
2781 { | 2619 { |
2782 __vallocate(__n); | 2620 __vallocate(__n); |
2783 __construct_at_end(__first, __last); | 2621 __construct_at_end(__first, __last); |
2784 } | 2622 } |
2785 } | 2623 } |
2786 | 2624 |
2787 #ifndef _LIBCPP_CXX03_LANG | 2625 #ifndef _LIBCPP_CXX03_LANG |
2788 | 2626 |
2789 template <class _Allocator> | 2627 template <class _Allocator> |
2628 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2790 vector<bool, _Allocator>::vector(initializer_list<value_type> __il) | 2629 vector<bool, _Allocator>::vector(initializer_list<value_type> __il) |
2791 : __begin_(nullptr), | 2630 : __begin_(nullptr), |
2792 __size_(0), | 2631 __size_(0), |
2793 __cap_alloc_(0, __default_init_tag()) | 2632 __cap_alloc_(0, __default_init_tag()) |
2794 { | 2633 { |
2799 __construct_at_end(__il.begin(), __il.end()); | 2638 __construct_at_end(__il.begin(), __il.end()); |
2800 } | 2639 } |
2801 } | 2640 } |
2802 | 2641 |
2803 template <class _Allocator> | 2642 template <class _Allocator> |
2643 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2804 vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) | 2644 vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) |
2805 : __begin_(nullptr), | 2645 : __begin_(nullptr), |
2806 __size_(0), | 2646 __size_(0), |
2807 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) | 2647 __cap_alloc_(0, static_cast<__storage_allocator>(__a)) |
2808 { | 2648 { |
2815 } | 2655 } |
2816 | 2656 |
2817 #endif // _LIBCPP_CXX03_LANG | 2657 #endif // _LIBCPP_CXX03_LANG |
2818 | 2658 |
2819 template <class _Allocator> | 2659 template <class _Allocator> |
2660 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2820 vector<bool, _Allocator>::~vector() | 2661 vector<bool, _Allocator>::~vector() |
2821 { | 2662 { |
2822 if (__begin_ != nullptr) | 2663 if (__begin_ != nullptr) |
2823 __storage_traits::deallocate(__alloc(), __begin_, __cap()); | 2664 __storage_traits::deallocate(__alloc(), __begin_, __cap()); |
2824 __invalidate_all_iterators(); | 2665 std::__debug_db_invalidate_all(this); |
2825 } | 2666 } |
2826 | 2667 |
2827 template <class _Allocator> | 2668 template <class _Allocator> |
2669 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2828 vector<bool, _Allocator>::vector(const vector& __v) | 2670 vector<bool, _Allocator>::vector(const vector& __v) |
2829 : __begin_(nullptr), | 2671 : __begin_(nullptr), |
2830 __size_(0), | 2672 __size_(0), |
2831 __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) | 2673 __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) |
2832 { | 2674 { |
2836 __construct_at_end(__v.begin(), __v.end()); | 2678 __construct_at_end(__v.begin(), __v.end()); |
2837 } | 2679 } |
2838 } | 2680 } |
2839 | 2681 |
2840 template <class _Allocator> | 2682 template <class _Allocator> |
2683 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2841 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) | 2684 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) |
2842 : __begin_(nullptr), | 2685 : __begin_(nullptr), |
2843 __size_(0), | 2686 __size_(0), |
2844 __cap_alloc_(0, __a) | 2687 __cap_alloc_(0, __a) |
2845 { | 2688 { |
2849 __construct_at_end(__v.begin(), __v.end()); | 2692 __construct_at_end(__v.begin(), __v.end()); |
2850 } | 2693 } |
2851 } | 2694 } |
2852 | 2695 |
2853 template <class _Allocator> | 2696 template <class _Allocator> |
2697 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2854 vector<bool, _Allocator>& | 2698 vector<bool, _Allocator>& |
2855 vector<bool, _Allocator>::operator=(const vector& __v) | 2699 vector<bool, _Allocator>::operator=(const vector& __v) |
2856 { | 2700 { |
2857 if (this != &__v) | 2701 if (this != std::addressof(__v)) |
2858 { | 2702 { |
2859 __copy_assign_alloc(__v); | 2703 __copy_assign_alloc(__v); |
2860 if (__v.__size_) | 2704 if (__v.__size_) |
2861 { | 2705 { |
2862 if (__v.__size_ > capacity()) | 2706 if (__v.__size_ > capacity()) |
2863 { | 2707 { |
2864 __vdeallocate(); | 2708 __vdeallocate(); |
2865 __vallocate(__v.__size_); | 2709 __vallocate(__v.__size_); |
2866 } | 2710 } |
2867 _VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_); | 2711 std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_); |
2868 } | 2712 } |
2869 __size_ = __v.__size_; | 2713 __size_ = __v.__size_; |
2870 } | 2714 } |
2871 return *this; | 2715 return *this; |
2872 } | 2716 } |
2873 | 2717 |
2874 #ifndef _LIBCPP_CXX03_LANG | 2718 template <class _Allocator> |
2875 | 2719 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v) |
2876 template <class _Allocator> | |
2877 inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v) | |
2878 #if _LIBCPP_STD_VER > 14 | 2720 #if _LIBCPP_STD_VER > 14 |
2879 _NOEXCEPT | 2721 _NOEXCEPT |
2880 #else | 2722 #else |
2881 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | 2723 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
2882 #endif | 2724 #endif |
2883 : __begin_(__v.__begin_), | 2725 : __begin_(__v.__begin_), |
2884 __size_(__v.__size_), | 2726 __size_(__v.__size_), |
2885 __cap_alloc_(_VSTD::move(__v.__cap_alloc_)) { | 2727 __cap_alloc_(std::move(__v.__cap_alloc_)) { |
2886 __v.__begin_ = nullptr; | 2728 __v.__begin_ = nullptr; |
2887 __v.__size_ = 0; | 2729 __v.__size_ = 0; |
2888 __v.__cap() = 0; | 2730 __v.__cap() = 0; |
2889 } | 2731 } |
2890 | 2732 |
2891 template <class _Allocator> | 2733 template <class _Allocator> |
2892 vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type>& __a) | 2734 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2735 vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a) | |
2893 : __begin_(nullptr), | 2736 : __begin_(nullptr), |
2894 __size_(0), | 2737 __size_(0), |
2895 __cap_alloc_(0, __a) | 2738 __cap_alloc_(0, __a) |
2896 { | 2739 { |
2897 if (__a == allocator_type(__v.__alloc())) | 2740 if (__a == allocator_type(__v.__alloc())) |
2908 __construct_at_end(__v.begin(), __v.end()); | 2751 __construct_at_end(__v.begin(), __v.end()); |
2909 } | 2752 } |
2910 } | 2753 } |
2911 | 2754 |
2912 template <class _Allocator> | 2755 template <class _Allocator> |
2913 inline _LIBCPP_INLINE_VISIBILITY | 2756 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
2914 vector<bool, _Allocator>& | 2757 vector<bool, _Allocator>& |
2915 vector<bool, _Allocator>::operator=(vector&& __v) | 2758 vector<bool, _Allocator>::operator=(vector&& __v) |
2916 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) | 2759 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) |
2917 { | 2760 { |
2918 __move_assign(__v, integral_constant<bool, | 2761 __move_assign(__v, integral_constant<bool, |
2919 __storage_traits::propagate_on_container_move_assignment::value>()); | 2762 __storage_traits::propagate_on_container_move_assignment::value>()); |
2920 return *this; | 2763 return *this; |
2921 } | 2764 } |
2922 | 2765 |
2923 template <class _Allocator> | 2766 template <class _Allocator> |
2924 void | 2767 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
2925 vector<bool, _Allocator>::__move_assign(vector& __c, false_type) | 2768 vector<bool, _Allocator>::__move_assign(vector& __c, false_type) |
2926 { | 2769 { |
2927 if (__alloc() != __c.__alloc()) | 2770 if (__alloc() != __c.__alloc()) |
2928 assign(__c.begin(), __c.end()); | 2771 assign(__c.begin(), __c.end()); |
2929 else | 2772 else |
2930 __move_assign(__c, true_type()); | 2773 __move_assign(__c, true_type()); |
2931 } | 2774 } |
2932 | 2775 |
2933 template <class _Allocator> | 2776 template <class _Allocator> |
2934 void | 2777 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
2935 vector<bool, _Allocator>::__move_assign(vector& __c, true_type) | 2778 vector<bool, _Allocator>::__move_assign(vector& __c, true_type) |
2936 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | 2779 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
2937 { | 2780 { |
2938 __vdeallocate(); | 2781 __vdeallocate(); |
2939 __move_assign_alloc(__c); | 2782 __move_assign_alloc(__c); |
2942 this->__cap() = __c.__cap(); | 2785 this->__cap() = __c.__cap(); |
2943 __c.__begin_ = nullptr; | 2786 __c.__begin_ = nullptr; |
2944 __c.__cap() = __c.__size_ = 0; | 2787 __c.__cap() = __c.__size_ = 0; |
2945 } | 2788 } |
2946 | 2789 |
2947 #endif // !_LIBCPP_CXX03_LANG | 2790 template <class _Allocator> |
2948 | 2791 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
2949 template <class _Allocator> | |
2950 void | |
2951 vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) | 2792 vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) |
2952 { | 2793 { |
2953 __size_ = 0; | 2794 __size_ = 0; |
2954 if (__n > 0) | 2795 if (__n > 0) |
2955 { | 2796 { |
2956 size_type __c = capacity(); | 2797 size_type __c = capacity(); |
2957 if (__n <= __c) | 2798 if (__n <= __c) |
2958 __size_ = __n; | 2799 __size_ = __n; |
2959 else | 2800 else |
2960 { | 2801 { |
2961 vector __v(__alloc()); | 2802 vector __v(get_allocator()); |
2962 __v.reserve(__recommend(__n)); | 2803 __v.reserve(__recommend(__n)); |
2963 __v.__size_ = __n; | 2804 __v.__size_ = __n; |
2964 swap(__v); | 2805 swap(__v); |
2965 } | 2806 } |
2966 _VSTD::fill_n(begin(), __n, __x); | 2807 std::fill_n(begin(), __n, __x); |
2967 } | 2808 } |
2968 __invalidate_all_iterators(); | 2809 std::__debug_db_invalidate_all(this); |
2969 } | 2810 } |
2970 | 2811 |
2971 template <class _Allocator> | 2812 template <class _Allocator> |
2972 template <class _InputIterator> | 2813 template <class _InputIterator> |
2973 typename enable_if | 2814 _LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, |
2974 < | |
2975 __is_cpp17_input_iterator<_InputIterator>::value && | |
2976 !__is_cpp17_forward_iterator<_InputIterator>::value, | |
2977 void | 2815 void |
2978 >::type | 2816 >::type |
2979 vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) | 2817 vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) |
2980 { | 2818 { |
2981 clear(); | 2819 clear(); |
2983 push_back(*__first); | 2821 push_back(*__first); |
2984 } | 2822 } |
2985 | 2823 |
2986 template <class _Allocator> | 2824 template <class _Allocator> |
2987 template <class _ForwardIterator> | 2825 template <class _ForwardIterator> |
2826 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
2988 typename enable_if | 2827 typename enable_if |
2989 < | 2828 < |
2990 __is_cpp17_forward_iterator<_ForwardIterator>::value, | 2829 __is_cpp17_forward_iterator<_ForwardIterator>::value, |
2991 void | 2830 void |
2992 >::type | 2831 >::type |
2993 vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) | 2832 vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) |
2994 { | 2833 { |
2995 clear(); | 2834 clear(); |
2996 difference_type __ns = _VSTD::distance(__first, __last); | 2835 difference_type __ns = std::distance(__first, __last); |
2997 _LIBCPP_ASSERT(__ns >= 0, "invalid range specified"); | 2836 _LIBCPP_ASSERT(__ns >= 0, "invalid range specified"); |
2998 const size_t __n = static_cast<size_type>(__ns); | 2837 const size_t __n = static_cast<size_type>(__ns); |
2999 if (__n) | 2838 if (__n) |
3000 { | 2839 { |
3001 if (__n > capacity()) | 2840 if (__n > capacity()) |
3006 __construct_at_end(__first, __last); | 2845 __construct_at_end(__first, __last); |
3007 } | 2846 } |
3008 } | 2847 } |
3009 | 2848 |
3010 template <class _Allocator> | 2849 template <class _Allocator> |
3011 void | 2850 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
3012 vector<bool, _Allocator>::reserve(size_type __n) | 2851 vector<bool, _Allocator>::reserve(size_type __n) |
3013 { | 2852 { |
3014 if (__n > capacity()) | 2853 if (__n > capacity()) |
3015 { | 2854 { |
3016 vector __v(this->__alloc()); | 2855 if (__n > max_size()) |
2856 this->__throw_length_error(); | |
2857 vector __v(this->get_allocator()); | |
3017 __v.__vallocate(__n); | 2858 __v.__vallocate(__n); |
3018 __v.__construct_at_end(this->begin(), this->end()); | 2859 __v.__construct_at_end(this->begin(), this->end()); |
3019 swap(__v); | 2860 swap(__v); |
3020 __invalidate_all_iterators(); | 2861 std::__debug_db_invalidate_all(this); |
3021 } | 2862 } |
3022 } | 2863 } |
3023 | 2864 |
3024 template <class _Allocator> | 2865 template <class _Allocator> |
3025 void | 2866 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
3026 vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT | 2867 vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT |
3027 { | 2868 { |
3028 if (__external_cap_to_internal(size()) > __cap()) | 2869 if (__external_cap_to_internal(size()) > __cap()) |
3029 { | 2870 { |
3030 #ifndef _LIBCPP_NO_EXCEPTIONS | 2871 #ifndef _LIBCPP_NO_EXCEPTIONS |
3058 this->__throw_out_of_range(); | 2899 this->__throw_out_of_range(); |
3059 return (*this)[__n]; | 2900 return (*this)[__n]; |
3060 } | 2901 } |
3061 | 2902 |
3062 template <class _Allocator> | 2903 template <class _Allocator> |
3063 void | 2904 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
3064 vector<bool, _Allocator>::push_back(const value_type& __x) | 2905 vector<bool, _Allocator>::push_back(const value_type& __x) |
3065 { | 2906 { |
3066 if (this->__size_ == this->capacity()) | 2907 if (this->__size_ == this->capacity()) |
3067 reserve(__recommend(this->__size_ + 1)); | 2908 reserve(__recommend(this->__size_ + 1)); |
3068 ++this->__size_; | 2909 ++this->__size_; |
3069 back() = __x; | 2910 back() = __x; |
3070 } | 2911 } |
3071 | 2912 |
3072 template <class _Allocator> | 2913 template <class _Allocator> |
3073 typename vector<bool, _Allocator>::iterator | 2914 _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator |
3074 vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) | 2915 vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) |
3075 { | 2916 { |
3076 iterator __r; | 2917 iterator __r; |
3077 if (size() < capacity()) | 2918 if (size() < capacity()) |
3078 { | 2919 { |
3079 const_iterator __old_end = end(); | 2920 const_iterator __old_end = end(); |
3080 ++__size_; | 2921 ++__size_; |
3081 _VSTD::copy_backward(__position, __old_end, end()); | 2922 std::copy_backward(__position, __old_end, end()); |
3082 __r = __const_iterator_cast(__position); | 2923 __r = __const_iterator_cast(__position); |
3083 } | 2924 } |
3084 else | 2925 else |
3085 { | 2926 { |
3086 vector __v(__alloc()); | 2927 vector __v(get_allocator()); |
3087 __v.reserve(__recommend(__size_ + 1)); | 2928 __v.reserve(__recommend(__size_ + 1)); |
3088 __v.__size_ = __size_ + 1; | 2929 __v.__size_ = __size_ + 1; |
3089 __r = _VSTD::copy(cbegin(), __position, __v.begin()); | 2930 __r = std::copy(cbegin(), __position, __v.begin()); |
3090 _VSTD::copy_backward(__position, cend(), __v.end()); | 2931 std::copy_backward(__position, cend(), __v.end()); |
3091 swap(__v); | 2932 swap(__v); |
3092 } | 2933 } |
3093 *__r = __x; | 2934 *__r = __x; |
3094 return __r; | 2935 return __r; |
3095 } | 2936 } |
3096 | 2937 |
3097 template <class _Allocator> | 2938 template <class _Allocator> |
3098 typename vector<bool, _Allocator>::iterator | 2939 _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator |
3099 vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) | 2940 vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) |
3100 { | 2941 { |
3101 iterator __r; | 2942 iterator __r; |
3102 size_type __c = capacity(); | 2943 size_type __c = capacity(); |
3103 if (__n <= __c && size() <= __c - __n) | 2944 if (__n <= __c && size() <= __c - __n) |
3104 { | 2945 { |
3105 const_iterator __old_end = end(); | 2946 const_iterator __old_end = end(); |
3106 __size_ += __n; | 2947 __size_ += __n; |
3107 _VSTD::copy_backward(__position, __old_end, end()); | 2948 std::copy_backward(__position, __old_end, end()); |
3108 __r = __const_iterator_cast(__position); | 2949 __r = __const_iterator_cast(__position); |
3109 } | 2950 } |
3110 else | 2951 else |
3111 { | 2952 { |
3112 vector __v(__alloc()); | 2953 vector __v(get_allocator()); |
3113 __v.reserve(__recommend(__size_ + __n)); | 2954 __v.reserve(__recommend(__size_ + __n)); |
3114 __v.__size_ = __size_ + __n; | 2955 __v.__size_ = __size_ + __n; |
3115 __r = _VSTD::copy(cbegin(), __position, __v.begin()); | 2956 __r = std::copy(cbegin(), __position, __v.begin()); |
3116 _VSTD::copy_backward(__position, cend(), __v.end()); | 2957 std::copy_backward(__position, cend(), __v.end()); |
3117 swap(__v); | 2958 swap(__v); |
3118 } | 2959 } |
3119 _VSTD::fill_n(__r, __n, __x); | 2960 std::fill_n(__r, __n, __x); |
3120 return __r; | 2961 return __r; |
3121 } | 2962 } |
3122 | 2963 |
3123 template <class _Allocator> | 2964 template <class _Allocator> |
3124 template <class _InputIterator> | 2965 template <class _InputIterator> |
3125 typename enable_if | 2966 _LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, |
3126 < | |
3127 __is_cpp17_input_iterator <_InputIterator>::value && | |
3128 !__is_cpp17_forward_iterator<_InputIterator>::value, | |
3129 typename vector<bool, _Allocator>::iterator | 2967 typename vector<bool, _Allocator>::iterator |
3130 >::type | 2968 >::type |
3131 vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) | 2969 vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) |
3132 { | 2970 { |
3133 difference_type __off = __position - begin(); | 2971 difference_type __off = __position - begin(); |
3136 for (; size() != capacity() && __first != __last; ++__first) | 2974 for (; size() != capacity() && __first != __last; ++__first) |
3137 { | 2975 { |
3138 ++this->__size_; | 2976 ++this->__size_; |
3139 back() = *__first; | 2977 back() = *__first; |
3140 } | 2978 } |
3141 vector __v(__alloc()); | 2979 vector __v(get_allocator()); |
3142 if (__first != __last) | 2980 if (__first != __last) |
3143 { | 2981 { |
3144 #ifndef _LIBCPP_NO_EXCEPTIONS | 2982 #ifndef _LIBCPP_NO_EXCEPTIONS |
3145 try | 2983 try |
3146 { | 2984 { |
3158 erase(__old_end, end()); | 2996 erase(__old_end, end()); |
3159 throw; | 2997 throw; |
3160 } | 2998 } |
3161 #endif // _LIBCPP_NO_EXCEPTIONS | 2999 #endif // _LIBCPP_NO_EXCEPTIONS |
3162 } | 3000 } |
3163 __p = _VSTD::rotate(__p, __old_end, end()); | 3001 __p = std::rotate(__p, __old_end, end()); |
3164 insert(__p, __v.begin(), __v.end()); | 3002 insert(__p, __v.begin(), __v.end()); |
3165 return begin() + __off; | 3003 return begin() + __off; |
3166 } | 3004 } |
3167 | 3005 |
3168 template <class _Allocator> | 3006 template <class _Allocator> |
3169 template <class _ForwardIterator> | 3007 template <class _ForwardIterator> |
3008 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
3170 typename enable_if | 3009 typename enable_if |
3171 < | 3010 < |
3172 __is_cpp17_forward_iterator<_ForwardIterator>::value, | 3011 __is_cpp17_forward_iterator<_ForwardIterator>::value, |
3173 typename vector<bool, _Allocator>::iterator | 3012 typename vector<bool, _Allocator>::iterator |
3174 >::type | 3013 >::type |
3175 vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) | 3014 vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) |
3176 { | 3015 { |
3177 const difference_type __n_signed = _VSTD::distance(__first, __last); | 3016 const difference_type __n_signed = std::distance(__first, __last); |
3178 _LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified"); | 3017 _LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified"); |
3179 const size_type __n = static_cast<size_type>(__n_signed); | 3018 const size_type __n = static_cast<size_type>(__n_signed); |
3180 iterator __r; | 3019 iterator __r; |
3181 size_type __c = capacity(); | 3020 size_type __c = capacity(); |
3182 if (__n <= __c && size() <= __c - __n) | 3021 if (__n <= __c && size() <= __c - __n) |
3183 { | 3022 { |
3184 const_iterator __old_end = end(); | 3023 const_iterator __old_end = end(); |
3185 __size_ += __n; | 3024 __size_ += __n; |
3186 _VSTD::copy_backward(__position, __old_end, end()); | 3025 std::copy_backward(__position, __old_end, end()); |
3187 __r = __const_iterator_cast(__position); | 3026 __r = __const_iterator_cast(__position); |
3188 } | 3027 } |
3189 else | 3028 else |
3190 { | 3029 { |
3191 vector __v(__alloc()); | 3030 vector __v(get_allocator()); |
3192 __v.reserve(__recommend(__size_ + __n)); | 3031 __v.reserve(__recommend(__size_ + __n)); |
3193 __v.__size_ = __size_ + __n; | 3032 __v.__size_ = __size_ + __n; |
3194 __r = _VSTD::copy(cbegin(), __position, __v.begin()); | 3033 __r = std::copy(cbegin(), __position, __v.begin()); |
3195 _VSTD::copy_backward(__position, cend(), __v.end()); | 3034 std::copy_backward(__position, cend(), __v.end()); |
3196 swap(__v); | 3035 swap(__v); |
3197 } | 3036 } |
3198 _VSTD::copy(__first, __last, __r); | 3037 std::copy(__first, __last, __r); |
3199 return __r; | 3038 return __r; |
3200 } | 3039 } |
3201 | 3040 |
3202 template <class _Allocator> | 3041 template <class _Allocator> |
3203 inline _LIBCPP_INLINE_VISIBILITY | 3042 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3204 typename vector<bool, _Allocator>::iterator | 3043 typename vector<bool, _Allocator>::iterator |
3205 vector<bool, _Allocator>::erase(const_iterator __position) | 3044 vector<bool, _Allocator>::erase(const_iterator __position) |
3206 { | 3045 { |
3207 iterator __r = __const_iterator_cast(__position); | 3046 iterator __r = __const_iterator_cast(__position); |
3208 _VSTD::copy(__position + 1, this->cend(), __r); | 3047 std::copy(__position + 1, this->cend(), __r); |
3209 --__size_; | 3048 --__size_; |
3210 return __r; | 3049 return __r; |
3211 } | 3050 } |
3212 | 3051 |
3213 template <class _Allocator> | 3052 template <class _Allocator> |
3053 _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
3214 typename vector<bool, _Allocator>::iterator | 3054 typename vector<bool, _Allocator>::iterator |
3215 vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) | 3055 vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) |
3216 { | 3056 { |
3217 iterator __r = __const_iterator_cast(__first); | 3057 iterator __r = __const_iterator_cast(__first); |
3218 difference_type __d = __last - __first; | 3058 difference_type __d = __last - __first; |
3219 _VSTD::copy(__last, this->cend(), __r); | 3059 std::copy(__last, this->cend(), __r); |
3220 __size_ -= __d; | 3060 __size_ -= __d; |
3221 return __r; | 3061 return __r; |
3222 } | 3062 } |
3223 | 3063 |
3224 template <class _Allocator> | 3064 template <class _Allocator> |
3225 void | 3065 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
3226 vector<bool, _Allocator>::swap(vector& __x) | 3066 vector<bool, _Allocator>::swap(vector& __x) |
3227 #if _LIBCPP_STD_VER >= 14 | 3067 #if _LIBCPP_STD_VER >= 14 |
3228 _NOEXCEPT | 3068 _NOEXCEPT |
3229 #else | 3069 #else |
3230 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || | 3070 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || |
3231 __is_nothrow_swappable<allocator_type>::value) | 3071 __is_nothrow_swappable<allocator_type>::value) |
3232 #endif | 3072 #endif |
3233 { | 3073 { |
3234 _VSTD::swap(this->__begin_, __x.__begin_); | 3074 std::swap(this->__begin_, __x.__begin_); |
3235 _VSTD::swap(this->__size_, __x.__size_); | 3075 std::swap(this->__size_, __x.__size_); |
3236 _VSTD::swap(this->__cap(), __x.__cap()); | 3076 std::swap(this->__cap(), __x.__cap()); |
3237 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(), | 3077 std::__swap_allocator(this->__alloc(), __x.__alloc(), |
3238 integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>()); | 3078 integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>()); |
3239 } | 3079 } |
3240 | 3080 |
3241 template <class _Allocator> | 3081 template <class _Allocator> |
3242 void | 3082 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
3243 vector<bool, _Allocator>::resize(size_type __sz, value_type __x) | 3083 vector<bool, _Allocator>::resize(size_type __sz, value_type __x) |
3244 { | 3084 { |
3245 size_type __cs = size(); | 3085 size_type __cs = size(); |
3246 if (__cs < __sz) | 3086 if (__cs < __sz) |
3247 { | 3087 { |
3253 __r = end(); | 3093 __r = end(); |
3254 __size_ += __n; | 3094 __size_ += __n; |
3255 } | 3095 } |
3256 else | 3096 else |
3257 { | 3097 { |
3258 vector __v(__alloc()); | 3098 vector __v(get_allocator()); |
3259 __v.reserve(__recommend(__size_ + __n)); | 3099 __v.reserve(__recommend(__size_ + __n)); |
3260 __v.__size_ = __size_ + __n; | 3100 __v.__size_ = __size_ + __n; |
3261 __r = _VSTD::copy(cbegin(), cend(), __v.begin()); | 3101 __r = std::copy(cbegin(), cend(), __v.begin()); |
3262 swap(__v); | 3102 swap(__v); |
3263 } | 3103 } |
3264 _VSTD::fill_n(__r, __n, __x); | 3104 std::fill_n(__r, __n, __x); |
3265 } | 3105 } |
3266 else | 3106 else |
3267 __size_ = __sz; | 3107 __size_ = __sz; |
3268 } | 3108 } |
3269 | 3109 |
3270 template <class _Allocator> | 3110 template <class _Allocator> |
3271 void | 3111 _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
3272 vector<bool, _Allocator>::flip() _NOEXCEPT | 3112 vector<bool, _Allocator>::flip() _NOEXCEPT |
3273 { | 3113 { |
3274 // do middle whole words | 3114 // do middle whole words |
3275 size_type __n = __size_; | 3115 size_type __n = __size_; |
3276 __storage_pointer __p = __begin_; | 3116 __storage_pointer __p = __begin_; |
3285 *__p |= ~__b & __m; | 3125 *__p |= ~__b & __m; |
3286 } | 3126 } |
3287 } | 3127 } |
3288 | 3128 |
3289 template <class _Allocator> | 3129 template <class _Allocator> |
3290 bool | 3130 _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
3291 vector<bool, _Allocator>::__invariants() const | 3131 vector<bool, _Allocator>::__invariants() const |
3292 { | 3132 { |
3293 if (this->__begin_ == nullptr) | 3133 if (this->__begin_ == nullptr) |
3294 { | 3134 { |
3295 if (this->__size_ != 0 || this->__cap() != 0) | 3135 if (this->__size_ != 0 || this->__cap() != 0) |
3304 } | 3144 } |
3305 return true; | 3145 return true; |
3306 } | 3146 } |
3307 | 3147 |
3308 template <class _Allocator> | 3148 template <class _Allocator> |
3309 size_t | 3149 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t |
3310 vector<bool, _Allocator>::__hash_code() const _NOEXCEPT | 3150 vector<bool, _Allocator>::__hash_code() const _NOEXCEPT |
3311 { | 3151 { |
3312 size_t __h = 0; | 3152 size_t __h = 0; |
3313 // do middle whole words | 3153 // do middle whole words |
3314 size_type __n = __size_; | 3154 size_type __n = __size_; |
3324 return __h; | 3164 return __h; |
3325 } | 3165 } |
3326 | 3166 |
3327 template <class _Allocator> | 3167 template <class _Allocator> |
3328 struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > | 3168 struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > |
3329 : public unary_function<vector<bool, _Allocator>, size_t> | 3169 : public __unary_function<vector<bool, _Allocator>, size_t> |
3330 { | 3170 { |
3331 _LIBCPP_INLINE_VISIBILITY | 3171 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3332 size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT | 3172 size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT |
3333 {return __vec.__hash_code();} | 3173 {return __vec.__hash_code();} |
3334 }; | 3174 }; |
3335 | 3175 |
3336 template <class _Tp, class _Allocator> | 3176 template <class _Tp, class _Allocator> |
3337 inline _LIBCPP_INLINE_VISIBILITY | 3177 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3178 inline _LIBCPP_HIDE_FROM_ABI | |
3338 bool | 3179 bool |
3339 operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 3180 operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
3340 { | 3181 { |
3341 const typename vector<_Tp, _Allocator>::size_type __sz = __x.size(); | 3182 const typename vector<_Tp, _Allocator>::size_type __sz = __x.size(); |
3342 return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); | 3183 return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); |
3343 } | 3184 } |
3344 | 3185 |
3345 template <class _Tp, class _Allocator> | 3186 template <class _Tp, class _Allocator> |
3346 inline _LIBCPP_INLINE_VISIBILITY | 3187 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3188 inline _LIBCPP_HIDE_FROM_ABI | |
3347 bool | 3189 bool |
3348 operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 3190 operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
3349 { | 3191 { |
3350 return !(__x == __y); | 3192 return !(__x == __y); |
3351 } | 3193 } |
3352 | 3194 |
3353 template <class _Tp, class _Allocator> | 3195 template <class _Tp, class _Allocator> |
3354 inline _LIBCPP_INLINE_VISIBILITY | 3196 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3197 inline _LIBCPP_HIDE_FROM_ABI | |
3355 bool | 3198 bool |
3356 operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 3199 operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
3357 { | 3200 { |
3358 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); | 3201 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
3359 } | 3202 } |
3360 | 3203 |
3361 template <class _Tp, class _Allocator> | 3204 template <class _Tp, class _Allocator> |
3362 inline _LIBCPP_INLINE_VISIBILITY | 3205 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3206 inline _LIBCPP_HIDE_FROM_ABI | |
3363 bool | 3207 bool |
3364 operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 3208 operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
3365 { | 3209 { |
3366 return __y < __x; | 3210 return __y < __x; |
3367 } | 3211 } |
3368 | 3212 |
3369 template <class _Tp, class _Allocator> | 3213 template <class _Tp, class _Allocator> |
3370 inline _LIBCPP_INLINE_VISIBILITY | 3214 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3215 inline _LIBCPP_HIDE_FROM_ABI | |
3371 bool | 3216 bool |
3372 operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 3217 operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
3373 { | 3218 { |
3374 return !(__x < __y); | 3219 return !(__x < __y); |
3375 } | 3220 } |
3376 | 3221 |
3377 template <class _Tp, class _Allocator> | 3222 template <class _Tp, class _Allocator> |
3378 inline _LIBCPP_INLINE_VISIBILITY | 3223 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3224 inline _LIBCPP_HIDE_FROM_ABI | |
3379 bool | 3225 bool |
3380 operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) | 3226 operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
3381 { | 3227 { |
3382 return !(__y < __x); | 3228 return !(__y < __x); |
3383 } | 3229 } |
3384 | 3230 |
3385 template <class _Tp, class _Allocator> | 3231 template <class _Tp, class _Allocator> |
3386 inline _LIBCPP_INLINE_VISIBILITY | 3232 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3233 inline _LIBCPP_HIDE_FROM_ABI | |
3387 void | 3234 void |
3388 swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) | 3235 swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) |
3389 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) | 3236 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
3390 { | 3237 { |
3391 __x.swap(__y); | 3238 __x.swap(__y); |
3392 } | 3239 } |
3393 | 3240 |
3394 #if _LIBCPP_STD_VER > 17 | 3241 #if _LIBCPP_STD_VER > 17 |
3395 template <class _Tp, class _Allocator, class _Up> | 3242 template <class _Tp, class _Allocator, class _Up> |
3396 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type | 3243 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3244 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type | |
3397 erase(vector<_Tp, _Allocator>& __c, const _Up& __v) { | 3245 erase(vector<_Tp, _Allocator>& __c, const _Up& __v) { |
3398 auto __old_size = __c.size(); | 3246 auto __old_size = __c.size(); |
3399 __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end()); | 3247 __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end()); |
3400 return __old_size - __c.size(); | 3248 return __old_size - __c.size(); |
3401 } | 3249 } |
3402 | 3250 |
3403 template <class _Tp, class _Allocator, class _Predicate> | 3251 template <class _Tp, class _Allocator, class _Predicate> |
3404 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type | 3252 _LIBCPP_CONSTEXPR_SINCE_CXX20 |
3253 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type | |
3405 erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) { | 3254 erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) { |
3406 auto __old_size = __c.size(); | 3255 auto __old_size = __c.size(); |
3407 __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); | 3256 __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end()); |
3408 return __old_size - __c.size(); | 3257 return __old_size - __c.size(); |
3409 } | 3258 } |
3410 #endif | 3259 |
3260 template <> | |
3261 inline constexpr bool __format::__enable_insertable<std::vector<char>> = true; | |
3262 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
3263 template <> | |
3264 inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true; | |
3265 #endif | |
3266 | |
3267 #endif // _LIBCPP_STD_VER > 17 | |
3411 | 3268 |
3412 _LIBCPP_END_NAMESPACE_STD | 3269 _LIBCPP_END_NAMESPACE_STD |
3413 | 3270 |
3271 #if _LIBCPP_STD_VER > 14 | |
3272 _LIBCPP_BEGIN_NAMESPACE_STD | |
3273 namespace pmr { | |
3274 template <class _ValueT> | |
3275 using vector = std::vector<_ValueT, polymorphic_allocator<_ValueT>>; | |
3276 } // namespace pmr | |
3277 _LIBCPP_END_NAMESPACE_STD | |
3278 #endif | |
3279 | |
3414 _LIBCPP_POP_MACROS | 3280 _LIBCPP_POP_MACROS |
3415 | 3281 |
3282 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
3283 # include <algorithm> | |
3284 # include <typeinfo> | |
3285 # include <utility> | |
3286 #endif | |
3287 | |
3416 #endif // _LIBCPP_VECTOR | 3288 #endif // _LIBCPP_VECTOR |