deque.tcc, [...]: Re-indent contents of namespace std, re-wrap comment lines as necessary.

2002-08-09  Phil Edwards  <pme@gcc.gnu.org>

	* include/bits/deque.tcc, include/bits/list.tcc,
	include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
	include/bits/stl_list.h, include/bits/stl_map.h,
	include/bits/stl_multimap.h, include/bits/stl_queue.h,
	include/bits/stl_stack.h, include/bits/stl_vector.h,
	include/bits/vector.tcc:  Re-indent contents of namespace std,
	re-wrap comment lines as necessary.

From-SVN: r56165
This commit is contained in:
Phil Edwards 2002-08-09 16:51:15 +00:00
parent 2043c38e8d
commit 3971a4d235
12 changed files with 6345 additions and 6381 deletions

View File

@ -1,3 +1,13 @@
2002-08-09 Phil Edwards <pme@gcc.gnu.org>
* include/bits/deque.tcc, include/bits/list.tcc,
include/bits/stl_deque.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_list.h, include/bits/stl_map.h,
include/bits/stl_multimap.h, include/bits/stl_queue.h,
include/bits/stl_stack.h, include/bits/stl_vector.h,
include/bits/vector.tcc: Re-indent contents of namespace std,
re-wrap comment lines as necessary.
2002-08-08 Danny Smith <dannysmith@users.sourceforge.net>
Benjamin Kosnik <bkoz@redhat.com>

File diff suppressed because it is too large Load Diff

View File

@ -61,228 +61,124 @@
#ifndef __GLIBCPP_INTERNAL_LIST_TCC
#define __GLIBCPP_INTERNAL_LIST_TCC
// Since this entire file is within namespace std, there's no reason to
// waste two spaces along the left column. Thus the leading indentation is
// slightly violated from here on.
namespace std
{
template<typename _Tp, typename _Alloc>
void
_List_base<_Tp,_Alloc>::
__clear()
{
typedef _List_node<_Tp> _Node;
_Node* __cur = static_cast<_Node*>(_M_node->_M_next);
while (__cur != _M_node)
template<typename _Tp, typename _Alloc>
void
_List_base<_Tp,_Alloc>::
__clear()
{
_Node* __tmp = __cur;
__cur = static_cast<_Node*>(__cur->_M_next);
_Destroy(&__tmp->_M_data);
_M_put_node(__tmp);
typedef _List_node<_Tp> _Node;
_Node* __cur = static_cast<_Node*>(_M_node->_M_next);
while (__cur != _M_node)
{
_Node* __tmp = __cur;
__cur = static_cast<_Node*>(__cur->_M_next);
_Destroy(&__tmp->_M_data);
_M_put_node(__tmp);
}
_M_node->_M_next = _M_node;
_M_node->_M_prev = _M_node;
}
_M_node->_M_next = _M_node;
_M_node->_M_prev = _M_node;
}
template<typename _Tp, typename _Alloc>
typename list<_Tp,_Alloc>::iterator
list<_Tp,_Alloc>::
insert(iterator __position, const value_type& __x)
{
_Node* __tmp = _M_create_node(__x);
__tmp->_M_next = __position._M_node;
__tmp->_M_prev = __position._M_node->_M_prev;
__position._M_node->_M_prev->_M_next = __tmp;
__position._M_node->_M_prev = __tmp;
return __tmp;
}
template<typename _Tp, typename _Alloc>
typename list<_Tp,_Alloc>::iterator
list<_Tp,_Alloc>::
erase(iterator __position)
{
_List_node_base* __next_node = __position._M_node->_M_next;
_List_node_base* __prev_node = __position._M_node->_M_prev;
_Node* __n = static_cast<_Node*>(__position._M_node);
__prev_node->_M_next = __next_node;
__next_node->_M_prev = __prev_node;
_Destroy(&__n->_M_data);
_M_put_node(__n);
return iterator(static_cast<_Node*>(__next_node));
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
resize(size_type __new_size, const value_type& __x)
{
iterator __i = begin();
size_type __len = 0;
for ( ; __i != end() && __len < __new_size; ++__i, ++__len)
;
if (__len == __new_size)
erase(__i, end());
else // __i == end()
insert(end(), __new_size - __len, __x);
}
template<typename _Tp, typename _Alloc>
list<_Tp,_Alloc>&
list<_Tp,_Alloc>::
operator=(const list& __x)
{
if (this != &__x)
template<typename _Tp, typename _Alloc>
typename list<_Tp,_Alloc>::iterator
list<_Tp,_Alloc>::
insert(iterator __position, const value_type& __x)
{
iterator __first1 = begin();
iterator __last1 = end();
const_iterator __first2 = __x.begin();
const_iterator __last2 = __x.end();
while (__first1 != __last1 && __first2 != __last2)
*__first1++ = *__first2++;
if (__first2 == __last2)
erase(__first1, __last1);
else
insert(__last1, __first2, __last2);
_Node* __tmp = _M_create_node(__x);
__tmp->_M_next = __position._M_node;
__tmp->_M_prev = __position._M_node->_M_prev;
__position._M_node->_M_prev->_M_next = __tmp;
__position._M_node->_M_prev = __tmp;
return __tmp;
}
return *this;
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
_M_fill_assign(size_type __n, const value_type& __val)
{
iterator __i = begin();
for ( ; __i != end() && __n > 0; ++__i, --__n)
*__i = __val;
if (__n > 0)
insert(end(), __n, __val);
else
erase(__i, end());
}
template<typename _Tp, typename _Alloc>
template <typename _InputIter>
template<typename _Tp, typename _Alloc>
typename list<_Tp,_Alloc>::iterator
list<_Tp,_Alloc>::
erase(iterator __position)
{
_List_node_base* __next_node = __position._M_node->_M_next;
_List_node_base* __prev_node = __position._M_node->_M_prev;
_Node* __n = static_cast<_Node*>(__position._M_node);
__prev_node->_M_next = __next_node;
__next_node->_M_prev = __prev_node;
_Destroy(&__n->_M_data);
_M_put_node(__n);
return iterator(static_cast<_Node*>(__next_node));
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
_M_assign_dispatch(_InputIter __first2, _InputIter __last2, __false_type)
resize(size_type __new_size, const value_type& __x)
{
iterator __first1 = begin();
iterator __last1 = end();
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
*__first1 = *__first2;
if (__first2 == __last2)
erase(__first1, __last1);
else
insert(__last1, __first2, __last2);
iterator __i = begin();
size_type __len = 0;
for ( ; __i != end() && __len < __new_size; ++__i, ++__len)
;
if (__len == __new_size)
erase(__i, end());
else // __i == end()
insert(end(), __new_size - __len, __x);
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
remove(const value_type& __value)
{
iterator __first = begin();
iterator __last = end();
while (__first != __last)
template<typename _Tp, typename _Alloc>
list<_Tp,_Alloc>&
list<_Tp,_Alloc>::
operator=(const list& __x)
{
iterator __next = __first;
++__next;
if (*__first == __value)
erase(__first);
__first = __next;
}
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
unique()
{
iterator __first = begin();
iterator __last = end();
if (__first == __last) return;
iterator __next = __first;
while (++__next != __last)
{
if (*__first == *__next)
erase(__next);
else
__first = __next;
__next = __first;
}
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
merge(list& __x)
{
iterator __first1 = begin();
iterator __last1 = end();
iterator __first2 = __x.begin();
iterator __last2 = __x.end();
while (__first1 != __last1 && __first2 != __last2)
if (*__first2 < *__first1)
if (this != &__x)
{
iterator __next = __first2;
_M_transfer(__first1, __first2, ++__next);
__first2 = __next;
iterator __first1 = begin();
iterator __last1 = end();
const_iterator __first2 = __x.begin();
const_iterator __last2 = __x.end();
while (__first1 != __last1 && __first2 != __last2)
*__first1++ = *__first2++;
if (__first2 == __last2)
erase(__first1, __last1);
else
insert(__last1, __first2, __last2);
}
else
++__first1;
if (__first2 != __last2)
_M_transfer(__last1, __first2, __last2);
}
// FIXME put this somewhere else
inline void
__List_base_reverse(_List_node_base* __p)
{
_List_node_base* __tmp = __p;
do {
std::swap(__tmp->_M_next, __tmp->_M_prev);
__tmp = __tmp->_M_prev; // Old next node is now prev.
} while (__tmp != __p);
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
sort()
{
// Do nothing if the list has length 0 or 1.
if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node)
{
list __carry;
list __counter[64];
int __fill = 0;
while (!empty())
{
__carry.splice(__carry.begin(), *this, begin());
int __i = 0;
while(__i < __fill && !__counter[__i].empty())
{
__counter[__i].merge(__carry);
__carry.swap(__counter[__i++]);
}
__carry.swap(__counter[__i]);
if (__i == __fill) ++__fill;
}
for (int __i = 1; __i < __fill; ++__i)
__counter[__i].merge(__counter[__i-1]);
swap(__counter[__fill-1]);
return *this;
}
}
template<typename _Tp, typename _Alloc>
template <typename _Predicate>
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
remove_if(_Predicate __pred)
_M_fill_assign(size_type __n, const value_type& __val)
{
iterator __i = begin();
for ( ; __i != end() && __n > 0; ++__i, --__n)
*__i = __val;
if (__n > 0)
insert(end(), __n, __val);
else
erase(__i, end());
}
template<typename _Tp, typename _Alloc>
template <typename _InputIter>
void
list<_Tp,_Alloc>::
_M_assign_dispatch(_InputIter __first2, _InputIter __last2, __false_type)
{
iterator __first1 = begin();
iterator __last1 = end();
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
*__first1 = *__first2;
if (__first2 == __last2)
erase(__first1, __last1);
else
insert(__last1, __first2, __last2);
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
remove(const value_type& __value)
{
iterator __first = begin();
iterator __last = end();
@ -290,16 +186,16 @@ template<typename _Tp, typename _Alloc>
{
iterator __next = __first;
++__next;
if (__pred(*__first)) erase(__first);
if (*__first == __value)
erase(__first);
__first = __next;
}
}
template<typename _Tp, typename _Alloc>
template <typename _BinaryPredicate>
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
unique(_BinaryPredicate __binary_pred)
unique()
{
iterator __first = begin();
iterator __last = end();
@ -307,26 +203,25 @@ template<typename _Tp, typename _Alloc>
iterator __next = __first;
while (++__next != __last)
{
if (__binary_pred(*__first, *__next))
if (*__first == *__next)
erase(__next);
else
__first = __next;
__next = __first;
}
}
template<typename _Tp, typename _Alloc>
template <typename _StrictWeakOrdering>
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
merge(list& __x, _StrictWeakOrdering __comp)
merge(list& __x)
{
iterator __first1 = begin();
iterator __last1 = end();
iterator __first2 = __x.begin();
iterator __last2 = __x.end();
while (__first1 != __last1 && __first2 != __last2)
if (__comp(*__first2, *__first1))
if (*__first2 < *__first1)
{
iterator __next = __first2;
_M_transfer(__first1, __first2, ++__next);
@ -334,41 +229,140 @@ template<typename _Tp, typename _Alloc>
}
else
++__first1;
if (__first2 != __last2) _M_transfer(__last1, __first2, __last2);
if (__first2 != __last2)
_M_transfer(__last1, __first2, __last2);
}
template<typename _Tp, typename _Alloc>
template <typename _StrictWeakOrdering>
void
list<_Tp,_Alloc>::
sort(_StrictWeakOrdering __comp)
// FIXME put this somewhere else
inline void
__List_base_reverse(_List_node_base* __p)
{
// Do nothing if the list has length 0 or 1.
if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node)
{
list __carry;
list __counter[64];
int __fill = 0;
while (!empty())
{
__carry.splice(__carry.begin(), *this, begin());
int __i = 0;
while(__i < __fill && !__counter[__i].empty())
{
__counter[__i].merge(__carry, __comp);
__carry.swap(__counter[__i++]);
}
__carry.swap(__counter[__i]);
if (__i == __fill) ++__fill;
}
for (int __i = 1; __i < __fill; ++__i)
__counter[__i].merge(__counter[__i-1], __comp);
swap(__counter[__fill-1]);
}
_List_node_base* __tmp = __p;
do {
std::swap(__tmp->_M_next, __tmp->_M_prev);
__tmp = __tmp->_M_prev; // Old next node is now prev.
} while (__tmp != __p);
}
template<typename _Tp, typename _Alloc>
void
list<_Tp,_Alloc>::
sort()
{
// Do nothing if the list has length 0 or 1.
if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node)
{
list __carry;
list __counter[64];
int __fill = 0;
while (!empty())
{
__carry.splice(__carry.begin(), *this, begin());
int __i = 0;
while(__i < __fill && !__counter[__i].empty())
{
__counter[__i].merge(__carry);
__carry.swap(__counter[__i++]);
}
__carry.swap(__counter[__i]);
if (__i == __fill) ++__fill;
}
for (int __i = 1; __i < __fill; ++__i)
__counter[__i].merge(__counter[__i-1]);
swap(__counter[__fill-1]);
}
}
template<typename _Tp, typename _Alloc>
template <typename _Predicate>
void
list<_Tp,_Alloc>::
remove_if(_Predicate __pred)
{
iterator __first = begin();
iterator __last = end();
while (__first != __last)
{
iterator __next = __first;
++__next;
if (__pred(*__first)) erase(__first);
__first = __next;
}
}
template<typename _Tp, typename _Alloc>
template <typename _BinaryPredicate>
void
list<_Tp,_Alloc>::
unique(_BinaryPredicate __binary_pred)
{
iterator __first = begin();
iterator __last = end();
if (__first == __last) return;
iterator __next = __first;
while (++__next != __last)
{
if (__binary_pred(*__first, *__next))
erase(__next);
else
__first = __next;
__next = __first;
}
}
template<typename _Tp, typename _Alloc>
template <typename _StrictWeakOrdering>
void
list<_Tp,_Alloc>::
merge(list& __x, _StrictWeakOrdering __comp)
{
iterator __first1 = begin();
iterator __last1 = end();
iterator __first2 = __x.begin();
iterator __last2 = __x.end();
while (__first1 != __last1 && __first2 != __last2)
if (__comp(*__first2, *__first1))
{
iterator __next = __first2;
_M_transfer(__first1, __first2, ++__next);
__first2 = __next;
}
else
++__first1;
if (__first2 != __last2) _M_transfer(__last1, __first2, __last2);
}
template<typename _Tp, typename _Alloc>
template <typename _StrictWeakOrdering>
void
list<_Tp,_Alloc>::
sort(_StrictWeakOrdering __comp)
{
// Do nothing if the list has length 0 or 1.
if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node)
{
list __carry;
list __counter[64];
int __fill = 0;
while (!empty())
{
__carry.splice(__carry.begin(), *this, begin());
int __i = 0;
while(__i < __fill && !__counter[__i].empty())
{
__counter[__i].merge(__carry, __comp);
__carry.swap(__counter[__i++]);
}
__carry.swap(__counter[__i]);
if (__i == __fill) ++__fill;
}
for (int __i = 1; __i < __fill; ++__i)
__counter[__i].merge(__counter[__i-1], __comp);
swap(__counter[__fill-1]);
}
}
} // namespace std
#endif /* __GLIBCPP_INTERNAL_LIST_TCC */

File diff suppressed because it is too large Load Diff

View File

@ -67,113 +67,105 @@
#pragma GCC system_header
#include <bits/concept_check.h>
// Since this entire file is within namespace std, there's no reason to
// waste two spaces along the left column. Thus the leading indentation is
// slightly violated from here on.
namespace std
{
template<typename _InputIterator>
inline typename iterator_traits<_InputIterator>::difference_type
__distance(_InputIterator __first, _InputIterator __last, input_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>)
typename iterator_traits<_InputIterator>::difference_type __n = 0;
while (__first != __last) {
++__first; ++__n;
template<typename _InputIterator>
inline typename iterator_traits<_InputIterator>::difference_type
__distance(_InputIterator __first, _InputIterator __last,
input_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIterator>)
typename iterator_traits<_InputIterator>::difference_type __n = 0;
while (__first != __last) {
++__first; ++__n;
}
return __n;
}
return __n;
}
template<typename _RandomAccessIterator>
inline typename iterator_traits<_RandomAccessIterator>::difference_type
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
random_access_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
return __last - __first;
}
/**
* @brief A generalization of pointer arithmetic.
* @param first An input iterator.
* @param last An input iterator.
* @return The distance between them.
*
* Returns @c n such that first + n == last. This requires that @p last
* must be reachable from @p first. Note that @c n may be negative.
*
* For random access iterators, this uses their @c + and @c - operations
* and are constant time. For other %iterator classes they are linear time.
*/
template<typename _InputIterator>
inline typename iterator_traits<_InputIterator>::difference_type
distance(_InputIterator __first, _InputIterator __last)
{
// concept requirements -- taken care of in __distance
return __distance(__first, __last, __iterator_category(__first));
}
template<typename _InputIter, typename _Distance>
inline void
__advance(_InputIter& __i, _Distance __n, input_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>)
while (__n--) ++__i;
}
template<typename _BidirectionalIterator, typename _Distance>
inline void
__advance(_BidirectionalIterator& __i, _Distance __n,
bidirectional_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>)
if (__n > 0)
template<typename _RandomAccessIterator>
inline typename iterator_traits<_RandomAccessIterator>::difference_type
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
random_access_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
return __last - __first;
}
/**
* @brief A generalization of pointer arithmetic.
* @param first An input iterator.
* @param last An input iterator.
* @return The distance between them.
*
* Returns @c n such that first + n == last. This requires that @p last
* must be reachable from @p first. Note that @c n may be negative.
*
* For random access iterators, this uses their @c + and @c - operations
* and are constant time. For other %iterator classes they are linear time.
*/
template<typename _InputIterator>
inline typename iterator_traits<_InputIterator>::difference_type
distance(_InputIterator __first, _InputIterator __last)
{
// concept requirements -- taken care of in __distance
return __distance(__first, __last, __iterator_category(__first));
}
template<typename _InputIter, typename _Distance>
inline void
__advance(_InputIter& __i, _Distance __n, input_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_InputIteratorConcept<_InputIter>)
while (__n--) ++__i;
else
while (__n++) --__i;
}
template<typename _RandomAccessIterator, typename _Distance>
inline void
__advance(_RandomAccessIterator& __i, _Distance __n,
random_access_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
__i += __n;
}
/**
* @brief A generalization of pointer arithmetic.
* @param i An input iterator.
* @param n The "delta" by which to change @p i.
* @return Nothing.
*
* This increments @p i by @p n. For bidirectional and random access
* iterators, @p n may be negative, in which case @p i is decremented.
*
* For random access iterators, this uses their @c + and @c - operations
* and are constant time. For other %iterator classes they are linear time.
*/
template<typename _InputIterator, typename _Distance>
inline void
advance(_InputIterator& __i, _Distance __n)
{
// concept requirements -- taken care of in __advance
__advance(__i, __n, __iterator_category(__i));
}
}
template<typename _BidirectionalIterator, typename _Distance>
inline void
__advance(_BidirectionalIterator& __i, _Distance __n,
bidirectional_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_BidirectionalIteratorConcept<_BidirectionalIterator>)
if (__n > 0)
while (__n--) ++__i;
else
while (__n++) --__i;
}
template<typename _RandomAccessIterator, typename _Distance>
inline void
__advance(_RandomAccessIterator& __i, _Distance __n,
random_access_iterator_tag)
{
// concept requirements
__glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>)
__i += __n;
}
/**
* @brief A generalization of pointer arithmetic.
* @param i An input iterator.
* @param n The "delta" by which to change @p i.
* @return Nothing.
*
* This increments @p i by @p n. For bidirectional and random access
* iterators, @p n may be negative, in which case @p i is decremented.
*
* For random access iterators, this uses their @c + and @c - operations
* and are constant time. For other %iterator classes they are linear time.
*/
template<typename _InputIterator, typename _Distance>
inline void
advance(_InputIterator& __i, _Distance __n)
{
// concept requirements -- taken care of in __advance
__advance(__i, __n, __iterator_category(__i));
}
} // namespace std
#endif /* __GLIBCPP_INTERNAL_ITERATOR_BASE_FUNCS_H */
// Local Variables:
// mode:C++
// End:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,373 +63,368 @@
#include <bits/concept_check.h>
// Since this entire file is within namespace std, there's no reason to
// waste two spaces along the left column. Thus the leading indentation is
// slightly violated from here on.
namespace std
{
// Forward declarations of operators < and ==, needed for friend declaration.
template <typename _Tp, typename _Sequence = deque<_Tp> >
class queue;
template <typename _Tp, typename _Seq>
inline bool operator==(const queue<_Tp,_Seq>&, const queue<_Tp,_Seq>&);
template <typename _Tp, typename _Seq>
inline bool operator<(const queue<_Tp,_Seq>&, const queue<_Tp,_Seq>&);
/**
* @brief A standard container giving FIFO behavior.
*
* @ingroup Containers
* @ingroup Sequences
*
* Meets many of the requirements of a <a href="tables.html#65">container</a>,
* but does not define anything to do with iterators. Very few of the
* other standard container interfaces are defined.
*
* This is not a true container, but an @e adaptor. It holds another
* container, and provides a wrapper interface to that container. The
* wrapper is what enforces strict first-in-first-out %queue behavior.
*
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::deque, but it can be any type
* that supports @c front, @c back, @c push_back, and @c pop_front,
* such as std::list or an appropriate user-defined type.
*
* Members not found in "normal" containers are @c container_type,
* which is a typedef for the second Sequence parameter, and @c push and
* @c pop, which are standard %queue/FIFO operations.
*/
template <typename _Tp, typename _Sequence>
class queue
{
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
__glibcpp_class_requires(_Tp, _SGIAssignableConcept)
__glibcpp_class_requires(_Sequence, _FrontInsertionSequenceConcept)
__glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
__glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
template <typename _Tp1, typename _Seq1>
friend bool operator== (const queue<_Tp1, _Seq1>&,
const queue<_Tp1, _Seq1>&);
template <typename _Tp1, typename _Seq1>
friend bool operator< (const queue<_Tp1, _Seq1>&,
const queue<_Tp1, _Seq1>&);
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
// Forward declarations of operators < and ==, needed for friend declaration.
template <typename _Tp, typename _Sequence = deque<_Tp> >
class queue;
template <typename _Tp, typename _Seq>
inline bool operator==(const queue<_Tp,_Seq>&, const queue<_Tp,_Seq>&);
template <typename _Tp, typename _Seq>
inline bool operator<(const queue<_Tp,_Seq>&, const queue<_Tp,_Seq>&);
/**
* 'c' is the underlying container. Maintainers wondering why this isn't
* uglified as per style guidelines should note that this name is
* specified in the standard, [23.2.3.1]. (Why? Presumably for the same
* reason that it's protected instead of private: to allow derivation.
* But none of the other containers allow for derivation. Odd.)
*/
_Sequence c;
public:
/**
* @brief Default constructor creates no elements.
*/
explicit
queue(const _Sequence& __c = _Sequence())
: c(__c) {}
/**
* Returns true if the %queue is empty.
*/
bool
empty() const { return c.empty(); }
/** Returns the number of elements in the %queue. */
size_type
size() const { return c.size(); }
/**
* Returns a read/write reference to the data at the first element of the
* %queue.
*/
reference
front() { return c.front(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
const_reference
front() const { return c.front(); }
/**
* Returns a read/write reference to the data at the last element of the
* %queue.
*/
reference
back() { return c.back(); }
/**
* Returns a read-only (constant) reference to the data at the last
* element of the %queue.
*/
const_reference
back() const { return c.back(); }
/**
* @brief Add data to the end of the %queue.
* @param x Data to be added.
* @brief A standard container giving FIFO behavior.
*
* This is a typical %queue operation. The function creates an element at
* the end of the %queue and assigns the given data to it.
* The time complexity of the operation depends on the underlying
* sequence.
*/
void
push(const value_type& __x) { c.push_back(__x); }
/**
* @brief Removes first element.
* @ingroup Containers
* @ingroup Sequences
*
* This is a typical %queue operation. It shrinks the %queue by one.
* The time complexity of the operation depends on the underlying
* sequence.
* Meets many of the requirements of a
* <a href="tables.html#65">container</a>,
* but does not define anything to do with iterators. Very few of the
* other standard container interfaces are defined.
*
* Note that no data is returned, and if the first element's data is
* needed, it should be retrieved before pop() is called.
*/
void
pop() { c.pop_front(); }
};
/**
* @brief Queue equality comparison.
* @param x A %queue.
* @param y A %queue of the same type as @a x.
* @return True iff the size and elements of the queues are equal.
*
* This is an equivalence relation. Complexity and semantics depend on the
* underlying sequence type, but the expected rules are: this relation is
* linear in the size of the sequences, and queues are considered equivalent
* if their sequences compare equal.
*/
template <typename _Tp, typename _Sequence>
inline bool
operator==(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
{ return __x.c == __y.c; }
/**
* @brief Queue ordering relation.
* @param x A %queue.
* @param y A %queue of the same type as @a x.
* @return True iff @a x is lexographically less than @a y.
*
* This is an total ordering relation. Complexity and semantics depend on the
* underlying sequence type, but the expected rules are: this relation is
* linear in the size of the sequences, the elements must be comparable
* with @c <, and std::lexographical_compare() is usually used to make the
* determination.
*/
template <typename _Tp, typename _Sequence>
inline bool
operator<(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template <typename _Tp, typename _Sequence>
inline bool
operator!=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
{ return !(__x == __y); }
/// Based on operator<
template <typename _Tp, typename _Sequence>
inline bool
operator>(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
{ return __y < __x; }
/// Based on operator<
template <typename _Tp, typename _Sequence>
inline bool
operator<=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
{ return !(__y < __x); }
/// Based on operator<
template <typename _Tp, typename _Sequence>
inline bool
operator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
{ return !(__x < __y); }
/**
* @brief A standard container automatically sorting its contents.
*
* @ingroup Containers
* @ingroup Sequences
*
* This is not a true container, but an @e adaptor. It holds another
* container, and provides a wrapper interface to that container. The
* wrapper is what enforces sorting and first-in-first-out %queue behavior.
* Very few of the standard container/sequence interface requirements are
* met (e.g., iterators).
*
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::vector, but it can be any type
* that supports @c front(), @c push_back, @c pop_back, and random-access
* iterators, such as std::deque or an appropriate user-defined type.
*
* The third template parameter supplies the means of making priority
* comparisons. It defaults to @c less<value_type> but can be anything
* defining a strict weak ordering.
*
* Members not found in "normal" containers are @c container_type,
* which is a typedef for the second Sequence parameter, and @c push,
* @c pop, and @c top, which are standard %queue/FIFO operations.
*
* @note No equality/comparison operators are provided for %priority_queue.
*
* @note Sorting of the elements takes place as they are added to, and
* removed from, the %priority_queue using the %priority_queue's
* member functions. If you access the elements by other means, and
* change their data such that the sorting order would be different,
* the %priority_queue will not re-sort the elements for you. (How
* could it know to do so?)
*/
template <typename _Tp, typename _Sequence = vector<_Tp>,
typename _Compare = less<typename _Sequence::value_type> >
class priority_queue
{
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
__glibcpp_class_requires(_Tp, _SGIAssignableConcept)
__glibcpp_class_requires(_Sequence, _SequenceConcept)
__glibcpp_class_requires(_Sequence, _RandomAccessContainerConcept)
__glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
__glibcpp_class_requires4(_Compare, bool, _Tp, _Tp, _BinaryFunctionConcept)
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
// See queue::c for notes on these names.
_Sequence c;
_Compare comp;
public:
/**
* @brief Default constructor creates no elements.
*/
explicit
priority_queue(const _Compare& __x = _Compare(),
const _Sequence& __s = _Sequence())
: c(__s), comp(__x)
{ make_heap(c.begin(), c.end(), comp); }
/**
* @brief Builds a %queue from a range.
* @param first An input iterator.
* @param last An input iterator.
* @param x A comparison functor describing a strict weak ordering.
* @param s An initial sequence with which to start.
*
* Begins by copying @a s, inserting a copy of the elements from
* @a [first,last) into the copy of @a s, then ordering the copy
* according to @a x.
* This is not a true container, but an @e adaptor. It holds another
* container, and provides a wrapper interface to that container. The
* wrapper is what enforces strict first-in-first-out %queue behavior.
*
* For more information on function objects, see the documentation on
* @link s20_3_1_base functor base classes@endlink.
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::deque, but it can be any type
* that supports @c front, @c back, @c push_back, and @c pop_front,
* such as std::list or an appropriate user-defined type.
*
* Members not found in "normal" containers are @c container_type,
* which is a typedef for the second Sequence parameter, and @c push and
* @c pop, which are standard %queue/FIFO operations.
*/
template <typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x = _Compare(),
const _Sequence& __s = _Sequence())
: c(__s), comp(__x)
{
c.insert(c.end(), __first, __last);
make_heap(c.begin(), c.end(), comp);
template <typename _Tp, typename _Sequence>
class queue
{
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
__glibcpp_class_requires(_Tp, _SGIAssignableConcept)
__glibcpp_class_requires(_Sequence, _FrontInsertionSequenceConcept)
__glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
__glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
template <typename _Tp1, typename _Seq1>
friend bool operator== (const queue<_Tp1, _Seq1>&,
const queue<_Tp1, _Seq1>&);
template <typename _Tp1, typename _Seq1>
friend bool operator< (const queue<_Tp1, _Seq1>&,
const queue<_Tp1, _Seq1>&);
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
/**
* 'c' is the underlying container. Maintainers wondering why this isn't
* uglified as per style guidelines should note that this name is
* specified in the standard, [23.2.3.1]. (Why? Presumably for the same
* reason that it's protected instead of private: to allow derivation.
* But none of the other containers allow for derivation. Odd.)
*/
_Sequence c;
public:
/**
* @brief Default constructor creates no elements.
*/
explicit
queue(const _Sequence& __c = _Sequence())
: c(__c) {}
/**
* Returns true if the %queue is empty.
*/
bool
empty() const { return c.empty(); }
/** Returns the number of elements in the %queue. */
size_type
size() const { return c.size(); }
/**
* Returns a read/write reference to the data at the first element of the
* %queue.
*/
reference
front() { return c.front(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
const_reference
front() const { return c.front(); }
/**
* Returns a read/write reference to the data at the last element of the
* %queue.
*/
reference
back() { return c.back(); }
/**
* Returns a read-only (constant) reference to the data at the last
* element of the %queue.
*/
const_reference
back() const { return c.back(); }
/**
* @brief Add data to the end of the %queue.
* @param x Data to be added.
*
* This is a typical %queue operation. The function creates an element at
* the end of the %queue and assigns the given data to it.
* The time complexity of the operation depends on the underlying
* sequence.
*/
void
push(const value_type& __x) { c.push_back(__x); }
/**
* @brief Removes first element.
*
* This is a typical %queue operation. It shrinks the %queue by one.
* The time complexity of the operation depends on the underlying
* sequence.
*
* Note that no data is returned, and if the first element's data is
* needed, it should be retrieved before pop() is called.
*/
void
pop() { c.pop_front(); }
};
/**
* @brief Queue equality comparison.
* @param x A %queue.
* @param y A %queue of the same type as @a x.
* @return True iff the size and elements of the queues are equal.
*
* This is an equivalence relation. Complexity and semantics depend on the
* underlying sequence type, but the expected rules are: this relation is
* linear in the size of the sequences, and queues are considered equivalent
* if their sequences compare equal.
*/
template <typename _Tp, typename _Sequence>
inline bool
operator==(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
{ return __x.c == __y.c; }
/**
* @brief Queue ordering relation.
* @param x A %queue.
* @param y A %queue of the same type as @a x.
* @return True iff @a x is lexographically less than @a y.
*
* This is an total ordering relation. Complexity and semantics depend on
* the underlying sequence type, but the expected rules are: this relation
* is linear in the size of the sequences, the elements must be comparable
* with @c <, and std::lexographical_compare() is usually used to make the
* determination.
*/
template <typename _Tp, typename _Sequence>
inline bool
operator<(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template <typename _Tp, typename _Sequence>
inline bool
operator!=(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
{ return !(__x == __y); }
/// Based on operator<
template <typename _Tp, typename _Sequence>
inline bool
operator>(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
{ return __y < __x; }
/// Based on operator<
template <typename _Tp, typename _Sequence>
inline bool
operator<=(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
{ return !(__y < __x); }
/// Based on operator<
template <typename _Tp, typename _Sequence>
inline bool
operator>=(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y)
{ return !(__x < __y); }
/**
* @brief A standard container automatically sorting its contents.
*
* @ingroup Containers
* @ingroup Sequences
*
* This is not a true container, but an @e adaptor. It holds another
* container, and provides a wrapper interface to that container. The
* wrapper is what enforces sorting and first-in-first-out %queue behavior.
* Very few of the standard container/sequence interface requirements are
* met (e.g., iterators).
*
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::vector, but it can be any type
* that supports @c front(), @c push_back, @c pop_back, and random-access
* iterators, such as std::deque or an appropriate user-defined type.
*
* The third template parameter supplies the means of making priority
* comparisons. It defaults to @c less<value_type> but can be anything
* defining a strict weak ordering.
*
* Members not found in "normal" containers are @c container_type,
* which is a typedef for the second Sequence parameter, and @c push,
* @c pop, and @c top, which are standard %queue/FIFO operations.
*
* @note No equality/comparison operators are provided for %priority_queue.
*
* @note Sorting of the elements takes place as they are added to, and
* removed from, the %priority_queue using the %priority_queue's
* member functions. If you access the elements by other means, and
* change their data such that the sorting order would be different,
* the %priority_queue will not re-sort the elements for you. (How
* could it know to do so?)
*/
template <typename _Tp, typename _Sequence = vector<_Tp>,
typename _Compare = less<typename _Sequence::value_type> >
class priority_queue
{
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
__glibcpp_class_requires(_Tp, _SGIAssignableConcept)
__glibcpp_class_requires(_Sequence, _SequenceConcept)
__glibcpp_class_requires(_Sequence, _RandomAccessContainerConcept)
__glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
__glibcpp_class_requires4(_Compare, bool, _Tp, _Tp, _BinaryFunctionConcept)
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
// See queue::c for notes on these names.
_Sequence c;
_Compare comp;
public:
/**
* @brief Default constructor creates no elements.
*/
explicit
priority_queue(const _Compare& __x = _Compare(),
const _Sequence& __s = _Sequence())
: c(__s), comp(__x)
{ make_heap(c.begin(), c.end(), comp); }
/**
* @brief Builds a %queue from a range.
* @param first An input iterator.
* @param last An input iterator.
* @param x A comparison functor describing a strict weak ordering.
* @param s An initial sequence with which to start.
*
* Begins by copying @a s, inserting a copy of the elements from
* @a [first,last) into the copy of @a s, then ordering the copy
* according to @a x.
*
* For more information on function objects, see the documentation on
* @link s20_3_1_base functor base classes@endlink.
*/
template <typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x = _Compare(),
const _Sequence& __s = _Sequence())
: c(__s), comp(__x)
{
c.insert(c.end(), __first, __last);
make_heap(c.begin(), c.end(), comp);
}
/**
* Returns true if the %queue is empty.
*/
bool
empty() const { return c.empty(); }
/** Returns the number of elements in the %queue. */
size_type
size() const { return c.size(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
const_reference
top() const { return c.front(); }
/**
* @brief Add data to the %queue.
* @param x Data to be added.
*
* This is a typical %queue operation.
* The time complexity of the operation depends on the underlying
* sequence.
*/
void
push(const value_type& __x)
{
try
{
c.push_back(__x);
push_heap(c.begin(), c.end(), comp);
}
catch(...)
{
c.clear();
__throw_exception_again;
}
}
/**
* Returns true if the %queue is empty.
*/
bool
empty() const { return c.empty(); }
/** Returns the number of elements in the %queue. */
size_type
size() const { return c.size(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
const_reference
top() const { return c.front(); }
/**
* @brief Add data to the %queue.
* @param x Data to be added.
*
* This is a typical %queue operation.
* The time complexity of the operation depends on the underlying
* sequence.
*/
void
push(const value_type& __x)
{
try
{
c.push_back(__x);
push_heap(c.begin(), c.end(), comp);
}
catch(...)
{
c.clear();
__throw_exception_again;
}
}
/**
* @brief Removes first element.
*
* This is a typical %queue operation. It shrinks the %queue by one.
* The time complexity of the operation depends on the underlying
* sequence.
*
* Note that no data is returned, and if the first element's data is
* needed, it should be retrieved before pop() is called.
*/
void
pop()
{
try
{
pop_heap(c.begin(), c.end(), comp);
c.pop_back();
}
catch(...)
{
c.clear();
__throw_exception_again;
}
}
};
// No equality/comparison operators are provided for priority_queue.
/**
* @brief Removes first element.
*
* This is a typical %queue operation. It shrinks the %queue by one.
* The time complexity of the operation depends on the underlying
* sequence.
*
* Note that no data is returned, and if the first element's data is
* needed, it should be retrieved before pop() is called.
*/
void
pop()
{
try
{
pop_heap(c.begin(), c.end(), comp);
c.pop_back();
}
catch(...)
{
c.clear();
__throw_exception_again;
}
}
};
// No equality/comparison operators are provided for priority_queue.
} // namespace std
#endif /* __GLIBCPP_INTERNAL_QUEUE_H */

View File

@ -63,192 +63,188 @@
#include <bits/concept_check.h>
// Since this entire file is within namespace std, there's no reason to
// waste two spaces along the left column. Thus the leading indentation is
// slightly violated from here on.
namespace std
{
// Forward declarations of operators == and <, needed for friend declaration.
template <typename _Tp, typename _Sequence = deque<_Tp> >
class stack;
template <typename _Tp, typename _Seq>
inline bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
template <typename _Tp, typename _Seq>
inline bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
/**
* @brief A standard container giving FILO behavior.
*
* @ingroup Containers
* @ingroup Sequences
*
* Meets many of the requirements of a <a href="tables.html#65">container</a>,
* but does not define anything to do with iterators. Very few of the
* other standard container interfaces are defined.
*
* This is not a true container, but an @e adaptor. It holds another
* container, and provides a wrapper interface to that container. The
* wrapper is what enforces strict first-in-last-out %stack behavior.
*
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::deque, but it can be any type
* that supports @c back, @c push_back, and @c pop_front, such as
* std::list, std::vector, or an appropriate user-defined type.
*
* Members not found in "normal" containers are @c container_type,
* which is a typedef for the second Sequence parameter, and @c push,
* @c pop, and @c top, which are standard %stack/FILO operations.
*/
template <typename _Tp, typename _Sequence>
class stack
{
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
__glibcpp_class_requires(_Tp, _SGIAssignableConcept)
__glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
__glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
template <typename _Tp1, typename _Seq1>
friend bool operator== (const stack<_Tp1, _Seq1>&,
const stack<_Tp1, _Seq1>&);
template <typename _Tp1, typename _Seq1>
friend bool operator< (const stack<_Tp1, _Seq1>&,
const stack<_Tp1, _Seq1>&);
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
// See queue::c for notes on this name.
_Sequence c;
public:
// XXX removed old def ctor, added def arg to this one to match 14882
// Forward declarations of operators == and <, needed for friend declaration.
template <typename _Tp, typename _Sequence = deque<_Tp> >
class stack;
template <typename _Tp, typename _Seq>
inline bool operator==(const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y);
template <typename _Tp, typename _Seq>
inline bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
/**
* @brief Default constructor creates no elements.
*/
explicit
stack(const _Sequence& __c = _Sequence())
: c(__c) {}
/**
* Returns true if the %stack is empty.
*/
bool
empty() const { return c.empty(); }
/** Returns the number of elements in the %stack. */
size_type
size() const { return c.size(); }
/**
* Returns a read/write reference to the data at the first element of the
* %stack.
*/
reference
top() { return c.back(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %stack.
*/
const_reference
top() const { return c.back(); }
/**
* @brief Add data to the top of the %stack.
* @param x Data to be added.
* @brief A standard container giving FILO behavior.
*
* This is a typical %stack operation. The function creates an element at
* the top of the %stack and assigns the given data to it.
* The time complexity of the operation depends on the underlying
* sequence.
* @ingroup Containers
* @ingroup Sequences
*
* Meets many of the requirements of a
* <a href="tables.html#65">container</a>,
* but does not define anything to do with iterators. Very few of the
* other standard container interfaces are defined.
*
* This is not a true container, but an @e adaptor. It holds another
* container, and provides a wrapper interface to that container. The
* wrapper is what enforces strict first-in-last-out %stack behavior.
*
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::deque, but it can be any type
* that supports @c back, @c push_back, and @c pop_front, such as
* std::list, std::vector, or an appropriate user-defined type.
*
* Members not found in "normal" containers are @c container_type,
* which is a typedef for the second Sequence parameter, and @c push,
* @c pop, and @c top, which are standard %stack/FILO operations.
*/
void
push(const value_type& __x) { c.push_back(__x); }
template <typename _Tp, typename _Sequence>
class stack
{
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
__glibcpp_class_requires(_Tp, _SGIAssignableConcept)
__glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
__glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
template <typename _Tp1, typename _Seq1>
friend bool operator== (const stack<_Tp1, _Seq1>&,
const stack<_Tp1, _Seq1>&);
template <typename _Tp1, typename _Seq1>
friend bool operator< (const stack<_Tp1, _Seq1>&,
const stack<_Tp1, _Seq1>&);
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
// See queue::c for notes on this name.
_Sequence c;
public:
// XXX removed old def ctor, added def arg to this one to match 14882
/**
* @brief Default constructor creates no elements.
*/
explicit
stack(const _Sequence& __c = _Sequence())
: c(__c) {}
/**
* Returns true if the %stack is empty.
*/
bool
empty() const { return c.empty(); }
/** Returns the number of elements in the %stack. */
size_type
size() const { return c.size(); }
/**
* Returns a read/write reference to the data at the first element of the
* %stack.
*/
reference
top() { return c.back(); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %stack.
*/
const_reference
top() const { return c.back(); }
/**
* @brief Add data to the top of the %stack.
* @param x Data to be added.
*
* This is a typical %stack operation. The function creates an element at
* the top of the %stack and assigns the given data to it.
* The time complexity of the operation depends on the underlying
* sequence.
*/
void
push(const value_type& __x) { c.push_back(__x); }
/**
* @brief Removes first element.
*
* This is a typical %stack operation. It shrinks the %stack by one.
* The time complexity of the operation depends on the underlying
* sequence.
*
* Note that no data is returned, and if the first element's data is
* needed, it should be retrieved before pop() is called.
*/
void
pop() { c.pop_back(); }
};
/**
* @brief Removes first element.
* @brief Stack equality comparison.
* @param x A %stack.
* @param y A %stack of the same type as @a x.
* @return True iff the size and elements of the stacks are equal.
*
* This is a typical %stack operation. It shrinks the %stack by one.
* The time complexity of the operation depends on the underlying
* sequence.
*
* Note that no data is returned, and if the first element's data is
* needed, it should be retrieved before pop() is called.
* This is an equivalence relation. Complexity and semantics depend on the
* underlying sequence type, but the expected rules are: this relation is
* linear in the size of the sequences, and stacks are considered equivalent
* if their sequences compare equal.
*/
void
pop() { c.pop_back(); }
};
/**
* @brief Stack equality comparison.
* @param x A %stack.
* @param y A %stack of the same type as @a x.
* @return True iff the size and elements of the stacks are equal.
*
* This is an equivalence relation. Complexity and semantics depend on the
* underlying sequence type, but the expected rules are: this relation is
* linear in the size of the sequences, and stacks are considered equivalent
* if their sequences compare equal.
*/
template <typename _Tp, typename _Seq>
inline bool
operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return __x.c == __y.c; }
/**
* @brief Stack ordering relation.
* @param x A %stack.
* @param y A %stack of the same type as @a x.
* @return True iff @a x is lexographically less than @a y.
*
* This is an total ordering relation. Complexity and semantics depend on the
* underlying sequence type, but the expected rules are: this relation is
* linear in the size of the sequences, the elements must be comparable
* with @c <, and std::lexographical_compare() is usually used to make the
* determination.
*/
template <typename _Tp, typename _Seq>
inline bool
operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template <typename _Tp, typename _Seq>
inline bool
operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return !(__x == __y); }
/// Based on operator<
template <typename _Tp, typename _Seq>
inline bool
operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return __y < __x; }
/// Based on operator<
template <typename _Tp, typename _Seq>
inline bool
operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return !(__y < __x); }
/// Based on operator<
template <typename _Tp, typename _Seq>
inline bool
operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return !(__x < __y); }
template <typename _Tp, typename _Seq>
inline bool
operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return __x.c == __y.c; }
/**
* @brief Stack ordering relation.
* @param x A %stack.
* @param y A %stack of the same type as @a x.
* @return True iff @a x is lexographically less than @a y.
*
* This is an total ordering relation. Complexity and semantics depend on
* the underlying sequence type, but the expected rules are: this relation
* is linear in the size of the sequences, the elements must be comparable
* with @c <, and std::lexographical_compare() is usually used to make the
* determination.
*/
template <typename _Tp, typename _Seq>
inline bool
operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template <typename _Tp, typename _Seq>
inline bool
operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return !(__x == __y); }
/// Based on operator<
template <typename _Tp, typename _Seq>
inline bool
operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return __y < __x; }
/// Based on operator<
template <typename _Tp, typename _Seq>
inline bool
operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return !(__y < __x); }
/// Based on operator<
template <typename _Tp, typename _Seq>
inline bool
operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
{ return !(__x < __y); }
} // namespace std
#endif /* __GLIBCPP_INTERNAL_STACK_H */

File diff suppressed because it is too large Load Diff

View File

@ -61,287 +61,186 @@
#ifndef __GLIBCPP_INTERNAL_VECTOR_TCC
#define __GLIBCPP_INTERNAL_VECTOR_TCC
// Since this entire file is within namespace std, there's no reason to
// waste two spaces along the left column. Thus the leading indentation is
// slightly violated from here on.
namespace std
{
template <typename _Tp, typename _Alloc>
void
vector<_Tp,_Alloc>::
reserve(size_type __n)
{
if (capacity() < __n)
template <typename _Tp, typename _Alloc>
void
vector<_Tp,_Alloc>::
reserve(size_type __n)
{
const size_type __old_size = size();
pointer __tmp = _M_allocate_and_copy(__n, _M_start, _M_finish);
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __tmp;
_M_finish = __tmp + __old_size;
_M_end_of_storage = _M_start + __n;
}
}
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 (_M_finish != _M_end_of_storage && __position == end())
{
_Construct(_M_finish, __x);
++_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())
copy(__position + 1, end(), __position);
--_M_finish;
_Destroy(_M_finish);
return __position;
}
template <typename _Tp, typename _Alloc>
typename vector<_Tp,_Alloc>::iterator
vector<_Tp,_Alloc>::
erase(iterator __first, iterator __last)
{
iterator __i(copy(__last, end(), __first));
_Destroy(__i, end());
_M_finish = _M_finish - (__last - __first);
return __first;
}
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())
if (capacity() < __n)
{
pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());
const size_type __old_size = size();
pointer __tmp = _M_allocate_and_copy(__n, _M_start, _M_finish);
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __tmp;
_M_end_of_storage = _M_start + __xlen;
_M_finish = __tmp + __old_size;
_M_end_of_storage = _M_start + __n;
}
else if (size() >= __xlen)
}
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 (_M_finish != _M_end_of_storage && __position == end())
{
iterator __i(copy(__x.begin(), __x.end(), begin()));
_Destroy(__i, end());
_Construct(_M_finish, __x);
++_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())
copy(__position + 1, end(), __position);
--_M_finish;
_Destroy(_M_finish);
return __position;
}
template <typename _Tp, typename _Alloc>
typename vector<_Tp,_Alloc>::iterator
vector<_Tp,_Alloc>::
erase(iterator __first, iterator __last)
{
iterator __i(copy(__last, end(), __first));
_Destroy(__i, end());
_M_finish = _M_finish - (__last - __first);
return __first;
}
template <typename _Tp, typename _Alloc>
vector<_Tp,_Alloc>&
vector<_Tp,_Alloc>::
operator=(const vector<_Tp,_Alloc>& __x)
{
if (&__x != this)
{
copy(__x.begin(), __x.begin() + size(), _M_start);
uninitialized_copy(__x.begin() + size(), __x.end(), _M_finish);
}
_M_finish = _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())
{
fill(begin(), end(), __val);
_M_finish = uninitialized_fill_n(_M_finish, __n - size(), __val);
}
else
erase(fill_n(begin(), __n, __val), end());
}
template <typename _Tp, typename _Alloc> template <typename _InputIter>
void
vector<_Tp,_Alloc>::
_M_assign_aux(_InputIter __first, _InputIter __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 _ForwardIter>
void
vector<_Tp,_Alloc>::
_M_assign_aux(_ForwardIter __first, _ForwardIter __last, forward_iterator_tag)
{
size_type __len = distance(__first, __last);
if (__len > capacity())
{
pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __tmp;
_M_end_of_storage = _M_finish = _M_start + __len;
}
else if (size() >= __len)
{
iterator __new_finish(copy(__first, __last, _M_start));
_Destroy(__new_finish, end());
_M_finish = __new_finish.base();
}
else
{
_ForwardIter __mid = __first;
advance(__mid, size());
copy(__first, __mid, _M_start);
_M_finish = uninitialized_copy(__mid, __last, _M_finish);
}
}
template <typename _Tp, typename _Alloc>
void
vector<_Tp,_Alloc>::
_M_insert_aux(iterator __position, const _Tp& __x)
{
if (_M_finish != _M_end_of_storage)
{
_Construct(_M_finish, *(_M_finish - 1));
++_M_finish;
_Tp __x_copy = __x;
copy_backward(__position, iterator(_M_finish-2), iterator(_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(_M_allocate(__len));
iterator __new_finish(__new_start);
try
const size_type __xlen = __x.size();
if (__xlen > capacity())
{
__new_finish = uninitialized_copy(iterator(_M_start), __position,
__new_start);
_Construct(__new_finish.base(), __x);
++__new_finish;
__new_finish = uninitialized_copy(__position, iterator(_M_finish),
__new_finish);
pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __tmp;
_M_end_of_storage = _M_start + __xlen;
}
catch(...)
else if (size() >= __xlen)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start.base(),__len);
__throw_exception_again;
}
_Destroy(begin(), end());
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start.base();
_M_finish = __new_finish.base();
_M_end_of_storage = __new_start.base() + __len;
}
}
#ifdef _GLIBCPP_DEPRECATED
template <typename _Tp, typename _Alloc>
void
vector<_Tp,_Alloc>::
_M_insert_aux(iterator __position)
{
if (_M_finish != _M_end_of_storage)
{
_Construct(_M_finish, *(_M_finish - 1));
++_M_finish;
copy_backward(__position, iterator(_M_finish - 2),
iterator(_M_finish - 1));
*__position = value_type();
}
else
{
const size_type __old_size = size();
const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
pointer __new_start = _M_allocate(__len);
pointer __new_finish = __new_start;
try
{
__new_finish = uninitialized_copy(iterator(_M_start), __position,
__new_start);
_Construct(__new_finish);
++__new_finish;
__new_finish = uninitialized_copy(__position, iterator(_M_finish),
__new_finish);
}
catch(...)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start,__len);
__throw_exception_again;
}
_Destroy(begin(), end());
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start;
_M_finish = __new_finish;
_M_end_of_storage = __new_start + __len;
}
}
#endif
template <typename _Tp, typename _Alloc>
void
vector<_Tp,_Alloc>::
_M_fill_insert(iterator __position, size_type __n, const value_type& __x)
{
if (__n != 0)
{
if (size_type(_M_end_of_storage - _M_finish) >= __n) {
value_type __x_copy = __x;
const size_type __elems_after = end() - __position;
iterator __old_finish(_M_finish);
if (__elems_after > __n)
{
uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
_M_finish += __n;
copy_backward(__position, __old_finish - __n, __old_finish);
fill(__position, __position + __n, __x_copy);
iterator __i(copy(__x.begin(), __x.end(), begin()));
_Destroy(__i, end());
}
else
{
uninitialized_fill_n(_M_finish, __n - __elems_after, __x_copy);
_M_finish += __n - __elems_after;
uninitialized_copy(__position, __old_finish, _M_finish);
_M_finish += __elems_after;
fill(__position, __old_finish, __x_copy);
copy(__x.begin(), __x.begin() + size(), _M_start);
uninitialized_copy(__x.begin() + size(), __x.end(), _M_finish);
}
_M_finish = _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())
{
fill(begin(), end(), __val);
_M_finish = uninitialized_fill_n(_M_finish, __n - size(), __val);
}
else
erase(fill_n(begin(), __n, __val), end());
}
template <typename _Tp, typename _Alloc> template <typename _InputIter>
void
vector<_Tp,_Alloc>::
_M_assign_aux(_InputIter __first, _InputIter __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 _ForwardIter>
void
vector<_Tp,_Alloc>::
_M_assign_aux(_ForwardIter __first, _ForwardIter __last,
forward_iterator_tag)
{
size_type __len = distance(__first, __last);
if (__len > capacity())
{
pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __tmp;
_M_end_of_storage = _M_finish = _M_start + __len;
}
else if (size() >= __len)
{
iterator __new_finish(copy(__first, __last, _M_start));
_Destroy(__new_finish, end());
_M_finish = __new_finish.base();
}
else
{
_ForwardIter __mid = __first;
advance(__mid, size());
copy(__first, __mid, _M_start);
_M_finish = uninitialized_copy(__mid, __last, _M_finish);
}
}
template <typename _Tp, typename _Alloc>
void
vector<_Tp,_Alloc>::
_M_insert_aux(iterator __position, const _Tp& __x)
{
if (_M_finish != _M_end_of_storage)
{
_Construct(_M_finish, *(_M_finish - 1));
++_M_finish;
_Tp __x_copy = __x;
copy_backward(__position, iterator(_M_finish-2), iterator(_M_finish-1));
*__position = __x_copy;
}
else
{
const size_type __old_size = size();
const size_type __len = __old_size + max(__old_size, __n);
const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
iterator __new_start(_M_allocate(__len));
iterator __new_finish(__new_start);
try
{
__new_finish = uninitialized_copy(begin(), __position, __new_start);
__new_finish = uninitialized_fill_n(__new_finish, __n, __x);
__new_finish
= uninitialized_copy(__position, end(), __new_finish);
__new_finish = uninitialized_copy(iterator(_M_start), __position,
__new_start);
_Construct(__new_finish.base(), __x);
++__new_finish;
__new_finish = uninitialized_copy(__position, iterator(_M_finish),
__new_finish);
}
catch(...)
{
@ -349,91 +248,188 @@ template <typename _Tp, typename _Alloc>
_M_deallocate(__new_start.base(),__len);
__throw_exception_again;
}
_Destroy(_M_start, _M_finish);
_Destroy(begin(), end());
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start.base();
_M_finish = __new_finish.base();
_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)
#ifdef _GLIBCPP_DEPRECATED
template <typename _Tp, typename _Alloc>
void
vector<_Tp,_Alloc>::
_M_insert_aux(iterator __position)
{
__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 = distance(__first, __last);
if (size_type(_M_end_of_storage - _M_finish) >= __n)
if (_M_finish != _M_end_of_storage)
{
const size_type __elems_after = end() - __position;
iterator __old_finish(_M_finish);
if (__elems_after > __n)
{
uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
_M_finish += __n;
copy_backward(__position, __old_finish - __n, __old_finish);
copy(__first, __last, __position);
}
else
{
_ForwardIterator __mid = __first;
advance(__mid, __elems_after);
uninitialized_copy(__mid, __last, _M_finish);
_M_finish += __n - __elems_after;
uninitialized_copy(__position, __old_finish, _M_finish);
_M_finish += __elems_after;
copy(__first, __mid, __position);
}
_Construct(_M_finish, *(_M_finish - 1));
++_M_finish;
copy_backward(__position, iterator(_M_finish - 2),
iterator(_M_finish - 1));
*__position = value_type();
}
else
{
const size_type __old_size = size();
const size_type __len = __old_size + max(__old_size, __n);
iterator __new_start(_M_allocate(__len));
iterator __new_finish(__new_start);
const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
pointer __new_start = _M_allocate(__len);
pointer __new_finish = __new_start;
try
{
__new_finish = uninitialized_copy(iterator(_M_start),
__position, __new_start);
__new_finish = uninitialized_copy(__first, __last, __new_finish);
__new_finish = uninitialized_copy(iterator(_M_start), __position,
__new_start);
_Construct(__new_finish);
++__new_finish;
__new_finish = uninitialized_copy(__position, iterator(_M_finish),
__new_finish);
}
catch(...)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start.base(), __len);
_M_deallocate(__new_start,__len);
__throw_exception_again;
}
_Destroy(_M_start, _M_finish);
_Destroy(begin(), end());
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start.base();
_M_finish = __new_finish.base();
_M_end_of_storage = __new_start.base() + __len;
_M_start = __new_start;
_M_finish = __new_finish;
_M_end_of_storage = __new_start + __len;
}
}
#endif
template <typename _Tp, typename _Alloc>
void
vector<_Tp,_Alloc>::
_M_fill_insert(iterator __position, size_type __n, const value_type& __x)
{
if (__n != 0)
{
if (size_type(_M_end_of_storage - _M_finish) >= __n) {
value_type __x_copy = __x;
const size_type __elems_after = end() - __position;
iterator __old_finish(_M_finish);
if (__elems_after > __n)
{
uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
_M_finish += __n;
copy_backward(__position, __old_finish - __n, __old_finish);
fill(__position, __position + __n, __x_copy);
}
else
{
uninitialized_fill_n(_M_finish, __n - __elems_after, __x_copy);
_M_finish += __n - __elems_after;
uninitialized_copy(__position, __old_finish, _M_finish);
_M_finish += __elems_after;
fill(__position, __old_finish, __x_copy);
}
}
else
{
const size_type __old_size = size();
const size_type __len = __old_size + max(__old_size, __n);
iterator __new_start(_M_allocate(__len));
iterator __new_finish(__new_start);
try
{
__new_finish = uninitialized_copy(begin(), __position,
__new_start);
__new_finish = uninitialized_fill_n(__new_finish, __n, __x);
__new_finish
= uninitialized_copy(__position, end(), __new_finish);
}
catch(...)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start.base(),__len);
__throw_exception_again;
}
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start.base();
_M_finish = __new_finish.base();
_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 = distance(__first, __last);
if (size_type(_M_end_of_storage - _M_finish) >= __n)
{
const size_type __elems_after = end() - __position;
iterator __old_finish(_M_finish);
if (__elems_after > __n)
{
uninitialized_copy(_M_finish - __n, _M_finish, _M_finish);
_M_finish += __n;
copy_backward(__position, __old_finish - __n, __old_finish);
copy(__first, __last, __position);
}
else
{
_ForwardIterator __mid = __first;
advance(__mid, __elems_after);
uninitialized_copy(__mid, __last, _M_finish);
_M_finish += __n - __elems_after;
uninitialized_copy(__position, __old_finish, _M_finish);
_M_finish += __elems_after;
copy(__first, __mid, __position);
}
}
else
{
const size_type __old_size = size();
const size_type __len = __old_size + max(__old_size, __n);
iterator __new_start(_M_allocate(__len));
iterator __new_finish(__new_start);
try
{
__new_finish = uninitialized_copy(iterator(_M_start),
__position, __new_start);
__new_finish = uninitialized_copy(__first, __last, __new_finish);
__new_finish = uninitialized_copy(__position, iterator(_M_finish),
__new_finish);
}
catch(...)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start.base(), __len);
__throw_exception_again;
}
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start.base();
_M_finish = __new_finish.base();
_M_end_of_storage = __new_start.base() + __len;
}
}
}
}
} // namespace std
#endif /* __GLIBCPP_INTERNAL_VECTOR_TCC */