Commit 705debec by Paolo Carlini Committed by Paolo Carlini

stl_bvector.h: Trivial formatting fixes.

2004-08-09  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/stl_bvector.h: Trivial formatting fixes.

2004-08-09  Paolo Carlini  <pcarlini@suse.de>

	* src/ios.cc (ios_base::_M_grow_words): Uglify the names.

From-SVN: r85716
parent 27f577e5
2004-08-09 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_bvector.h: Trivial formatting fixes.
2004-08-09 Paolo Carlini <pcarlini@suse.de>
* src/ios.cc (ios_base::_M_grow_words): Uglify the names.
2004-08-07 Jonathan Wakely <redi@gcc.gnu.org> 2004-08-07 Jonathan Wakely <redi@gcc.gnu.org>
Paolo Carlini <pcarlini@suse.de> Paolo Carlini <pcarlini@suse.de>
......
...@@ -76,7 +76,8 @@ namespace _GLIBCXX_STD ...@@ -76,7 +76,8 @@ namespace _GLIBCXX_STD
_Bit_reference() : _M_p(0), _M_mask(0) { } _Bit_reference() : _M_p(0), _M_mask(0) { }
operator bool() const { return !!(*_M_p & _M_mask); } operator bool() const
{ return !!(*_M_p & _M_mask); }
_Bit_reference& _Bit_reference&
operator=(bool __x) operator=(bool __x)
...@@ -101,7 +102,8 @@ namespace _GLIBCXX_STD ...@@ -101,7 +102,8 @@ namespace _GLIBCXX_STD
{ return !bool(*this) && bool(__x); } { return !bool(*this) && bool(__x); }
void void
flip() { *_M_p ^= _M_mask; } flip()
{ *_M_p ^= _M_mask; }
}; };
struct _Bit_iterator_base : public iterator<random_access_iterator_tag, bool> struct _Bit_iterator_base : public iterator<random_access_iterator_tag, bool>
...@@ -188,11 +190,13 @@ namespace _GLIBCXX_STD ...@@ -188,11 +190,13 @@ namespace _GLIBCXX_STD
typedef _Bit_iterator iterator; typedef _Bit_iterator iterator;
_Bit_iterator() : _Bit_iterator_base(0, 0) { } _Bit_iterator() : _Bit_iterator_base(0, 0) { }
_Bit_iterator(_Bit_type * __x, unsigned int __y) _Bit_iterator(_Bit_type * __x, unsigned int __y)
: _Bit_iterator_base(__x, __y) { } : _Bit_iterator_base(__x, __y) { }
reference reference
operator*() const { return reference(_M_p, 1UL << _M_offset); } operator*() const
{ return reference(_M_p, 1UL << _M_offset); }
iterator& iterator&
operator++() operator++()
...@@ -258,8 +262,8 @@ namespace _GLIBCXX_STD ...@@ -258,8 +262,8 @@ namespace _GLIBCXX_STD
}; };
inline _Bit_iterator inline _Bit_iterator
operator+(ptrdiff_t __n, const _Bit_iterator& __x) { return __x + __n; } operator+(ptrdiff_t __n, const _Bit_iterator& __x)
{ return __x + __n; }
struct _Bit_const_iterator : public _Bit_iterator_base struct _Bit_const_iterator : public _Bit_iterator_base
{ {
...@@ -269,8 +273,10 @@ namespace _GLIBCXX_STD ...@@ -269,8 +273,10 @@ namespace _GLIBCXX_STD
typedef _Bit_const_iterator const_iterator; typedef _Bit_const_iterator const_iterator;
_Bit_const_iterator() : _Bit_iterator_base(0, 0) { } _Bit_const_iterator() : _Bit_iterator_base(0, 0) { }
_Bit_const_iterator(_Bit_type * __x, unsigned int __y) _Bit_const_iterator(_Bit_type * __x, unsigned int __y)
: _Bit_iterator_base(__x, __y) { } : _Bit_iterator_base(__x, __y) { }
_Bit_const_iterator(const _Bit_iterator& __x) _Bit_const_iterator(const _Bit_iterator& __x)
: _Bit_iterator_base(__x._M_p, __x._M_offset) { } : _Bit_iterator_base(__x._M_p, __x._M_offset) { }
...@@ -370,7 +376,8 @@ namespace _GLIBCXX_STD ...@@ -370,7 +376,8 @@ namespace _GLIBCXX_STD
_Bvector_base(const allocator_type& __a) : _M_impl(__a) { } _Bvector_base(const allocator_type& __a) : _M_impl(__a) { }
~_Bvector_base() { this->_M_deallocate(); } ~_Bvector_base()
{ this->_M_deallocate(); }
protected: protected:
_Bvector_impl _M_impl; _Bvector_impl _M_impl;
...@@ -384,7 +391,7 @@ namespace _GLIBCXX_STD ...@@ -384,7 +391,7 @@ namespace _GLIBCXX_STD
{ {
if (_M_impl._M_start._M_p) if (_M_impl._M_start._M_p)
_M_impl.deallocate(_M_impl._M_start._M_p, _M_impl.deallocate(_M_impl._M_start._M_p,
_M_impl._M_end_of_storage - _M_impl._M_start._M_p); _M_impl._M_end_of_storage - _M_impl._M_start._M_p);
} }
}; };
} // namespace std } // namespace std
...@@ -440,16 +447,19 @@ template<typename _Alloc> ...@@ -440,16 +447,19 @@ template<typename _Alloc>
using _Bvector_base<_Alloc>::_M_deallocate; using _Bvector_base<_Alloc>::_M_deallocate;
protected: protected:
void _M_initialize(size_type __n) void
_M_initialize(size_type __n)
{ {
_Bit_type* __q = this->_M_allocate(__n); _Bit_type* __q = this->_M_allocate(__n);
this->_M_impl._M_end_of_storage = __q this->_M_impl._M_end_of_storage = (__q
+ (__n + _S_word_bit - 1) / _S_word_bit; + ((__n + _S_word_bit - 1)
/ _S_word_bit));
this->_M_impl._M_start = iterator(__q, 0); this->_M_impl._M_start = iterator(__q, 0);
this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n); this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n);
} }
void _M_insert_aux(iterator __position, bool __x) void
_M_insert_aux(iterator __position, bool __x)
{ {
if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage) if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage)
{ {
...@@ -467,129 +477,154 @@ template<typename _Alloc> ...@@ -467,129 +477,154 @@ template<typename _Alloc>
*__i++ = __x; *__i++ = __x;
this->_M_impl._M_finish = std::copy(__position, end(), __i); this->_M_impl._M_finish = std::copy(__position, end(), __i);
this->_M_deallocate(); this->_M_deallocate();
this->_M_impl._M_end_of_storage = __q + (__len + _S_word_bit - 1) this->_M_impl._M_end_of_storage = (__q + ((__len + _S_word_bit - 1)
/ _S_word_bit; / _S_word_bit));
this->_M_impl._M_start = iterator(__q, 0); this->_M_impl._M_start = iterator(__q, 0);
} }
} }
template<class _InputIterator> template<class _InputIterator>
void _M_initialize_range(_InputIterator __first, _InputIterator __last, void
input_iterator_tag) _M_initialize_range(_InputIterator __first, _InputIterator __last,
{ input_iterator_tag)
this->_M_impl._M_start = iterator(); {
this->_M_impl._M_finish = iterator(); this->_M_impl._M_start = iterator();
this->_M_impl._M_end_of_storage = 0; this->_M_impl._M_finish = iterator();
for ( ; __first != __last; ++__first) this->_M_impl._M_end_of_storage = 0;
push_back(*__first); for (; __first != __last; ++__first)
} push_back(*__first);
}
template<class _ForwardIterator> template<class _ForwardIterator>
void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, void
forward_iterator_tag) _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
{ forward_iterator_tag)
const size_type __n = std::distance(__first, __last); {
_M_initialize(__n); const size_type __n = std::distance(__first, __last);
std::copy(__first, __last, this->_M_impl._M_start); _M_initialize(__n);
} std::copy(__first, __last, this->_M_impl._M_start);
}
template<class _InputIterator> template<class _InputIterator>
void _M_insert_range(iterator __pos, _InputIterator __first, void
_InputIterator __last, input_iterator_tag) _M_insert_range(iterator __pos, _InputIterator __first,
{ _InputIterator __last, input_iterator_tag)
for ( ; __first != __last; ++__first) {
{ for (; __first != __last; ++__first)
__pos = insert(__pos, *__first); {
++__pos; __pos = insert(__pos, *__first);
} ++__pos;
} }
}
template<class _ForwardIterator> template<class _ForwardIterator>
void _M_insert_range(iterator __position, _ForwardIterator __first, void
_ForwardIterator __last, forward_iterator_tag) _M_insert_range(iterator __position, _ForwardIterator __first,
{ _ForwardIterator __last, forward_iterator_tag)
if (__first != __last) {
{ if (__first != __last)
size_type __n = std::distance(__first, __last); {
if (capacity() - size() >= __n) size_type __n = std::distance(__first, __last);
{ if (capacity() - size() >= __n)
std::copy_backward(__position, end(), {
this->_M_impl._M_finish + difference_type(__n)); std::copy_backward(__position, end(),
std::copy(__first, __last, __position); this->_M_impl._M_finish
this->_M_impl._M_finish += difference_type(__n); + difference_type(__n));
} std::copy(__first, __last, __position);
else this->_M_impl._M_finish += difference_type(__n);
{ }
const size_type __len = size() + std::max(size(), __n); else
_Bit_type * __q = this->_M_allocate(__len); {
iterator __i = std::copy(begin(), __position, iterator(__q, 0)); const size_type __len = size() + std::max(size(), __n);
__i = std::copy(__first, __last, __i); _Bit_type * __q = this->_M_allocate(__len);
this->_M_impl._M_finish = std::copy(__position, end(), __i); iterator __i = std::copy(begin(), __position,
this->_M_deallocate(); iterator(__q, 0));
this->_M_impl._M_end_of_storage = __q + (__len + _S_word_bit - 1) __i = std::copy(__first, __last, __i);
/ _S_word_bit; this->_M_impl._M_finish = std::copy(__position, end(), __i);
this->_M_impl._M_start = iterator(__q, 0); this->_M_deallocate();
} this->_M_impl._M_end_of_storage = (__q
} + ((__len + _S_word_bit - 1)
} / _S_word_bit));
this->_M_impl._M_start = iterator(__q, 0);
}
}
}
public: public:
iterator begin() iterator
begin()
{ return this->_M_impl._M_start; } { return this->_M_impl._M_start; }
const_iterator begin() const const_iterator
begin() const
{ return this->_M_impl._M_start; } { return this->_M_impl._M_start; }
iterator end() iterator
end()
{ return this->_M_impl._M_finish; } { return this->_M_impl._M_finish; }
const_iterator end() const const_iterator
end() const
{ return this->_M_impl._M_finish; } { return this->_M_impl._M_finish; }
reverse_iterator rbegin() reverse_iterator
rbegin()
{ return reverse_iterator(end()); } { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const const_reverse_iterator
rbegin() const
{ return const_reverse_iterator(end()); } { return const_reverse_iterator(end()); }
reverse_iterator rend() reverse_iterator
rend()
{ return reverse_iterator(begin()); } { return reverse_iterator(begin()); }
const_reverse_iterator rend() const const_reverse_iterator
rend() const
{ return const_reverse_iterator(begin()); } { return const_reverse_iterator(begin()); }
size_type size() const size_type
size() const
{ return size_type(end() - begin()); } { return size_type(end() - begin()); }
size_type max_size() const size_type
max_size() const
{ return size_type(-1); } { return size_type(-1); }
size_type capacity() const size_type
capacity() const
{ return size_type(const_iterator(this->_M_impl._M_end_of_storage, 0) { return size_type(const_iterator(this->_M_impl._M_end_of_storage, 0)
- begin()); } - begin()); }
bool empty() const bool
empty() const
{ return begin() == end(); } { return begin() == end(); }
reference operator[](size_type __n) reference
operator[](size_type __n)
{ return *(begin() + difference_type(__n)); } { return *(begin() + difference_type(__n)); }
const_reference operator[](size_type __n) const const_reference
operator[](size_type __n) const
{ return *(begin() + difference_type(__n)); } { return *(begin() + difference_type(__n)); }
void _M_range_check(size_type __n) const void
_M_range_check(size_type __n) const
{ {
if (__n >= this->size()) if (__n >= this->size())
__throw_out_of_range(__N("vector<bool>::_M_range_check")); __throw_out_of_range(__N("vector<bool>::_M_range_check"));
} }
reference at(size_type __n) reference
at(size_type __n)
{ _M_range_check(__n); return (*this)[__n]; } { _M_range_check(__n); return (*this)[__n]; }
const_reference at(size_type __n) const const_reference
at(size_type __n) const
{ _M_range_check(__n); return (*this)[__n]; } { _M_range_check(__n); return (*this)[__n]; }
explicit vector(const allocator_type& __a = allocator_type()) explicit
: _Bvector_base<_Alloc>(__a) { } vector(const allocator_type& __a = allocator_type())
: _Bvector_base<_Alloc>(__a) { }
vector(size_type __n, bool __value, vector(size_type __n, bool __value,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
...@@ -600,7 +635,8 @@ template<typename _Alloc> ...@@ -600,7 +635,8 @@ template<typename _Alloc>
__value ? ~0 : 0); __value ? ~0 : 0);
} }
explicit vector(size_type __n) explicit
vector(size_type __n)
: _Bvector_base<_Alloc>(allocator_type()) : _Bvector_base<_Alloc>(allocator_type())
{ {
_M_initialize(__n); _M_initialize(__n);
...@@ -608,7 +644,8 @@ template<typename _Alloc> ...@@ -608,7 +644,8 @@ template<typename _Alloc>
this->_M_impl._M_end_of_storage, 0); this->_M_impl._M_end_of_storage, 0);
} }
vector(const vector& __x) : _Bvector_base<_Alloc>(__x.get_allocator()) vector(const vector& __x)
: _Bvector_base<_Alloc>(__x.get_allocator())
{ {
_M_initialize(__x.size()); _M_initialize(__x.size());
std::copy(__x.begin(), __x.end(), this->_M_impl._M_start); std::copy(__x.begin(), __x.end(), this->_M_impl._M_start);
...@@ -616,12 +653,13 @@ template<typename _Alloc> ...@@ -616,12 +653,13 @@ template<typename _Alloc>
// Check whether it's an integral type. If so, it's not an iterator. // Check whether it's an integral type. If so, it's not an iterator.
template<class _Integer> template<class _Integer>
void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) void
{ _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
_M_initialize(__n); {
std::fill(this->_M_impl._M_start._M_p, _M_initialize(__n);
this->_M_impl._M_end_of_storage, __x ? ~0 : 0); std::fill(this->_M_impl._M_start._M_p,
} this->_M_impl._M_end_of_storage, __x ? ~0 : 0);
}
template<class _InputIterator> template<class _InputIterator>
void void
...@@ -633,15 +671,16 @@ template<typename _Alloc> ...@@ -633,15 +671,16 @@ template<typename _Alloc>
template<class _InputIterator> template<class _InputIterator>
vector(_InputIterator __first, _InputIterator __last, vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Bvector_base<_Alloc>(__a) : _Bvector_base<_Alloc>(__a)
{ {
typedef typename _Is_integer<_InputIterator>::_Integral _Integral; typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
_M_initialize_dispatch(__first, __last, _Integral()); _M_initialize_dispatch(__first, __last, _Integral());
} }
~vector() { } ~vector() { }
vector& operator=(const vector& __x) vector&
operator=(const vector& __x)
{ {
if (&__x == this) if (&__x == this)
return *this; return *this;
...@@ -660,7 +699,8 @@ template<typename _Alloc> ...@@ -660,7 +699,8 @@ template<typename _Alloc>
// The range version is a member template, so we dispatch on whether // The range version is a member template, so we dispatch on whether
// or not the type is an integer. // or not the type is an integer.
void _M_fill_assign(size_t __n, bool __x) void
_M_fill_assign(size_t __n, bool __x)
{ {
if (__n > size()) if (__n > size())
{ {
...@@ -676,55 +716,62 @@ template<typename _Alloc> ...@@ -676,55 +716,62 @@ template<typename _Alloc>
} }
} }
void assign(size_t __n, bool __x) void
assign(size_t __n, bool __x)
{ _M_fill_assign(__n, __x); } { _M_fill_assign(__n, __x); }
template<class _InputIterator> template<class _InputIterator>
void assign(_InputIterator __first, _InputIterator __last) void
{ assign(_InputIterator __first, _InputIterator __last)
typedef typename _Is_integer<_InputIterator>::_Integral _Integral; {
_M_assign_dispatch(__first, __last, _Integral()); typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
} _M_assign_dispatch(__first, __last, _Integral());
}
template<class _Integer> template<class _Integer>
void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) void
{ _M_fill_assign((size_t) __n, (bool) __val); } _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign((size_t) __n, (bool) __val); }
template<class _InputIterator> template<class _InputIterator>
void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, void
__false_type) _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); } __false_type)
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
template<class _InputIterator> template<class _InputIterator>
void _M_assign_aux(_InputIterator __first, _InputIterator __last, void
input_iterator_tag) _M_assign_aux(_InputIterator __first, _InputIterator __last,
{ input_iterator_tag)
iterator __cur = begin(); {
for ( ; __first != __last && __cur != end(); ++__cur, ++__first) iterator __cur = begin();
*__cur = *__first; for (; __first != __last && __cur != end(); ++__cur, ++__first)
if (__first == __last) *__cur = *__first;
erase(__cur, end()); if (__first == __last)
else erase(__cur, end());
insert(end(), __first, __last); else
} insert(end(), __first, __last);
}
template<class _ForwardIterator> template<class _ForwardIterator>
void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, void
forward_iterator_tag) _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
{ forward_iterator_tag)
const size_type __len = std::distance(__first, __last); {
if (__len < size()) const size_type __len = std::distance(__first, __last);
erase(std::copy(__first, __last, begin()), end()); if (__len < size())
else erase(std::copy(__first, __last, begin()), end());
{ else
_ForwardIterator __mid = __first; {
std::advance(__mid, size()); _ForwardIterator __mid = __first;
std::copy(__first, __mid, begin()); std::advance(__mid, size());
insert(end(), __mid, __last); std::copy(__first, __mid, begin());
} insert(end(), __mid, __last);
} }
}
void reserve(size_type __n) void
reserve(size_type __n)
{ {
if (__n > this->max_size()) if (__n > this->max_size())
__throw_length_error(__N("vector::reserve")); __throw_length_error(__N("vector::reserve"));
...@@ -735,23 +782,29 @@ template<typename _Alloc> ...@@ -735,23 +782,29 @@ template<typename _Alloc>
iterator(__q, 0)); iterator(__q, 0));
this->_M_deallocate(); this->_M_deallocate();
this->_M_impl._M_start = iterator(__q, 0); this->_M_impl._M_start = iterator(__q, 0);
this->_M_impl._M_end_of_storage = __q + (__n + _S_word_bit - 1) / _S_word_bit; this->_M_impl._M_end_of_storage = (__q + (__n + _S_word_bit - 1)
/ _S_word_bit);
} }
} }
reference front() reference
front()
{ return *begin(); } { return *begin(); }
const_reference front() const const_reference
front() const
{ return *begin(); } { return *begin(); }
reference back() reference
back()
{ return *(end() - 1); } { return *(end() - 1); }
const_reference back() const const_reference
back() const
{ return *(end() - 1); } { return *(end() - 1); }
void push_back(bool __x) void
push_back(bool __x)
{ {
if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage) if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage)
*this->_M_impl._M_finish++ = __x; *this->_M_impl._M_finish++ = __x;
...@@ -759,7 +812,8 @@ template<typename _Alloc> ...@@ -759,7 +812,8 @@ template<typename _Alloc>
_M_insert_aux(end(), __x); _M_insert_aux(end(), __x);
} }
void swap(vector<bool, _Alloc>& __x) void
swap(vector<bool, _Alloc>& __x)
{ {
std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
...@@ -768,14 +822,16 @@ template<typename _Alloc> ...@@ -768,14 +822,16 @@ template<typename _Alloc>
} }
// [23.2.5]/1, third-to-last entry in synopsis listing // [23.2.5]/1, third-to-last entry in synopsis listing
static void swap(reference __x, reference __y) static void
swap(reference __x, reference __y)
{ {
bool __tmp = __x; bool __tmp = __x;
__x = __y; __x = __y;
__y = __tmp; __y = __tmp;
} }
iterator insert(iterator __position, bool __x = bool()) iterator
insert(iterator __position, bool __x = bool())
{ {
const difference_type __n = __position - begin(); const difference_type __n = __position - begin();
if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage
...@@ -789,26 +845,30 @@ template<typename _Alloc> ...@@ -789,26 +845,30 @@ template<typename _Alloc>
// Check whether it's an integral type. If so, it's not an iterator. // Check whether it's an integral type. If so, it's not an iterator.
template<class _Integer> template<class _Integer>
void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, void
__true_type) _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
{ _M_fill_insert(__pos, __n, __x); } __true_type)
{ _M_fill_insert(__pos, __n, __x); }
template<class _InputIterator> template<class _InputIterator>
void _M_insert_dispatch(iterator __pos, void
_InputIterator __first, _InputIterator __last, _M_insert_dispatch(iterator __pos,
__false_type) _InputIterator __first, _InputIterator __last,
{ _M_insert_range(__pos, __first, __last, __false_type)
std::__iterator_category(__first)); } { _M_insert_range(__pos, __first, __last,
std::__iterator_category(__first)); }
template<class _InputIterator> template<class _InputIterator>
void insert(iterator __position, void
_InputIterator __first, _InputIterator __last) insert(iterator __position,
{ _InputIterator __first, _InputIterator __last)
typedef typename _Is_integer<_InputIterator>::_Integral _Integral; {
_M_insert_dispatch(__position, __first, __last, _Integral()); typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
} _M_insert_dispatch(__position, __first, __last, _Integral());
}
void _M_fill_insert(iterator __position, size_type __n, bool __x) void
_M_fill_insert(iterator __position, size_type __n, bool __x)
{ {
if (__n == 0) if (__n == 0)
return; return;
...@@ -828,19 +888,22 @@ template<typename _Alloc> ...@@ -828,19 +888,22 @@ template<typename _Alloc>
this->_M_impl._M_finish = std::copy(__position, end(), this->_M_impl._M_finish = std::copy(__position, end(),
__i + difference_type(__n)); __i + difference_type(__n));
this->_M_deallocate(); this->_M_deallocate();
this->_M_impl._M_end_of_storage = __q + (__len + _S_word_bit - 1) this->_M_impl._M_end_of_storage = (__q + ((__len + _S_word_bit - 1)
/ _S_word_bit; / _S_word_bit));
this->_M_impl._M_start = iterator(__q, 0); this->_M_impl._M_start = iterator(__q, 0);
} }
} }
void insert(iterator __position, size_type __n, bool __x) void
insert(iterator __position, size_type __n, bool __x)
{ _M_fill_insert(__position, __n, __x); } { _M_fill_insert(__position, __n, __x); }
void pop_back() void
pop_back()
{ --this->_M_impl._M_finish; } { --this->_M_impl._M_finish; }
iterator erase(iterator __position) iterator
erase(iterator __position)
{ {
if (__position + 1 != end()) if (__position + 1 != end())
std::copy(__position + 1, end(), __position); std::copy(__position + 1, end(), __position);
...@@ -848,13 +911,15 @@ template<typename _Alloc> ...@@ -848,13 +911,15 @@ template<typename _Alloc>
return __position; return __position;
} }
iterator erase(iterator __first, iterator __last) iterator
erase(iterator __first, iterator __last)
{ {
this->_M_impl._M_finish = std::copy(__last, end(), __first); this->_M_impl._M_finish = std::copy(__last, end(), __first);
return __first; return __first;
} }
void resize(size_type __new_size, bool __x = bool()) void
resize(size_type __new_size, bool __x = bool())
{ {
if (__new_size < size()) if (__new_size < size())
erase(begin() + difference_type(__new_size), end()); erase(begin() + difference_type(__new_size), end());
...@@ -862,14 +927,16 @@ template<typename _Alloc> ...@@ -862,14 +927,16 @@ template<typename _Alloc>
insert(end(), __new_size - size(), __x); insert(end(), __new_size - size(), __x);
} }
void flip() void
flip()
{ {
for (_Bit_type * __p = this->_M_impl._M_start._M_p; for (_Bit_type * __p = this->_M_impl._M_start._M_p;
__p != this->_M_impl._M_end_of_storage; ++__p) __p != this->_M_impl._M_end_of_storage; ++__p)
*__p = ~*__p; *__p = ~*__p;
} }
void clear() void
clear()
{ erase(begin(), end()); } { erase(begin(), end()); }
}; };
} // namespace std } // namespace std
......
...@@ -149,32 +149,32 @@ namespace std ...@@ -149,32 +149,32 @@ namespace std
// 27.4.2.5 iword/pword storage // 27.4.2.5 iword/pword storage
ios_base::_Words& ios_base::_Words&
ios_base::_M_grow_words(int ix, bool iword) ios_base::_M_grow_words(int __ix, bool __iword)
{ {
// Precondition: _M_word_size <= ix // Precondition: _M_word_size <= __ix
int newsize = _S_local_word_size; int __newsize = _S_local_word_size;
_Words* words = _M_local_word; _Words* __words = _M_local_word;
if (ix > _S_local_word_size - 1) if (__ix > _S_local_word_size - 1)
{ {
if (ix < numeric_limits<int>::max()) if (__ix < numeric_limits<int>::max())
{ {
newsize = ix + 1; __newsize = __ix + 1;
try try
{ words = new _Words[newsize]; } { __words = new _Words[__newsize]; }
catch (...) catch (...)
{ {
_M_streambuf_state |= badbit; _M_streambuf_state |= badbit;
if (_M_streambuf_state & _M_exception) if (_M_streambuf_state & _M_exception)
__throw_ios_failure(__N("ios_base::_M_grow_words " __throw_ios_failure(__N("ios_base::_M_grow_words "
"allocation failed")); "allocation failed"));
if (iword) if (__iword)
_M_word_zero._M_iword = 0; _M_word_zero._M_iword = 0;
else else
_M_word_zero._M_pword = 0; _M_word_zero._M_pword = 0;
return _M_word_zero; return _M_word_zero;
} }
for (int i = 0; i < _M_word_size; i++) for (int __i = 0; __i < _M_word_size; __i++)
words[i] = _M_word[i]; __words[__i] = _M_word[__i];
if (_M_word && _M_word != _M_local_word) if (_M_word && _M_word != _M_local_word)
{ {
delete [] _M_word; delete [] _M_word;
...@@ -186,16 +186,16 @@ namespace std ...@@ -186,16 +186,16 @@ namespace std
_M_streambuf_state |= badbit; _M_streambuf_state |= badbit;
if (_M_streambuf_state & _M_exception) if (_M_streambuf_state & _M_exception)
__throw_ios_failure(__N("ios_base::_M_grow_words is not valid")); __throw_ios_failure(__N("ios_base::_M_grow_words is not valid"));
if (iword) if (__iword)
_M_word_zero._M_iword = 0; _M_word_zero._M_iword = 0;
else else
_M_word_zero._M_pword = 0; _M_word_zero._M_pword = 0;
return _M_word_zero; return _M_word_zero;
} }
} }
_M_word = words; _M_word = __words;
_M_word_size = newsize; _M_word_size = __newsize;
return _M_word[ix]; return _M_word[__ix];
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment