This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] More trivial formatting fixes
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 26 Apr 2004 11:04:46 +0200
- Subject: [v3] More trivial formatting fixes
Hi,
tested x86-linux.
Paolo.
///////////////
2004-04-26 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_vector.h: Trivial formatting fixes.
* include/bits/vector.tcc: Likewise.
diff -prN libstdc++-v3-orig/include/bits/stl_vector.h libstdc++-v3/include/bits/stl_vector.h
*** libstdc++-v3-orig/include/bits/stl_vector.h Fri Apr 16 21:04:03 2004
--- libstdc++-v3/include/bits/stl_vector.h Mon Apr 26 00:58:22 2004
***************
*** 1,6 ****
// Vector implementation -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
--- 1,6 ----
// Vector implementation -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
*************** namespace _GLIBCXX_STD
*** 76,87 ****
struct _Vector_base
{
struct _Vector_impl
! : public _Alloc {
_Tp* _M_start;
_Tp* _M_finish;
_Tp* _M_end_of_storage;
_Vector_impl (_Alloc const& __a)
! : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
{ }
};
--- 76,88 ----
struct _Vector_base
{
struct _Vector_impl
! : public _Alloc
! {
_Tp* _M_start;
_Tp* _M_finish;
_Tp* _M_end_of_storage;
_Vector_impl (_Alloc const& __a)
! : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
{ }
};
*************** namespace _GLIBCXX_STD
*** 89,101 ****
typedef _Alloc allocator_type;
allocator_type
! get_allocator() const { return *static_cast<const _Alloc*>(&this->_M_impl); }
! _Vector_base(const allocator_type& __a) : _M_impl(__a)
{ }
_Vector_base(size_t __n, const allocator_type& __a)
! : _M_impl(__a)
{
this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_finish = this->_M_impl._M_start;
--- 90,104 ----
typedef _Alloc allocator_type;
allocator_type
! get_allocator() const
! { return *static_cast<const _Alloc*>(&this->_M_impl); }
! _Vector_base(const allocator_type& __a)
! : _M_impl(__a)
{ }
_Vector_base(size_t __n, const allocator_type& __a)
! : _M_impl(__a)
{
this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_finish = this->_M_impl._M_start;
*************** namespace _GLIBCXX_STD
*** 103,120 ****
}
~_Vector_base()
! { _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start); }
public:
_Vector_impl _M_impl;
_Tp*
! _M_allocate(size_t __n) { return _M_impl.allocate(__n); }
void
_M_deallocate(_Tp* __p, size_t __n)
! { if (__p) _M_impl.deallocate(__p, __n); }
};
--- 106,126 ----
}
~_Vector_base()
! { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
! - this->_M_impl._M_start); }
public:
_Vector_impl _M_impl;
_Tp*
! _M_allocate(size_t __n)
! { return _M_impl.allocate(__n); }
void
_M_deallocate(_Tp* __p, size_t __n)
! { if (__p)
! _M_impl.deallocate(__p, __n);
! }
};
*************** namespace _GLIBCXX_STD
*** 179,185 ****
*/
explicit
vector(const allocator_type& __a = allocator_type())
! : _Base(__a) { }
/**
* @brief Create a %vector with copies of an exemplar element.
--- 185,192 ----
*/
explicit
vector(const allocator_type& __a = allocator_type())
! : _Base(__a)
! { }
/**
* @brief Create a %vector with copies of an exemplar element.
*************** namespace _GLIBCXX_STD
*** 191,198 ****
vector(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(__n, __a)
! { this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
! __n, __value); }
/**
* @brief Create a %vector with default elements.
--- 198,206 ----
vector(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(__n, __a)
! { this->_M_impl._M_finish = std::uninitialized_fill_n(this->
! _M_impl._M_start,
! __n, __value); }
/**
* @brief Create a %vector with default elements.
*************** namespace _GLIBCXX_STD
*** 204,211 ****
explicit
vector(size_type __n)
: _Base(__n, allocator_type())
! { this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
! __n, value_type()); }
/**
* @brief %Vector copy constructor.
--- 212,221 ----
explicit
vector(size_type __n)
: _Base(__n, allocator_type())
! { this->_M_impl._M_finish = std::uninitialized_fill_n(this->
! _M_impl._M_start,
! __n,
! value_type()); }
/**
* @brief %Vector copy constructor.
*************** namespace _GLIBCXX_STD
*** 218,225 ****
*/
vector(const vector& __x)
: _Base(__x.size(), __x.get_allocator())
! { this->_M_impl._M_finish = std::uninitialized_copy(__x.begin(), __x.end(),
! this->_M_impl._M_start);
}
/**
--- 228,237 ----
*/
vector(const vector& __x)
: _Base(__x.size(), __x.get_allocator())
! { this->_M_impl._M_finish = std::uninitialized_copy(__x.begin(),
! __x.end(),
! this->
! _M_impl._M_start);
}
/**
*************** namespace _GLIBCXX_STD
*** 253,259 ****
* not touched in any way. Managing the pointer is the user's
* responsibilty.
*/
! ~vector() { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); }
/**
* @brief %Vector assignment operator.
--- 265,272 ----
* not touched in any way. Managing the pointer is the user's
* responsibilty.
*/
! ~vector()
! { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); }
/**
* @brief %Vector assignment operator.
*************** namespace _GLIBCXX_STD
*** 311,317 ****
* element order.
*/
iterator
! begin() { return iterator (this->_M_impl._M_start); }
/**
* Returns a read-only (constant) iterator that points to the
--- 324,331 ----
* element order.
*/
iterator
! begin()
! { return iterator (this->_M_impl._M_start); }
/**
* Returns a read-only (constant) iterator that points to the
*************** namespace _GLIBCXX_STD
*** 319,325 ****
* element order.
*/
const_iterator
! begin() const { return const_iterator (this->_M_impl._M_start); }
/**
* Returns a read/write iterator that points one past the last
--- 333,340 ----
* element order.
*/
const_iterator
! begin() const
! { return const_iterator (this->_M_impl._M_start); }
/**
* Returns a read/write iterator that points one past the last
*************** namespace _GLIBCXX_STD
*** 327,333 ****
* element order.
*/
iterator
! end() { return iterator (this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) iterator that points one past
--- 342,349 ----
* element order.
*/
iterator
! end()
! { return iterator (this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) iterator that points one past
*************** namespace _GLIBCXX_STD
*** 335,341 ****
* ordinary element order.
*/
const_iterator
! end() const { return const_iterator (this->_M_impl._M_finish); }
/**
* Returns a read/write reverse iterator that points to the
--- 351,358 ----
* ordinary element order.
*/
const_iterator
! end() const
! { return const_iterator (this->_M_impl._M_finish); }
/**
* Returns a read/write reverse iterator that points to the
*************** namespace _GLIBCXX_STD
*** 343,349 ****
* element order.
*/
reverse_iterator
! rbegin() { return reverse_iterator(end()); }
/**
* Returns a read-only (constant) reverse iterator that points
--- 360,367 ----
* element order.
*/
reverse_iterator
! rbegin()
! { return reverse_iterator(end()); }
/**
* Returns a read-only (constant) reverse iterator that points
*************** namespace _GLIBCXX_STD
*** 351,357 ****
* reverse element order.
*/
const_reverse_iterator
! rbegin() const { return const_reverse_iterator(end()); }
/**
* Returns a read/write reverse iterator that points to one
--- 369,376 ----
* reverse element order.
*/
const_reverse_iterator
! rbegin() const
! { return const_reverse_iterator(end()); }
/**
* Returns a read/write reverse iterator that points to one
*************** namespace _GLIBCXX_STD
*** 359,365 ****
* in reverse element order.
*/
reverse_iterator
! rend() { return reverse_iterator(begin()); }
/**
* Returns a read-only (constant) reverse iterator that points
--- 378,385 ----
* in reverse element order.
*/
reverse_iterator
! rend()
! { return reverse_iterator(begin()); }
/**
* Returns a read-only (constant) reverse iterator that points
*************** namespace _GLIBCXX_STD
*** 367,382 ****
* is done in reverse element order.
*/
const_reverse_iterator
! rend() const { return const_reverse_iterator(begin()); }
// [23.2.4.2] capacity
/** Returns the number of elements in the %vector. */
size_type
! size() const { return size_type(end() - begin()); }
/** Returns the size() of the largest possible %vector. */
size_type
! max_size() const { return size_type(-1) / sizeof(value_type); }
/**
* @brief Resizes the %vector to the specified number of elements.
--- 387,405 ----
* is done in reverse element order.
*/
const_reverse_iterator
! rend() const
! { return const_reverse_iterator(begin()); }
// [23.2.4.2] capacity
/** Returns the number of elements in the %vector. */
size_type
! size() const
! { return size_type(end() - begin()); }
/** Returns the size() of the largest possible %vector. */
size_type
! max_size() const
! { return size_type(-1) / sizeof(value_type); }
/**
* @brief Resizes the %vector to the specified number of elements.
*************** namespace _GLIBCXX_STD
*** 409,415 ****
* default-constructed.
*/
void
! resize(size_type __new_size) { resize(__new_size, value_type()); }
/**
* Returns the total number of elements that the %vector can
--- 432,439 ----
* default-constructed.
*/
void
! resize(size_type __new_size)
! { resize(__new_size, value_type()); }
/**
* Returns the total number of elements that the %vector can
*************** namespace _GLIBCXX_STD
*** 417,430 ****
*/
size_type
capacity() const
! { return size_type(const_iterator(this->_M_impl._M_end_of_storage) - begin()); }
/**
* Returns true if the %vector is empty. (Thus begin() would
* equal end().)
*/
bool
! empty() const { return begin() == end(); }
/**
* @brief Attempt to preallocate enough memory for specified number of
--- 441,456 ----
*/
size_type
capacity() const
! { return size_type(const_iterator(this->_M_impl._M_end_of_storage)
! - begin()); }
/**
* Returns true if the %vector is empty. (Thus begin() would
* equal end().)
*/
bool
! empty() const
! { return begin() == end(); }
/**
* @brief Attempt to preallocate enough memory for specified number of
*************** namespace _GLIBCXX_STD
*** 459,465 ****
* see at().)
*/
reference
! operator[](size_type __n) { return *(begin() + __n); }
/**
* @brief Subscript access to the data contained in the %vector.
--- 485,492 ----
* see at().)
*/
reference
! operator[](size_type __n)
! { return *(begin() + __n); }
/**
* @brief Subscript access to the data contained in the %vector.
*************** namespace _GLIBCXX_STD
*** 473,479 ****
* see at().)
*/
const_reference
! operator[](size_type __n) const { return *(begin() + __n); }
protected:
/// @if maint Safety check used only from at(). @endif
--- 500,507 ----
* see at().)
*/
const_reference
! operator[](size_type __n) const
! { return *(begin() + __n); }
protected:
/// @if maint Safety check used only from at(). @endif
*************** namespace _GLIBCXX_STD
*** 497,503 ****
* function throws out_of_range if the check fails.
*/
reference
! at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
/**
* @brief Provides access to the data contained in the %vector.
--- 525,535 ----
* function throws out_of_range if the check fails.
*/
reference
! at(size_type __n)
! {
! _M_range_check(__n);
! return (*this)[__n];
! }
/**
* @brief Provides access to the data contained in the %vector.
*************** namespace _GLIBCXX_STD
*** 511,545 ****
* function throws out_of_range if the check fails.
*/
const_reference
! at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
/**
* Returns a read/write reference to the data at the first
* element of the %vector.
*/
reference
! front() { return *begin(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %vector.
*/
const_reference
! front() const { return *begin(); }
/**
* Returns a read/write reference to the data at the last
* element of the %vector.
*/
reference
! back() { return *(end() - 1); }
!
/**
* Returns a read-only (constant) reference to the data at the
* last element of the %vector.
*/
const_reference
! back() const { return *(end() - 1); }
// [23.2.4.3] modifiers
/**
--- 543,585 ----
* function throws out_of_range if the check fails.
*/
const_reference
! at(size_type __n) const
! {
! _M_range_check(__n);
! return (*this)[__n];
! }
/**
* Returns a read/write reference to the data at the first
* element of the %vector.
*/
reference
! front()
! { return *begin(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %vector.
*/
const_reference
! front() const
! { return *begin(); }
/**
* Returns a read/write reference to the data at the last
* element of the %vector.
*/
reference
! back()
! { return *(end() - 1); }
!
/**
* Returns a read-only (constant) reference to the data at the
* last element of the %vector.
*/
const_reference
! back() const
! { return *(end() - 1); }
// [23.2.4.3] modifiers
/**
*************** namespace _GLIBCXX_STD
*** 688,694 ****
{
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_end_of_storage, __x._M_impl._M_end_of_storage);
}
/**
--- 728,735 ----
{
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_end_of_storage,
! __x._M_impl._M_end_of_storage);
}
/**
*************** namespace _GLIBCXX_STD
*** 698,704 ****
* the user's responsibilty.
*/
void
! clear() { erase(begin(), end()); }
protected:
/**
--- 739,746 ----
* the user's responsibilty.
*/
void
! clear()
! { erase(begin(), end()); }
protected:
/**
*************** namespace _GLIBCXX_STD
*** 735,742 ****
{
this->_M_impl._M_start = _M_allocate(__n);
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
! this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
! __n, __value);
}
// Called by the range constructor to implement [23.1.1]/9
--- 777,785 ----
{
this->_M_impl._M_start = _M_allocate(__n);
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
! this->_M_impl._M_finish = std::uninitialized_fill_n(this->
! _M_impl._M_start,
! __n, __value);
}
// Called by the range constructor to implement [23.1.1]/9
*************** namespace _GLIBCXX_STD
*** 770,776 ****
this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
this->_M_impl._M_finish = std::uninitialized_copy(__first, __last,
! this->_M_impl._M_start);
}
--- 813,820 ----
this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
this->_M_impl._M_finish = std::uninitialized_copy(__first, __last,
! this->
! _M_impl._M_start);
}
*************** namespace _GLIBCXX_STD
*** 873,883 ****
*/
template<typename _Tp, typename _Alloc>
inline bool
! operator==(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
! {
! return __x.size() == __y.size() &&
! std::equal(__x.begin(), __x.end(), __y.begin());
! }
/**
* @brief Vector ordering relation.
--- 917,925 ----
*/
template<typename _Tp, typename _Alloc>
inline bool
! operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
! { return (__x.size() == __y.size()
! && std::equal(__x.begin(), __x.end(), __y.begin())); }
/**
* @brief Vector ordering relation.
*************** namespace _GLIBCXX_STD
*** 892,931 ****
*/
template<typename _Tp, typename _Alloc>
inline bool
! operator<(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
! {
! return std::lexicographical_compare(__x.begin(), __x.end(),
! __y.begin(), __y.end());
! }
/// Based on operator==
template<typename _Tp, typename _Alloc>
inline bool
! operator!=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
! operator>(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
! operator<=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
! operator>=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
{ return !(__x < __y); }
/// See std::vector::swap().
template<typename _Tp, typename _Alloc>
inline void
! swap(vector<_Tp,_Alloc>& __x, vector<_Tp,_Alloc>& __y)
{ __x.swap(__y); }
} // namespace std
--- 934,971 ----
*/
template<typename _Tp, typename _Alloc>
inline bool
! operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
! { return std::lexicographical_compare(__x.begin(), __x.end(),
! __y.begin(), __y.end()); }
/// Based on operator==
template<typename _Tp, typename _Alloc>
inline bool
! operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
! operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
! operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
inline bool
! operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::vector::swap().
template<typename _Tp, typename _Alloc>
inline void
! swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
{ __x.swap(__y); }
} // namespace std
diff -prN libstdc++-v3-orig/include/bits/vector.tcc libstdc++-v3/include/bits/vector.tcc
*** libstdc++-v3-orig/include/bits/vector.tcc Fri Apr 16 21:04:04 2004
--- libstdc++-v3/include/bits/vector.tcc Mon Apr 26 01:11:03 2004
***************
*** 1,6 ****
// Vector implementation (out of line) -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
--- 1,6 ----
// Vector implementation (out of line) -*- C++ -*-
! // Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
*************** namespace _GLIBCXX_STD
*** 65,71 ****
{
template<typename _Tp, typename _Alloc>
void
! vector<_Tp,_Alloc>::
reserve(size_type __n)
{
if (__n > this->max_size())
--- 65,71 ----
{
template<typename _Tp, typename _Alloc>
void
! vector<_Tp, _Alloc>::
reserve(size_type __n)
{
if (__n > this->max_size())
*************** namespace _GLIBCXX_STD
*** 78,84 ****
this->_M_impl._M_finish);
std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
_M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
this->_M_impl._M_start = __tmp;
this->_M_impl._M_finish = __tmp + __old_size;
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
--- 78,85 ----
this->_M_impl._M_finish);
std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
_M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage
! - this->_M_impl._M_start);
this->_M_impl._M_start = __tmp;
this->_M_impl._M_finish = __tmp + __old_size;
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
*************** namespace _GLIBCXX_STD
*** 86,109 ****
}
template<typename _Tp, typename _Alloc>
! typename vector<_Tp,_Alloc>::iterator
! vector<_Tp,_Alloc>::
insert(iterator __position, const value_type& __x)
{
size_type __n = __position - begin();
! if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage && __position == end())
! {
! std::_Construct(this->_M_impl._M_finish, __x);
! ++this->_M_impl._M_finish;
! }
else
_M_insert_aux(__position, __x);
return begin() + __n;
}
template<typename _Tp, typename _Alloc>
! typename vector<_Tp,_Alloc>::iterator
! vector<_Tp,_Alloc>::
erase(iterator __position)
{
if (__position + 1 != end())
--- 87,111 ----
}
template<typename _Tp, typename _Alloc>
! typename vector<_Tp, _Alloc>::iterator
! vector<_Tp, _Alloc>::
insert(iterator __position, const value_type& __x)
{
size_type __n = __position - begin();
! if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage
! && __position == end())
! {
! std::_Construct(this->_M_impl._M_finish, __x);
! ++this->_M_impl._M_finish;
! }
else
_M_insert_aux(__position, __x);
return begin() + __n;
}
template<typename _Tp, typename _Alloc>
! typename vector<_Tp, _Alloc>::iterator
! vector<_Tp, _Alloc>::
erase(iterator __position)
{
if (__position + 1 != end())
*************** namespace _GLIBCXX_STD
*** 114,121 ****
}
template<typename _Tp, typename _Alloc>
! typename vector<_Tp,_Alloc>::iterator
! vector<_Tp,_Alloc>::
erase(iterator __first, iterator __last)
{
iterator __i(copy(__last, end(), __first));
--- 116,123 ----
}
template<typename _Tp, typename _Alloc>
! typename vector<_Tp, _Alloc>::iterator
! vector<_Tp, _Alloc>::
erase(iterator __first, iterator __last)
{
iterator __i(copy(__last, end(), __first));
*************** namespace _GLIBCXX_STD
*** 125,226 ****
}
template<typename _Tp, typename _Alloc>
! vector<_Tp,_Alloc>&
! vector<_Tp,_Alloc>::
! operator=(const vector<_Tp,_Alloc>& __x)
{
if (&__x != this)
! {
! const size_type __xlen = __x.size();
! if (__xlen > capacity())
! {
! pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __tmp;
! this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
! }
! else if (size() >= __xlen)
! {
! iterator __i(copy(__x.begin(), __x.end(), begin()));
! std::_Destroy(__i, end());
! }
! else
! {
! std::copy(__x.begin(), __x.begin() + size(), this->_M_impl._M_start);
! std::uninitialized_copy(__x.begin() + size(), __x.end(), this->_M_impl._M_finish);
! }
! this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
! }
return *this;
}
template<typename _Tp, typename _Alloc>
void
! vector<_Tp,_Alloc>::
_M_fill_assign(size_t __n, const value_type& __val)
{
if (__n > capacity())
! {
! vector __tmp(__n, __val, get_allocator());
! __tmp.swap(*this);
! }
else if (__n > size())
! {
! std::fill(begin(), end(), __val);
! this->_M_impl._M_finish
! = std::uninitialized_fill_n(this->_M_impl._M_finish, __n - size(), __val);
! }
else
erase(fill_n(begin(), __n, __val), end());
}
! template<typename _Tp, typename _Alloc> template<typename _InputIterator>
! void
! vector<_Tp,_Alloc>::
! _M_assign_aux(_InputIterator __first, _InputIterator __last, input_iterator_tag)
! {
! iterator __cur(begin());
! for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
! *__cur = *__first;
! if (__first == __last)
! erase(__cur, end());
! else
! insert(end(), __first, __last);
! }
!
! template<typename _Tp, typename _Alloc> template<typename _ForwardIterator>
! void
! vector<_Tp,_Alloc>::
! _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
! forward_iterator_tag)
! {
! size_type __len = std::distance(__first, __last);
!
! if (__len > capacity())
! {
! pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __tmp;
! this->_M_impl._M_end_of_storage = this->_M_impl._M_finish = this->_M_impl._M_start + __len;
! }
! else if (size() >= __len)
! {
! iterator __new_finish(copy(__first, __last, this->_M_impl._M_start));
! std::_Destroy(__new_finish, end());
! this->_M_impl._M_finish = __new_finish.base();
}
! else
{
! _ForwardIterator __mid = __first;
! std::advance(__mid, size());
! std::copy(__first, __mid, this->_M_impl._M_start);
! this->_M_impl._M_finish = std::uninitialized_copy(__mid, __last, this->_M_impl._M_finish);
}
- }
template<typename _Tp, typename _Alloc>
void
--- 127,244 ----
}
template<typename _Tp, typename _Alloc>
! vector<_Tp, _Alloc>&
! vector<_Tp, _Alloc>::
! operator=(const vector<_Tp, _Alloc>& __x)
{
if (&__x != this)
! {
! const size_type __xlen = __x.size();
! if (__xlen > capacity())
! {
! pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(),
! __x.end());
! std::_Destroy(this->_M_impl._M_start,
! this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage
! - this->_M_impl._M_start);
! this->_M_impl._M_start = __tmp;
! this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
! }
! else if (size() >= __xlen)
! {
! iterator __i(copy(__x.begin(), __x.end(), begin()));
! std::_Destroy(__i, end());
! }
! else
! {
! std::copy(__x.begin(), __x.begin() + size(),
! this->_M_impl._M_start);
! std::uninitialized_copy(__x.begin() + size(),
! __x.end(), this->_M_impl._M_finish);
! }
! this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
! }
return *this;
}
template<typename _Tp, typename _Alloc>
void
! vector<_Tp, _Alloc>::
_M_fill_assign(size_t __n, const value_type& __val)
{
if (__n > capacity())
! {
! vector __tmp(__n, __val, get_allocator());
! __tmp.swap(*this);
! }
else if (__n > size())
! {
! std::fill(begin(), end(), __val);
! this->_M_impl._M_finish = std::uninitialized_fill_n(this->
! _M_impl._M_finish,
! __n - size(),
! __val);
! }
else
erase(fill_n(begin(), __n, __val), end());
}
! template<typename _Tp, typename _Alloc>
! template<typename _InputIterator>
! void
! vector<_Tp, _Alloc>::
! _M_assign_aux(_InputIterator __first, _InputIterator __last,
! input_iterator_tag)
! {
! iterator __cur(begin());
! for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
! *__cur = *__first;
! if (__first == __last)
! erase(__cur, end());
! else
! insert(end(), __first, __last);
}
!
! template<typename _Tp, typename _Alloc>
! template<typename _ForwardIterator>
! void
! vector<_Tp,_Alloc>::
! _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
! forward_iterator_tag)
{
! size_type __len = std::distance(__first, __last);
!
! if (__len > capacity())
! {
! pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage
! - this->_M_impl._M_start);
! this->_M_impl._M_start = __tmp;
! this->_M_impl._M_finish = this->_M_impl._M_start + __len;
! this->_M_impl._M_end_of_storage = this->_M_impl._M_finish;
! }
! else if (size() >= __len)
! {
! iterator __new_finish(copy(__first, __last,
! this->_M_impl._M_start));
! std::_Destroy(__new_finish, end());
! this->_M_impl._M_finish = __new_finish.base();
! }
! else
! {
! _ForwardIterator __mid = __first;
! std::advance(__mid, size());
! std::copy(__first, __mid, this->_M_impl._M_start);
! this->_M_impl._M_finish = std::uninitialized_copy(__mid,
! __last,
! this->_M_impl.
! _M_finish);
! }
}
template<typename _Tp, typename _Alloc>
void
*************** namespace _GLIBCXX_STD
*** 228,272 ****
_M_insert_aux(iterator __position, const _Tp& __x)
{
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
! {
! std::_Construct(this->_M_impl._M_finish, *(this->_M_impl._M_finish - 1));
! ++this->_M_impl._M_finish;
! _Tp __x_copy = __x;
! std::copy_backward(__position,
! iterator(this->_M_impl._M_finish-2),
! iterator(this->_M_impl._M_finish-1));
! *__position = __x_copy;
! }
else
! {
! const size_type __old_size = size();
! const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
! iterator __new_start(this->_M_allocate(__len));
! iterator __new_finish(__new_start);
! try
! {
! __new_finish = std::uninitialized_copy(iterator(this->_M_impl._M_start),
! __position,
! __new_start);
! std::_Construct(__new_finish.base(), __x);
! ++__new_finish;
! __new_finish = std::uninitialized_copy(__position,
! iterator(this->_M_impl._M_finish),
! __new_finish);
! }
! catch(...)
! {
! std::_Destroy(__new_start,__new_finish);
! _M_deallocate(__new_start.base(),__len);
! __throw_exception_again;
}
! std::_Destroy(begin(), end());
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
! }
}
template<typename _Tp, typename _Alloc>
--- 246,294 ----
_M_insert_aux(iterator __position, const _Tp& __x)
{
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
! {
! std::_Construct(this->_M_impl._M_finish,
! *(this->_M_impl._M_finish - 1));
! ++this->_M_impl._M_finish;
! _Tp __x_copy = __x;
! std::copy_backward(__position,
! iterator(this->_M_impl._M_finish-2),
! iterator(this->_M_impl._M_finish-1));
! *__position = __x_copy;
! }
else
! {
! const size_type __old_size = size();
! const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
! iterator __new_start(this->_M_allocate(__len));
! iterator __new_finish(__new_start);
! try
! {
! __new_finish = std::uninitialized_copy(iterator(this->
! _M_impl._M_start),
! __position,
! __new_start);
! std::_Construct(__new_finish.base(), __x);
! ++__new_finish;
! __new_finish = std::uninitialized_copy(__position,
! iterator(this->_M_impl.
! _M_finish),
! __new_finish);
}
! catch(...)
! {
! std::_Destroy(__new_start,__new_finish);
! _M_deallocate(__new_start.base(),__len);
! __throw_exception_again;
! }
! std::_Destroy(begin(), end());
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage
! - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
! }
}
template<typename _Tp, typename _Alloc>
*************** namespace _GLIBCXX_STD
*** 275,414 ****
_M_fill_insert(iterator __position, size_type __n, const value_type& __x)
{
if (__n != 0)
! {
! if (size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish) >= __n)
! {
! value_type __x_copy = __x;
! const size_type __elems_after = end() - __position;
! iterator __old_finish(this->_M_impl._M_finish);
! if (__elems_after > __n)
! {
! std::uninitialized_copy(this->_M_impl._M_finish - __n,
! this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n;
! std::copy_backward(__position, __old_finish - __n, __old_finish);
! std::fill(__position, __position + __n, __x_copy);
! }
! else
! {
! std::uninitialized_fill_n(this->_M_impl._M_finish,
! __n - __elems_after,
! __x_copy);
! this->_M_impl._M_finish += __n - __elems_after;
! std::uninitialized_copy(__position, __old_finish, this->_M_impl._M_finish);
! this->_M_impl._M_finish += __elems_after;
! std::fill(__position, __old_finish, __x_copy);
! }
! }
! else
! {
! const size_type __old_size = size();
! const size_type __len = __old_size + std::max(__old_size, __n);
! iterator __new_start(this->_M_allocate(__len));
! iterator __new_finish(__new_start);
! try
! {
! __new_finish = std::uninitialized_copy(begin(), __position,
! __new_start);
! __new_finish = std::uninitialized_fill_n(__new_finish, __n, __x);
! __new_finish = std::uninitialized_copy(__position, end(),
! __new_finish);
! }
! catch(...)
! {
! std::_Destroy(__new_start,__new_finish);
! _M_deallocate(__new_start.base(),__len);
! __throw_exception_again;
! }
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
! }
! }
}
template<typename _Tp, typename _Alloc> template<typename _InputIterator>
void
vector<_Tp,_Alloc>::
! _M_range_insert(iterator __pos,
! _InputIterator __first, _InputIterator __last,
! input_iterator_tag)
{
for ( ; __first != __last; ++__first)
! {
! __pos = insert(__pos, *__first);
! ++__pos;
! }
}
! template<typename _Tp, typename _Alloc> template<typename _ForwardIterator>
! void
! vector<_Tp,_Alloc>::
! _M_range_insert(iterator __position,_ForwardIterator __first,
! _ForwardIterator __last, forward_iterator_tag)
! {
! if (__first != __last)
{
! size_type __n = std::distance(__first, __last);
! if (size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish) >= __n)
! {
! const size_type __elems_after = end() - __position;
! iterator __old_finish(this->_M_impl._M_finish);
! if (__elems_after > __n)
! {
! std::uninitialized_copy(this->_M_impl._M_finish - __n,
! this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n;
! std::copy_backward(__position, __old_finish - __n, __old_finish);
! std::copy(__first, __last, __position);
! }
! else
! {
! _ForwardIterator __mid = __first;
! std::advance(__mid, __elems_after);
! std::uninitialized_copy(__mid, __last, this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n - __elems_after;
! std::uninitialized_copy(__position, __old_finish, this->_M_impl._M_finish);
! this->_M_impl._M_finish += __elems_after;
! std::copy(__first, __mid, __position);
! }
! }
! else
! {
! const size_type __old_size = size();
! const size_type __len = __old_size + std::max(__old_size, __n);
! iterator __new_start(this->_M_allocate(__len));
! iterator __new_finish(__new_start);
! try
! {
! __new_finish = std::uninitialized_copy(iterator(this->_M_impl._M_start),
! __position, __new_start);
! __new_finish = std::uninitialized_copy(__first, __last,
! __new_finish);
! __new_finish = std::uninitialized_copy(__position,
! iterator(this->_M_impl._M_finish),
! __new_finish);
! }
! catch(...)
! {
! std::_Destroy(__new_start,__new_finish);
! _M_deallocate(__new_start.base(), __len);
! __throw_exception_again;
! }
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
! }
}
- }
} // namespace std
#endif /* _VECTOR_TCC */
--- 297,451 ----
_M_fill_insert(iterator __position, size_type __n, const value_type& __x)
{
if (__n != 0)
! {
! if (size_type(this->_M_impl._M_end_of_storage
! - this->_M_impl._M_finish) >= __n)
! {
! value_type __x_copy = __x;
! const size_type __elems_after = end() - __position;
! iterator __old_finish(this->_M_impl._M_finish);
! if (__elems_after > __n)
! {
! std::uninitialized_copy(this->_M_impl._M_finish - __n,
! this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n;
! std::copy_backward(__position, __old_finish - __n,
! __old_finish);
! std::fill(__position, __position + __n, __x_copy);
! }
! else
! {
! std::uninitialized_fill_n(this->_M_impl._M_finish,
! __n - __elems_after,
! __x_copy);
! this->_M_impl._M_finish += __n - __elems_after;
! std::uninitialized_copy(__position, __old_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __elems_after;
! std::fill(__position, __old_finish, __x_copy);
! }
! }
! else
! {
! const size_type __old_size = size();
! const size_type __len = __old_size + std::max(__old_size, __n);
! iterator __new_start(this->_M_allocate(__len));
! iterator __new_finish(__new_start);
! try
! {
! __new_finish = std::uninitialized_copy(begin(), __position,
! __new_start);
! __new_finish = std::uninitialized_fill_n(__new_finish, __n,
! __x);
! __new_finish = std::uninitialized_copy(__position, end(),
! __new_finish);
! }
! catch(...)
! {
! std::_Destroy(__new_start,__new_finish);
! _M_deallocate(__new_start.base(),__len);
! __throw_exception_again;
! }
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage
! - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
! }
! }
}
template<typename _Tp, typename _Alloc> template<typename _InputIterator>
void
vector<_Tp,_Alloc>::
! _M_range_insert(iterator __pos, _InputIterator __first,
! _InputIterator __last, input_iterator_tag)
{
for ( ; __first != __last; ++__first)
! {
! __pos = insert(__pos, *__first);
! ++__pos;
! }
}
! template<typename _Tp, typename _Alloc>
! template<typename _ForwardIterator>
! void
! vector<_Tp,_Alloc>::
! _M_range_insert(iterator __position,_ForwardIterator __first,
! _ForwardIterator __last, forward_iterator_tag)
{
! if (__first != __last)
! {
! size_type __n = std::distance(__first, __last);
! if (size_type(this->_M_impl._M_end_of_storage
! - this->_M_impl._M_finish) >= __n)
! {
! const size_type __elems_after = end() - __position;
! iterator __old_finish(this->_M_impl._M_finish);
! if (__elems_after > __n)
! {
! std::uninitialized_copy(this->_M_impl._M_finish - __n,
! this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n;
! std::copy_backward(__position, __old_finish - __n,
! __old_finish);
! std::copy(__first, __last, __position);
! }
! else
! {
! _ForwardIterator __mid = __first;
! std::advance(__mid, __elems_after);
! std::uninitialized_copy(__mid, __last,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n - __elems_after;
! std::uninitialized_copy(__position, __old_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __elems_after;
! std::copy(__first, __mid, __position);
! }
! }
! else
! {
! const size_type __old_size = size();
! const size_type __len = __old_size + std::max(__old_size, __n);
! iterator __new_start(this->_M_allocate(__len));
! iterator __new_finish(__new_start);
! try
! {
! __new_finish = std::uninitialized_copy(iterator(this->
! _M_impl.
! _M_start),
! __position,
! __new_start);
! __new_finish = std::uninitialized_copy(__first, __last,
! __new_finish);
! __new_finish = std::uninitialized_copy(__position,
! iterator(this->
! _M_impl.
! _M_finish),
! __new_finish);
! }
! catch(...)
! {
! std::_Destroy(__new_start,__new_finish);
! _M_deallocate(__new_start.base(), __len);
! __throw_exception_again;
! }
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage
! - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
! }
! }
}
} // namespace std
#endif /* _VECTOR_TCC */