57#define _STL_BVECTOR_H 1
59#ifndef _GLIBCXX_ALWAYS_INLINE
60#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
63#if __cplusplus >= 201103L
68namespace std _GLIBCXX_VISIBILITY(default)
70_GLIBCXX_BEGIN_NAMESPACE_VERSION
72 typedef unsigned long _Bit_type;
73 enum { _S_word_bit = int(__CHAR_BIT__ *
sizeof(_Bit_type)) };
75 __attribute__((__nonnull__))
78 __fill_bvector_n(_Bit_type*,
size_t,
bool) _GLIBCXX_NOEXCEPT;
80_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
88 _Bit_reference(_Bit_type * __x, _Bit_type __y)
89 : _M_p(__x), _M_mask(__y) { }
92 _Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { }
94#if __cplusplus >= 201103L
95 _Bit_reference(
const _Bit_reference&) =
default;
98 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
99 operator bool() const _GLIBCXX_NOEXCEPT
100 {
return !!(*_M_p & _M_mask); }
104 operator=(
bool __x) _GLIBCXX_NOEXCEPT
113#if __cplusplus > 202002L
114 constexpr const _Bit_reference&
115 operator=(
bool __x)
const noexcept
127 operator=(
const _Bit_reference& __x) _GLIBCXX_NOEXCEPT
128 {
return *
this = bool(__x); }
130 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
132 operator==(
const _Bit_reference& __x)
const
133 {
return bool(*
this) == bool(__x); }
135 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
137 operator<(
const _Bit_reference& __x)
const
138 {
return !bool(*
this) && bool(__x); }
142 flip() _GLIBCXX_NOEXCEPT
143 { *_M_p ^= _M_mask; }
145#if __cplusplus >= 201103L
148 swap(_Bit_reference __x, _Bit_reference __y)
noexcept
157 swap(_Bit_reference __x,
bool& __y)
noexcept
166 swap(
bool& __x, _Bit_reference __y)
noexcept
176#pragma GCC diagnostic push
177#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
178 struct _Bit_iterator_base
179 :
public std::iterator<std::random_access_iterator_tag, bool>
182 unsigned int _M_offset;
184 _GLIBCXX20_CONSTEXPR _GLIBCXX_ALWAYS_INLINE
186 _M_assume_normalized()
const
188#if __has_attribute(__assume__) && !defined(__clang__)
189 unsigned int __ofst = _M_offset;
190 __attribute__ ((__assume__ (__ofst <
unsigned(_S_word_bit))));
195 _Bit_iterator_base(_Bit_type * __x,
unsigned int __y)
196 : _M_p(__x), _M_offset(__y) { }
202 _M_assume_normalized();
203 if (_M_offset++ ==
int(_S_word_bit) - 1)
214 _M_assume_normalized();
215 if (_M_offset-- == 0)
217 _M_offset = int(_S_word_bit) - 1;
224 _M_incr(ptrdiff_t __i)
226 _M_assume_normalized();
228 _M_p += __n / int(_S_word_bit);
229 __n = __n % int(_S_word_bit);
232 __n += int(_S_word_bit);
235 _M_offset =
static_cast<unsigned int>(__n);
239 friend _GLIBCXX20_CONSTEXPR
bool
240 operator==(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
242 __x._M_assume_normalized();
243 __y._M_assume_normalized();
244 return __x._M_p == __y._M_p && __x._M_offset == __y._M_offset;
247#if __cpp_lib_three_way_comparison
249 friend constexpr strong_ordering
250 operator<=>(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
253 __x._M_assume_normalized();
254 __y._M_assume_normalized();
255 if (
const auto __cmp = __x._M_p <=> __y._M_p; __cmp != 0)
257 return __x._M_offset <=> __y._M_offset;
262 operator<(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
264 __x._M_assume_normalized();
265 __y._M_assume_normalized();
266 return __x._M_p < __y._M_p
267 || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset);
272 operator!=(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
273 {
return !(__x == __y); }
277 operator>(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
278 {
return __y < __x; }
282 operator<=(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
283 {
return !(__y < __x); }
287 operator>=(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
288 {
return !(__x < __y); }
291 friend _GLIBCXX20_CONSTEXPR ptrdiff_t
292 operator-(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
294 __x._M_assume_normalized();
295 __y._M_assume_normalized();
296 return (
int(_S_word_bit) * (__x._M_p - __y._M_p)
297 + __x._M_offset - __y._M_offset);
300#pragma GCC diagnostic pop
302 struct _Bit_iterator :
public _Bit_iterator_base
304 typedef _Bit_reference reference;
305#if __cplusplus > 201703L
306 typedef void pointer;
308 typedef _Bit_reference* pointer;
310 typedef _Bit_iterator iterator;
313 _Bit_iterator() : _Bit_iterator_base(0, 0) { }
316 _Bit_iterator(_Bit_type * __x,
unsigned int __y)
317 : _Bit_iterator_base(__x, __y) { }
321 _M_const_cast()
const
324 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
328 _M_assume_normalized();
329 return reference(_M_p, 1UL << _M_offset);
344 iterator __tmp = *
this;
361 iterator __tmp = *
this;
382 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
385 {
return *(*
this + __i); }
388 friend _GLIBCXX20_CONSTEXPR iterator
391 iterator __tmp = __x;
397 friend _GLIBCXX20_CONSTEXPR iterator
399 {
return __x + __n; }
402 friend _GLIBCXX20_CONSTEXPR iterator
405 iterator __tmp = __x;
411 struct _Bit_const_iterator :
public _Bit_iterator_base
413 typedef bool reference;
414 typedef bool const_reference;
415#if __cplusplus > 201703L
416 typedef void pointer;
418 typedef const bool* pointer;
420 typedef _Bit_const_iterator const_iterator;
423 _Bit_const_iterator() : _Bit_iterator_base(0, 0) { }
426 _Bit_const_iterator(_Bit_type * __x,
unsigned int __y)
427 : _Bit_iterator_base(__x, __y) { }
430 _Bit_const_iterator(
const _Bit_iterator& __x)
431 : _Bit_iterator_base(__x._M_p, __x._M_offset) { }
435 _M_const_cast()
const
436 {
return _Bit_iterator(_M_p, _M_offset); }
438 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
442 _M_assume_normalized();
443 return _Bit_reference(_M_p, 1UL << _M_offset);
458 const_iterator __tmp = *
this;
475 const_iterator __tmp = *
this;
496 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
499 {
return *(*
this + __i); }
502 friend _GLIBCXX20_CONSTEXPR const_iterator
505 const_iterator __tmp = __x;
511 friend _GLIBCXX20_CONSTEXPR const_iterator
514 const_iterator __tmp = __x;
520 friend _GLIBCXX20_CONSTEXPR const_iterator
522 {
return __x + __n; }
525 template<
typename _Alloc>
528 typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
529 rebind<_Bit_type>::other _Bit_alloc_type;
530 typedef typename __gnu_cxx::__alloc_traits<_Bit_alloc_type>
532 typedef typename _Bit_alloc_traits::pointer _Bit_pointer;
534 struct _Bvector_impl_data
536#if !_GLIBCXX_INLINE_VERSION
537 _Bit_iterator _M_start;
544 void operator=(_Bit_iterator __it) { _M_p = __it._M_p; }
547 _Bit_iterator _M_finish;
548 _Bit_pointer _M_end_of_storage;
551 _Bvector_impl_data() _GLIBCXX_NOEXCEPT
552 : _M_start(), _M_finish(), _M_end_of_storage()
555#if __cplusplus >= 201103L
556 _Bvector_impl_data(
const _Bvector_impl_data&) =
default;
559 operator=(
const _Bvector_impl_data&) =
default;
562 _Bvector_impl_data(_Bvector_impl_data&& __x) noexcept
563 : _Bvector_impl_data(__x)
568 _M_move_data(_Bvector_impl_data&& __x)
noexcept
577 _M_reset() _GLIBCXX_NOEXCEPT
578 { *
this = _Bvector_impl_data(); }
582 _M_swap_data(_Bvector_impl_data& __x) _GLIBCXX_NOEXCEPT
586 std::swap(*
this, __x);
591 :
public _Bit_alloc_type,
public _Bvector_impl_data
594 _Bvector_impl() _GLIBCXX_NOEXCEPT_IF(
595 is_nothrow_default_constructible<_Bit_alloc_type>::value)
596#if __cpp_concepts && __glibcxx_type_trait_variable_templates
597 requires is_default_constructible_v<_Bit_alloc_type>
603 _Bvector_impl(
const _Bit_alloc_type& __a) _GLIBCXX_NOEXCEPT
604 : _Bit_alloc_type(__a)
607#if __cplusplus >= 201103L
611 _Bvector_impl(_Bvector_impl&& __x) noexcept
616 _Bvector_impl(_Bit_alloc_type&& __a, _Bvector_impl&& __x) noexcept
623 _M_end_addr() const _GLIBCXX_NOEXCEPT
625 if (this->_M_end_of_storage)
632 typedef _Alloc allocator_type;
636 _M_get_Bit_allocator() _GLIBCXX_NOEXCEPT
637 {
return this->_M_impl; }
640 const _Bit_alloc_type&
641 _M_get_Bit_allocator() const _GLIBCXX_NOEXCEPT
642 {
return this->_M_impl; }
646 get_allocator() const _GLIBCXX_NOEXCEPT
647 {
return allocator_type(_M_get_Bit_allocator()); }
649#if __cplusplus >= 201103L
650 _Bvector_base() =
default;
656 _Bvector_base(
const allocator_type& __a)
657 : _M_impl(_Bit_alloc_type(__a)) { }
659#if __cplusplus >= 201103L
660 _Bvector_base(_Bvector_base&&) =
default;
663 _Bvector_base(_Bvector_base&& __x,
const allocator_type& __a) noexcept
664 : _M_impl(_Bit_alloc_type(__a),
std::move(__x._M_impl))
670 { this->_M_deallocate(); }
673 _Bvector_impl _M_impl;
677 _M_allocate(
size_t __n)
680#if __cpp_lib_is_constant_evaluated && __cpp_constexpr_dynamic_alloc
681 if (std::is_constant_evaluated())
684 for (
size_t __i = 0; __i < __n; ++__i)
695 if (_M_impl._M_start._M_p)
697 const size_t __n = _M_impl._M_end_addr() - _M_impl._M_start._M_p;
699 _M_impl._M_end_of_storage - __n,
705#if __cplusplus >= 201103L
708 _M_move_data(_Bvector_base&& __x)
noexcept
709 { _M_impl._M_move_data(
std::move(__x._M_impl)); }
716 {
return (__n +
int(_S_word_bit) - 1) / int(_S_word_bit); }
740 template<
typename _Alloc>
741 class vector<bool, _Alloc> :
protected _Bvector_base<_Alloc>
743 typedef _Bvector_base<_Alloc> _Base;
744 typedef typename _Base::_Bit_pointer _Bit_pointer;
745 typedef typename _Base::_Bit_alloc_traits _Bit_alloc_traits;
747#if __cplusplus >= 201103L
752 typedef bool value_type;
753 typedef size_t size_type;
754 typedef ptrdiff_t difference_type;
755 typedef _Bit_reference reference;
756 typedef bool const_reference;
757 typedef _Bit_reference* pointer;
758 typedef const bool* const_pointer;
759 typedef _Bit_iterator iterator;
760 typedef _Bit_const_iterator const_iterator;
763 typedef _Alloc allocator_type;
768 {
return _Base::get_allocator(); }
771 using _Base::_M_allocate;
772 using _Base::_M_deallocate;
773 using _Base::_S_nword;
774 using _Base::_M_get_Bit_allocator;
777#if __cplusplus >= 201103L
785 vector(
const allocator_type& __a)
788#if __cplusplus >= 201103L
791 vector(size_type __n,
const allocator_type& __a = allocator_type())
796 vector(size_type __n,
const bool& __value,
797 const allocator_type& __a = allocator_type())
800 vector(size_type __n,
const bool& __value =
bool(),
801 const allocator_type& __a = allocator_type())
805 _M_check_and_initialize(__n);
806 _M_initialize_value(__value);
811 : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator()))
813 const_iterator __xbegin = __x.
begin(), __xend = __x.
end();
814 _M_initialize(__x.
size());
815 _M_copy_aligned(__xbegin, __xend,
begin());
818#if __cplusplus >= 201103L
819 vector(vector&&) =
default;
835 _M_initialize(__x.
size());
836 _M_copy_aligned(__x.
begin(), __x.
end(), begin());
843 vector(vector&& __x,
const __type_identity_t<allocator_type>& __a)
844 noexcept(_Bit_alloc_traits::_S_always_equal())
850 vector(
const vector& __x,
const __type_identity_t<allocator_type>& __a)
853 _M_initialize(__x.
size());
854 _M_copy_aligned(__x.
begin(), __x.
end(), begin());
859 const allocator_type& __a = allocator_type())
862 _M_initialize_range(__l.begin(), __l.end(),
867#if __cplusplus >= 201103L
868 template<
typename _InputIterator,
869 typename = std::_RequireInputIter<_InputIterator>>
871 vector(_InputIterator __first, _InputIterator __last,
872 const allocator_type& __a = allocator_type())
875 _M_initialize_range(__first, __last,
879 template<
typename _InputIterator>
880 vector(_InputIterator __first, _InputIterator __last,
881 const allocator_type& __a = allocator_type())
885 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
886 _M_initialize_dispatch(__first, __last, _Integral());
891 ~vector() _GLIBCXX_NOEXCEPT { }
899#if __cplusplus >= 201103L
900 if (_Bit_alloc_traits::_S_propagate_on_copy_assign())
902 if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator())
904 this->_M_deallocate();
905 std::__alloc_on_copy(_M_get_Bit_allocator(),
906 __x._M_get_Bit_allocator());
907 _M_initialize(__x.
size());
910 std::__alloc_on_copy(_M_get_Bit_allocator(),
911 __x._M_get_Bit_allocator());
914 if (__x.
size() > capacity())
916 this->_M_deallocate();
917 _M_initialize(__x.
size());
919 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
924#if __cplusplus >= 201103L
927 operator=(vector&& __x)
noexcept(_Bit_alloc_traits::_S_nothrow_move())
929 if (_Bit_alloc_traits::_S_propagate_on_move_assign()
930 || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator())
932 this->_M_deallocate();
934 std::__alloc_on_move(_M_get_Bit_allocator(),
935 __x._M_get_Bit_allocator());
939 if (__x.
size() > capacity())
941 this->_M_deallocate();
942 _M_initialize(__x.
size());
944 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
955 this->
assign(__l.begin(), __l.end());
966 assign(size_type __n,
const bool& __x)
967 { _M_fill_assign(__n, __x); }
969#if __cplusplus >= 201103L
970 template<
typename _InputIterator,
971 typename = std::_RequireInputIter<_InputIterator>>
974 assign(_InputIterator __first, _InputIterator __last)
977 template<
typename _InputIterator>
979 assign(_InputIterator __first, _InputIterator __last)
982 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
983 _M_assign_dispatch(__first, __last, _Integral());
987#if __cplusplus >= 201103L
994 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
996 begin() _GLIBCXX_NOEXCEPT
997 {
return iterator(this->_M_impl._M_start._M_p, 0); }
999 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1001 begin()
const _GLIBCXX_NOEXCEPT
1002 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
1004 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1006 end() _GLIBCXX_NOEXCEPT
1007 {
return this->_M_impl._M_finish; }
1009 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1011 end()
const _GLIBCXX_NOEXCEPT
1012 {
return this->_M_impl._M_finish; }
1014 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1016 rbegin() _GLIBCXX_NOEXCEPT
1017 {
return reverse_iterator(
end()); }
1019 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1020 const_reverse_iterator
1021 rbegin()
const _GLIBCXX_NOEXCEPT
1022 {
return const_reverse_iterator(
end()); }
1024 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1026 rend() _GLIBCXX_NOEXCEPT
1027 {
return reverse_iterator(
begin()); }
1029 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1030 const_reverse_iterator
1031 rend()
const _GLIBCXX_NOEXCEPT
1032 {
return const_reverse_iterator(
begin()); }
1034#if __cplusplus >= 201103L
1035 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1038 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
1040 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1042 cend()
const noexcept
1043 {
return this->_M_impl._M_finish; }
1045 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1046 const_reverse_iterator
1048 {
return const_reverse_iterator(
end()); }
1050 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1051 const_reverse_iterator
1052 crend()
const noexcept
1053 {
return const_reverse_iterator(
begin()); }
1056 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1058 size()
const _GLIBCXX_NOEXCEPT
1059 {
return size_type(
end() -
begin()); }
1061 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1065 const size_type __isize =
1066 __gnu_cxx::__numeric_traits<difference_type>::__max
1067 - int(_S_word_bit) + 1;
1068 const size_type __asize
1070 return (__asize <= __isize /
int(_S_word_bit)
1071 ? __asize *
int(_S_word_bit) : __isize);
1074 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1077 {
return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
1080 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1082 empty()
const _GLIBCXX_NOEXCEPT
1085 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1088 {
return begin()[__n]; }
1090 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1093 {
return begin()[__n]; }
1096 _GLIBCXX20_CONSTEXPR
1100 if (__n >= this->
size())
1101 __throw_out_of_range_fmt(__N(
"vector<bool>::_M_range_check: __n "
1102 "(which is %zu) >= this->size() "
1108 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1113 return (*
this)[__n];
1116 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1118 at(size_type __n)
const
1121 return (*
this)[__n];
1124 _GLIBCXX20_CONSTEXPR
1129 __throw_length_error(__N(
"vector::reserve"));
1134 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1137 {
return *
begin(); }
1139 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1142 {
return *
begin(); }
1144 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1147 {
return *(
end() - 1); }
1149 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1152 {
return *(
end() - 1); }
1154 _GLIBCXX20_CONSTEXPR
1158 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1159 *this->_M_impl._M_finish++ = __x;
1161 _M_insert_aux(
end(), __x);
1164 _GLIBCXX20_CONSTEXPR
1166 swap(vector& __x) _GLIBCXX_NOEXCEPT
1168#if __cplusplus >= 201103L
1169 __glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value
1170 || _M_get_Bit_allocator() == __x._M_get_Bit_allocator());
1172 this->_M_impl._M_swap_data(__x._M_impl);
1173 _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(),
1174 __x._M_get_Bit_allocator());
1178 _GLIBCXX20_CONSTEXPR
1180 swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT
1187 _GLIBCXX20_CONSTEXPR
1189#if __cplusplus >= 201103L
1190 insert(const_iterator __position,
const bool& __x)
1192 insert(iterator __position,
const bool& __x)
1195 const difference_type __n = __position -
begin();
1196 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()
1197 && __position == end())
1198 *this->_M_impl._M_finish++ = __x;
1200 _M_insert_aux(__position._M_const_cast(), __x);
1201 return begin() + __n;
1204#if _GLIBCXX_USE_DEPRECATED
1205 _GLIBCXX_DEPRECATED_SUGGEST(
"insert(position, false)")
1207 insert(const_iterator __position)
1208 {
return this->
insert(__position._M_const_cast(),
false); }
1211#if __cplusplus >= 201103L
1212 template<
typename _InputIterator,
1213 typename = std::_RequireInputIter<_InputIterator>>
1214 _GLIBCXX20_CONSTEXPR
1216 insert(const_iterator __position,
1217 _InputIterator __first, _InputIterator __last)
1219 difference_type __offset = __position -
cbegin();
1220 _M_insert_range(__position._M_const_cast(),
1223 return begin() + __offset;
1226 template<
typename _InputIterator>
1228 insert(iterator __position,
1229 _InputIterator __first, _InputIterator __last)
1232 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1233 _M_insert_dispatch(__position, __first, __last, _Integral());
1237#if __cplusplus >= 201103L
1238 _GLIBCXX20_CONSTEXPR
1240 insert(const_iterator __position, size_type __n,
const bool& __x)
1242 difference_type __offset = __position -
cbegin();
1243 _M_fill_insert(__position._M_const_cast(), __n, __x);
1244 return begin() + __offset;
1248 insert(iterator __position, size_type __n,
const bool& __x)
1249 { _M_fill_insert(__position, __n, __x); }
1252#if __cplusplus >= 201103L
1253 _GLIBCXX20_CONSTEXPR
1256 {
return this->
insert(__p, __l.begin(), __l.end()); }
1259 _GLIBCXX20_CONSTEXPR
1262 { --this->_M_impl._M_finish; }
1264 _GLIBCXX20_CONSTEXPR
1266#if __cplusplus >= 201103L
1267 erase(const_iterator __position)
1269 erase(iterator __position)
1271 {
return _M_erase(__position._M_const_cast()); }
1273 _GLIBCXX20_CONSTEXPR
1275#if __cplusplus >= 201103L
1276 erase(const_iterator __first, const_iterator __last)
1278 erase(iterator __first, iterator __last)
1280 {
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
1282 _GLIBCXX20_CONSTEXPR
1284 resize(size_type __new_size,
bool __x =
bool())
1286 if (__new_size <
size())
1287 _M_erase_at_end(
begin() + difference_type(__new_size));
1292#if __cplusplus >= 201103L
1293 _GLIBCXX20_CONSTEXPR
1296 { _M_shrink_to_fit(); }
1299 _GLIBCXX20_CONSTEXPR
1301 flip() _GLIBCXX_NOEXCEPT
1303 _Bit_type *
const __end = this->_M_impl._M_end_addr();
1304 for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p)
1308 _GLIBCXX20_CONSTEXPR
1310 clear() _GLIBCXX_NOEXCEPT
1311 { _M_erase_at_end(
begin()); }
1313#if __cplusplus >= 201103L
1314 template<
typename... _Args>
1315#if __cplusplus > 201402L
1316 _GLIBCXX20_CONSTEXPR
1321 emplace_back(_Args&&... __args)
1324#if __cplusplus > 201402L
1329 template<
typename... _Args>
1330 _GLIBCXX20_CONSTEXPR
1332 emplace(const_iterator __pos, _Args&&... __args)
1338 _GLIBCXX20_CONSTEXPR
1340 _M_copy_aligned(const_iterator __first, const_iterator __last,
1343 _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p);
1344 return std::copy(const_iterator(__last._M_p, 0), __last,
1348 _GLIBCXX20_CONSTEXPR
1350 _M_initialize(size_type __n)
1353 _GLIBCXX_DEBUG_ASSERT(__n <= (
size_t)-_S_word_bit);
1357 _Bit_pointer __q = this->_M_allocate(__n);
1358 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1360 this->_M_impl._M_start = __start;
1361 this->_M_impl._M_finish = __start + difference_type(__n);
1365 template<
typename _SizeT>
1366 _GLIBCXX20_CONSTEXPR
1368 _M_check_and_initialize(_SizeT __n)
1371 __throw_length_error(
1372 __N(
"Cannot create std::vector<bool> larger than max_size()"));
1373 _M_initialize(
static_cast<size_type
>(__n));
1376 _GLIBCXX20_CONSTEXPR
1378 _M_initialize_value(
bool __x) _GLIBCXX_NOEXCEPT
1380 if (_Bit_type* __p = this->_M_impl._M_start._M_p)
1381 __fill_bvector_n(__p, this->_M_impl._M_end_addr() - __p, __x);
1384 _GLIBCXX20_CONSTEXPR
1386 _M_reallocate(size_type __n);
1388#if __cplusplus >= 201103L
1389 _GLIBCXX20_CONSTEXPR
1394#if __cplusplus < 201103L
1397 template<
typename _Integer>
1399 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1401 _M_check_and_initialize(
static_cast<size_type
>(__n));
1402 _M_initialize_value(__x);
1405 template<
typename _InputIterator>
1407 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1409 { _M_initialize_range(__first, __last,
1413 template<
typename _InputIterator>
1414 _GLIBCXX20_CONSTEXPR
1416 _M_initialize_range(_InputIterator __first, _InputIterator __last,
1419 for (; __first != __last; ++__first)
1423 template<
typename _ForwardIterator>
1424 _GLIBCXX20_CONSTEXPR
1426 _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
1430 std::copy(__first, __last,
begin());
1433#if __cplusplus < 201103L
1436 template<
typename _Integer>
1438 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1439 { _M_fill_assign(__n, __val); }
1441 template<
class _InputIterator>
1443 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1448 _GLIBCXX20_CONSTEXPR
1450 _M_fill_assign(
size_t __n,
bool __x)
1454 _M_initialize_value(__x);
1459 _M_erase_at_end(
begin() + __n);
1460 _M_initialize_value(__x);
1464 template<
typename _InputIterator>
1465 _GLIBCXX20_CONSTEXPR
1467 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1470 iterator __cur =
begin();
1471 for (; __first != __last && __cur !=
end(); ++__cur, (void)++__first)
1473 if (__first == __last)
1474 _M_erase_at_end(__cur);
1479 template<
typename _ForwardIterator>
1480 _GLIBCXX20_CONSTEXPR
1482 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1487 _M_erase_at_end(std::copy(__first, __last,
begin()));
1490 _ForwardIterator __mid = __first;
1492 std::copy(__first, __mid,
begin());
1497#if __cplusplus < 201103L
1500 template<
typename _Integer>
1502 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
1504 { _M_fill_insert(__pos, __n, __x); }
1506 template<
typename _InputIterator>
1508 _M_insert_dispatch(iterator __pos,
1509 _InputIterator __first, _InputIterator __last,
1511 { _M_insert_range(__pos, __first, __last,
1515 _GLIBCXX20_CONSTEXPR
1517 _M_fill_insert(iterator __position, size_type __n,
bool __x);
1519 template<
typename _InputIterator>
1520 _GLIBCXX20_CONSTEXPR
1522 _M_insert_range(iterator __pos, _InputIterator __first,
1525 for (; __first != __last; ++__first)
1527 __pos =
insert(__pos, *__first);
1532 template<
typename _ForwardIterator>
1533 _GLIBCXX20_CONSTEXPR
1535 _M_insert_range(iterator __position, _ForwardIterator __first,
1538 _GLIBCXX20_CONSTEXPR
1540 _M_insert_aux(iterator __position,
bool __x);
1542 _GLIBCXX20_CONSTEXPR
1544 _M_check_len(size_type __n,
const char* __s)
const
1547 __throw_length_error(__N(__s));
1553 _GLIBCXX20_CONSTEXPR
1555 _M_erase_at_end(iterator __pos)
1556 { this->_M_impl._M_finish = __pos; }
1558 _GLIBCXX20_CONSTEXPR
1560 _M_erase(iterator __pos);
1562 _GLIBCXX20_CONSTEXPR
1564 _M_erase(iterator __first, iterator __last);
1572#if __cplusplus >= 201103L
1573 void data() =
delete;
1579_GLIBCXX_END_NAMESPACE_CONTAINER
1582 _GLIBCXX20_CONSTEXPR
1584 __fill_bvector(_Bit_type* __v,
unsigned int __first,
unsigned int __last,
1585 bool __x) _GLIBCXX_NOEXCEPT
1587 const _Bit_type __fmask = ~0ul << __first;
1588 const _Bit_type __lmask = ~0ul >> (_S_word_bit - __last);
1589 const _Bit_type __mask = __fmask & __lmask;
1598 __attribute__((__nonnull__))
1599 _GLIBCXX20_CONSTEXPR
1601 __fill_bvector_n(_Bit_type* __p,
size_t __n,
bool __x) _GLIBCXX_NOEXCEPT
1603#if __cpp_lib_is_constant_evaluated
1604 if (std::is_constant_evaluated())
1606 for (
size_t __i = 0; __i < __n; ++__i)
1607 __p[__i] = __x ? ~0ul : 0ul;
1611 __builtin_memset(__p, __x ? ~0 : 0, __n *
sizeof(_Bit_type));
1615 _GLIBCXX20_CONSTEXPR
1617 __fill_a1(_GLIBCXX_STD_C::_Bit_iterator __first,
1618 _GLIBCXX_STD_C::_Bit_iterator __last,
const bool& __x)
1620 if (__first._M_p != __last._M_p)
1622 _Bit_type* __first_p = __first._M_p;
1623 if (__first._M_offset != 0)
1624 __fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x);
1626 __fill_bvector_n(__first_p, __last._M_p - __first_p, __x);
1628 if (__last._M_offset != 0)
1629 __fill_bvector(__last._M_p, 0, __last._M_offset, __x);
1631 else if (__first._M_offset != __last._M_offset)
1632 __fill_bvector(__first._M_p, __first._M_offset, __last._M_offset, __x);
1635#if __cplusplus >= 201103L
1638 template<
typename _Alloc>
1640 :
public __hash_base<size_t, _GLIBCXX_STD_C::vector<bool, _Alloc>>
1643 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>&)
const noexcept;
1647_GLIBCXX_END_NAMESPACE_VERSION
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr _Tp * to_address(_Tp *__ptr) noexcept
Obtain address referenced by a pointer to an object.
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
Primary class template hash.
typename __detected_or_t< is_empty< _Bit_alloc_type >, __equal, _Bit_alloc_type >::type is_always_equal
Forward iterators support a superset of input iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.
ptrdiff_t difference_type
A standard container which offers fixed time access to individual elements in any order.
constexpr iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into vector before specified iterator.
constexpr void push_back(const value_type &__x)
Add data to the end of the vector.
constexpr reverse_iterator rbegin() noexcept
constexpr iterator end() noexcept
vector()=default
Creates a vector with no elements.
constexpr iterator emplace(const_iterator __position, _Args &&... __args)
Inserts an object in vector before specified iterator.
constexpr iterator begin() noexcept
constexpr size_type capacity() const noexcept
constexpr ~vector() noexcept
constexpr void assign(size_type __n, const value_type &__val)
Assigns a given value to a vector.
constexpr void swap(vector &__x) noexcept
Swaps data with another vector.
constexpr _Tp * data() noexcept
constexpr void pop_back() noexcept
Removes last element.
constexpr void reserve(size_type __n)
Attempt to preallocate enough memory for specified number of elements.
constexpr reference at(size_type __n)
Provides access to the data contained in the vector.
constexpr void resize(size_type __new_size)
Resizes the vector to the specified number of elements.
constexpr void _M_range_check(size_type __n) const
Safety check used only from at().
constexpr reference front() noexcept
constexpr iterator erase(const_iterator __position)
Remove element at given position.
constexpr bool empty() const noexcept
constexpr reverse_iterator rend() noexcept
constexpr const_reverse_iterator crbegin() const noexcept
constexpr const_iterator cbegin() const noexcept
constexpr void clear() noexcept
constexpr allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
constexpr size_type size() const noexcept
constexpr vector & operator=(const vector &__x)
Vector assignment operator.
constexpr reference back() noexcept
constexpr const_reverse_iterator crend() const noexcept
constexpr const_iterator cend() const noexcept
constexpr reference operator[](size_type __n) noexcept
Subscript access to the data contained in the vector.
constexpr void shrink_to_fit()
constexpr size_type max_size() const noexcept
static constexpr pointer allocate(_Bit_alloc_type &__a, size_type __n)
static constexpr void deallocate(_Bit_alloc_type &__a, pointer __p, size_type __n)
static constexpr size_type max_size(const _Bit_alloc_type &__a) noexcept