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;
352 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
355 {
return *(*
this + __i); }
358 friend _GLIBCXX20_CONSTEXPR iterator
361 iterator __tmp = __x;
367 friend _GLIBCXX20_CONSTEXPR iterator
369 {
return __x + __n; }
372 friend _GLIBCXX20_CONSTEXPR iterator
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;
463 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
466 {
return *(*
this + __i); }
469 friend _GLIBCXX20_CONSTEXPR const_iterator
472 const_iterator __tmp = __x;
478 friend _GLIBCXX20_CONSTEXPR const_iterator
481 const_iterator __tmp = __x;
487 friend _GLIBCXX20_CONSTEXPR const_iterator
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); }
701 template<
typename _Alloc>
702 class vector<bool, _Alloc> :
protected _Bvector_base<_Alloc>
704 typedef _Bvector_base<_Alloc> _Base;
705 typedef typename _Base::_Bit_pointer _Bit_pointer;
708#if __cplusplus >= 201103L
713 typedef bool value_type;
714 typedef size_t size_type;
715 typedef ptrdiff_t difference_type;
716 typedef _Bit_reference reference;
717 typedef bool const_reference;
718 typedef _Bit_reference* pointer;
719 typedef const bool* const_pointer;
720 typedef _Bit_iterator iterator;
721 typedef _Bit_const_iterator const_iterator;
724 typedef _Alloc allocator_type;
729 {
return _Base::get_allocator(); }
732 using _Base::_M_allocate;
733 using _Base::_M_deallocate;
734 using _Base::_S_nword;
735 using _Base::_M_get_Bit_allocator;
738#if __cplusplus >= 201103L
746 vector(
const allocator_type& __a)
749#if __cplusplus >= 201103L
752 vector(size_type __n,
const allocator_type& __a = allocator_type())
757 vector(size_type __n,
const bool& __value,
758 const allocator_type& __a = allocator_type())
761 vector(size_type __n,
const bool& __value =
bool(),
762 const allocator_type& __a = allocator_type())
767 _M_initialize_value(__value);
772 : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator()))
774 _M_initialize(__x.
size());
778#if __cplusplus >= 201103L
795 _M_initialize(__x.
size());
803 vector(
vector&& __x,
const __type_identity_t<allocator_type>& __a)
804 noexcept(_Bit_alloc_traits::_S_always_equal())
810 vector(
const vector& __x,
const __type_identity_t<allocator_type>& __a)
813 _M_initialize(__x.
size());
819 const allocator_type& __a = allocator_type())
822 _M_initialize_range(__l.begin(), __l.end(),
827#if __cplusplus >= 201103L
828 template<
typename _InputIterator,
829 typename = std::_RequireInputIter<_InputIterator>>
831 vector(_InputIterator __first, _InputIterator __last,
832 const allocator_type& __a = allocator_type())
835 _M_initialize_range(__first, __last,
839 template<
typename _InputIterator>
840 vector(_InputIterator __first, _InputIterator __last,
841 const allocator_type& __a = allocator_type())
845 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
846 _M_initialize_dispatch(__first, __last, _Integral());
851 ~vector() _GLIBCXX_NOEXCEPT { }
859#if __cplusplus >= 201103L
860 if (_Bit_alloc_traits::_S_propagate_on_copy_assign())
862 if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator())
864 this->_M_deallocate();
865 std::__alloc_on_copy(_M_get_Bit_allocator(),
866 __x._M_get_Bit_allocator());
867 _M_initialize(__x.
size());
870 std::__alloc_on_copy(_M_get_Bit_allocator(),
871 __x._M_get_Bit_allocator());
876 this->_M_deallocate();
877 _M_initialize(__x.
size());
879 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
884#if __cplusplus >= 201103L
889 if (_Bit_alloc_traits::_S_propagate_on_move_assign()
890 || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator())
892 this->_M_deallocate();
894 std::__alloc_on_move(_M_get_Bit_allocator(),
895 __x._M_get_Bit_allocator());
901 this->_M_deallocate();
902 _M_initialize(__x.
size());
904 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
915 this->
assign(__l.begin(), __l.end());
926 assign(size_type __n,
const bool& __x)
927 { _M_fill_assign(__n, __x); }
929#if __cplusplus >= 201103L
930 template<
typename _InputIterator,
931 typename = std::_RequireInputIter<_InputIterator>>
934 assign(_InputIterator __first, _InputIterator __last)
937 template<
typename _InputIterator>
939 assign(_InputIterator __first, _InputIterator __last)
942 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
943 _M_assign_dispatch(__first, __last, _Integral());
947#if __cplusplus >= 201103L
954 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
956 begin() _GLIBCXX_NOEXCEPT
957 {
return iterator(this->_M_impl._M_start._M_p, 0); }
959 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
961 begin()
const _GLIBCXX_NOEXCEPT
962 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
964 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
966 end() _GLIBCXX_NOEXCEPT
967 {
return this->_M_impl._M_finish; }
969 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
971 end()
const _GLIBCXX_NOEXCEPT
972 {
return this->_M_impl._M_finish; }
974 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
976 rbegin() _GLIBCXX_NOEXCEPT
979 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
981 rbegin()
const _GLIBCXX_NOEXCEPT
984 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
986 rend() _GLIBCXX_NOEXCEPT
989 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
991 rend()
const _GLIBCXX_NOEXCEPT
994#if __cplusplus >= 201103L
995 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
998 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
1000 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1002 cend()
const noexcept
1003 {
return this->_M_impl._M_finish; }
1005 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1010 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1012 crend()
const noexcept
1016 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1018 size()
const _GLIBCXX_NOEXCEPT
1019 {
return size_type(
end() -
begin()); }
1021 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1025 const size_type __isize =
1026 __gnu_cxx::__numeric_traits<difference_type>::__max
1027 - int(_S_word_bit) + 1;
1028 const size_type __asize
1029 = _Bit_alloc_traits::max_size(_M_get_Bit_allocator());
1030 return (__asize <= __isize /
int(_S_word_bit)
1031 ? __asize *
int(_S_word_bit) : __isize);
1034 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1037 {
return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
1040 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1042 empty()
const _GLIBCXX_NOEXCEPT
1045 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1048 {
return begin()[__n]; }
1050 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1053 {
return begin()[__n]; }
1056 _GLIBCXX20_CONSTEXPR
1060 if (__n >= this->
size())
1061 __throw_out_of_range_fmt(__N(
"vector<bool>::_M_range_check: __n "
1062 "(which is %zu) >= this->size() "
1068 _GLIBCXX20_CONSTEXPR
1073 return (*
this)[__n];
1076 _GLIBCXX20_CONSTEXPR
1078 at(size_type __n)
const
1081 return (*
this)[__n];
1084 _GLIBCXX20_CONSTEXPR
1089 __throw_length_error(__N(
"vector::reserve"));
1094 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1097 {
return *
begin(); }
1099 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1102 {
return *
begin(); }
1104 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1107 {
return *(
end() - 1); }
1109 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1112 {
return *(
end() - 1); }
1114 _GLIBCXX20_CONSTEXPR
1118 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1119 *this->_M_impl._M_finish++ = __x;
1121 _M_insert_aux(
end(), __x);
1124 _GLIBCXX20_CONSTEXPR
1126 swap(
vector& __x) _GLIBCXX_NOEXCEPT
1128#if __cplusplus >= 201103L
1129 __glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value
1130 || _M_get_Bit_allocator() == __x._M_get_Bit_allocator());
1132 this->_M_impl._M_swap_data(__x._M_impl);
1133 _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(),
1134 __x._M_get_Bit_allocator());
1138 _GLIBCXX20_CONSTEXPR
1140 swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT
1147 _GLIBCXX20_CONSTEXPR
1149#if __cplusplus >= 201103L
1150 insert(const_iterator __position,
const bool& __x)
1152 insert(iterator __position,
const bool& __x)
1155 const difference_type __n = __position -
begin();
1156 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()
1157 && __position ==
end())
1158 *this->_M_impl._M_finish++ = __x;
1160 _M_insert_aux(__position._M_const_cast(), __x);
1161 return begin() + __n;
1164#if _GLIBCXX_USE_DEPRECATED
1165 _GLIBCXX_DEPRECATED_SUGGEST(
"insert(position, false)")
1167 insert(const_iterator __position)
1168 {
return this->
insert(__position._M_const_cast(),
false); }
1171#if __cplusplus >= 201103L
1172 template<
typename _InputIterator,
1173 typename = std::_RequireInputIter<_InputIterator>>
1174 _GLIBCXX20_CONSTEXPR
1176 insert(const_iterator __position,
1177 _InputIterator __first, _InputIterator __last)
1179 difference_type __offset = __position -
cbegin();
1180 _M_insert_range(__position._M_const_cast(),
1183 return begin() + __offset;
1186 template<
typename _InputIterator>
1188 insert(iterator __position,
1189 _InputIterator __first, _InputIterator __last)
1192 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1193 _M_insert_dispatch(__position, __first, __last, _Integral());
1197#if __cplusplus >= 201103L
1198 _GLIBCXX20_CONSTEXPR
1200 insert(const_iterator __position, size_type __n,
const bool& __x)
1202 difference_type __offset = __position -
cbegin();
1203 _M_fill_insert(__position._M_const_cast(), __n, __x);
1204 return begin() + __offset;
1208 insert(iterator __position, size_type __n,
const bool& __x)
1209 { _M_fill_insert(__position, __n, __x); }
1212#if __cplusplus >= 201103L
1213 _GLIBCXX20_CONSTEXPR
1216 {
return this->
insert(__p, __l.begin(), __l.end()); }
1219 _GLIBCXX20_CONSTEXPR
1222 { --this->_M_impl._M_finish; }
1224 _GLIBCXX20_CONSTEXPR
1226#if __cplusplus >= 201103L
1227 erase(const_iterator __position)
1229 erase(iterator __position)
1231 {
return _M_erase(__position._M_const_cast()); }
1233 _GLIBCXX20_CONSTEXPR
1235#if __cplusplus >= 201103L
1236 erase(const_iterator __first, const_iterator __last)
1238 erase(iterator __first, iterator __last)
1240 {
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
1242 _GLIBCXX20_CONSTEXPR
1244 resize(size_type __new_size,
bool __x =
bool())
1246 if (__new_size <
size())
1247 _M_erase_at_end(
begin() + difference_type(__new_size));
1252#if __cplusplus >= 201103L
1253 _GLIBCXX20_CONSTEXPR
1256 { _M_shrink_to_fit(); }
1259 _GLIBCXX20_CONSTEXPR
1261 flip() _GLIBCXX_NOEXCEPT
1263 _Bit_type *
const __end = this->_M_impl._M_end_addr();
1264 for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p)
1268 _GLIBCXX20_CONSTEXPR
1270 clear() _GLIBCXX_NOEXCEPT
1271 { _M_erase_at_end(
begin()); }
1273#if __cplusplus >= 201103L
1274 template<
typename... _Args>
1275#if __cplusplus > 201402L
1276 _GLIBCXX20_CONSTEXPR
1281 emplace_back(_Args&&... __args)
1284#if __cplusplus > 201402L
1289 template<
typename... _Args>
1290 _GLIBCXX20_CONSTEXPR
1292 emplace(const_iterator __pos, _Args&&... __args)
1293 {
return insert(__pos,
bool(__args...)); }
1298 _GLIBCXX20_CONSTEXPR
1300 _M_copy_aligned(const_iterator __first, const_iterator __last,
1303 _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p);
1304 return std::copy(const_iterator(__last._M_p, 0), __last,
1308 _GLIBCXX20_CONSTEXPR
1310 _M_initialize(size_type __n)
1314 _Bit_pointer __q = this->_M_allocate(__n);
1315 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1317 this->_M_impl._M_start = __start;
1318 this->_M_impl._M_finish = __start + difference_type(__n);
1322 _GLIBCXX20_CONSTEXPR
1324 _M_initialize_value(
bool __x) _GLIBCXX_NOEXCEPT
1326 if (_Bit_type* __p = this->_M_impl._M_start._M_p)
1327 __fill_bvector_n(__p, this->_M_impl._M_end_addr() - __p, __x);
1330 _GLIBCXX20_CONSTEXPR
1332 _M_reallocate(size_type __n);
1334#if __cplusplus >= 201103L
1335 _GLIBCXX20_CONSTEXPR
1340#if __cplusplus < 201103L
1343 template<
typename _Integer>
1345 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1347 _M_initialize(
static_cast<size_type
>(__n));
1348 _M_initialize_value(__x);
1351 template<
typename _InputIterator>
1353 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1355 { _M_initialize_range(__first, __last,
1359 template<
typename _InputIterator>
1360 _GLIBCXX20_CONSTEXPR
1362 _M_initialize_range(_InputIterator __first, _InputIterator __last,
1365 for (; __first != __last; ++__first)
1369 template<
typename _ForwardIterator>
1370 _GLIBCXX20_CONSTEXPR
1372 _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
1377 std::copy(__first, __last,
begin());
1380#if __cplusplus < 201103L
1383 template<
typename _Integer>
1385 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1386 { _M_fill_assign(__n, __val); }
1388 template<
class _InputIterator>
1390 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1395 _GLIBCXX20_CONSTEXPR
1397 _M_fill_assign(
size_t __n,
bool __x)
1401 _M_initialize_value(__x);
1406 _M_erase_at_end(
begin() + __n);
1407 _M_initialize_value(__x);
1411 template<
typename _InputIterator>
1412 _GLIBCXX20_CONSTEXPR
1414 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1417 iterator __cur =
begin();
1418 for (; __first != __last && __cur !=
end(); ++__cur, (void)++__first)
1420 if (__first == __last)
1421 _M_erase_at_end(__cur);
1426 template<
typename _ForwardIterator>
1427 _GLIBCXX20_CONSTEXPR
1429 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1434 _M_erase_at_end(std::copy(__first, __last,
begin()));
1437 _ForwardIterator __mid = __first;
1439 std::copy(__first, __mid,
begin());
1444#if __cplusplus < 201103L
1447 template<
typename _Integer>
1449 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
1451 { _M_fill_insert(__pos, __n, __x); }
1453 template<
typename _InputIterator>
1455 _M_insert_dispatch(iterator __pos,
1456 _InputIterator __first, _InputIterator __last,
1458 { _M_insert_range(__pos, __first, __last,
1462 _GLIBCXX20_CONSTEXPR
1464 _M_fill_insert(iterator __position, size_type __n,
bool __x);
1466 template<
typename _InputIterator>
1467 _GLIBCXX20_CONSTEXPR
1469 _M_insert_range(iterator __pos, _InputIterator __first,
1472 for (; __first != __last; ++__first)
1474 __pos =
insert(__pos, *__first);
1479 template<
typename _ForwardIterator>
1480 _GLIBCXX20_CONSTEXPR
1482 _M_insert_range(iterator __position, _ForwardIterator __first,
1485 _GLIBCXX20_CONSTEXPR
1487 _M_insert_aux(iterator __position,
bool __x);
1489 _GLIBCXX20_CONSTEXPR
1491 _M_check_len(size_type __n,
const char* __s)
const
1494 __throw_length_error(__N(__s));
1500 _GLIBCXX20_CONSTEXPR
1502 _M_erase_at_end(iterator __pos)
1503 { this->_M_impl._M_finish = __pos; }
1505 _GLIBCXX20_CONSTEXPR
1507 _M_erase(iterator __pos);
1509 _GLIBCXX20_CONSTEXPR
1511 _M_erase(iterator __first, iterator __last);
1519#if __cplusplus >= 201103L
1520 void data() =
delete;
1526_GLIBCXX_END_NAMESPACE_CONTAINER
1529 _GLIBCXX20_CONSTEXPR
1531 __fill_bvector(_Bit_type* __v,
unsigned int __first,
unsigned int __last,
1532 bool __x) _GLIBCXX_NOEXCEPT
1534 const _Bit_type __fmask = ~0ul << __first;
1535 const _Bit_type __lmask = ~0ul >> (_S_word_bit - __last);
1536 const _Bit_type __mask = __fmask & __lmask;
1545 __attribute__((__nonnull__))
1546 _GLIBCXX20_CONSTEXPR
1548 __fill_bvector_n(_Bit_type* __p,
size_t __n,
bool __x) _GLIBCXX_NOEXCEPT
1550#if __cpp_lib_is_constant_evaluated
1553 for (
size_t __i = 0; __i < __n; ++__i)
1554 __p[__i] = __x ? ~0ul : 0ul;
1558 __builtin_memset(__p, __x ? ~0 : 0, __n * sizeof(_Bit_type));
1562 _GLIBCXX20_CONSTEXPR
1564 __fill_a1(_GLIBCXX_STD_C::_Bit_iterator __first,
1565 _GLIBCXX_STD_C::_Bit_iterator __last,
const bool& __x)
1567 if (__first._M_p != __last._M_p)
1569 _Bit_type* __first_p = __first._M_p;
1570 if (__first._M_offset != 0)
1571 __fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x);
1573 __fill_bvector_n(__first_p, __last._M_p - __first_p, __x);
1575 if (__last._M_offset != 0)
1576 __fill_bvector(__last._M_p, 0, __last._M_offset, __x);
1578 else if (__first._M_offset != __last._M_offset)
1579 __fill_bvector(__first._M_p, __first._M_offset, __last._M_offset, __x);
1582#if __cplusplus >= 201103L
1585 template<
typename _Alloc>
1587 :
public __hash_base<size_t, _GLIBCXX_STD_C::vector<bool, _Alloc>>
1590 operator()(
const _GLIBCXX_STD_C::vector<bool, _Alloc>&)
const noexcept;
1594_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 _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.