692 class vector<bool, _Alloc> :
protected _Bvector_base<_Alloc>
694 typedef _Bvector_base<_Alloc> _Base;
695 typedef typename _Base::_Bit_pointer _Bit_pointer;
698#if __cplusplus >= 201103L
703 typedef bool value_type;
704 typedef size_t size_type;
705 typedef ptrdiff_t difference_type;
706 typedef _Bit_reference reference;
707 typedef bool const_reference;
708 typedef _Bit_reference* pointer;
709 typedef const bool* const_pointer;
710 typedef _Bit_iterator iterator;
711 typedef _Bit_const_iterator const_iterator;
714 typedef _Alloc allocator_type;
719 {
return _Base::get_allocator(); }
722 using _Base::_M_allocate;
723 using _Base::_M_deallocate;
724 using _Base::_S_nword;
725 using _Base::_M_get_Bit_allocator;
728#if __cplusplus >= 201103L
736 vector(
const allocator_type& __a)
739#if __cplusplus >= 201103L
742 vector(size_type __n,
const allocator_type& __a = allocator_type())
747 vector(size_type __n,
const bool& __value,
748 const allocator_type& __a = allocator_type())
751 vector(size_type __n,
const bool& __value =
bool(),
752 const allocator_type& __a = allocator_type())
757 _M_initialize_value(__value);
762 : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator()))
764 _M_initialize(__x.
size());
768#if __cplusplus >= 201103L
785 _M_initialize(__x.
size());
793 vector(
vector&& __x,
const __type_identity_t<allocator_type>& __a)
794 noexcept(_Bit_alloc_traits::_S_always_equal())
800 vector(
const vector& __x,
const __type_identity_t<allocator_type>& __a)
803 _M_initialize(__x.
size());
809 const allocator_type& __a = allocator_type())
812 _M_initialize_range(__l.begin(), __l.end(),
817#if __cplusplus >= 201103L
818 template<
typename _InputIterator,
819 typename = std::_RequireInputIter<_InputIterator>>
821 vector(_InputIterator __first, _InputIterator __last,
822 const allocator_type& __a = allocator_type())
825 _M_initialize_range(__first, __last,
829 template<
typename _InputIterator>
830 vector(_InputIterator __first, _InputIterator __last,
831 const allocator_type& __a = allocator_type())
835 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
836 _M_initialize_dispatch(__first, __last, _Integral());
841 ~vector() _GLIBCXX_NOEXCEPT { }
849#if __cplusplus >= 201103L
850 if (_Bit_alloc_traits::_S_propagate_on_copy_assign())
852 if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator())
854 this->_M_deallocate();
855 std::__alloc_on_copy(_M_get_Bit_allocator(),
856 __x._M_get_Bit_allocator());
857 _M_initialize(__x.
size());
860 std::__alloc_on_copy(_M_get_Bit_allocator(),
861 __x._M_get_Bit_allocator());
866 this->_M_deallocate();
867 _M_initialize(__x.
size());
869 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
874#if __cplusplus >= 201103L
879 if (_Bit_alloc_traits::_S_propagate_on_move_assign()
880 || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator())
882 this->_M_deallocate();
884 std::__alloc_on_move(_M_get_Bit_allocator(),
885 __x._M_get_Bit_allocator());
891 this->_M_deallocate();
892 _M_initialize(__x.
size());
894 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
905 this->
assign(__l.begin(), __l.end());
916 assign(size_type __n,
const bool& __x)
917 { _M_fill_assign(__n, __x); }
919#if __cplusplus >= 201103L
920 template<
typename _InputIterator,
921 typename = std::_RequireInputIter<_InputIterator>>
924 assign(_InputIterator __first, _InputIterator __last)
927 template<
typename _InputIterator>
929 assign(_InputIterator __first, _InputIterator __last)
932 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
933 _M_assign_dispatch(__first, __last, _Integral());
937#if __cplusplus >= 201103L
944 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
946 begin() _GLIBCXX_NOEXCEPT
947 {
return iterator(this->_M_impl._M_start._M_p, 0); }
949 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
951 begin()
const _GLIBCXX_NOEXCEPT
952 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
954 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
956 end() _GLIBCXX_NOEXCEPT
957 {
return this->_M_impl._M_finish; }
959 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
961 end()
const _GLIBCXX_NOEXCEPT
962 {
return this->_M_impl._M_finish; }
964 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
966 rbegin() _GLIBCXX_NOEXCEPT
969 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
971 rbegin()
const _GLIBCXX_NOEXCEPT
974 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
976 rend() _GLIBCXX_NOEXCEPT
979 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
981 rend()
const _GLIBCXX_NOEXCEPT
984#if __cplusplus >= 201103L
985 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
988 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
990 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
992 cend()
const noexcept
993 {
return this->_M_impl._M_finish; }
995 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1000 [[__nodiscard__]] _GLIBCXX20_CONSTEXPR
1002 crend()
const noexcept
1006 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1008 size()
const _GLIBCXX_NOEXCEPT
1009 {
return size_type(
end() -
begin()); }
1011 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1015 const size_type __isize =
1016 __gnu_cxx::__numeric_traits<difference_type>::__max
1017 - int(_S_word_bit) + 1;
1018 const size_type __asize
1019 = _Bit_alloc_traits::max_size(_M_get_Bit_allocator());
1020 return (__asize <= __isize /
int(_S_word_bit)
1021 ? __asize *
int(_S_word_bit) : __isize);
1024 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1027 {
return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
1030 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1032 empty()
const _GLIBCXX_NOEXCEPT
1035 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1038 {
return begin()[__n]; }
1040 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1043 {
return begin()[__n]; }
1046 _GLIBCXX20_CONSTEXPR
1050 if (__n >= this->
size())
1051 __throw_out_of_range_fmt(__N(
"vector<bool>::_M_range_check: __n "
1052 "(which is %zu) >= this->size() "
1058 _GLIBCXX20_CONSTEXPR
1063 return (*
this)[__n];
1066 _GLIBCXX20_CONSTEXPR
1068 at(size_type __n)
const
1071 return (*
this)[__n];
1074 _GLIBCXX20_CONSTEXPR
1079 __throw_length_error(__N(
"vector::reserve"));
1084 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1087 {
return *
begin(); }
1089 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1092 {
return *
begin(); }
1094 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1097 {
return *(
end() - 1); }
1099 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1102 {
return *(
end() - 1); }
1104 _GLIBCXX20_CONSTEXPR
1108 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
1109 *this->_M_impl._M_finish++ = __x;
1111 _M_insert_aux(
end(), __x);
1114 _GLIBCXX20_CONSTEXPR
1118#if __cplusplus >= 201103L
1119 __glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value
1120 || _M_get_Bit_allocator() == __x._M_get_Bit_allocator());
1122 this->_M_impl._M_swap_data(__x._M_impl);
1123 _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(),
1124 __x._M_get_Bit_allocator());
1128 _GLIBCXX20_CONSTEXPR
1130 swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT
1137 _GLIBCXX20_CONSTEXPR
1139#if __cplusplus >= 201103L
1140 insert(const_iterator __position,
const bool& __x)
1142 insert(iterator __position,
const bool& __x)
1145 const difference_type __n = __position -
begin();
1146 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()
1147 && __position ==
end())
1148 *this->_M_impl._M_finish++ = __x;
1150 _M_insert_aux(__position._M_const_cast(), __x);
1151 return begin() + __n;
1154#if _GLIBCXX_USE_DEPRECATED
1155 _GLIBCXX_DEPRECATED_SUGGEST(
"insert(position, false)")
1157 insert(const_iterator __position)
1158 {
return this->
insert(__position._M_const_cast(),
false); }
1161#if __cplusplus >= 201103L
1162 template<
typename _InputIterator,
1163 typename = std::_RequireInputIter<_InputIterator>>
1164 _GLIBCXX20_CONSTEXPR
1166 insert(const_iterator __position,
1167 _InputIterator __first, _InputIterator __last)
1169 difference_type __offset = __position -
cbegin();
1170 _M_insert_range(__position._M_const_cast(),
1173 return begin() + __offset;
1176 template<
typename _InputIterator>
1178 insert(iterator __position,
1179 _InputIterator __first, _InputIterator __last)
1182 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1183 _M_insert_dispatch(__position, __first, __last, _Integral());
1187#if __cplusplus >= 201103L
1188 _GLIBCXX20_CONSTEXPR
1190 insert(const_iterator __position, size_type __n,
const bool& __x)
1192 difference_type __offset = __position -
cbegin();
1193 _M_fill_insert(__position._M_const_cast(), __n, __x);
1194 return begin() + __offset;
1198 insert(iterator __position, size_type __n,
const bool& __x)
1199 { _M_fill_insert(__position, __n, __x); }
1202#if __cplusplus >= 201103L
1203 _GLIBCXX20_CONSTEXPR
1206 {
return this->
insert(__p, __l.begin(), __l.end()); }
1209 _GLIBCXX20_CONSTEXPR
1212 { --this->_M_impl._M_finish; }
1214 _GLIBCXX20_CONSTEXPR
1216#if __cplusplus >= 201103L
1217 erase(const_iterator __position)
1219 erase(iterator __position)
1221 {
return _M_erase(__position._M_const_cast()); }
1223 _GLIBCXX20_CONSTEXPR
1225#if __cplusplus >= 201103L
1226 erase(const_iterator __first, const_iterator __last)
1228 erase(iterator __first, iterator __last)
1230 {
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
1232 _GLIBCXX20_CONSTEXPR
1234 resize(size_type __new_size,
bool __x =
bool())
1236 if (__new_size <
size())
1237 _M_erase_at_end(
begin() + difference_type(__new_size));
1242#if __cplusplus >= 201103L
1243 _GLIBCXX20_CONSTEXPR
1246 { _M_shrink_to_fit(); }
1249 _GLIBCXX20_CONSTEXPR
1251 flip() _GLIBCXX_NOEXCEPT
1253 _Bit_type *
const __end = this->_M_impl._M_end_addr();
1254 for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p)
1258 _GLIBCXX20_CONSTEXPR
1260 clear() _GLIBCXX_NOEXCEPT
1261 { _M_erase_at_end(
begin()); }
1263#if __cplusplus >= 201103L
1264 template<
typename... _Args>
1265#if __cplusplus > 201402L
1266 _GLIBCXX20_CONSTEXPR
1271 emplace_back(_Args&&... __args)
1274#if __cplusplus > 201402L
1279 template<
typename... _Args>
1280 _GLIBCXX20_CONSTEXPR
1282 emplace(const_iterator __pos, _Args&&... __args)
1283 {
return insert(__pos,
bool(__args...)); }
1288 _GLIBCXX20_CONSTEXPR
1290 _M_copy_aligned(const_iterator __first, const_iterator __last,
1293 _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p);
1294 return std::copy(const_iterator(__last._M_p, 0), __last,
1298 _GLIBCXX20_CONSTEXPR
1300 _M_initialize(size_type __n)
1304 _Bit_pointer __q = this->_M_allocate(__n);
1305 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1307 this->_M_impl._M_start = __start;
1308 this->_M_impl._M_finish = __start + difference_type(__n);
1312 _GLIBCXX20_CONSTEXPR
1314 _M_initialize_value(
bool __x) _GLIBCXX_NOEXCEPT
1316 if (_Bit_type* __p = this->_M_impl._M_start._M_p)
1317 __fill_bvector_n(__p, this->_M_impl._M_end_addr() - __p, __x);
1320 _GLIBCXX20_CONSTEXPR
1322 _M_reallocate(size_type __n);
1324#if __cplusplus >= 201103L
1325 _GLIBCXX20_CONSTEXPR
1330#if __cplusplus < 201103L
1333 template<
typename _Integer>
1335 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1337 _M_initialize(
static_cast<size_type
>(__n));
1338 _M_initialize_value(__x);
1341 template<
typename _InputIterator>
1343 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1345 { _M_initialize_range(__first, __last,
1349 template<
typename _InputIterator>
1350 _GLIBCXX20_CONSTEXPR
1352 _M_initialize_range(_InputIterator __first, _InputIterator __last,
1355 for (; __first != __last; ++__first)
1359 template<
typename _ForwardIterator>
1360 _GLIBCXX20_CONSTEXPR
1362 _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
1367 std::copy(__first, __last,
begin());
1370#if __cplusplus < 201103L
1373 template<
typename _Integer>
1375 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1376 { _M_fill_assign(__n, __val); }
1378 template<
class _InputIterator>
1380 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1385 _GLIBCXX20_CONSTEXPR
1387 _M_fill_assign(
size_t __n,
bool __x)
1391 _M_initialize_value(__x);
1396 _M_erase_at_end(
begin() + __n);
1397 _M_initialize_value(__x);
1401 template<
typename _InputIterator>
1402 _GLIBCXX20_CONSTEXPR
1404 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1407 iterator __cur =
begin();
1408 for (; __first != __last && __cur !=
end(); ++__cur, (void)++__first)
1410 if (__first == __last)
1411 _M_erase_at_end(__cur);
1416 template<
typename _ForwardIterator>
1417 _GLIBCXX20_CONSTEXPR
1419 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1424 _M_erase_at_end(std::copy(__first, __last,
begin()));
1427 _ForwardIterator __mid = __first;
1429 std::copy(__first, __mid,
begin());
1434#if __cplusplus < 201103L
1437 template<
typename _Integer>
1439 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
1441 { _M_fill_insert(__pos, __n, __x); }
1443 template<
typename _InputIterator>
1445 _M_insert_dispatch(iterator __pos,
1446 _InputIterator __first, _InputIterator __last,
1448 { _M_insert_range(__pos, __first, __last,
1452 _GLIBCXX20_CONSTEXPR
1454 _M_fill_insert(iterator __position, size_type __n,
bool __x);
1456 template<
typename _InputIterator>
1457 _GLIBCXX20_CONSTEXPR
1459 _M_insert_range(iterator __pos, _InputIterator __first,
1462 for (; __first != __last; ++__first)
1464 __pos =
insert(__pos, *__first);
1469 template<
typename _ForwardIterator>
1470 _GLIBCXX20_CONSTEXPR
1472 _M_insert_range(iterator __position, _ForwardIterator __first,
1475 _GLIBCXX20_CONSTEXPR
1477 _M_insert_aux(iterator __position,
bool __x);
1479 _GLIBCXX20_CONSTEXPR
1481 _M_check_len(size_type __n,
const char* __s)
const
1484 __throw_length_error(__N(__s));
1490 _GLIBCXX20_CONSTEXPR
1492 _M_erase_at_end(iterator __pos)
1493 { this->_M_impl._M_finish = __pos; }
1495 _GLIBCXX20_CONSTEXPR
1497 _M_erase(iterator __pos);
1499 _GLIBCXX20_CONSTEXPR
1501 _M_erase(iterator __first, iterator __last);
1509#if __cplusplus >= 201103L
1510 void data() =
delete;