57#define _STL_BVECTOR_H 1
59#if __cplusplus >= 201103L
64namespace std _GLIBCXX_VISIBILITY(default)
66_GLIBCXX_BEGIN_NAMESPACE_VERSION
68 typedef unsigned long _Bit_type;
69 enum { _S_word_bit = int(__CHAR_BIT__ *
sizeof(_Bit_type)) };
71 __attribute__((__nonnull__))
74 __fill_bvector_n(_Bit_type*,
size_t,
bool) _GLIBCXX_NOEXCEPT;
76_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
84 _Bit_reference(_Bit_type * __x, _Bit_type __y)
85 : _M_p(__x), _M_mask(__y) { }
88 _Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { }
90#if __cplusplus >= 201103L
91 _Bit_reference(
const _Bit_reference&) =
default;
94 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
95 operator bool() const _GLIBCXX_NOEXCEPT
96 {
return !!(*_M_p & _M_mask); }
100 operator=(
bool __x) _GLIBCXX_NOEXCEPT
109#if __cplusplus > 202002L
110 constexpr const _Bit_reference&
111 operator=(
bool __x)
const noexcept
123 operator=(
const _Bit_reference& __x) _GLIBCXX_NOEXCEPT
124 {
return *
this = bool(__x); }
126 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
128 operator==(
const _Bit_reference& __x)
const
129 {
return bool(*
this) == bool(__x); }
131 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
133 operator<(
const _Bit_reference& __x)
const
134 {
return !bool(*
this) && bool(__x); }
138 flip() _GLIBCXX_NOEXCEPT
139 { *_M_p ^= _M_mask; }
141#if __cplusplus >= 201103L
144 swap(_Bit_reference __x, _Bit_reference __y)
noexcept
153 swap(_Bit_reference __x,
bool& __y)
noexcept
162 swap(
bool& __x, _Bit_reference __y)
noexcept
172#pragma GCC diagnostic push
173#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
174 struct _Bit_iterator_base
175 :
public std::iterator<std::random_access_iterator_tag, bool>
178 unsigned int _M_offset;
181 _Bit_iterator_base(_Bit_type * __x,
unsigned int __y)
182 : _M_p(__x), _M_offset(__y) { }
188 if (_M_offset++ ==
int(_S_word_bit) - 1)
199 if (_M_offset-- == 0)
201 _M_offset = int(_S_word_bit) - 1;
208 _M_incr(ptrdiff_t __i)
211 _M_p += __n / int(_S_word_bit);
212 __n = __n % int(_S_word_bit);
215 __n += int(_S_word_bit);
218 _M_offset =
static_cast<unsigned int>(__n);
222 friend _GLIBCXX20_CONSTEXPR
bool
223 operator==(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
224 {
return __x._M_p == __y._M_p && __x._M_offset == __y._M_offset; }
226#if __cpp_lib_three_way_comparison
228 friend constexpr strong_ordering
229 operator<=>(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
232 if (
const auto __cmp = __x._M_p <=> __y._M_p; __cmp != 0)
234 return __x._M_offset <=> __y._M_offset;
239 operator<(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
241 return __x._M_p < __y._M_p
242 || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset);
247 operator!=(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
248 {
return !(__x == __y); }
252 operator>(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
253 {
return __y < __x; }
257 operator<=(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
258 {
return !(__y < __x); }
262 operator>=(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
263 {
return !(__x < __y); }
266 friend _GLIBCXX20_CONSTEXPR ptrdiff_t
267 operator-(
const _Bit_iterator_base& __x,
const _Bit_iterator_base& __y)
269 return (
int(_S_word_bit) * (__x._M_p - __y._M_p)
270 + __x._M_offset - __y._M_offset);
273#pragma GCC diagnostic pop
275 struct _Bit_iterator :
public _Bit_iterator_base
277 typedef _Bit_reference reference;
278#if __cplusplus > 201703L
279 typedef void pointer;
281 typedef _Bit_reference* pointer;
283 typedef _Bit_iterator iterator;
286 _Bit_iterator() : _Bit_iterator_base(0, 0) { }
289 _Bit_iterator(_Bit_type * __x,
unsigned int __y)
290 : _Bit_iterator_base(__x, __y) { }
294 _M_const_cast()
const
297 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
300 {
return reference(_M_p, 1UL << _M_offset); }
314 iterator __tmp = *
this;
331 iterator __tmp = *
this;
338 operator+=(difference_type __i)
346 operator-=(difference_type __i)
352 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
354 operator[](difference_type __i)
const
355 {
return *(*
this + __i); }
358 friend _GLIBCXX20_CONSTEXPR iterator
359 operator+(
const iterator& __x, difference_type __n)
361 iterator __tmp = __x;
367 friend _GLIBCXX20_CONSTEXPR iterator
368 operator+(difference_type __n,
const iterator& __x)
369 {
return __x + __n; }
372 friend _GLIBCXX20_CONSTEXPR iterator
373 operator-(
const iterator& __x, difference_type __n)
375 iterator __tmp = __x;
381 struct _Bit_const_iterator :
public _Bit_iterator_base
383 typedef bool reference;
384 typedef bool const_reference;
385#if __cplusplus > 201703L
386 typedef void pointer;
388 typedef const bool* pointer;
390 typedef _Bit_const_iterator const_iterator;
393 _Bit_const_iterator() : _Bit_iterator_base(0, 0) { }
396 _Bit_const_iterator(_Bit_type * __x,
unsigned int __y)
397 : _Bit_iterator_base(__x, __y) { }
400 _Bit_const_iterator(
const _Bit_iterator& __x)
401 : _Bit_iterator_base(__x._M_p, __x._M_offset) { }
405 _M_const_cast()
const
406 {
return _Bit_iterator(_M_p, _M_offset); }
408 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
411 {
return _Bit_reference(_M_p, 1UL << _M_offset); }
425 const_iterator __tmp = *
this;
442 const_iterator __tmp = *
this;
449 operator+=(difference_type __i)
457 operator-=(difference_type __i)
463 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
465 operator[](difference_type __i)
const
466 {
return *(*
this + __i); }
469 friend _GLIBCXX20_CONSTEXPR const_iterator
470 operator+(
const const_iterator& __x, difference_type __n)
472 const_iterator __tmp = __x;
478 friend _GLIBCXX20_CONSTEXPR const_iterator
479 operator-(
const const_iterator& __x, difference_type __n)
481 const_iterator __tmp = __x;
487 friend _GLIBCXX20_CONSTEXPR const_iterator
488 operator+(difference_type __n,
const const_iterator& __x)
489 {
return __x + __n; }
492 template<
typename _Alloc>
496 rebind<_Bit_type>::other _Bit_alloc_type;
499 typedef typename _Bit_alloc_traits::pointer _Bit_pointer;
501 struct _Bvector_impl_data
503#if !_GLIBCXX_INLINE_VERSION
504 _Bit_iterator _M_start;
511 void operator=(_Bit_iterator __it) { _M_p = __it._M_p; }
514 _Bit_iterator _M_finish;
515 _Bit_pointer _M_end_of_storage;
518 _Bvector_impl_data() _GLIBCXX_NOEXCEPT
519 : _M_start(), _M_finish(), _M_end_of_storage()
522#if __cplusplus >= 201103L
523 _Bvector_impl_data(
const _Bvector_impl_data&) =
default;
526 operator=(
const _Bvector_impl_data&) =
default;
529 _Bvector_impl_data(_Bvector_impl_data&& __x) noexcept
530 : _Bvector_impl_data(__x)
535 _M_move_data(_Bvector_impl_data&& __x)
noexcept
544 _M_reset() _GLIBCXX_NOEXCEPT
545 { *
this = _Bvector_impl_data(); }
549 _M_swap_data(_Bvector_impl_data& __x) _GLIBCXX_NOEXCEPT
558 :
public _Bit_alloc_type,
public _Bvector_impl_data
561 _Bvector_impl() _GLIBCXX_NOEXCEPT_IF(
562 is_nothrow_default_constructible<_Bit_alloc_type>::value)
567 _Bvector_impl(
const _Bit_alloc_type& __a) _GLIBCXX_NOEXCEPT
568 : _Bit_alloc_type(__a)
571#if __cplusplus >= 201103L
575 _Bvector_impl(_Bvector_impl&& __x) noexcept
580 _Bvector_impl(_Bit_alloc_type&& __a, _Bvector_impl&& __x) noexcept
587 _M_end_addr() const _GLIBCXX_NOEXCEPT
589 if (this->_M_end_of_storage)
596 typedef _Alloc allocator_type;
600 _M_get_Bit_allocator() _GLIBCXX_NOEXCEPT
601 {
return this->_M_impl; }
604 const _Bit_alloc_type&
605 _M_get_Bit_allocator() const _GLIBCXX_NOEXCEPT
606 {
return this->_M_impl; }
610 get_allocator() const _GLIBCXX_NOEXCEPT
611 {
return allocator_type(_M_get_Bit_allocator()); }
613#if __cplusplus >= 201103L
614 _Bvector_base() =
default;
620 _Bvector_base(
const allocator_type& __a)
623#if __cplusplus >= 201103L
624 _Bvector_base(_Bvector_base&&) =
default;
627 _Bvector_base(_Bvector_base&& __x,
const allocator_type& __a) noexcept
628 : _M_impl(_Bit_alloc_type(__a),
std::move(__x._M_impl))
634 { this->_M_deallocate(); }
637 _Bvector_impl _M_impl;
641 _M_allocate(
size_t __n)
644#if __cpp_lib_is_constant_evaluated
648 for (
size_t __i = 0; __i < __n; ++__i)
659 if (_M_impl._M_start._M_p)
661 const size_t __n = _M_impl._M_end_addr() - _M_impl._M_start._M_p;
663 _M_impl._M_end_of_storage - __n,
669#if __cplusplus >= 201103L
672 _M_move_data(_Bvector_base&& __x)
noexcept
673 { _M_impl._M_move_data(
std::move(__x._M_impl)); }
679 {
return (__n +
int(_S_word_bit) - 1) / int(_S_word_bit); }
703 template<
typename _Alloc>
704 class vector<bool, _Alloc> :
protected _Bvector_base<_Alloc>
706 typedef _Bvector_base<_Alloc> _Base;
707 typedef typename _Base::_Bit_pointer _Bit_pointer;
710#if __cplusplus >= 201103L
715 typedef bool value_type;
716 typedef size_t size_type;
717 typedef ptrdiff_t difference_type;
718 typedef _Bit_reference reference;
719 typedef bool const_reference;
720 typedef _Bit_reference* pointer;
721 typedef const bool* const_pointer;
722 typedef _Bit_iterator iterator;
723 typedef _Bit_const_iterator const_iterator;
726 typedef _Alloc allocator_type;
731 {
return _Base::get_allocator(); }
734 using _Base::_M_allocate;
735 using _Base::_M_deallocate;
736 using _Base::_S_nword;
737 using _Base::_M_get_Bit_allocator;
740#if __cplusplus >= 201103L
748 vector(
const allocator_type& __a)
751#if __cplusplus >= 201103L
754 vector(size_type __n,
const allocator_type& __a = allocator_type())
759 vector(size_type __n,
const bool& __value,
760 const allocator_type& __a = allocator_type())
763 vector(size_type __n,
const bool& __value =
bool(),
764 const allocator_type& __a = allocator_type())
769 _M_initialize_value(__value);
774 : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator()))
776 _M_initialize(__x.
size());
780#if __cplusplus >= 201103L
797 _M_initialize(__x.
size());
805 vector(
vector&& __x,
const __type_identity_t<allocator_type>& __a)
806 noexcept(_Bit_alloc_traits::_S_always_equal())
812 vector(
const vector& __x,
const __type_identity_t<allocator_type>& __a)
815 _M_initialize(__x.
size());
821 const allocator_type& __a = allocator_type())
824 _M_initialize_range(__l.begin(), __l.end(),
829#if __cplusplus >= 201103L
830 template<
typename _InputIterator,
831 typename = std::_RequireInputIter<_InputIterator>>
833 vector(_InputIterator __first, _InputIterator __last,
834 const allocator_type& __a = allocator_type())
837 _M_initialize_range(__first, __last,
841 template<
typename _InputIterator>
842 vector(_InputIterator __first, _InputIterator __last,
843 const allocator_type& __a = allocator_type())
847 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
848 _M_initialize_dispatch(__first, __last, _Integral());
853 ~vector() _GLIBCXX_NOEXCEPT { }
861#if __cplusplus >= 201103L
862 if (_Bit_alloc_traits::_S_propagate_on_copy_assign())
864 if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator())
866 this->_M_deallocate();
867 std::__alloc_on_copy(_M_get_Bit_allocator(),
868 __x._M_get_Bit_allocator());
869 _M_initialize(__x.
size());
872 std::__alloc_on_copy(_M_get_Bit_allocator(),
873 __x._M_get_Bit_allocator());
878 this->_M_deallocate();
879 _M_initialize(__x.
size());
881 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
886#if __cplusplus >= 201103L
891 if (_Bit_alloc_traits::_S_propagate_on_move_assign()
892 || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator())
894 this->_M_deallocate();
896 std::__alloc_on_move(_M_get_Bit_allocator(),
897 __x._M_get_Bit_allocator());
903 this->_M_deallocate();
904 _M_initialize(__x.
size());
906 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
917 this->
assign(__l.begin(), __l.end());
928 assign(size_type __n,
const bool& __x)
929 { _M_fill_assign(__n, __x); }
931#if __cplusplus >= 201103L
932 template<
typename _InputIterator,
933 typename = std::_RequireInputIter<_InputIterator>>
936 assign(_InputIterator __first, _InputIterator __last)
939 template<
typename _InputIterator>
941 assign(_InputIterator __first, _InputIterator __last)
944 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
945 _M_assign_dispatch(__first, __last, _Integral());
949#if __cplusplus >= 201103L
956 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
958 begin() _GLIBCXX_NOEXCEPT
959 {
return iterator(this->_M_impl._M_start._M_p, 0); }
961 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
963 begin()
const _GLIBCXX_NOEXCEPT
964 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
966 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
968 end() _GLIBCXX_NOEXCEPT
969 {
return this->_M_impl._M_finish; }
971 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
973 end()
const _GLIBCXX_NOEXCEPT
974 {
return this->_M_impl._M_finish; }
976 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
978 rbegin() _GLIBCXX_NOEXCEPT
981 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
983 rbegin()
const _GLIBCXX_NOEXCEPT
986 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
988 rend() _GLIBCXX_NOEXCEPT
991 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
993 rend()
const _GLIBCXX_NOEXCEPT
996#if __cplusplus >= 201103L
997 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1000 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
1002 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1004 cend()
const noexcept
1005 {
return this->_M_impl._M_finish; }
1007 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1012 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1014 crend()
const noexcept
1018 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1020 size()
const _GLIBCXX_NOEXCEPT
1021 {
return size_type(
end() -
begin()); }
1023 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1027 const size_type __isize =
1028 __gnu_cxx::__numeric_traits<difference_type>::__max
1029 - int(_S_word_bit) + 1;
1030 const size_type __asize
1031 = _Bit_alloc_traits::max_size(_M_get_Bit_allocator());
1032 return (__asize <= __isize /
int(_S_word_bit)
1033 ? __asize *
int(_S_word_bit) : __isize);
1036 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1039 {
return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
1042 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1044 empty()
const _GLIBCXX_NOEXCEPT
1047 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1050 {
return begin()[__n]; }
1052 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1055 {
return begin()[__n]; }
1058 _GLIBCXX20_CONSTEXPR
1062 if (__n >= this->
size())
1063 __throw_out_of_range_fmt(__N(
"vector<bool>::_M_range_check: __n "
1064 "(which is %zu) >= this->size() "
1070 _GLIBCXX20_CONSTEXPR
1075 return (*
this)[__n];
1078 _GLIBCXX20_CONSTEXPR
1080 at(size_type __n)
const
1083 return (*
this)[__n];
1086 _GLIBCXX20_CONSTEXPR
1091 __throw_length_error(__N(
"vector::reserve"));
1096 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1099 {
return *
begin(); }
1101 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1104 {
return *
begin(); }
1106 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1109 {
return *(
end() - 1); }
1111 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1114 {
return *(
end() - 1); }
1116 _GLIBCXX20_CONSTEXPR
1120 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1121 *this->_M_impl._M_finish++ = __x;
1123 _M_insert_aux(
end(), __x);
1126 _GLIBCXX20_CONSTEXPR
1130#if __cplusplus >= 201103L
1131 __glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value
1132 || _M_get_Bit_allocator() == __x._M_get_Bit_allocator());
1134 this->_M_impl._M_swap_data(__x._M_impl);
1135 _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(),
1136 __x._M_get_Bit_allocator());
1140 _GLIBCXX20_CONSTEXPR
1142 swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT
1149 _GLIBCXX20_CONSTEXPR
1151#if __cplusplus >= 201103L
1152 insert(const_iterator __position,
const bool& __x)
1154 insert(iterator __position,
const bool& __x)
1157 const difference_type __n = __position -
begin();
1158 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()
1159 && __position ==
end())
1160 *this->_M_impl._M_finish++ = __x;
1162 _M_insert_aux(__position._M_const_cast(), __x);
1163 return begin() + __n;
1166#if _GLIBCXX_USE_DEPRECATED
1167 _GLIBCXX_DEPRECATED_SUGGEST(
"insert(position, false)")
1169 insert(const_iterator __position)
1170 {
return this->
insert(__position._M_const_cast(),
false); }
1173#if __cplusplus >= 201103L
1174 template<
typename _InputIterator,
1175 typename = std::_RequireInputIter<_InputIterator>>
1176 _GLIBCXX20_CONSTEXPR
1178 insert(const_iterator __position,
1179 _InputIterator __first, _InputIterator __last)
1181 difference_type __offset = __position -
cbegin();
1182 _M_insert_range(__position._M_const_cast(),
1185 return begin() + __offset;
1188 template<
typename _InputIterator>
1190 insert(iterator __position,
1191 _InputIterator __first, _InputIterator __last)
1194 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1195 _M_insert_dispatch(__position, __first, __last, _Integral());
1199#if __cplusplus >= 201103L
1200 _GLIBCXX20_CONSTEXPR
1202 insert(const_iterator __position, size_type __n,
const bool& __x)
1204 difference_type __offset = __position -
cbegin();
1205 _M_fill_insert(__position._M_const_cast(), __n, __x);
1206 return begin() + __offset;
1210 insert(iterator __position, size_type __n,
const bool& __x)
1211 { _M_fill_insert(__position, __n, __x); }
1214#if __cplusplus >= 201103L
1215 _GLIBCXX20_CONSTEXPR
1218 {
return this->
insert(__p, __l.begin(), __l.end()); }
1221 _GLIBCXX20_CONSTEXPR
1224 { --this->_M_impl._M_finish; }
1226 _GLIBCXX20_CONSTEXPR
1228#if __cplusplus >= 201103L
1229 erase(const_iterator __position)
1231 erase(iterator __position)
1233 {
return _M_erase(__position._M_const_cast()); }
1235 _GLIBCXX20_CONSTEXPR
1237#if __cplusplus >= 201103L
1238 erase(const_iterator __first, const_iterator __last)
1240 erase(iterator __first, iterator __last)
1242 {
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
1244 _GLIBCXX20_CONSTEXPR
1246 resize(size_type __new_size,
bool __x =
bool())
1248 if (__new_size <
size())
1249 _M_erase_at_end(
begin() + difference_type(__new_size));
1254#if __cplusplus >= 201103L
1255 _GLIBCXX20_CONSTEXPR
1258 { _M_shrink_to_fit(); }
1261 _GLIBCXX20_CONSTEXPR
1263 flip() _GLIBCXX_NOEXCEPT
1265 _Bit_type *
const __end = this->_M_impl._M_end_addr();
1266 for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p)
1270 _GLIBCXX20_CONSTEXPR
1272 clear() _GLIBCXX_NOEXCEPT
1273 { _M_erase_at_end(
begin()); }
1275#if __cplusplus >= 201103L
1276 template<
typename... _Args>
1277#if __cplusplus > 201402L
1278 _GLIBCXX20_CONSTEXPR
1283 emplace_back(_Args&&... __args)
1286#if __cplusplus > 201402L
1291 template<
typename... _Args>
1292 _GLIBCXX20_CONSTEXPR
1294 emplace(const_iterator __pos, _Args&&... __args)
1295 {
return insert(__pos,
bool(__args...)); }
1300 _GLIBCXX20_CONSTEXPR
1302 _M_copy_aligned(const_iterator __first, const_iterator __last,
1305 _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p);
1306 return std::copy(const_iterator(__last._M_p, 0), __last,
1310 _GLIBCXX20_CONSTEXPR
1312 _M_initialize(size_type __n)
1316 _Bit_pointer __q = this->_M_allocate(__n);
1317 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1319 this->_M_impl._M_start = __start;
1320 this->_M_impl._M_finish = __start + difference_type(__n);
1324 _GLIBCXX20_CONSTEXPR
1326 _M_initialize_value(
bool __x) _GLIBCXX_NOEXCEPT
1328 if (_Bit_type* __p = this->_M_impl._M_start._M_p)
1329 __fill_bvector_n(__p, this->_M_impl._M_end_addr() - __p, __x);
1332 _GLIBCXX20_CONSTEXPR
1334 _M_reallocate(size_type __n);
1336#if __cplusplus >= 201103L
1337 _GLIBCXX20_CONSTEXPR
1342#if __cplusplus < 201103L
1345 template<
typename _Integer>
1347 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1349 _M_initialize(
static_cast<size_type
>(__n));
1350 _M_initialize_value(__x);
1353 template<
typename _InputIterator>
1355 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1357 { _M_initialize_range(__first, __last,
1361 template<
typename _InputIterator>
1362 _GLIBCXX20_CONSTEXPR
1364 _M_initialize_range(_InputIterator __first, _InputIterator __last,
1367 for (; __first != __last; ++__first)
1371 template<
typename _ForwardIterator>
1372 _GLIBCXX20_CONSTEXPR
1374 _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
1379 std::copy(__first, __last,
begin());
1382#if __cplusplus < 201103L
1385 template<
typename _Integer>
1387 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1388 { _M_fill_assign(__n, __val); }
1390 template<
class _InputIterator>
1392 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1397 _GLIBCXX20_CONSTEXPR
1399 _M_fill_assign(
size_t __n,
bool __x)
1403 _M_initialize_value(__x);
1408 _M_erase_at_end(
begin() + __n);
1409 _M_initialize_value(__x);
1413 template<
typename _InputIterator>
1414 _GLIBCXX20_CONSTEXPR
1416 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1419 iterator __cur =
begin();
1420 for (; __first != __last && __cur !=
end(); ++__cur, (void)++__first)
1422 if (__first == __last)
1423 _M_erase_at_end(__cur);
1428 template<
typename _ForwardIterator>
1429 _GLIBCXX20_CONSTEXPR
1431 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1436 _M_erase_at_end(std::copy(__first, __last,
begin()));
1439 _ForwardIterator __mid = __first;
1441 std::copy(__first, __mid,
begin());
1446#if __cplusplus < 201103L
1449 template<
typename _Integer>
1451 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
1453 { _M_fill_insert(__pos, __n, __x); }
1455 template<
typename _InputIterator>
1457 _M_insert_dispatch(iterator __pos,
1458 _InputIterator __first, _InputIterator __last,
1460 { _M_insert_range(__pos, __first, __last,
1464 _GLIBCXX20_CONSTEXPR
1466 _M_fill_insert(iterator __position, size_type __n,
bool __x);
1468 template<
typename _InputIterator>
1469 _GLIBCXX20_CONSTEXPR
1471 _M_insert_range(iterator __pos, _InputIterator __first,
1474 for (; __first != __last; ++__first)
1476 __pos =
insert(__pos, *__first);
1481 template<
typename _ForwardIterator>
1482 _GLIBCXX20_CONSTEXPR
1484 _M_insert_range(iterator __position, _ForwardIterator __first,
1487 _GLIBCXX20_CONSTEXPR
1489 _M_insert_aux(iterator __position,
bool __x);
1491 _GLIBCXX20_CONSTEXPR
1493 _M_check_len(size_type __n,
const char* __s)
const
1496 __throw_length_error(__N(__s));
1502 _GLIBCXX20_CONSTEXPR
1504 _M_erase_at_end(iterator __pos)
1505 { this->_M_impl._M_finish = __pos; }
1507 _GLIBCXX20_CONSTEXPR
1509 _M_erase(iterator __pos);
1511 _GLIBCXX20_CONSTEXPR
1513 _M_erase(iterator __first, iterator __last);
1521#if __cplusplus >= 201103L
1522 void data() =
delete;
1528_GLIBCXX_END_NAMESPACE_CONTAINER
1531 _GLIBCXX20_CONSTEXPR
1533 __fill_bvector(_Bit_type* __v,
unsigned int __first,
unsigned int __last,
1534 bool __x) _GLIBCXX_NOEXCEPT
1536 const _Bit_type __fmask = ~0ul << __first;
1537 const _Bit_type __lmask = ~0ul >> (_S_word_bit - __last);
1538 const _Bit_type __mask = __fmask & __lmask;
1547 __attribute__((__nonnull__))
1548 _GLIBCXX20_CONSTEXPR
1550 __fill_bvector_n(_Bit_type* __p,
size_t __n,
bool __x) _GLIBCXX_NOEXCEPT
1552#if __cpp_lib_is_constant_evaluated
1555 for (
size_t __i = 0; __i < __n; ++__i)
1556 __p[__i] = __x ? ~0ul : 0ul;
1560 __builtin_memset(__p, __x ? ~0 : 0, __n *
sizeof(_Bit_type));
1564 _GLIBCXX20_CONSTEXPR
1566 __fill_a1(_GLIBCXX_STD_C::_Bit_iterator __first,
1567 _GLIBCXX_STD_C::_Bit_iterator __last,
const bool& __x)
1569 if (__first._M_p != __last._M_p)
1571 _Bit_type* __first_p = __first._M_p;
1572 if (__first._M_offset != 0)
1573 __fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x);
1575 __fill_bvector_n(__first_p, __last._M_p - __first_p, __x);
1577 if (__last._M_offset != 0)
1578 __fill_bvector(__last._M_p, 0, __last._M_offset, __x);
1580 else if (__first._M_offset != __last._M_offset)
1581 __fill_bvector(__first._M_p, __first._M_offset, __last._M_offset, __x);
1584#if __cplusplus >= 201103L
1587 template<
typename _Alloc>
1589 :
public __hash_base<size_t, _GLIBCXX_STD_C::vector<bool, _Alloc>>
1592 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>&)
const noexcept;
1596_GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
constexpr complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
constexpr bool is_constant_evaluated() noexcept
Returns true only when called during constant evaluation.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
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< _Alloc >, __equal, _Alloc >::type is_always_equal
Whether all instances of the allocator type compare equal.
Forward iterators support a superset of input iterator operations.
Random-access iterators support a superset of bidirectional iterator operations.
ptrdiff_t difference_type
Distance between iterators is represented as this 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
Uniform interface to C++98 and C++11 allocators.
static constexpr pointer allocate(_Alloc &__a, size_type __n)
Allocate memory.
static constexpr void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.