695 class vector<bool, _Alloc> :
protected _Bvector_base<_Alloc>
697 typedef _Bvector_base<_Alloc> _Base;
698 typedef typename _Base::_Bit_pointer _Bit_pointer;
699 typedef typename _Base::_Bit_alloc_traits _Bit_alloc_traits;
701#if __cplusplus >= 201103L
706 typedef bool value_type;
707 typedef size_t size_type;
708 typedef ptrdiff_t difference_type;
709 typedef _Bit_reference reference;
710 typedef bool const_reference;
711 typedef _Bit_reference* pointer;
712 typedef const bool* const_pointer;
713 typedef _Bit_iterator iterator;
714 typedef _Bit_const_iterator const_iterator;
717 typedef _Alloc allocator_type;
722 {
return _Base::get_allocator(); }
725 using _Base::_M_allocate;
726 using _Base::_M_deallocate;
727 using _Base::_S_nword;
728 using _Base::_M_get_Bit_allocator;
731#if __cplusplus >= 201103L
739 vector(
const allocator_type& __a)
742#if __cplusplus >= 201103L
745 vector(size_type __n,
const allocator_type& __a = allocator_type())
750 vector(size_type __n,
const bool& __value,
751 const allocator_type& __a = allocator_type())
754 vector(size_type __n,
const bool& __value =
bool(),
755 const allocator_type& __a = allocator_type())
760 _M_initialize_value(__value);
765 : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator()))
767 _M_initialize(__x.
size());
768 _M_copy_aligned(__x.
begin(), __x.
end(), begin());
771#if __cplusplus >= 201103L
772 vector(vector&&) =
default;
788 _M_initialize(__x.
size());
789 _M_copy_aligned(__x.
begin(), __x.
end(), begin());
796 vector(vector&& __x,
const __type_identity_t<allocator_type>& __a)
797 noexcept(_Bit_alloc_traits::_S_always_equal())
803 vector(
const vector& __x,
const __type_identity_t<allocator_type>& __a)
806 _M_initialize(__x.
size());
807 _M_copy_aligned(__x.
begin(), __x.
end(), begin());
812 const allocator_type& __a = allocator_type())
815 _M_initialize_range(__l.begin(), __l.end(),
820#if __cplusplus >= 201103L
821 template<
typename _InputIterator,
822 typename = std::_RequireInputIter<_InputIterator>>
824 vector(_InputIterator __first, _InputIterator __last,
825 const allocator_type& __a = allocator_type())
828 _M_initialize_range(__first, __last,
832 template<
typename _InputIterator>
833 vector(_InputIterator __first, _InputIterator __last,
834 const allocator_type& __a = allocator_type())
838 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
839 _M_initialize_dispatch(__first, __last, _Integral());
844 ~vector() _GLIBCXX_NOEXCEPT { }
852#if __cplusplus >= 201103L
853 if (_Bit_alloc_traits::_S_propagate_on_copy_assign())
855 if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator())
857 this->_M_deallocate();
858 std::__alloc_on_copy(_M_get_Bit_allocator(),
859 __x._M_get_Bit_allocator());
860 _M_initialize(__x.
size());
863 std::__alloc_on_copy(_M_get_Bit_allocator(),
864 __x._M_get_Bit_allocator());
867 if (__x.
size() > capacity())
869 this->_M_deallocate();
870 _M_initialize(__x.
size());
872 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
877#if __cplusplus >= 201103L
880 operator=(vector&& __x)
noexcept(_Bit_alloc_traits::_S_nothrow_move())
882 if (_Bit_alloc_traits::_S_propagate_on_move_assign()
883 || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator())
885 this->_M_deallocate();
887 std::__alloc_on_move(_M_get_Bit_allocator(),
888 __x._M_get_Bit_allocator());
892 if (__x.
size() > capacity())
894 this->_M_deallocate();
895 _M_initialize(__x.
size());
897 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
908 this->
assign(__l.begin(), __l.end());
919 assign(size_type __n,
const bool& __x)
920 { _M_fill_assign(__n, __x); }
922#if __cplusplus >= 201103L
923 template<
typename _InputIterator,
924 typename = std::_RequireInputIter<_InputIterator>>
927 assign(_InputIterator __first, _InputIterator __last)
930 template<
typename _InputIterator>
932 assign(_InputIterator __first, _InputIterator __last)
935 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
936 _M_assign_dispatch(__first, __last, _Integral());
940#if __cplusplus >= 201103L
947 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
949 begin() _GLIBCXX_NOEXCEPT
950 {
return iterator(this->_M_impl._M_start._M_p, 0); }
952 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
954 begin()
const _GLIBCXX_NOEXCEPT
955 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
957 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
959 end() _GLIBCXX_NOEXCEPT
960 {
return this->_M_impl._M_finish; }
962 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
964 end()
const _GLIBCXX_NOEXCEPT
965 {
return this->_M_impl._M_finish; }
967 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
969 rbegin() _GLIBCXX_NOEXCEPT
970 {
return reverse_iterator(
end()); }
972 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
973 const_reverse_iterator
974 rbegin()
const _GLIBCXX_NOEXCEPT
975 {
return const_reverse_iterator(
end()); }
977 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
979 rend() _GLIBCXX_NOEXCEPT
980 {
return reverse_iterator(
begin()); }
982 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
983 const_reverse_iterator
984 rend()
const _GLIBCXX_NOEXCEPT
985 {
return const_reverse_iterator(
begin()); }
987#if __cplusplus >= 201103L
988 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
991 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
993 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
995 cend()
const noexcept
996 {
return this->_M_impl._M_finish; }
998 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
999 const_reverse_iterator
1001 {
return const_reverse_iterator(
end()); }
1003 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1004 const_reverse_iterator
1005 crend()
const noexcept
1006 {
return const_reverse_iterator(
begin()); }
1009 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1011 size()
const _GLIBCXX_NOEXCEPT
1012 {
return size_type(
end() -
begin()); }
1014 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1018 const size_type __isize =
1019 __gnu_cxx::__numeric_traits<difference_type>::__max
1020 - int(_S_word_bit) + 1;
1021 const size_type __asize
1023 return (__asize <= __isize /
int(_S_word_bit)
1024 ? __asize *
int(_S_word_bit) : __isize);
1027 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1030 {
return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
1033 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1035 empty()
const _GLIBCXX_NOEXCEPT
1038 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1041 {
return begin()[__n]; }
1043 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1046 {
return begin()[__n]; }
1049 _GLIBCXX20_CONSTEXPR
1053 if (__n >= this->
size())
1054 __throw_out_of_range_fmt(__N(
"vector<bool>::_M_range_check: __n "
1055 "(which is %zu) >= this->size() "
1061 _GLIBCXX20_CONSTEXPR
1066 return (*
this)[__n];
1069 _GLIBCXX20_CONSTEXPR
1071 at(size_type __n)
const
1074 return (*
this)[__n];
1077 _GLIBCXX20_CONSTEXPR
1082 __throw_length_error(__N(
"vector::reserve"));
1087 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1090 {
return *
begin(); }
1092 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1095 {
return *
begin(); }
1097 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1100 {
return *(
end() - 1); }
1102 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1105 {
return *(
end() - 1); }
1107 _GLIBCXX20_CONSTEXPR
1111 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1112 *this->_M_impl._M_finish++ = __x;
1114 _M_insert_aux(
end(), __x);
1117 _GLIBCXX20_CONSTEXPR
1119 swap(vector& __x) _GLIBCXX_NOEXCEPT
1121#if __cplusplus >= 201103L
1122 __glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value
1123 || _M_get_Bit_allocator() == __x._M_get_Bit_allocator());
1125 this->_M_impl._M_swap_data(__x._M_impl);
1126 _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(),
1127 __x._M_get_Bit_allocator());
1131 _GLIBCXX20_CONSTEXPR
1133 swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT
1140 _GLIBCXX20_CONSTEXPR
1142#if __cplusplus >= 201103L
1143 insert(const_iterator __position,
const bool& __x)
1145 insert(iterator __position,
const bool& __x)
1148 const difference_type __n = __position -
begin();
1149 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()
1150 && __position == end())
1151 *this->_M_impl._M_finish++ = __x;
1153 _M_insert_aux(__position._M_const_cast(), __x);
1154 return begin() + __n;
1157#if _GLIBCXX_USE_DEPRECATED
1158 _GLIBCXX_DEPRECATED_SUGGEST(
"insert(position, false)")
1160 insert(const_iterator __position)
1161 {
return this->
insert(__position._M_const_cast(),
false); }
1164#if __cplusplus >= 201103L
1165 template<
typename _InputIterator,
1166 typename = std::_RequireInputIter<_InputIterator>>
1167 _GLIBCXX20_CONSTEXPR
1169 insert(const_iterator __position,
1170 _InputIterator __first, _InputIterator __last)
1172 difference_type __offset = __position -
cbegin();
1173 _M_insert_range(__position._M_const_cast(),
1176 return begin() + __offset;
1179 template<
typename _InputIterator>
1181 insert(iterator __position,
1182 _InputIterator __first, _InputIterator __last)
1185 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1186 _M_insert_dispatch(__position, __first, __last, _Integral());
1190#if __cplusplus >= 201103L
1191 _GLIBCXX20_CONSTEXPR
1193 insert(const_iterator __position, size_type __n,
const bool& __x)
1195 difference_type __offset = __position -
cbegin();
1196 _M_fill_insert(__position._M_const_cast(), __n, __x);
1197 return begin() + __offset;
1201 insert(iterator __position, size_type __n,
const bool& __x)
1202 { _M_fill_insert(__position, __n, __x); }
1205#if __cplusplus >= 201103L
1206 _GLIBCXX20_CONSTEXPR
1209 {
return this->
insert(__p, __l.begin(), __l.end()); }
1212 _GLIBCXX20_CONSTEXPR
1215 { --this->_M_impl._M_finish; }
1217 _GLIBCXX20_CONSTEXPR
1219#if __cplusplus >= 201103L
1220 erase(const_iterator __position)
1222 erase(iterator __position)
1224 {
return _M_erase(__position._M_const_cast()); }
1226 _GLIBCXX20_CONSTEXPR
1228#if __cplusplus >= 201103L
1229 erase(const_iterator __first, const_iterator __last)
1231 erase(iterator __first, iterator __last)
1233 {
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
1235 _GLIBCXX20_CONSTEXPR
1237 resize(size_type __new_size,
bool __x =
bool())
1239 if (__new_size <
size())
1240 _M_erase_at_end(
begin() + difference_type(__new_size));
1245#if __cplusplus >= 201103L
1246 _GLIBCXX20_CONSTEXPR
1249 { _M_shrink_to_fit(); }
1252 _GLIBCXX20_CONSTEXPR
1254 flip() _GLIBCXX_NOEXCEPT
1256 _Bit_type *
const __end = this->_M_impl._M_end_addr();
1257 for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p)
1261 _GLIBCXX20_CONSTEXPR
1263 clear() _GLIBCXX_NOEXCEPT
1264 { _M_erase_at_end(
begin()); }
1266#if __cplusplus >= 201103L
1267 template<
typename... _Args>
1268#if __cplusplus > 201402L
1269 _GLIBCXX20_CONSTEXPR
1274 emplace_back(_Args&&... __args)
1277#if __cplusplus > 201402L
1282 template<
typename... _Args>
1283 _GLIBCXX20_CONSTEXPR
1285 emplace(const_iterator __pos, _Args&&... __args)
1286 {
return insert(__pos,
bool(__args...)); }
1291 _GLIBCXX20_CONSTEXPR
1293 _M_copy_aligned(const_iterator __first, const_iterator __last,
1296 _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p);
1297 return std::copy(const_iterator(__last._M_p, 0), __last,
1301 _GLIBCXX20_CONSTEXPR
1303 _M_initialize(size_type __n)
1307 _Bit_pointer __q = this->_M_allocate(__n);
1308 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1310 this->_M_impl._M_start = __start;
1311 this->_M_impl._M_finish = __start + difference_type(__n);
1315 _GLIBCXX20_CONSTEXPR
1317 _M_initialize_value(
bool __x) _GLIBCXX_NOEXCEPT
1319 if (_Bit_type* __p = this->_M_impl._M_start._M_p)
1320 __fill_bvector_n(__p, this->_M_impl._M_end_addr() - __p, __x);
1323 _GLIBCXX20_CONSTEXPR
1325 _M_reallocate(size_type __n);
1327#if __cplusplus >= 201103L
1328 _GLIBCXX20_CONSTEXPR
1333#if __cplusplus < 201103L
1336 template<
typename _Integer>
1338 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1340 _M_initialize(
static_cast<size_type
>(__n));
1341 _M_initialize_value(__x);
1344 template<
typename _InputIterator>
1346 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1348 { _M_initialize_range(__first, __last,
1352 template<
typename _InputIterator>
1353 _GLIBCXX20_CONSTEXPR
1355 _M_initialize_range(_InputIterator __first, _InputIterator __last,
1358 for (; __first != __last; ++__first)
1362 template<
typename _ForwardIterator>
1363 _GLIBCXX20_CONSTEXPR
1365 _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
1370 std::copy(__first, __last,
begin());
1373#if __cplusplus < 201103L
1376 template<
typename _Integer>
1378 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1379 { _M_fill_assign(__n, __val); }
1381 template<
class _InputIterator>
1383 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1388 _GLIBCXX20_CONSTEXPR
1390 _M_fill_assign(
size_t __n,
bool __x)
1394 _M_initialize_value(__x);
1399 _M_erase_at_end(
begin() + __n);
1400 _M_initialize_value(__x);
1404 template<
typename _InputIterator>
1405 _GLIBCXX20_CONSTEXPR
1407 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1410 iterator __cur =
begin();
1411 for (; __first != __last && __cur !=
end(); ++__cur, (void)++__first)
1413 if (__first == __last)
1414 _M_erase_at_end(__cur);
1419 template<
typename _ForwardIterator>
1420 _GLIBCXX20_CONSTEXPR
1422 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1427 _M_erase_at_end(std::copy(__first, __last,
begin()));
1430 _ForwardIterator __mid = __first;
1432 std::copy(__first, __mid,
begin());
1437#if __cplusplus < 201103L
1440 template<
typename _Integer>
1442 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
1444 { _M_fill_insert(__pos, __n, __x); }
1446 template<
typename _InputIterator>
1448 _M_insert_dispatch(iterator __pos,
1449 _InputIterator __first, _InputIterator __last,
1451 { _M_insert_range(__pos, __first, __last,
1455 _GLIBCXX20_CONSTEXPR
1457 _M_fill_insert(iterator __position, size_type __n,
bool __x);
1459 template<
typename _InputIterator>
1460 _GLIBCXX20_CONSTEXPR
1462 _M_insert_range(iterator __pos, _InputIterator __first,
1465 for (; __first != __last; ++__first)
1467 __pos =
insert(__pos, *__first);
1472 template<
typename _ForwardIterator>
1473 _GLIBCXX20_CONSTEXPR
1475 _M_insert_range(iterator __position, _ForwardIterator __first,
1478 _GLIBCXX20_CONSTEXPR
1480 _M_insert_aux(iterator __position,
bool __x);
1482 _GLIBCXX20_CONSTEXPR
1484 _M_check_len(size_type __n,
const char* __s)
const
1487 __throw_length_error(__N(__s));
1493 _GLIBCXX20_CONSTEXPR
1495 _M_erase_at_end(iterator __pos)
1496 { this->_M_impl._M_finish = __pos; }
1498 _GLIBCXX20_CONSTEXPR
1500 _M_erase(iterator __pos);
1502 _GLIBCXX20_CONSTEXPR
1504 _M_erase(iterator __first, iterator __last);
1512#if __cplusplus >= 201103L
1513 void data() =
delete;