llvm-project
2992 строки · 119.5 Кб
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
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.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_VECTOR11#define _LIBCPP_VECTOR12
13// clang-format off
14
15/*
16vector synopsis
17
18namespace std
19{
20
21template <class T, class Allocator = allocator<T> >
22class vector
23{
24public:
25typedef T value_type;
26typedef Allocator allocator_type;
27typedef typename allocator_type::reference reference;
28typedef typename allocator_type::const_reference const_reference;
29typedef implementation-defined iterator;
30typedef implementation-defined const_iterator;
31typedef typename allocator_type::size_type size_type;
32typedef typename allocator_type::difference_type difference_type;
33typedef typename allocator_type::pointer pointer;
34typedef typename allocator_type::const_pointer const_pointer;
35typedef std::reverse_iterator<iterator> reverse_iterator;
36typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
37
38vector()
39noexcept(is_nothrow_default_constructible<allocator_type>::value);
40explicit vector(const allocator_type&);
41explicit vector(size_type n);
42explicit vector(size_type n, const allocator_type&); // C++14
43vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
44template <class InputIterator>
45vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
46template<container-compatible-range<T> R>
47constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator()); // C++23
48vector(const vector& x);
49vector(vector&& x)
50noexcept(is_nothrow_move_constructible<allocator_type>::value);
51vector(initializer_list<value_type> il);
52vector(initializer_list<value_type> il, const allocator_type& a);
53~vector();
54vector& operator=(const vector& x);
55vector& operator=(vector&& x)
56noexcept(
57allocator_type::propagate_on_container_move_assignment::value ||
58allocator_type::is_always_equal::value); // C++17
59vector& operator=(initializer_list<value_type> il);
60template <class InputIterator>
61void assign(InputIterator first, InputIterator last);
62template<container-compatible-range<T> R>
63constexpr void assign_range(R&& rg); // C++23
64void assign(size_type n, const value_type& u);
65void assign(initializer_list<value_type> il);
66
67allocator_type get_allocator() const noexcept;
68
69iterator begin() noexcept;
70const_iterator begin() const noexcept;
71iterator end() noexcept;
72const_iterator end() const noexcept;
73
74reverse_iterator rbegin() noexcept;
75const_reverse_iterator rbegin() const noexcept;
76reverse_iterator rend() noexcept;
77const_reverse_iterator rend() const noexcept;
78
79const_iterator cbegin() const noexcept;
80const_iterator cend() const noexcept;
81const_reverse_iterator crbegin() const noexcept;
82const_reverse_iterator crend() const noexcept;
83
84size_type size() const noexcept;
85size_type max_size() const noexcept;
86size_type capacity() const noexcept;
87bool empty() const noexcept;
88void reserve(size_type n);
89void shrink_to_fit() noexcept;
90
91reference operator[](size_type n);
92const_reference operator[](size_type n) const;
93reference at(size_type n);
94const_reference at(size_type n) const;
95
96reference front();
97const_reference front() const;
98reference back();
99const_reference back() const;
100
101value_type* data() noexcept;
102const value_type* data() const noexcept;
103
104void push_back(const value_type& x);
105void push_back(value_type&& x);
106template <class... Args>
107reference emplace_back(Args&&... args); // reference in C++17
108template<container-compatible-range<T> R>
109constexpr void append_range(R&& rg); // C++23
110void pop_back();
111
112template <class... Args> iterator emplace(const_iterator position, Args&&... args);
113iterator insert(const_iterator position, const value_type& x);
114iterator insert(const_iterator position, value_type&& x);
115iterator insert(const_iterator position, size_type n, const value_type& x);
116template <class InputIterator>
117iterator insert(const_iterator position, InputIterator first, InputIterator last);
118template<container-compatible-range<T> R>
119constexpr iterator insert_range(const_iterator position, R&& rg); // C++23
120iterator insert(const_iterator position, initializer_list<value_type> il);
121
122iterator erase(const_iterator position);
123iterator erase(const_iterator first, const_iterator last);
124
125void clear() noexcept;
126
127void resize(size_type sz);
128void resize(size_type sz, const value_type& c);
129
130void swap(vector&)
131noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
132allocator_traits<allocator_type>::is_always_equal::value); // C++17
133
134bool __invariants() const;
135};
136
137template <class Allocator = allocator<T> >
138class vector<bool, Allocator>
139{
140public:
141typedef bool value_type;
142typedef Allocator allocator_type;
143typedef implementation-defined iterator;
144typedef implementation-defined const_iterator;
145typedef typename allocator_type::size_type size_type;
146typedef typename allocator_type::difference_type difference_type;
147typedef iterator pointer;
148typedef const_iterator const_pointer;
149typedef std::reverse_iterator<iterator> reverse_iterator;
150typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
151
152class reference
153{
154public:
155reference(const reference&) noexcept;
156operator bool() const noexcept;
157reference& operator=(bool x) noexcept;
158reference& operator=(const reference& x) noexcept;
159iterator operator&() const noexcept;
160void flip() noexcept;
161};
162
163class const_reference
164{
165public:
166const_reference(const reference&) noexcept;
167operator bool() const noexcept;
168const_iterator operator&() const noexcept;
169};
170
171vector()
172noexcept(is_nothrow_default_constructible<allocator_type>::value);
173explicit vector(const allocator_type&);
174explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14
175vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
176template <class InputIterator>
177vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
178template<container-compatible-range<bool> R>
179constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator());
180vector(const vector& x);
181vector(vector&& x)
182noexcept(is_nothrow_move_constructible<allocator_type>::value);
183vector(initializer_list<value_type> il);
184vector(initializer_list<value_type> il, const allocator_type& a);
185~vector();
186vector& operator=(const vector& x);
187vector& operator=(vector&& x)
188noexcept(
189allocator_type::propagate_on_container_move_assignment::value ||
190allocator_type::is_always_equal::value); // C++17
191vector& operator=(initializer_list<value_type> il);
192template <class InputIterator>
193void assign(InputIterator first, InputIterator last);
194template<container-compatible-range<T> R>
195constexpr void assign_range(R&& rg); // C++23
196void assign(size_type n, const value_type& u);
197void assign(initializer_list<value_type> il);
198
199allocator_type get_allocator() const noexcept;
200
201iterator begin() noexcept;
202const_iterator begin() const noexcept;
203iterator end() noexcept;
204const_iterator end() const noexcept;
205
206reverse_iterator rbegin() noexcept;
207const_reverse_iterator rbegin() const noexcept;
208reverse_iterator rend() noexcept;
209const_reverse_iterator rend() const noexcept;
210
211const_iterator cbegin() const noexcept;
212const_iterator cend() const noexcept;
213const_reverse_iterator crbegin() const noexcept;
214const_reverse_iterator crend() const noexcept;
215
216size_type size() const noexcept;
217size_type max_size() const noexcept;
218size_type capacity() const noexcept;
219bool empty() const noexcept;
220void reserve(size_type n);
221void shrink_to_fit() noexcept;
222
223reference operator[](size_type n);
224const_reference operator[](size_type n) const;
225reference at(size_type n);
226const_reference at(size_type n) const;
227
228reference front();
229const_reference front() const;
230reference back();
231const_reference back() const;
232
233void push_back(const value_type& x);
234template <class... Args> reference emplace_back(Args&&... args); // C++14; reference in C++17
235template<container-compatible-range<T> R>
236constexpr void append_range(R&& rg); // C++23
237void pop_back();
238
239template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14
240iterator insert(const_iterator position, const value_type& x);
241iterator insert(const_iterator position, size_type n, const value_type& x);
242template <class InputIterator>
243iterator insert(const_iterator position, InputIterator first, InputIterator last);
244template<container-compatible-range<T> R>
245constexpr iterator insert_range(const_iterator position, R&& rg); // C++23
246iterator insert(const_iterator position, initializer_list<value_type> il);
247
248iterator erase(const_iterator position);
249iterator erase(const_iterator first, const_iterator last);
250
251void clear() noexcept;
252
253void resize(size_type sz);
254void resize(size_type sz, value_type x);
255
256void swap(vector&)
257noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
258allocator_traits<allocator_type>::is_always_equal::value); // C++17
259void flip() noexcept;
260
261bool __invariants() const;
262};
263
264template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
265vector(InputIterator, InputIterator, Allocator = Allocator())
266-> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17
267
268template<ranges::input_range R, class Allocator = allocator<ranges::range_value_t<R>>>
269vector(from_range_t, R&&, Allocator = Allocator())
270-> vector<ranges::range_value_t<R>, Allocator>; // C++23
271
272template <class Allocator> struct hash<std::vector<bool, Allocator>>;
273
274template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y); // constexpr since C++20
275template <class T, class Allocator> bool operator!=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); // removed in C++20
276template <class T, class Allocator> bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y); // removed in C++20
277template <class T, class Allocator> bool operator> (const vector<T,Allocator>& x, const vector<T,Allocator>& y); // removed in C++20
278template <class T, class Allocator> bool operator>=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); // removed in C++20
279template <class T, class Allocator> bool operator<=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); // removed in C++20
280template <class T, class Allocator> constexpr
281constexpr synth-three-way-result<T> operator<=>(const vector<T, Allocator>& x,
282const vector<T, Allocator>& y); // since C++20
283
284template <class T, class Allocator>
285void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
286noexcept(noexcept(x.swap(y)));
287
288template <class T, class Allocator, class U>
289typename vector<T, Allocator>::size_type
290erase(vector<T, Allocator>& c, const U& value); // since C++20
291template <class T, class Allocator, class Predicate>
292typename vector<T, Allocator>::size_type
293erase_if(vector<T, Allocator>& c, Predicate pred); // since C++20
294
295
296template<class T>
297inline constexpr bool is-vector-bool-reference = see below; // exposition only, since C++23
298
299template<class T, class charT> requires is-vector-bool-reference<T> // Since C++23
300struct formatter<T, charT>;
301
302} // std
303
304*/
305
306// clang-format on
307
308#include <__algorithm/copy.h>309#include <__algorithm/equal.h>310#include <__algorithm/fill_n.h>311#include <__algorithm/iterator_operations.h>312#include <__algorithm/lexicographical_compare.h>313#include <__algorithm/lexicographical_compare_three_way.h>314#include <__algorithm/remove.h>315#include <__algorithm/remove_if.h>316#include <__algorithm/rotate.h>317#include <__algorithm/unwrap_iter.h>318#include <__assert>319#include <__bit_reference>320#include <__concepts/same_as.h>321#include <__config>322#include <__debug_utils/sanitizers.h>323#include <__format/enable_insertable.h>324#include <__format/formatter.h>325#include <__format/formatter_bool.h>326#include <__functional/hash.h>327#include <__functional/unary_function.h>328#include <__fwd/vector.h>329#include <__iterator/advance.h>330#include <__iterator/distance.h>331#include <__iterator/iterator_traits.h>332#include <__iterator/reverse_iterator.h>333#include <__iterator/wrap_iter.h>334#include <__memory/addressof.h>335#include <__memory/allocate_at_least.h>336#include <__memory/allocator_traits.h>337#include <__memory/pointer_traits.h>338#include <__memory/swap_allocator.h>339#include <__memory/temp_value.h>340#include <__memory/uninitialized_algorithms.h>341#include <__memory_resource/polymorphic_allocator.h>342#include <__ranges/access.h>343#include <__ranges/concepts.h>344#include <__ranges/container_compatible_range.h>345#include <__ranges/from_range.h>346#include <__ranges/size.h>347#include <__split_buffer>348#include <__type_traits/is_allocator.h>349#include <__type_traits/is_constructible.h>350#include <__type_traits/is_nothrow_assignable.h>351#include <__type_traits/noexcept_move_assign_container.h>352#include <__type_traits/type_identity.h>353#include <__utility/exception_guard.h>354#include <__utility/forward.h>355#include <__utility/is_pointer_in_range.h>356#include <__utility/move.h>357#include <__utility/pair.h>358#include <__utility/swap.h>359#include <climits>360#include <cstring>361#include <limits>362#include <stdexcept>363#include <version>364
365// standard-mandated includes
366
367// [iterator.range]
368#include <__iterator/access.h>369#include <__iterator/data.h>370#include <__iterator/empty.h>371#include <__iterator/reverse_access.h>372#include <__iterator/size.h>373
374// [vector.syn]
375#include <compare>376#include <initializer_list>377
378#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)379# pragma GCC system_header380#endif381
382_LIBCPP_PUSH_MACROS
383#include <__undef_macros>384
385_LIBCPP_BEGIN_NAMESPACE_STD
386
387template <class _Tp, class _Allocator /* = allocator<_Tp> */>388class _LIBCPP_TEMPLATE_VIS vector {389private:390typedef allocator<_Tp> __default_allocator_type;391
392public:393typedef vector __self;394typedef _Tp value_type;395typedef _Allocator allocator_type;396typedef allocator_traits<allocator_type> __alloc_traits;397typedef value_type& reference;398typedef const value_type& const_reference;399typedef typename __alloc_traits::size_type size_type;400typedef typename __alloc_traits::difference_type difference_type;401typedef typename __alloc_traits::pointer pointer;402typedef typename __alloc_traits::const_pointer const_pointer;403// TODO: Implement iterator bounds checking without requiring the global database.404typedef __wrap_iter<pointer> iterator;405typedef __wrap_iter<const_pointer> const_iterator;406typedef std::reverse_iterator<iterator> reverse_iterator;407typedef std::reverse_iterator<const_iterator> const_reverse_iterator;408
409// A vector containers the following members which may be trivially relocatable:410// - pointer: may be trivially relocatable, so it's checked411// - allocator_type: may be trivially relocatable, so it's checked412// vector doesn't contain any self-references, so it's trivially relocatable if its members are.413using __trivially_relocatable = __conditional_t<414__libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,415vector,416void>;417
418static_assert(__check_valid_allocator<allocator_type>::value, "");419static_assert(is_same<typename allocator_type::value_type, value_type>::value,420"Allocator::value_type must be same type as value_type");421
422_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector()423_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {}424_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)425#if _LIBCPP_STD_VER <= 14426_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)427#else428_NOEXCEPT
429#endif430: __end_cap_(nullptr, __a) {431}432
433_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) {434auto __guard = std::__make_exception_guard(__destroy_vector(*this));435if (__n > 0) {436__vallocate(__n);437__construct_at_end(__n);438}439__guard.__complete();440}441
442#if _LIBCPP_STD_VER >= 14443_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a)444: __end_cap_(nullptr, __a) {445auto __guard = std::__make_exception_guard(__destroy_vector(*this));446if (__n > 0) {447__vallocate(__n);448__construct_at_end(__n);449}450__guard.__complete();451}452#endif453
454_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) {455auto __guard = std::__make_exception_guard(__destroy_vector(*this));456if (__n > 0) {457__vallocate(__n);458__construct_at_end(__n, __x);459}460__guard.__complete();461}462
463template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>464_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
465vector(size_type __n, const value_type& __x, const allocator_type& __a)466: __end_cap_(nullptr, __a) {467if (__n > 0) {468__vallocate(__n);469__construct_at_end(__n, __x);470}471}472
473template <class _InputIterator,474__enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&475is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,476int> = 0>477_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);478template <class _InputIterator,479__enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&480is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,481int> = 0>482_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
483vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);484
485template <486class _ForwardIterator,487__enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&488is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,489int> = 0>490_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);491
492template <493class _ForwardIterator,494__enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&495is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,496int> = 0>497_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
498vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);499
500#if _LIBCPP_STD_VER >= 23501template <_ContainerCompatibleRange<_Tp> _Range>502_LIBCPP_HIDE_FROM_ABI constexpr vector(503from_range_t, _Range&& __range, const allocator_type& __alloc = allocator_type())504: __end_cap_(nullptr, __alloc) {505if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {506auto __n = static_cast<size_type>(ranges::distance(__range));507__init_with_size(ranges::begin(__range), ranges::end(__range), __n);508
509} else {510__init_with_sentinel(ranges::begin(__range), ranges::end(__range));511}512}513#endif514
515private:516class __destroy_vector {517public:518_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {}519
520_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {521if (__vec_.__begin_ != nullptr) {522__vec_.__clear();523__vec_.__annotate_delete();524__alloc_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.capacity());525}526}527
528private:529vector& __vec_;530};531
532public:533_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector (*this)(); }534
535_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x);536_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
537vector(const vector& __x, const __type_identity_t<allocator_type>& __a);538_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(const vector& __x);539
540#ifndef _LIBCPP_CXX03_LANG541_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(initializer_list<value_type> __il);542
543_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
544vector(initializer_list<value_type> __il, const allocator_type& __a);545
546_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(initializer_list<value_type> __il) {547assign(__il.begin(), __il.end());548return *this;549}550#endif // !_LIBCPP_CXX03_LANG551
552_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(vector&& __x)553#if _LIBCPP_STD_VER >= 17554noexcept;555#else556_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);557#endif558
559_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
560vector(vector&& __x, const __type_identity_t<allocator_type>& __a);561_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x)562_NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value);563
564template <class _InputIterator,565__enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&566is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,567int> = 0>568_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last);569template <570class _ForwardIterator,571__enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&572is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,573int> = 0>574_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last);575
576#if _LIBCPP_STD_VER >= 23577template <_ContainerCompatibleRange<_Tp> _Range>578_LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) {579if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {580auto __n = static_cast<size_type>(ranges::distance(__range));581__assign_with_size(ranges::begin(__range), ranges::end(__range), __n);582
583} else {584__assign_with_sentinel(ranges::begin(__range), ranges::end(__range));585}586}587#endif588
589_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u);590
591#ifndef _LIBCPP_CXX03_LANG592_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) {593assign(__il.begin(), __il.end());594}595#endif596
597_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {598return this->__alloc();599}600
601_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT;602_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT;603_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT;604_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT;605
606_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT {607return reverse_iterator(end());608}609_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {610return const_reverse_iterator(end());611}612_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT {613return reverse_iterator(begin());614}615_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {616return const_reverse_iterator(begin());617}618
619_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }620_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }621_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT {622return rbegin();623}624_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }625
626_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT {627return static_cast<size_type>(this->__end_ - this->__begin_);628}629_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT {630return static_cast<size_type>(__end_cap() - this->__begin_);631}632_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {633return this->__begin_ == this->__end_;634}635_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT;636_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);637_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;638
639_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT;640_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT;641_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);642_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const;643
644_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT {645_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector");646return *this->__begin_;647}648_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT {649_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector");650return *this->__begin_;651}652_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT {653_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector");654return *(this->__end_ - 1);655}656_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT {657_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector");658return *(this->__end_ - 1);659}660
661_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT {662return std::__to_address(this->__begin_);663}664
665_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT {666return std::__to_address(this->__begin_);667}668
669_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);670
671_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);672
673template <class... _Args>674_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
675#if _LIBCPP_STD_VER >= 17676reference
677emplace_back(_Args&&... __args);678#else679void680emplace_back(_Args&&... __args);681#endif682
683#if _LIBCPP_STD_VER >= 23684template <_ContainerCompatibleRange<_Tp> _Range>685_LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {686insert_range(end(), std::forward<_Range>(__range));687}688#endif689
690_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back();691
692_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x);693
694_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x);695template <class... _Args>696_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args);697
698_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
699insert(const_iterator __position, size_type __n, const_reference __x);700
701template <class _InputIterator,702__enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&703is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value,704int> = 0>705_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
706insert(const_iterator __position, _InputIterator __first, _InputIterator __last);707
708#if _LIBCPP_STD_VER >= 23709template <_ContainerCompatibleRange<_Tp> _Range>710_LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {711if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {712auto __n = static_cast<size_type>(ranges::distance(__range));713return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);714
715} else {716return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));717}718}719#endif720
721template <722class _ForwardIterator,723__enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&724is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value,725int> = 0>726_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
727insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);728
729#ifndef _LIBCPP_CXX03_LANG730_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
731insert(const_iterator __position, initializer_list<value_type> __il) {732return insert(__position, __il.begin(), __il.end());733}734#endif735
736_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position);737_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last);738
739_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT {740size_type __old_size = size();741__clear();742__annotate_shrink(__old_size);743}744
745_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz);746_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x);747
748_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&)749#if _LIBCPP_STD_VER >= 14750_NOEXCEPT;751#else752_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);753#endif754
755_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;756
757private:758pointer __begin_ = nullptr;759pointer __end_ = nullptr;760__compressed_pair<pointer, allocator_type> __end_cap_ =761__compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());762
763// Allocate space for __n objects764// throws length_error if __n > max_size()765// throws (probably bad_alloc) if memory run out766// Precondition: __begin_ == __end_ == __end_cap() == 0767// Precondition: __n > 0768// Postcondition: capacity() >= __n769// Postcondition: size() == 0770_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {771if (__n > max_size())772__throw_length_error();773auto __allocation = std::__allocate_at_least(__alloc(), __n);774__begin_ = __allocation.ptr;775__end_ = __allocation.ptr;776__end_cap() = __begin_ + __allocation.count;777__annotate_new(0);778}779
780_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT;781_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const;782_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);783_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);784
785template <class _InputIterator, class _Sentinel>786_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void787__init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) {788auto __guard = std::__make_exception_guard(__destroy_vector(*this));789
790if (__n > 0) {791__vallocate(__n);792__construct_at_end(__first, __last, __n);793}794
795__guard.__complete();796}797
798template <class _InputIterator, class _Sentinel>799_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void800__init_with_sentinel(_InputIterator __first, _Sentinel __last) {801auto __guard = std::__make_exception_guard(__destroy_vector(*this));802
803for (; __first != __last; ++__first)804emplace_back(*__first);805
806__guard.__complete();807}808
809template <class _Iterator, class _Sentinel>810_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);811
812template <class _ForwardIterator, class _Sentinel>813_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void814__assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __n);815
816template <class _InputIterator, class _Sentinel>817_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
818__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);819
820template <class _Iterator, class _Sentinel>821_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
822__insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n);823
824template <class _InputIterator, class _Sentinel>825_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void826__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n);827
828_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);829_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);830_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT {831return iterator(__p);832}833_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT {834return const_iterator(__p);835}836_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void837__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);838_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
839__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);840_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void841__move_range(pointer __from_s, pointer __from_e, pointer __to);842_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)843_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);844_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type)845_NOEXCEPT_(__alloc_traits::is_always_equal::value);846_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT {847size_type __old_size = size();848__base_destruct_at_end(__new_last);849__annotate_shrink(__old_size);850}851
852template <class _Up>853_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __push_back_slow_path(_Up&& __x);854
855template <class... _Args>856_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __emplace_back_slow_path(_Args&&... __args);857
858// The following functions are no-ops outside of AddressSanitizer mode.859// We call annotations for every allocator, unless explicitly disabled.860//861// To disable annotations for a particular allocator, change value of862// __asan_annotate_container_with_allocator to false.863// For more details, see the "Using libc++" documentation page or864// the documentation for __sanitizer_annotate_contiguous_container.865
866_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void867__annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {868std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity(), __old_mid, __new_mid);869}870
871_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {872(void)__current_size;873#ifndef _LIBCPP_HAS_NO_ASAN874__annotate_contiguous_container(data() + capacity(), data() + __current_size);875#endif876}877
878_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {879#ifndef _LIBCPP_HAS_NO_ASAN880__annotate_contiguous_container(data() + size(), data() + capacity());881#endif882}883
884_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {885(void)__n;886#ifndef _LIBCPP_HAS_NO_ASAN887__annotate_contiguous_container(data() + size(), data() + size() + __n);888#endif889}890
891_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {892(void)__old_size;893#ifndef _LIBCPP_HAS_NO_ASAN894__annotate_contiguous_container(data() + __old_size, data() + size());895#endif896}897
898struct _ConstructTransaction {899_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)900: __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {901#ifndef _LIBCPP_HAS_NO_ASAN902__v_.__annotate_increase(__n);903#endif904}905
906_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {907__v_.__end_ = __pos_;908#ifndef _LIBCPP_HAS_NO_ASAN909if (__pos_ != __new_end_) {910__v_.__annotate_shrink(__new_end_ - __v_.__begin_);911}912#endif913}914
915vector& __v_;916pointer __pos_;917const_pointer const __new_end_;918
919_ConstructTransaction(_ConstructTransaction const&) = delete;920_ConstructTransaction& operator=(_ConstructTransaction const&) = delete;921};922
923template <class... _Args>924_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_one_at_end(_Args&&... __args) {925_ConstructTransaction __tx(*this, 1);926__alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);927++__tx.__pos_;928}929
930_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT {931return this->__end_cap_.second();932}933_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT {934return this->__end_cap_.second();935}936_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT {937return this->__end_cap_.first();938}939_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT {940return this->__end_cap_.first();941}942
943_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __clear() _NOEXCEPT {944__base_destruct_at_end(this->__begin_);945}946
947_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {948pointer __soon_to_be_end = this->__end_;949while (__new_last != __soon_to_be_end)950__alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));951this->__end_ = __new_last;952}953
954_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c) {955__copy_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>());956}957
958_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c)959_NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||960is_nothrow_move_assignable<allocator_type>::value) {961__move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());962}963
964_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); }965
966_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); }967
968_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c, true_type) {969if (__alloc() != __c.__alloc()) {970__clear();971__annotate_delete();972__alloc_traits::deallocate(__alloc(), this->__begin_, capacity());973this->__begin_ = this->__end_ = __end_cap() = nullptr;974}975__alloc() = __c.__alloc();976}977
978_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector&, false_type) {}979
980_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c, true_type)981_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {982__alloc() = std::move(__c.__alloc());983}984
985_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}986};987
988#if _LIBCPP_STD_VER >= 17989template <class _InputIterator,990class _Alloc = allocator<__iter_value_type<_InputIterator>>,991class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,992class = enable_if_t<__is_allocator<_Alloc>::value> >993vector(_InputIterator, _InputIterator) -> vector<__iter_value_type<_InputIterator>, _Alloc>;994
995template <class _InputIterator,996class _Alloc,997class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,998class = enable_if_t<__is_allocator<_Alloc>::value> >999vector(_InputIterator, _InputIterator, _Alloc) -> vector<__iter_value_type<_InputIterator>, _Alloc>;1000#endif1001
1002#if _LIBCPP_STD_VER >= 231003template <ranges::input_range _Range,1004class _Alloc = allocator<ranges::range_value_t<_Range>>,1005class = enable_if_t<__is_allocator<_Alloc>::value> >1006vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>;1007#endif1008
1009// __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of
1010// *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This
1011// function has a strong exception guarantee.
1012template <class _Tp, class _Allocator>1013_LIBCPP_CONSTEXPR_SINCE_CXX20 void1014vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) {1015__annotate_delete();1016auto __new_begin = __v.__begin_ - (__end_ - __begin_);1017std::__uninitialized_allocator_relocate(1018__alloc(), std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin));1019__v.__begin_ = __new_begin;1020__end_ = __begin_; // All the objects have been destroyed by relocating them.1021std::swap(this->__begin_, __v.__begin_);1022std::swap(this->__end_, __v.__end_);1023std::swap(this->__end_cap(), __v.__end_cap());1024__v.__first_ = __v.__begin_;1025__annotate_new(size());1026}
1027
1028// __swap_out_circular_buffer relocates the objects in [__begin_, __p) into the front of __v, the objects in
1029// [__p, __end_) into the back of __v and swaps the buffers of *this and __v. It is assumed that __v provides space for
1030// exactly (__p - __begin_) objects in the front and space for at least (__end_ - __p) objects in the back. This
1031// function has a strong exception guarantee if __begin_ == __p || __end_ == __p.
1032template <class _Tp, class _Allocator>1033_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer1034vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) {1035__annotate_delete();1036pointer __ret = __v.__begin_;1037
1038// Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_)1039// in case something in [__begin_, __p) throws.1040std::__uninitialized_allocator_relocate(1041__alloc(), std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_));1042__v.__end_ += (__end_ - __p);1043__end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them.1044auto __new_begin = __v.__begin_ - (__p - __begin_);1045
1046std::__uninitialized_allocator_relocate(1047__alloc(), std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin));1048__v.__begin_ = __new_begin;1049__end_ = __begin_; // All the objects have been destroyed by relocating them.1050
1051std::swap(this->__begin_, __v.__begin_);1052std::swap(this->__end_, __v.__end_);1053std::swap(this->__end_cap(), __v.__end_cap());1054__v.__first_ = __v.__begin_;1055__annotate_new(size());1056return __ret;1057}
1058
1059template <class _Tp, class _Allocator>1060_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT {1061if (this->__begin_ != nullptr) {1062clear();1063__annotate_delete();1064__alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity());1065this->__begin_ = this->__end_ = this->__end_cap() = nullptr;1066}1067}
1068
1069template <class _Tp, class _Allocator>1070_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::size_type1071vector<_Tp, _Allocator>::max_size() const _NOEXCEPT {1072return std::min<size_type>(__alloc_traits::max_size(this->__alloc()), numeric_limits<difference_type>::max());1073}
1074
1075// Precondition: __new_size > capacity()
1076template <class _Tp, class _Allocator>1077_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type1078vector<_Tp, _Allocator>::__recommend(size_type __new_size) const {1079const size_type __ms = max_size();1080if (__new_size > __ms)1081this->__throw_length_error();1082const size_type __cap = capacity();1083if (__cap >= __ms / 2)1084return __ms;1085return std::max<size_type>(2 * __cap, __new_size);1086}
1087
1088// Default constructs __n objects starting at __end_
1089// throws if construction throws
1090// Precondition: __n > 0
1091// Precondition: size() + __n <= capacity()
1092// Postcondition: size() == size() + __n
1093template <class _Tp, class _Allocator>1094_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) {1095_ConstructTransaction __tx(*this, __n);1096const_pointer __new_end = __tx.__new_end_;1097for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {1098__alloc_traits::construct(this->__alloc(), std::__to_address(__pos));1099}1100}
1101
1102// Copy constructs __n objects starting at __end_ from __x
1103// throws if construction throws
1104// Precondition: __n > 0
1105// Precondition: size() + __n <= capacity()
1106// Postcondition: size() == old size() + __n
1107// Postcondition: [i] == __x for all i in [size() - __n, __n)
1108template <class _Tp, class _Allocator>1109_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void1110vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {1111_ConstructTransaction __tx(*this, __n);1112const_pointer __new_end = __tx.__new_end_;1113for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {1114__alloc_traits::construct(this->__alloc(), std::__to_address(__pos), __x);1115}1116}
1117
1118template <class _Tp, class _Allocator>1119template <class _InputIterator, class _Sentinel>1120_LIBCPP_CONSTEXPR_SINCE_CXX20 void1121vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {1122_ConstructTransaction __tx(*this, __n);1123__tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_);1124}
1125
1126// Default constructs __n objects starting at __end_
1127// throws if construction throws
1128// Postcondition: size() == size() + __n
1129// Exception safety: strong.
1130template <class _Tp, class _Allocator>1131_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n) {1132if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)1133this->__construct_at_end(__n);1134else {1135allocator_type& __a = this->__alloc();1136__split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);1137__v.__construct_at_end(__n);1138__swap_out_circular_buffer(__v);1139}1140}
1141
1142// Default constructs __n objects starting at __end_
1143// throws if construction throws
1144// Postcondition: size() == size() + __n
1145// Exception safety: strong.
1146template <class _Tp, class _Allocator>1147_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) {1148if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)1149this->__construct_at_end(__n, __x);1150else {1151allocator_type& __a = this->__alloc();1152__split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);1153__v.__construct_at_end(__n, __x);1154__swap_out_circular_buffer(__v);1155}1156}
1157
1158template <class _Tp, class _Allocator>1159template <class _InputIterator,1160__enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&1161is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,1162int> >1163_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last) {1164__init_with_sentinel(__first, __last);1165}
1166
1167template <class _Tp, class _Allocator>1168template <class _InputIterator,1169__enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&1170is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,1171int> >1172_LIBCPP_CONSTEXPR_SINCE_CXX20
1173vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)1174: __end_cap_(nullptr, __a) {1175__init_with_sentinel(__first, __last);1176}
1177
1178template <class _Tp, class _Allocator>1179template <class _ForwardIterator,1180__enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&1181is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,1182int> >1183_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last) {1184size_type __n = static_cast<size_type>(std::distance(__first, __last));1185__init_with_size(__first, __last, __n);1186}
1187
1188template <class _Tp, class _Allocator>1189template <class _ForwardIterator,1190__enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&1191is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,1192int> >1193_LIBCPP_CONSTEXPR_SINCE_CXX20
1194vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)1195: __end_cap_(nullptr, __a) {1196size_type __n = static_cast<size_type>(std::distance(__first, __last));1197__init_with_size(__first, __last, __n);1198}
1199
1200template <class _Tp, class _Allocator>1201_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(const vector& __x)1202: __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) {1203__init_with_size(__x.__begin_, __x.__end_, __x.size());1204}
1205
1206template <class _Tp, class _Allocator>1207_LIBCPP_CONSTEXPR_SINCE_CXX20
1208vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)1209: __end_cap_(nullptr, __a) {1210__init_with_size(__x.__begin_, __x.__end_, __x.size());1211}
1212
1213template <class _Tp, class _Allocator>1214_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x)1215#if _LIBCPP_STD_VER >= 171216noexcept1217#else1218_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)1219#endif1220: __end_cap_(nullptr, std::move(__x.__alloc())) {1221this->__begin_ = __x.__begin_;1222this->__end_ = __x.__end_;1223this->__end_cap() = __x.__end_cap();1224__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;1225}
1226
1227template <class _Tp, class _Allocator>1228_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI1229vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)1230: __end_cap_(nullptr, __a) {1231if (__a == __x.__alloc()) {1232this->__begin_ = __x.__begin_;1233this->__end_ = __x.__end_;1234this->__end_cap() = __x.__end_cap();1235__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;1236} else {1237typedef move_iterator<iterator> _Ip;1238auto __guard = std::__make_exception_guard(__destroy_vector(*this));1239assign(_Ip(__x.begin()), _Ip(__x.end()));1240__guard.__complete();1241}1242}
1243
1244#ifndef _LIBCPP_CXX03_LANG1245
1246template <class _Tp, class _Allocator>1247_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI1248vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) {1249auto __guard = std::__make_exception_guard(__destroy_vector(*this));1250if (__il.size() > 0) {1251__vallocate(__il.size());1252__construct_at_end(__il.begin(), __il.end(), __il.size());1253}1254__guard.__complete();1255}
1256
1257template <class _Tp, class _Allocator>1258_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI1259vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)1260: __end_cap_(nullptr, __a) {1261auto __guard = std::__make_exception_guard(__destroy_vector(*this));1262if (__il.size() > 0) {1263__vallocate(__il.size());1264__construct_at_end(__il.begin(), __il.end(), __il.size());1265}1266__guard.__complete();1267}
1268
1269#endif // _LIBCPP_CXX03_LANG1270
1271template <class _Tp, class _Allocator>1272_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>&1273vector<_Tp, _Allocator>::operator=(vector&& __x)1274_NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {1275__move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());1276return *this;1277}
1278
1279template <class _Tp, class _Allocator>1280_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)1281_NOEXCEPT_(__alloc_traits::is_always_equal::value) {1282if (__alloc() != __c.__alloc()) {1283typedef move_iterator<iterator> _Ip;1284assign(_Ip(__c.begin()), _Ip(__c.end()));1285} else1286__move_assign(__c, true_type());1287}
1288
1289template <class _Tp, class _Allocator>1290_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)1291_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {1292__vdeallocate();1293__move_assign_alloc(__c); // this can throw1294this->__begin_ = __c.__begin_;1295this->__end_ = __c.__end_;1296this->__end_cap() = __c.__end_cap();1297__c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;1298}
1299
1300template <class _Tp, class _Allocator>1301_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>&1302vector<_Tp, _Allocator>::operator=(const vector& __x) {1303if (this != std::addressof(__x)) {1304__copy_assign_alloc(__x);1305assign(__x.__begin_, __x.__end_);1306}1307return *this;1308}
1309
1310template <class _Tp, class _Allocator>1311template <class _InputIterator,1312__enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&1313is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,1314int> >1315_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) {1316__assign_with_sentinel(__first, __last);1317}
1318
1319template <class _Tp, class _Allocator>1320template <class _Iterator, class _Sentinel>1321_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void1322vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {1323clear();1324for (; __first != __last; ++__first)1325emplace_back(*__first);1326}
1327
1328template <class _Tp, class _Allocator>1329template <class _ForwardIterator,1330__enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&1331is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,1332int> >1333_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) {1334__assign_with_size(__first, __last, std::distance(__first, __last));1335}
1336
1337template <class _Tp, class _Allocator>1338template <class _ForwardIterator, class _Sentinel>1339_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void1340vector<_Tp, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __n) {1341size_type __new_size = static_cast<size_type>(__n);1342if (__new_size <= capacity()) {1343if (__new_size > size()) {1344_ForwardIterator __mid = std::next(__first, size());1345std::copy(__first, __mid, this->__begin_);1346__construct_at_end(__mid, __last, __new_size - size());1347} else {1348pointer __m = std::__copy<_ClassicAlgPolicy>(__first, __last, this->__begin_).second;1349this->__destruct_at_end(__m);1350}1351} else {1352__vdeallocate();1353__vallocate(__recommend(__new_size));1354__construct_at_end(__first, __last, __new_size);1355}1356}
1357
1358template <class _Tp, class _Allocator>1359_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) {1360if (__n <= capacity()) {1361size_type __s = size();1362std::fill_n(this->__begin_, std::min(__n, __s), __u);1363if (__n > __s)1364__construct_at_end(__n - __s, __u);1365else1366this->__destruct_at_end(this->__begin_ + __n);1367} else {1368__vdeallocate();1369__vallocate(__recommend(static_cast<size_type>(__n)));1370__construct_at_end(__n, __u);1371}1372}
1373
1374template <class _Tp, class _Allocator>1375_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator1376vector<_Tp, _Allocator>::begin() _NOEXCEPT {1377return __make_iter(this->__begin_);1378}
1379
1380template <class _Tp, class _Allocator>1381_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator1382vector<_Tp, _Allocator>::begin() const _NOEXCEPT {1383return __make_iter(this->__begin_);1384}
1385
1386template <class _Tp, class _Allocator>1387_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator1388vector<_Tp, _Allocator>::end() _NOEXCEPT {1389return __make_iter(this->__end_);1390}
1391
1392template <class _Tp, class _Allocator>1393_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator1394vector<_Tp, _Allocator>::end() const _NOEXCEPT {1395return __make_iter(this->__end_);1396}
1397
1398template <class _Tp, class _Allocator>1399_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::reference1400vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT {1401_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");1402return this->__begin_[__n];1403}
1404
1405template <class _Tp, class _Allocator>1406_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_reference1407vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT {1408_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");1409return this->__begin_[__n];1410}
1411
1412template <class _Tp, class _Allocator>1413_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::at(size_type __n) {1414if (__n >= size())1415this->__throw_out_of_range();1416return this->__begin_[__n];1417}
1418
1419template <class _Tp, class _Allocator>1420_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::const_reference1421vector<_Tp, _Allocator>::at(size_type __n) const {1422if (__n >= size())1423this->__throw_out_of_range();1424return this->__begin_[__n];1425}
1426
1427template <class _Tp, class _Allocator>1428_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __n) {1429if (__n > capacity()) {1430if (__n > max_size())1431this->__throw_length_error();1432allocator_type& __a = this->__alloc();1433__split_buffer<value_type, allocator_type&> __v(__n, size(), __a);1434__swap_out_circular_buffer(__v);1435}1436}
1437
1438template <class _Tp, class _Allocator>1439_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {1440if (capacity() > size()) {1441#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1442try {1443#endif // _LIBCPP_HAS_NO_EXCEPTIONS1444allocator_type& __a = this->__alloc();1445__split_buffer<value_type, allocator_type&> __v(size(), size(), __a);1446__swap_out_circular_buffer(__v);1447#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1448} catch (...) {1449}1450#endif // _LIBCPP_HAS_NO_EXCEPTIONS1451}1452}
1453
1454template <class _Tp, class _Allocator>1455template <class _Up>1456_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer1457vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) {1458allocator_type& __a = this->__alloc();1459__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);1460// __v.push_back(std::forward<_Up>(__x));1461__alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Up>(__x));1462__v.__end_++;1463__swap_out_circular_buffer(__v);1464return this->__end_;1465}
1466
1467template <class _Tp, class _Allocator>1468_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void1469vector<_Tp, _Allocator>::push_back(const_reference __x) {1470pointer __end = this->__end_;1471if (__end < this->__end_cap()) {1472__construct_one_at_end(__x);1473++__end;1474} else {1475__end = __push_back_slow_path(__x);1476}1477this->__end_ = __end;1478}
1479
1480template <class _Tp, class _Allocator>1481_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void vector<_Tp, _Allocator>::push_back(value_type&& __x) {1482pointer __end = this->__end_;1483if (__end < this->__end_cap()) {1484__construct_one_at_end(std::move(__x));1485++__end;1486} else {1487__end = __push_back_slow_path(std::move(__x));1488}1489this->__end_ = __end;1490}
1491
1492template <class _Tp, class _Allocator>1493template <class... _Args>1494_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer1495vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) {1496allocator_type& __a = this->__alloc();1497__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);1498// __v.emplace_back(std::forward<_Args>(__args)...);1499__alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Args>(__args)...);1500__v.__end_++;1501__swap_out_circular_buffer(__v);1502return this->__end_;1503}
1504
1505template <class _Tp, class _Allocator>1506template <class... _Args>1507_LIBCPP_CONSTEXPR_SINCE_CXX20 inline1508#if _LIBCPP_STD_VER >= 171509typename vector<_Tp, _Allocator>::reference1510#else1511void1512#endif1513vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) {1514pointer __end = this->__end_;1515if (__end < this->__end_cap()) {1516__construct_one_at_end(std::forward<_Args>(__args)...);1517++__end;1518} else {1519__end = __emplace_back_slow_path(std::forward<_Args>(__args)...);1520}1521this->__end_ = __end;1522#if _LIBCPP_STD_VER >= 171523return *(__end - 1);1524#endif1525}
1526
1527template <class _Tp, class _Allocator>1528_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void vector<_Tp, _Allocator>::pop_back() {1529_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector::pop_back called on an empty vector");1530this->__destruct_at_end(this->__end_ - 1);1531}
1532
1533template <class _Tp, class _Allocator>1534_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator1535vector<_Tp, _Allocator>::erase(const_iterator __position) {1536_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(1537__position != end(), "vector::erase(iterator) called with a non-dereferenceable iterator");1538difference_type __ps = __position - cbegin();1539pointer __p = this->__begin_ + __ps;1540this->__destruct_at_end(std::move(__p + 1, this->__end_, __p));1541return __make_iter(__p);1542}
1543
1544template <class _Tp, class _Allocator>1545_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator1546vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) {1547_LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "vector::erase(first, last) called with invalid range");1548pointer __p = this->__begin_ + (__first - begin());1549if (__first != __last) {1550this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p));1551}1552return __make_iter(__p);1553}
1554
1555template <class _Tp, class _Allocator>1556_LIBCPP_CONSTEXPR_SINCE_CXX20 void1557vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) {1558pointer __old_last = this->__end_;1559difference_type __n = __old_last - __to;1560{1561pointer __i = __from_s + __n;1562_ConstructTransaction __tx(*this, __from_e - __i);1563for (pointer __pos = __tx.__pos_; __i < __from_e; ++__i, (void)++__pos, __tx.__pos_ = __pos) {1564__alloc_traits::construct(this->__alloc(), std::__to_address(__pos), std::move(*__i));1565}1566}1567std::move_backward(__from_s, __from_s + __n, __old_last);1568}
1569
1570template <class _Tp, class _Allocator>1571_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator1572vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) {1573pointer __p = this->__begin_ + (__position - begin());1574if (this->__end_ < this->__end_cap()) {1575if (__p == this->__end_) {1576__construct_one_at_end(__x);1577} else {1578__move_range(__p, this->__end_, __p + 1);1579const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);1580if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))1581++__xr;1582*__p = *__xr;1583}1584} else {1585allocator_type& __a = this->__alloc();1586__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);1587__v.push_back(__x);1588__p = __swap_out_circular_buffer(__v, __p);1589}1590return __make_iter(__p);1591}
1592
1593template <class _Tp, class _Allocator>1594_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator1595vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {1596pointer __p = this->__begin_ + (__position - begin());1597if (this->__end_ < this->__end_cap()) {1598if (__p == this->__end_) {1599__construct_one_at_end(std::move(__x));1600} else {1601__move_range(__p, this->__end_, __p + 1);1602*__p = std::move(__x);1603}1604} else {1605allocator_type& __a = this->__alloc();1606__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);1607__v.push_back(std::move(__x));1608__p = __swap_out_circular_buffer(__v, __p);1609}1610return __make_iter(__p);1611}
1612
1613template <class _Tp, class _Allocator>1614template <class... _Args>1615_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator1616vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {1617pointer __p = this->__begin_ + (__position - begin());1618if (this->__end_ < this->__end_cap()) {1619if (__p == this->__end_) {1620__construct_one_at_end(std::forward<_Args>(__args)...);1621} else {1622__temp_value<value_type, _Allocator> __tmp(this->__alloc(), std::forward<_Args>(__args)...);1623__move_range(__p, this->__end_, __p + 1);1624*__p = std::move(__tmp.get());1625}1626} else {1627allocator_type& __a = this->__alloc();1628__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);1629__v.emplace_back(std::forward<_Args>(__args)...);1630__p = __swap_out_circular_buffer(__v, __p);1631}1632return __make_iter(__p);1633}
1634
1635template <class _Tp, class _Allocator>1636_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator1637vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) {1638pointer __p = this->__begin_ + (__position - begin());1639if (__n > 0) {1640// We can't compare unrelated pointers inside constant expressions1641if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_)) {1642size_type __old_n = __n;1643pointer __old_last = this->__end_;1644if (__n > static_cast<size_type>(this->__end_ - __p)) {1645size_type __cx = __n - (this->__end_ - __p);1646__construct_at_end(__cx, __x);1647__n -= __cx;1648}1649if (__n > 0) {1650__move_range(__p, __old_last, __p + __old_n);1651const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);1652if (__p <= __xr && __xr < this->__end_)1653__xr += __old_n;1654std::fill_n(__p, __n, *__xr);1655}1656} else {1657allocator_type& __a = this->__alloc();1658__split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);1659__v.__construct_at_end(__n, __x);1660__p = __swap_out_circular_buffer(__v, __p);1661}1662}1663return __make_iter(__p);1664}
1665template <class _Tp, class _Allocator>1666template <class _InputIterator,1667__enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&1668is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,1669int> >1670_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator1671vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) {1672return __insert_with_sentinel(__position, __first, __last);1673}
1674
1675template <class _Tp, class _Allocator>1676template <class _InputIterator, class _Sentinel>1677_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator1678vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) {1679difference_type __off = __position - begin();1680pointer __p = this->__begin_ + __off;1681allocator_type& __a = this->__alloc();1682pointer __old_last = this->__end_;1683for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) {1684__construct_one_at_end(*__first);1685}1686__split_buffer<value_type, allocator_type&> __v(__a);1687if (__first != __last) {1688#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1689try {1690#endif // _LIBCPP_HAS_NO_EXCEPTIONS1691__v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last));1692difference_type __old_size = __old_last - this->__begin_;1693difference_type __old_p = __p - this->__begin_;1694reserve(__recommend(size() + __v.size()));1695__p = this->__begin_ + __old_p;1696__old_last = this->__begin_ + __old_size;1697#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1698} catch (...) {1699erase(__make_iter(__old_last), end());1700throw;1701}1702#endif // _LIBCPP_HAS_NO_EXCEPTIONS1703}1704__p = std::rotate(__p, __old_last, this->__end_);1705insert(__make_iter(__p), std::make_move_iterator(__v.begin()), std::make_move_iterator(__v.end()));1706return begin() + __off;1707}
1708
1709template <class _Tp, class _Allocator>1710template <class _ForwardIterator,1711__enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&1712is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,1713int> >1714_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator1715vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) {1716return __insert_with_size(__position, __first, __last, std::distance(__first, __last));1717}
1718
1719template <class _Tp, class _Allocator>1720template <class _Iterator, class _Sentinel>1721_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator1722vector<_Tp, _Allocator>::__insert_with_size(1723const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) {1724auto __insertion_size = __n;1725pointer __p = this->__begin_ + (__position - begin());1726if (__n > 0) {1727if (__n <= this->__end_cap() - this->__end_) {1728size_type __old_n = __n;1729pointer __old_last = this->__end_;1730_Iterator __m = std::next(__first, __n);1731difference_type __dx = this->__end_ - __p;1732if (__n > __dx) {1733__m = __first;1734difference_type __diff = this->__end_ - __p;1735std::advance(__m, __diff);1736__construct_at_end(__m, __last, __n - __diff);1737__n = __dx;1738}1739if (__n > 0) {1740__move_range(__p, __old_last, __p + __old_n);1741std::copy(__first, __m, __p);1742}1743} else {1744allocator_type& __a = this->__alloc();1745__split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);1746__v.__construct_at_end_with_size(__first, __insertion_size);1747__p = __swap_out_circular_buffer(__v, __p);1748}1749}1750return __make_iter(__p);1751}
1752
1753template <class _Tp, class _Allocator>1754_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz) {1755size_type __cs = size();1756if (__cs < __sz)1757this->__append(__sz - __cs);1758else if (__cs > __sz)1759this->__destruct_at_end(this->__begin_ + __sz);1760}
1761
1762template <class _Tp, class _Allocator>1763_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) {1764size_type __cs = size();1765if (__cs < __sz)1766this->__append(__sz - __cs, __x);1767else if (__cs > __sz)1768this->__destruct_at_end(this->__begin_ + __sz);1769}
1770
1771template <class _Tp, class _Allocator>1772_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x)1773#if _LIBCPP_STD_VER >= 141774_NOEXCEPT
1775#else1776_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)1777#endif1778{
1779_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(1780__alloc_traits::propagate_on_container_swap::value || this->__alloc() == __x.__alloc(),1781"vector::swap: Either propagate_on_container_swap must be true"1782" or the allocators must compare equal");1783std::swap(this->__begin_, __x.__begin_);1784std::swap(this->__end_, __x.__end_);1785std::swap(this->__end_cap(), __x.__end_cap());1786std::__swap_allocator(1787this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());1788}
1789
1790template <class _Tp, class _Allocator>1791_LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const {1792if (this->__begin_ == nullptr) {1793if (this->__end_ != nullptr || this->__end_cap() != nullptr)1794return false;1795} else {1796if (this->__begin_ > this->__end_)1797return false;1798if (this->__begin_ == this->__end_cap())1799return false;1800if (this->__end_ > this->__end_cap())1801return false;1802}1803return true;1804}
1805
1806// vector<bool>
1807
1808template <class _Allocator>1809class vector<bool, _Allocator>;1810
1811template <class _Allocator>1812struct hash<vector<bool, _Allocator> >;1813
1814template <class _Allocator>1815struct __has_storage_type<vector<bool, _Allocator> > {1816static const bool value = true;1817};1818
1819template <class _Allocator>1820class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> {1821public:1822typedef vector __self;1823typedef bool value_type;1824typedef _Allocator allocator_type;1825typedef allocator_traits<allocator_type> __alloc_traits;1826typedef typename __alloc_traits::size_type size_type;1827typedef typename __alloc_traits::difference_type difference_type;1828typedef size_type __storage_type;1829typedef __bit_iterator<vector, false> pointer;1830typedef __bit_iterator<vector, true> const_pointer;1831typedef pointer iterator;1832typedef const_pointer const_iterator;1833typedef std::reverse_iterator<iterator> reverse_iterator;1834typedef std::reverse_iterator<const_iterator> const_reverse_iterator;1835
1836private:1837typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator;1838typedef allocator_traits<__storage_allocator> __storage_traits;1839typedef typename __storage_traits::pointer __storage_pointer;1840typedef typename __storage_traits::const_pointer __const_storage_pointer;1841
1842__storage_pointer __begin_;1843size_type __size_;1844__compressed_pair<size_type, __storage_allocator> __cap_alloc_;1845
1846public:1847typedef __bit_reference<vector> reference;1848#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL1849using const_reference = bool;1850#else1851typedef __bit_const_reference<vector> const_reference;1852#endif1853
1854private:1855_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type& __cap() _NOEXCEPT { return __cap_alloc_.first(); }1856_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const size_type& __cap() const _NOEXCEPT {1857return __cap_alloc_.first();1858}1859_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __storage_allocator& __alloc() _NOEXCEPT {1860return __cap_alloc_.second();1861}1862_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const __storage_allocator& __alloc() const _NOEXCEPT {1863return __cap_alloc_.second();1864}1865
1866static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);1867
1868_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type1869__internal_cap_to_external(size_type __n) _NOEXCEPT {1870return __n * __bits_per_word;1871}1872_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type1873__external_cap_to_internal(size_type __n) _NOEXCEPT {1874return (__n - 1) / __bits_per_word + 1;1875}1876
1877public:1878_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector()1879_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);1880
1881_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(const allocator_type& __a)1882#if _LIBCPP_STD_VER <= 141883_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);1884#else1885_NOEXCEPT;1886#endif1887
1888private:1889class __destroy_vector {1890public:1891_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {}1892
1893_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {1894if (__vec_.__begin_ != nullptr)1895__storage_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.__cap());1896}1897
1898private:1899vector& __vec_;1900};1901
1902public:1903_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector (*this)(); }1904
1905_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n);1906#if _LIBCPP_STD_VER >= 141907_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a);1908#endif1909_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v);1910_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1911vector(size_type __n, const value_type& __v, const allocator_type& __a);1912template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>1913_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last);1914template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>1915_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1916vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);1917template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>1918_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last);1919template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>1920_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1921vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);1922
1923#if _LIBCPP_STD_VER >= 231924template <_ContainerCompatibleRange<bool> _Range>1925_LIBCPP_HIDE_FROM_ABI constexpr vector(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())1926: __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {1927if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {1928auto __n = static_cast<size_type>(ranges::distance(__range));1929__init_with_size(ranges::begin(__range), ranges::end(__range), __n);1930
1931} else {1932__init_with_sentinel(ranges::begin(__range), ranges::end(__range));1933}1934}1935#endif1936
1937_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v);1938_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a);1939_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(const vector& __v);1940
1941#ifndef _LIBCPP_CXX03_LANG1942_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il);1943_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1944vector(initializer_list<value_type> __il, const allocator_type& __a);1945
1946_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(initializer_list<value_type> __il) {1947assign(__il.begin(), __il.end());1948return *this;1949}1950
1951#endif // !_LIBCPP_CXX03_LANG1952
1953_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v)1954#if _LIBCPP_STD_VER >= 171955noexcept;1956#else1957_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);1958#endif1959_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1960vector(vector&& __v, const __type_identity_t<allocator_type>& __a);1961_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(vector&& __v)1962_NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value);1963
1964template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>1965void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last);1966template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>1967void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last);1968
1969#if _LIBCPP_STD_VER >= 231970template <_ContainerCompatibleRange<bool> _Range>1971_LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) {1972if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {1973auto __n = static_cast<size_type>(ranges::distance(__range));1974__assign_with_size(ranges::begin(__range), ranges::end(__range), __n);1975
1976} else {1977__assign_with_sentinel(ranges::begin(__range), ranges::end(__range));1978}1979}1980#endif1981
1982_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(size_type __n, const value_type& __x);1983
1984#ifndef _LIBCPP_CXX03_LANG1985_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(initializer_list<value_type> __il) {1986assign(__il.begin(), __il.end());1987}1988#endif1989
1990_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT {1991return allocator_type(this->__alloc());1992}1993
1994_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT;1995_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT {1996return __internal_cap_to_external(__cap());1997}1998_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; }1999_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {2000return __size_ == 0;2001}2002_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n);2003_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;2004
2005_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { return __make_iter(0); }2006_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { return __make_iter(0); }2007_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { return __make_iter(__size_); }2008_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT {2009return __make_iter(__size_);2010}2011
2012_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT {2013return reverse_iterator(end());2014}2015_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rbegin() const _NOEXCEPT {2016return const_reverse_iterator(end());2017}2018_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT {2019return reverse_iterator(begin());2020}2021_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT {2022return const_reverse_iterator(begin());2023}2024
2025_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { return __make_iter(0); }2026_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT {2027return __make_iter(__size_);2028}2029_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crbegin() const _NOEXCEPT {2030return rbegin();2031}2032_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }2033
2034_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) { return __make_ref(__n); }2035_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const {2036return __make_ref(__n);2037}2038_LIBCPP_HIDE_FROM_ABI reference at(size_type __n);2039_LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const;2040
2041_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() { return __make_ref(0); }2042_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const { return __make_ref(0); }2043_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() { return __make_ref(__size_ - 1); }2044_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const { return __make_ref(__size_ - 1); }2045
2046_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(const value_type& __x);2047#if _LIBCPP_STD_VER >= 142048template <class... _Args>2049# if _LIBCPP_STD_VER >= 172050_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference emplace_back(_Args&&... __args)2051# else2052_LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args)2053# endif2054{2055push_back(value_type(std::forward<_Args>(__args)...));2056# if _LIBCPP_STD_VER >= 172057return this->back();2058# endif2059}2060#endif2061
2062#if _LIBCPP_STD_VER >= 232063template <_ContainerCompatibleRange<bool> _Range>2064_LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {2065insert_range(end(), std::forward<_Range>(__range));2066}2067#endif2068
2069_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back() { --__size_; }2070
2071#if _LIBCPP_STD_VER >= 142072template <class... _Args>2073_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args) {2074return insert(__position, value_type(std::forward<_Args>(__args)...));2075}2076#endif2077
2078_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x);2079_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
2080insert(const_iterator __position, size_type __n, const value_type& __x);2081template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>2082iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2083insert(const_iterator __position, _InputIterator __first, _InputIterator __last);2084template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>2085iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2086insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);2087
2088#if _LIBCPP_STD_VER >= 232089template <_ContainerCompatibleRange<bool> _Range>2090_LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {2091if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {2092auto __n = static_cast<size_type>(ranges::distance(__range));2093return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);2094
2095} else {2096return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));2097}2098}2099#endif2100
2101#ifndef _LIBCPP_CXX03_LANG2102_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
2103insert(const_iterator __position, initializer_list<value_type> __il) {2104return insert(__position, __il.begin(), __il.end());2105}2106#endif2107
2108_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position);2109_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last);2110
2111_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT { __size_ = 0; }2112
2113_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&)2114#if _LIBCPP_STD_VER >= 142115_NOEXCEPT;2116#else2117_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);2118#endif2119_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT {2120std::swap(__x, __y);2121}2122
2123_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false);2124_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT;2125
2126_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;2127
2128private:2129_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); }2130
2131_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); }2132
2133template <class _InputIterator, class _Sentinel>2134_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2135__init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) {2136auto __guard = std::__make_exception_guard(__destroy_vector(*this));2137
2138if (__n > 0) {2139__vallocate(__n);2140__construct_at_end(std::move(__first), std::move(__last), __n);2141}2142
2143__guard.__complete();2144}2145
2146template <class _InputIterator, class _Sentinel>2147_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2148__init_with_sentinel(_InputIterator __first, _Sentinel __last) {2149#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2150try {2151#endif // _LIBCPP_HAS_NO_EXCEPTIONS2152for (; __first != __last; ++__first)2153push_back(*__first);2154#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2155} catch (...) {2156if (__begin_ != nullptr)2157__storage_traits::deallocate(__alloc(), __begin_, __cap());2158throw;2159}2160#endif // _LIBCPP_HAS_NO_EXCEPTIONS2161}2162
2163template <class _Iterator, class _Sentinel>2164_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);2165
2166template <class _ForwardIterator, class _Sentinel>2167_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void2168__assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __ns);2169
2170template <class _InputIterator, class _Sentinel>2171_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
2172__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);2173
2174template <class _Iterator, class _Sentinel>2175_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
2176__insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n);2177
2178// Allocate space for __n objects2179// throws length_error if __n > max_size()2180// throws (probably bad_alloc) if memory run out2181// Precondition: __begin_ == __end_ == __cap() == 02182// Precondition: __n > 02183// Postcondition: capacity() >= __n2184// Postcondition: size() == 02185_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) {2186if (__n > max_size())2187__throw_length_error();2188auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));2189__begin_ = __allocation.ptr;2190__size_ = 0;2191__cap() = __allocation.count;2192if (__libcpp_is_constant_evaluated()) {2193for (size_type __i = 0; __i != __cap(); ++__i)2194std::__construct_at(std::__to_address(__begin_) + __i);2195}2196}2197
2198_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT;2199_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type __align_it(size_type __new_size) _NOEXCEPT {2200return (__new_size + (__bits_per_word - 1)) & ~((size_type)__bits_per_word - 1);2201}2202_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const;2203_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x);2204template <class _InputIterator, class _Sentinel>2205_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2206__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n);2207_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append(size_type __n, const_reference __x);2208_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference __make_ref(size_type __pos) _NOEXCEPT {2209return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);2210}2211_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference __make_ref(size_type __pos) const _NOEXCEPT {2212return __bit_const_reference<vector>(2213__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);2214}2215_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iter(size_type __pos) _NOEXCEPT {2216return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));2217}2218_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_iter(size_type __pos) const _NOEXCEPT {2219return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));2220}2221_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {2222return begin() + (__p - cbegin());2223}2224
2225_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __v) {2226__copy_assign_alloc(2227__v, integral_constant<bool, __storage_traits::propagate_on_container_copy_assignment::value>());2228}2229_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __c, true_type) {2230if (__alloc() != __c.__alloc())2231__vdeallocate();2232__alloc() = __c.__alloc();2233}2234
2235_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector&, false_type) {}2236
2237_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type);2238_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type)2239_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);2240_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c)2241_NOEXCEPT_(!__storage_traits::propagate_on_container_move_assignment::value ||2242is_nothrow_move_assignable<allocator_type>::value) {2243__move_assign_alloc(2244__c, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>());2245}2246_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c, true_type)2247_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {2248__alloc() = std::move(__c.__alloc());2249}2250
2251_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}2252
2253_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT;2254
2255friend class __bit_reference<vector>;2256friend class __bit_const_reference<vector>;2257friend class __bit_iterator<vector, false>;2258friend class __bit_iterator<vector, true>;2259friend struct __bit_array<vector>;2260friend struct _LIBCPP_TEMPLATE_VIS hash<vector>;2261};2262
2263template <class _Allocator>2264_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT {2265if (this->__begin_ != nullptr) {2266__storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());2267this->__begin_ = nullptr;2268this->__size_ = this->__cap() = 0;2269}2270}
2271
2272template <class _Allocator>2273_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type2274vector<bool, _Allocator>::max_size() const _NOEXCEPT {2275size_type __amax = __storage_traits::max_size(__alloc());2276size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always2277if (__nmax / __bits_per_word <= __amax)2278return __nmax;2279return __internal_cap_to_external(__amax);2280}
2281
2282// Precondition: __new_size > capacity()
2283template <class _Allocator>2284inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type2285vector<bool, _Allocator>::__recommend(size_type __new_size) const {2286const size_type __ms = max_size();2287if (__new_size > __ms)2288this->__throw_length_error();2289const size_type __cap = capacity();2290if (__cap >= __ms / 2)2291return __ms;2292return std::max(2 * __cap, __align_it(__new_size));2293}
2294
2295// Default constructs __n objects starting at __end_
2296// Precondition: __n > 0
2297// Precondition: size() + __n <= capacity()
2298// Postcondition: size() == size() + __n
2299template <class _Allocator>2300inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2301vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) {2302size_type __old_size = this->__size_;2303this->__size_ += __n;2304if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) {2305if (this->__size_ <= __bits_per_word)2306this->__begin_[0] = __storage_type(0);2307else2308this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);2309}2310std::fill_n(__make_iter(__old_size), __n, __x);2311}
2312
2313template <class _Allocator>2314template <class _InputIterator, class _Sentinel>2315_LIBCPP_CONSTEXPR_SINCE_CXX20 void2316vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {2317size_type __old_size = this->__size_;2318this->__size_ += __n;2319if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) {2320if (this->__size_ <= __bits_per_word)2321this->__begin_[0] = __storage_type(0);2322else2323this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);2324}2325std::__copy<_ClassicAlgPolicy>(__first, __last, __make_iter(__old_size));2326}
2327
2328template <class _Allocator>2329inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector()2330_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)2331: __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {}2332
2333template <class _Allocator>2334inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const allocator_type& __a)2335#if _LIBCPP_STD_VER <= 142336_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)2337#else2338_NOEXCEPT
2339#endif2340: __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {2341}
2342
2343template <class _Allocator>2344_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n)2345: __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {2346if (__n > 0) {2347__vallocate(__n);2348__construct_at_end(__n, false);2349}2350}
2351
2352#if _LIBCPP_STD_VER >= 142353template <class _Allocator>2354_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)2355: __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {2356if (__n > 0) {2357__vallocate(__n);2358__construct_at_end(__n, false);2359}2360}
2361#endif2362
2363template <class _Allocator>2364_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)2365: __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {2366if (__n > 0) {2367__vallocate(__n);2368__construct_at_end(__n, __x);2369}2370}
2371
2372template <class _Allocator>2373_LIBCPP_CONSTEXPR_SINCE_CXX20
2374vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)2375: __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {2376if (__n > 0) {2377__vallocate(__n);2378__construct_at_end(__n, __x);2379}2380}
2381
2382template <class _Allocator>2383template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >2384_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last)2385: __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {2386__init_with_sentinel(__first, __last);2387}
2388
2389template <class _Allocator>2390template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >2391_LIBCPP_CONSTEXPR_SINCE_CXX20
2392vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)2393: __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {2394__init_with_sentinel(__first, __last);2395}
2396
2397template <class _Allocator>2398template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >2399_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last)2400: __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {2401auto __n = static_cast<size_type>(std::distance(__first, __last));2402__init_with_size(__first, __last, __n);2403}
2404
2405template <class _Allocator>2406template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >2407_LIBCPP_CONSTEXPR_SINCE_CXX20
2408vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)2409: __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {2410auto __n = static_cast<size_type>(std::distance(__first, __last));2411__init_with_size(__first, __last, __n);2412}
2413
2414#ifndef _LIBCPP_CXX03_LANG2415
2416template <class _Allocator>2417_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(initializer_list<value_type> __il)2418: __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {2419size_type __n = static_cast<size_type>(__il.size());2420if (__n > 0) {2421__vallocate(__n);2422__construct_at_end(__il.begin(), __il.end(), __n);2423}2424}
2425
2426template <class _Allocator>2427_LIBCPP_CONSTEXPR_SINCE_CXX20
2428vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)2429: __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {2430size_type __n = static_cast<size_type>(__il.size());2431if (__n > 0) {2432__vallocate(__n);2433__construct_at_end(__il.begin(), __il.end(), __n);2434}2435}
2436
2437#endif // _LIBCPP_CXX03_LANG2438
2439template <class _Allocator>2440_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v)2441: __begin_(nullptr),2442__size_(0),2443__cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) {2444if (__v.size() > 0) {2445__vallocate(__v.size());2446__construct_at_end(__v.begin(), __v.end(), __v.size());2447}2448}
2449
2450template <class _Allocator>2451_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)2452: __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) {2453if (__v.size() > 0) {2454__vallocate(__v.size());2455__construct_at_end(__v.begin(), __v.end(), __v.size());2456}2457}
2458
2459template <class _Allocator>2460_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator>::operator=(const vector& __v) {2461if (this != std::addressof(__v)) {2462__copy_assign_alloc(__v);2463if (__v.__size_) {2464if (__v.__size_ > capacity()) {2465__vdeallocate();2466__vallocate(__v.__size_);2467}2468std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);2469}2470__size_ = __v.__size_;2471}2472return *this;2473}
2474
2475template <class _Allocator>2476inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v)2477#if _LIBCPP_STD_VER >= 172478_NOEXCEPT
2479#else2480_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)2481#endif2482: __begin_(__v.__begin_),2483__size_(__v.__size_),2484__cap_alloc_(std::move(__v.__cap_alloc_)) {2485__v.__begin_ = nullptr;2486__v.__size_ = 0;2487__v.__cap() = 0;2488}
2489
2490template <class _Allocator>2491_LIBCPP_CONSTEXPR_SINCE_CXX20
2492vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)2493: __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) {2494if (__a == allocator_type(__v.__alloc())) {2495this->__begin_ = __v.__begin_;2496this->__size_ = __v.__size_;2497this->__cap() = __v.__cap();2498__v.__begin_ = nullptr;2499__v.__cap() = __v.__size_ = 0;2500} else if (__v.size() > 0) {2501__vallocate(__v.size());2502__construct_at_end(__v.begin(), __v.end(), __v.size());2503}2504}
2505
2506template <class _Allocator>2507inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>&2508vector<bool, _Allocator>::operator=(vector&& __v)2509_NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {2510__move_assign(__v, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>());2511return *this;2512}
2513
2514template <class _Allocator>2515_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, false_type) {2516if (__alloc() != __c.__alloc())2517assign(__c.begin(), __c.end());2518else2519__move_assign(__c, true_type());2520}
2521
2522template <class _Allocator>2523_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, true_type)2524_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {2525__vdeallocate();2526__move_assign_alloc(__c);2527this->__begin_ = __c.__begin_;2528this->__size_ = __c.__size_;2529this->__cap() = __c.__cap();2530__c.__begin_ = nullptr;2531__c.__cap() = __c.__size_ = 0;2532}
2533
2534template <class _Allocator>2535_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) {2536__size_ = 0;2537if (__n > 0) {2538size_type __c = capacity();2539if (__n <= __c)2540__size_ = __n;2541else {2542vector __v(get_allocator());2543__v.reserve(__recommend(__n));2544__v.__size_ = __n;2545swap(__v);2546}2547std::fill_n(begin(), __n, __x);2548}2549}
2550
2551template <class _Allocator>2552template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >2553_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) {2554__assign_with_sentinel(__first, __last);2555}
2556
2557template <class _Allocator>2558template <class _Iterator, class _Sentinel>2559_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void2560vector<bool, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {2561clear();2562for (; __first != __last; ++__first)2563push_back(*__first);2564}
2565
2566template <class _Allocator>2567template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >2568_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) {2569__assign_with_size(__first, __last, std::distance(__first, __last));2570}
2571
2572template <class _Allocator>2573template <class _ForwardIterator, class _Sentinel>2574_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void2575vector<bool, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __ns) {2576_LIBCPP_ASSERT_VALID_INPUT_RANGE(__ns >= 0, "invalid range specified");2577
2578clear();2579
2580const size_t __n = static_cast<size_type>(__ns);2581if (__n) {2582if (__n > capacity()) {2583__vdeallocate();2584__vallocate(__n);2585}2586__construct_at_end(__first, __last, __n);2587}2588}
2589
2590template <class _Allocator>2591_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type __n) {2592if (__n > capacity()) {2593if (__n > max_size())2594this->__throw_length_error();2595vector __v(this->get_allocator());2596__v.__vallocate(__n);2597__v.__construct_at_end(this->begin(), this->end(), this->size());2598swap(__v);2599}2600}
2601
2602template <class _Allocator>2603_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT {2604if (__external_cap_to_internal(size()) > __cap()) {2605#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2606try {2607#endif // _LIBCPP_HAS_NO_EXCEPTIONS2608vector(*this, allocator_type(__alloc())).swap(*this);2609#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2610} catch (...) {2611}2612#endif // _LIBCPP_HAS_NO_EXCEPTIONS2613}2614}
2615
2616template <class _Allocator>2617typename vector<bool, _Allocator>::reference vector<bool, _Allocator>::at(size_type __n) {2618if (__n >= size())2619this->__throw_out_of_range();2620return (*this)[__n];2621}
2622
2623template <class _Allocator>2624typename vector<bool, _Allocator>::const_reference vector<bool, _Allocator>::at(size_type __n) const {2625if (__n >= size())2626this->__throw_out_of_range();2627return (*this)[__n];2628}
2629
2630template <class _Allocator>2631_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::push_back(const value_type& __x) {2632if (this->__size_ == this->capacity())2633reserve(__recommend(this->__size_ + 1));2634++this->__size_;2635back() = __x;2636}
2637
2638template <class _Allocator>2639_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator2640vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) {2641iterator __r;2642if (size() < capacity()) {2643const_iterator __old_end = end();2644++__size_;2645std::copy_backward(__position, __old_end, end());2646__r = __const_iterator_cast(__position);2647} else {2648vector __v(get_allocator());2649__v.reserve(__recommend(__size_ + 1));2650__v.__size_ = __size_ + 1;2651__r = std::copy(cbegin(), __position, __v.begin());2652std::copy_backward(__position, cend(), __v.end());2653swap(__v);2654}2655*__r = __x;2656return __r;2657}
2658
2659template <class _Allocator>2660_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator2661vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) {2662iterator __r;2663size_type __c = capacity();2664if (__n <= __c && size() <= __c - __n) {2665const_iterator __old_end = end();2666__size_ += __n;2667std::copy_backward(__position, __old_end, end());2668__r = __const_iterator_cast(__position);2669} else {2670vector __v(get_allocator());2671__v.reserve(__recommend(__size_ + __n));2672__v.__size_ = __size_ + __n;2673__r = std::copy(cbegin(), __position, __v.begin());2674std::copy_backward(__position, cend(), __v.end());2675swap(__v);2676}2677std::fill_n(__r, __n, __x);2678return __r;2679}
2680
2681template <class _Allocator>2682template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >2683_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator2684vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) {2685return __insert_with_sentinel(__position, __first, __last);2686}
2687
2688template <class _Allocator>2689template <class _InputIterator, class _Sentinel>2690_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator2691vector<bool, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) {2692difference_type __off = __position - begin();2693iterator __p = __const_iterator_cast(__position);2694iterator __old_end = end();2695for (; size() != capacity() && __first != __last; ++__first) {2696++this->__size_;2697back() = *__first;2698}2699vector __v(get_allocator());2700if (__first != __last) {2701#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2702try {2703#endif // _LIBCPP_HAS_NO_EXCEPTIONS2704__v.__assign_with_sentinel(std::move(__first), std::move(__last));2705difference_type __old_size = static_cast<difference_type>(__old_end - begin());2706difference_type __old_p = __p - begin();2707reserve(__recommend(size() + __v.size()));2708__p = begin() + __old_p;2709__old_end = begin() + __old_size;2710#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2711} catch (...) {2712erase(__old_end, end());2713throw;2714}2715#endif // _LIBCPP_HAS_NO_EXCEPTIONS2716}2717__p = std::rotate(__p, __old_end, end());2718insert(__p, __v.begin(), __v.end());2719return begin() + __off;2720}
2721
2722template <class _Allocator>2723template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >2724_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator2725vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) {2726return __insert_with_size(__position, __first, __last, std::distance(__first, __last));2727}
2728
2729template <class _Allocator>2730template <class _ForwardIterator, class _Sentinel>2731_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator2732vector<bool, _Allocator>::__insert_with_size(2733const_iterator __position, _ForwardIterator __first, _Sentinel __last, difference_type __n_signed) {2734_LIBCPP_ASSERT_VALID_INPUT_RANGE(__n_signed >= 0, "invalid range specified");2735const size_type __n = static_cast<size_type>(__n_signed);2736iterator __r;2737size_type __c = capacity();2738if (__n <= __c && size() <= __c - __n) {2739const_iterator __old_end = end();2740__size_ += __n;2741std::copy_backward(__position, __old_end, end());2742__r = __const_iterator_cast(__position);2743} else {2744vector __v(get_allocator());2745__v.reserve(__recommend(__size_ + __n));2746__v.__size_ = __size_ + __n;2747__r = std::copy(cbegin(), __position, __v.begin());2748std::copy_backward(__position, cend(), __v.end());2749swap(__v);2750}2751std::__copy<_ClassicAlgPolicy>(__first, __last, __r);2752return __r;2753}
2754
2755template <class _Allocator>2756inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator2757vector<bool, _Allocator>::erase(const_iterator __position) {2758iterator __r = __const_iterator_cast(__position);2759std::copy(__position + 1, this->cend(), __r);2760--__size_;2761return __r;2762}
2763
2764template <class _Allocator>2765_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator2766vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) {2767iterator __r = __const_iterator_cast(__first);2768difference_type __d = __last - __first;2769std::copy(__last, this->cend(), __r);2770__size_ -= __d;2771return __r;2772}
2773
2774template <class _Allocator>2775_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x)2776#if _LIBCPP_STD_VER >= 142777_NOEXCEPT
2778#else2779_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)2780#endif2781{
2782std::swap(this->__begin_, __x.__begin_);2783std::swap(this->__size_, __x.__size_);2784std::swap(this->__cap(), __x.__cap());2785std::__swap_allocator(2786this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());2787}
2788
2789template <class _Allocator>2790_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::resize(size_type __sz, value_type __x) {2791size_type __cs = size();2792if (__cs < __sz) {2793iterator __r;2794size_type __c = capacity();2795size_type __n = __sz - __cs;2796if (__n <= __c && __cs <= __c - __n) {2797__r = end();2798__size_ += __n;2799} else {2800vector __v(get_allocator());2801__v.reserve(__recommend(__size_ + __n));2802__v.__size_ = __size_ + __n;2803__r = std::copy(cbegin(), cend(), __v.begin());2804swap(__v);2805}2806std::fill_n(__r, __n, __x);2807} else2808__size_ = __sz;2809}
2810
2811template <class _Allocator>2812_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::flip() _NOEXCEPT {2813// do middle whole words2814size_type __n = __size_;2815__storage_pointer __p = __begin_;2816for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)2817*__p = ~*__p;2818// do last partial word2819if (__n > 0) {2820__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);2821__storage_type __b = *__p & __m;2822*__p &= ~__m;2823*__p |= ~__b & __m;2824}2825}
2826
2827template <class _Allocator>2828_LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() const {2829if (this->__begin_ == nullptr) {2830if (this->__size_ != 0 || this->__cap() != 0)2831return false;2832} else {2833if (this->__cap() == 0)2834return false;2835if (this->__size_ > this->capacity())2836return false;2837}2838return true;2839}
2840
2841template <class _Allocator>2842_LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT {2843size_t __h = 0;2844// do middle whole words2845size_type __n = __size_;2846__storage_pointer __p = __begin_;2847for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)2848__h ^= *__p;2849// do last partial word2850if (__n > 0) {2851const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);2852__h ^= *__p & __m;2853}2854return __h;2855}
2856
2857template <class _Allocator>2858struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >2859: public __unary_function<vector<bool, _Allocator>, size_t> {2860_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t
2861operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT {2862return __vec.__hash_code();2863}2864};2865
2866template <class _Tp, class _Allocator>2867_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI bool2868operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {2869const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();2870return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());2871}
2872
2873#if _LIBCPP_STD_VER <= 172874
2875template <class _Tp, class _Allocator>2876inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {2877return !(__x == __y);2878}
2879
2880template <class _Tp, class _Allocator>2881inline _LIBCPP_HIDE_FROM_ABI bool operator<(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {2882return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());2883}
2884
2885template <class _Tp, class _Allocator>2886inline _LIBCPP_HIDE_FROM_ABI bool operator>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {2887return __y < __x;2888}
2889
2890template <class _Tp, class _Allocator>2891inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {2892return !(__x < __y);2893}
2894
2895template <class _Tp, class _Allocator>2896inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {2897return !(__y < __x);2898}
2899
2900#else // _LIBCPP_STD_VER <= 172901
2902template <class _Tp, class _Allocator>2903_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>2904operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {2905return std::lexicographical_compare_three_way(2906__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);2907}
2908
2909#endif // _LIBCPP_STD_VER <= 172910
2911template <class _Tp, class _Allocator>2912_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void2913swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {2914__x.swap(__y);2915}
2916
2917#if _LIBCPP_STD_VER >= 202918template <class _Tp, class _Allocator, class _Up>2919_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type2920erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {2921auto __old_size = __c.size();2922__c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());2923return __old_size - __c.size();2924}
2925
2926template <class _Tp, class _Allocator, class _Predicate>2927_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type2928erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {2929auto __old_size = __c.size();2930__c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());2931return __old_size - __c.size();2932}
2933
2934template <>2935inline constexpr bool __format::__enable_insertable<vector<char>> = true;2936# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2937template <>2938inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;2939# endif2940
2941#endif // _LIBCPP_STD_VER >= 202942
2943#if _LIBCPP_STD_VER >= 232944template <class _Tp, class _CharT>2945// Since is-vector-bool-reference is only used once it's inlined here.
2946requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>2947struct _LIBCPP_TEMPLATE_VIS formatter<_Tp, _CharT> {2948private:2949formatter<bool, _CharT> __underlying_;2950
2951public:2952template <class _ParseContext>2953_LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {2954return __underlying_.parse(__ctx);2955}2956
2957template <class _FormatContext>2958_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const {2959return __underlying_.format(__ref, __ctx);2960}2961};2962#endif // _LIBCPP_STD_VER >= 232963
2964_LIBCPP_END_NAMESPACE_STD
2965
2966#if _LIBCPP_STD_VER >= 172967_LIBCPP_BEGIN_NAMESPACE_STD
2968namespace pmr {2969template <class _ValueT>2970using vector _LIBCPP_AVAILABILITY_PMR = std::vector<_ValueT, polymorphic_allocator<_ValueT>>;2971} // namespace pmr2972_LIBCPP_END_NAMESPACE_STD
2973#endif2974
2975_LIBCPP_POP_MACROS
2976
2977#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 202978# include <algorithm>2979# include <atomic>2980# include <concepts>2981# include <cstdlib>2982# include <iosfwd>2983# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)2984# include <locale>2985# endif2986# include <tuple>2987# include <type_traits>2988# include <typeinfo>2989# include <utility>2990#endif2991
2992#endif // _LIBCPP_VECTOR2993