596 class vector<bool, _Alloc> :
protected _Bvector_base<_Alloc>
598 typedef _Bvector_base<_Alloc> _Base;
599 typedef typename _Base::_Bit_pointer _Bit_pointer;
600 typedef typename _Base::_Bit_alloc_traits _Bit_alloc_traits;
602#if __cplusplus >= 201103L
607 typedef bool value_type;
608 typedef size_t size_type;
609 typedef ptrdiff_t difference_type;
610 typedef _Bit_reference reference;
611 typedef bool const_reference;
612 typedef _Bit_reference* pointer;
613 typedef const bool* const_pointer;
614 typedef _Bit_iterator iterator;
615 typedef _Bit_const_iterator const_iterator;
618 typedef _Alloc allocator_type;
622 {
return _Base::get_allocator(); }
625 using _Base::_M_allocate;
626 using _Base::_M_deallocate;
627 using _Base::_S_nword;
628 using _Base::_M_get_Bit_allocator;
631#if __cplusplus >= 201103L
638 vector(
const allocator_type& __a)
641#if __cplusplus >= 201103L
643 vector(size_type __n,
const allocator_type& __a = allocator_type())
647 vector(size_type __n,
const bool& __value,
648 const allocator_type& __a = allocator_type())
651 vector(size_type __n,
const bool& __value =
bool(),
652 const allocator_type& __a = allocator_type())
657 _M_initialize_value(__value);
661 : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator()))
663 _M_initialize(__x.
size());
664 _M_copy_aligned(__x.
begin(), __x.
end(), begin());
667#if __cplusplus >= 201103L
668 vector(vector&&) =
default;
682 _M_initialize(__x.
size());
683 _M_copy_aligned(__x.
begin(), __x.
end(), begin());
689 vector(vector&& __x,
const allocator_type& __a)
690 noexcept(_Bit_alloc_traits::_S_always_equal())
695 vector(
const vector& __x,
const allocator_type& __a)
698 _M_initialize(__x.
size());
699 _M_copy_aligned(__x.
begin(), __x.
end(), begin());
703 const allocator_type& __a = allocator_type())
706 _M_initialize_range(__l.begin(), __l.end(),
711#if __cplusplus >= 201103L
712 template<
typename _InputIterator,
713 typename = std::_RequireInputIter<_InputIterator>>
714 vector(_InputIterator __first, _InputIterator __last,
715 const allocator_type& __a = allocator_type())
718 _M_initialize_range(__first, __last,
722 template<
typename _InputIterator>
723 vector(_InputIterator __first, _InputIterator __last,
724 const allocator_type& __a = allocator_type())
728 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
729 _M_initialize_dispatch(__first, __last, _Integral());
733 ~vector() _GLIBCXX_NOEXCEPT { }
740#if __cplusplus >= 201103L
741 if (_Bit_alloc_traits::_S_propagate_on_copy_assign())
743 if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator())
745 this->_M_deallocate();
746 std::__alloc_on_copy(_M_get_Bit_allocator(),
747 __x._M_get_Bit_allocator());
748 _M_initialize(__x.
size());
751 std::__alloc_on_copy(_M_get_Bit_allocator(),
752 __x._M_get_Bit_allocator());
755 if (__x.
size() > capacity())
757 this->_M_deallocate();
758 _M_initialize(__x.
size());
760 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
765#if __cplusplus >= 201103L
767 operator=(vector&& __x)
noexcept(_Bit_alloc_traits::_S_nothrow_move())
769 if (_Bit_alloc_traits::_S_propagate_on_move_assign()
770 || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator())
772 this->_M_deallocate();
774 std::__alloc_on_move(_M_get_Bit_allocator(),
775 __x._M_get_Bit_allocator());
779 if (__x.
size() > capacity())
781 this->_M_deallocate();
782 _M_initialize(__x.
size());
784 this->_M_impl._M_finish = _M_copy_aligned(__x.
begin(), __x.
end(),
794 this->
assign(__l.begin(), __l.end());
804 assign(size_type __n,
const bool& __x)
805 { _M_fill_assign(__n, __x); }
807#if __cplusplus >= 201103L
808 template<
typename _InputIterator,
809 typename = std::_RequireInputIter<_InputIterator>>
811 assign(_InputIterator __first, _InputIterator __last)
814 template<
typename _InputIterator>
816 assign(_InputIterator __first, _InputIterator __last)
819 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
820 _M_assign_dispatch(__first, __last, _Integral());
824#if __cplusplus >= 201103L
831 begin() _GLIBCXX_NOEXCEPT
832 {
return iterator(this->_M_impl._M_start._M_p, 0); }
835 begin()
const _GLIBCXX_NOEXCEPT
836 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
839 end() _GLIBCXX_NOEXCEPT
840 {
return this->_M_impl._M_finish; }
843 end()
const _GLIBCXX_NOEXCEPT
844 {
return this->_M_impl._M_finish; }
847 rbegin() _GLIBCXX_NOEXCEPT
848 {
return reverse_iterator(
end()); }
850 const_reverse_iterator
851 rbegin()
const _GLIBCXX_NOEXCEPT
852 {
return const_reverse_iterator(
end()); }
855 rend() _GLIBCXX_NOEXCEPT
856 {
return reverse_iterator(
begin()); }
858 const_reverse_iterator
859 rend()
const _GLIBCXX_NOEXCEPT
860 {
return const_reverse_iterator(
begin()); }
862#if __cplusplus >= 201103L
865 {
return const_iterator(this->_M_impl._M_start._M_p, 0); }
868 cend()
const noexcept
869 {
return this->_M_impl._M_finish; }
871 const_reverse_iterator
873 {
return const_reverse_iterator(
end()); }
875 const_reverse_iterator
876 crend()
const noexcept
877 {
return const_reverse_iterator(
begin()); }
881 size()
const _GLIBCXX_NOEXCEPT
882 {
return size_type(
end() -
begin()); }
887 const size_type __isize =
888 __gnu_cxx::__numeric_traits<difference_type>::__max
889 - int(_S_word_bit) + 1;
890 const size_type __asize
892 return (__asize <= __isize /
int(_S_word_bit)
893 ? __asize *
int(_S_word_bit) : __isize);
898 {
return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
901 _GLIBCXX_NODISCARD
bool
902 empty()
const _GLIBCXX_NOEXCEPT
907 {
return begin()[__n]; }
911 {
return begin()[__n]; }
917 if (__n >= this->
size())
918 __throw_out_of_range_fmt(__N(
"vector<bool>::_M_range_check: __n "
919 "(which is %zu) >= this->size() "
930 at(size_type __n)
const
937 __throw_length_error(__N(
"vector::reserve"));
952 {
return *(
end() - 1); }
956 {
return *(
end() - 1); }
964 data() _GLIBCXX_NOEXCEPT { }
969 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr())
970 *this->_M_impl._M_finish++ = __x;
972 _M_insert_aux(
end(), __x);
976 swap(vector& __x) _GLIBCXX_NOEXCEPT
978#if __cplusplus >= 201103L
979 __glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value
980 || _M_get_Bit_allocator() == __x._M_get_Bit_allocator());
982 this->_M_impl._M_swap_data(__x._M_impl);
983 _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(),
984 __x._M_get_Bit_allocator());
989 swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT
997#if __cplusplus >= 201103L
998 insert(const_iterator __position,
const bool& __x =
bool())
1000 insert(iterator __position,
const bool& __x =
bool())
1003 const difference_type __n = __position -
begin();
1004 if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()
1005 && __position == end())
1006 *this->_M_impl._M_finish++ = __x;
1008 _M_insert_aux(__position._M_const_cast(), __x);
1009 return begin() + __n;
1012#if __cplusplus >= 201103L
1013 template<
typename _InputIterator,
1014 typename = std::_RequireInputIter<_InputIterator>>
1016 insert(const_iterator __position,
1017 _InputIterator __first, _InputIterator __last)
1019 difference_type __offset = __position -
cbegin();
1020 _M_insert_range(__position._M_const_cast(),
1023 return begin() + __offset;
1026 template<
typename _InputIterator>
1028 insert(iterator __position,
1029 _InputIterator __first, _InputIterator __last)
1032 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1033 _M_insert_dispatch(__position, __first, __last, _Integral());
1037#if __cplusplus >= 201103L
1039 insert(const_iterator __position, size_type __n,
const bool& __x)
1041 difference_type __offset = __position -
cbegin();
1042 _M_fill_insert(__position._M_const_cast(), __n, __x);
1043 return begin() + __offset;
1047 insert(iterator __position, size_type __n,
const bool& __x)
1048 { _M_fill_insert(__position, __n, __x); }
1051#if __cplusplus >= 201103L
1054 {
return this->
insert(__p, __l.begin(), __l.end()); }
1059 { --this->_M_impl._M_finish; }
1062#if __cplusplus >= 201103L
1063 erase(const_iterator __position)
1065 erase(iterator __position)
1067 {
return _M_erase(__position._M_const_cast()); }
1070#if __cplusplus >= 201103L
1071 erase(const_iterator __first, const_iterator __last)
1073 erase(iterator __first, iterator __last)
1075 {
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
1078 resize(size_type __new_size,
bool __x =
bool())
1080 if (__new_size <
size())
1081 _M_erase_at_end(
begin() + difference_type(__new_size));
1086#if __cplusplus >= 201103L
1089 { _M_shrink_to_fit(); }
1093 flip() _GLIBCXX_NOEXCEPT
1095 _Bit_type *
const __end = this->_M_impl._M_end_addr();
1096 for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p)
1101 clear() _GLIBCXX_NOEXCEPT
1102 { _M_erase_at_end(
begin()); }
1104#if __cplusplus >= 201103L
1105 template<
typename... _Args>
1106#if __cplusplus > 201402L
1111 emplace_back(_Args&&... __args)
1114#if __cplusplus > 201402L
1119 template<
typename... _Args>
1121 emplace(const_iterator __pos, _Args&&... __args)
1122 {
return insert(__pos,
bool(__args...)); }
1128 _M_copy_aligned(const_iterator __first, const_iterator __last,
1131 _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p);
1132 return std::copy(const_iterator(__last._M_p, 0), __last,
1137 _M_initialize(size_type __n)
1141 _Bit_pointer __q = this->_M_allocate(__n);
1142 this->_M_impl._M_end_of_storage = __q + _S_nword(__n);
1144 this->_M_impl._M_start = __start;
1145 this->_M_impl._M_finish = __start + difference_type(__n);
1150 _M_initialize_value(
bool __x)
1152 if (_Bit_type* __p = this->_M_impl._M_start._M_p)
1153 __builtin_memset(__p, __x ? ~0 : 0,
1154 (this->_M_impl._M_end_addr() - __p)
1155 *
sizeof(_Bit_type));
1159 _M_reallocate(size_type __n);
1161#if __cplusplus >= 201103L
1166#if __cplusplus < 201103L
1169 template<
typename _Integer>
1171 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1173 _M_initialize(
static_cast<size_type
>(__n));
1174 _M_initialize_value(__x);
1177 template<
typename _InputIterator>
1179 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1181 { _M_initialize_range(__first, __last,
1185 template<
typename _InputIterator>
1187 _M_initialize_range(_InputIterator __first, _InputIterator __last,
1190 for (; __first != __last; ++__first)
1194 template<
typename _ForwardIterator>
1196 _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
1201 std::copy(__first, __last,
begin());
1204#if __cplusplus < 201103L
1207 template<
typename _Integer>
1209 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1210 { _M_fill_assign(__n, __val); }
1212 template<
class _InputIterator>
1214 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1220 _M_fill_assign(
size_t __n,
bool __x)
1224 _M_initialize_value(__x);
1229 _M_erase_at_end(
begin() + __n);
1230 _M_initialize_value(__x);
1234 template<
typename _InputIterator>
1236 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1239 iterator __cur =
begin();
1240 for (; __first != __last && __cur !=
end(); ++__cur, (void)++__first)
1242 if (__first == __last)
1243 _M_erase_at_end(__cur);
1248 template<
typename _ForwardIterator>
1250 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1255 _M_erase_at_end(std::copy(__first, __last,
begin()));
1258 _ForwardIterator __mid = __first;
1260 std::copy(__first, __mid,
begin());
1265#if __cplusplus < 201103L
1268 template<
typename _Integer>
1270 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
1272 { _M_fill_insert(__pos, __n, __x); }
1274 template<
typename _InputIterator>
1276 _M_insert_dispatch(iterator __pos,
1277 _InputIterator __first, _InputIterator __last,
1279 { _M_insert_range(__pos, __first, __last,
1284 _M_fill_insert(iterator __position, size_type __n,
bool __x);
1286 template<
typename _InputIterator>
1288 _M_insert_range(iterator __pos, _InputIterator __first,
1291 for (; __first != __last; ++__first)
1293 __pos =
insert(__pos, *__first);
1298 template<
typename _ForwardIterator>
1300 _M_insert_range(iterator __position, _ForwardIterator __first,
1304 _M_insert_aux(iterator __position,
bool __x);
1307 _M_check_len(size_type __n,
const char* __s)
const
1310 __throw_length_error(__N(__s));
1317 _M_erase_at_end(iterator __pos)
1318 { this->_M_impl._M_finish = __pos; }
1321 _M_erase(iterator __pos);
1324 _M_erase(iterator __first, iterator __last);