mirror of git://gcc.gnu.org/git/gcc.git
stl_list.h (list<>::insert(iterator, size_type, const value_type&), [...]): Adjust C++11 signatures to take const_iterator(s).
2013-07-01 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/stl_list.h (list<>::insert(iterator, size_type, const value_type&), list<>::insert(iterator, initializer_list<>), list<>::insert(iterator, _InputIterator, _InputIterator), list<>::splice(iterator, list&&), list<>::splice(iterator, list&), list<>::splice(iterator, list&&, iterator), list<>::splice(iterator, list&, iterator), list<>::splice(iterator, list&&, iterator, iterator), list<>::splice(iterator, list&, iterator, iterator)): Adjust C++11 signatures to take const_iterator(s). * include/bits/list.tcc (list<>::insert(const_iterator, size_type, const value_type&), list<>::insert(const_iterator, _InputIterator, _InputIterator)): Define. * include/ext/vstring.h (__versa_string<>::insert(iterator, size_type, _CharT), __versa_string<>::insert(iterator, _InputIterator, _InputIterator), __versa_string<>::insert(iterator, std::initializer_list<>), __versa_string<>::replace(iterator, iterator, _InputIterator, _InputIterator), __versa_string<>:: replace(iterator, iterator, std::initializer_list<>)): Adjust C++11 signatures to take const_iterator(s). (__versa_string<>::_M_replace_dispatch): Take const_iterators. * include/ext/vstring.tcc: Likewise. * include/debug/list: Adjust. * include/profile/list: Likewise. * testsuite/23_containers/list/operations/splice/const_iterator.cc: New. * testsuite/23_containers/list/modifiers/insert/const_iterator.cc: Extend. * testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc: Likewise. * testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc: Likewise. * testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc: Likewise. * testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc: Likewise. * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Adjust dg-error line number. * testsuite/23_containers/list/requirements/dr438/ constructor_1_neg.cc: Likewise. * testsuite/23_containers/list/requirements/dr438/ constructor_2_neg.cc: Likewise. * testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Likewise. From-SVN: r200580
This commit is contained in:
parent
31f8442be7
commit
019fdb7923
|
|
@ -1,3 +1,50 @@
|
|||
2013-07-01 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/bits/stl_list.h (list<>::insert(iterator,
|
||||
size_type, const value_type&), list<>::insert(iterator,
|
||||
initializer_list<>), list<>::insert(iterator, _InputIterator,
|
||||
_InputIterator), list<>::splice(iterator, list&&),
|
||||
list<>::splice(iterator, list&), list<>::splice(iterator, list&&,
|
||||
iterator), list<>::splice(iterator, list&, iterator),
|
||||
list<>::splice(iterator, list&&, iterator, iterator),
|
||||
list<>::splice(iterator, list&, iterator, iterator)): Adjust C++11
|
||||
signatures to take const_iterator(s).
|
||||
* include/bits/list.tcc (list<>::insert(const_iterator, size_type,
|
||||
const value_type&), list<>::insert(const_iterator, _InputIterator,
|
||||
_InputIterator)): Define.
|
||||
* include/ext/vstring.h (__versa_string<>::insert(iterator,
|
||||
size_type, _CharT), __versa_string<>::insert(iterator,
|
||||
_InputIterator, _InputIterator), __versa_string<>::insert(iterator,
|
||||
std::initializer_list<>), __versa_string<>::replace(iterator,
|
||||
iterator, _InputIterator, _InputIterator), __versa_string<>::
|
||||
replace(iterator, iterator, std::initializer_list<>)): Adjust C++11
|
||||
signatures to take const_iterator(s).
|
||||
(__versa_string<>::_M_replace_dispatch): Take const_iterators.
|
||||
* include/ext/vstring.tcc: Likewise.
|
||||
* include/debug/list: Adjust.
|
||||
* include/profile/list: Likewise.
|
||||
* testsuite/23_containers/list/operations/splice/const_iterator.cc:
|
||||
New.
|
||||
* testsuite/23_containers/list/modifiers/insert/const_iterator.cc:
|
||||
Extend.
|
||||
* testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc:
|
||||
Likewise.
|
||||
* testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc:
|
||||
Likewise.
|
||||
* testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc:
|
||||
Likewise.
|
||||
* testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc:
|
||||
Likewise.
|
||||
|
||||
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
|
||||
Adjust dg-error line number.
|
||||
* testsuite/23_containers/list/requirements/dr438/
|
||||
constructor_1_neg.cc: Likewise.
|
||||
* testsuite/23_containers/list/requirements/dr438/
|
||||
constructor_2_neg.cc: Likewise.
|
||||
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
|
||||
Likewise.
|
||||
|
||||
2013-06-30 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/bits/stl_deque.h (deque<>::insert(iterator,
|
||||
|
|
|
|||
|
|
@ -107,6 +107,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
return iterator(__tmp);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Tp, typename _Alloc>
|
||||
typename list<_Tp, _Alloc>::iterator
|
||||
list<_Tp, _Alloc>::
|
||||
insert(const_iterator __position, size_type __n, const value_type& __x)
|
||||
{
|
||||
if (__n)
|
||||
{
|
||||
list __tmp(__n, __x, get_allocator());
|
||||
iterator __it = __tmp.begin();
|
||||
splice(__position, __tmp);
|
||||
return __it;
|
||||
}
|
||||
return __position._M_const_cast();
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
template<typename _InputIterator, typename>
|
||||
typename list<_Tp, _Alloc>::iterator
|
||||
list<_Tp, _Alloc>::
|
||||
insert(const_iterator __position, _InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
list __tmp(__first, __last, get_allocator());
|
||||
if (!__tmp.empty())
|
||||
{
|
||||
iterator __it = __tmp.begin();
|
||||
splice(__position, __tmp);
|
||||
return __it;
|
||||
}
|
||||
return __position._M_const_cast();
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
typename list<_Tp, _Alloc>::iterator
|
||||
list<_Tp, _Alloc>::
|
||||
|
|
|
|||
|
|
@ -1113,9 +1113,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
|
||||
/**
|
||||
* @brief Inserts the contents of an initializer_list into %list
|
||||
* before specified iterator.
|
||||
* @param __p An iterator into the %list.
|
||||
* before specified const_iterator.
|
||||
* @param __p A const_iterator into the %list.
|
||||
* @param __l An initializer_list of value_type.
|
||||
* @return An iterator pointing to the first element inserted
|
||||
* (or __position).
|
||||
*
|
||||
* This function will insert copies of the data in the
|
||||
* initializer_list @a l into the %list before the location
|
||||
|
|
@ -1124,11 +1126,29 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* This operation is linear in the number of elements inserted and
|
||||
* does not invalidate iterators and references.
|
||||
*/
|
||||
void
|
||||
insert(iterator __p, initializer_list<value_type> __l)
|
||||
{ this->insert(__p, __l.begin(), __l.end()); }
|
||||
iterator
|
||||
insert(const_iterator __p, initializer_list<value_type> __l)
|
||||
{ return this->insert(__p, __l.begin(), __l.end()); }
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Inserts a number of copies of given data into the %list.
|
||||
* @param __position A const_iterator into the %list.
|
||||
* @param __n Number of elements to be inserted.
|
||||
* @param __x Data to be inserted.
|
||||
* @return An iterator pointing to the first element inserted
|
||||
* (or __position).
|
||||
*
|
||||
* This function will insert a specified number of copies of the
|
||||
* given data before the location specified by @a position.
|
||||
*
|
||||
* This operation is linear in the number of elements inserted and
|
||||
* does not invalidate iterators and references.
|
||||
*/
|
||||
iterator
|
||||
insert(const_iterator __position, size_type __n, const value_type& __x);
|
||||
#else
|
||||
/**
|
||||
* @brief Inserts a number of copies of given data into the %list.
|
||||
* @param __position An iterator into the %list.
|
||||
|
|
@ -1147,7 +1167,30 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
list __tmp(__n, __x, get_allocator());
|
||||
splice(__position, __tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Inserts a range into the %list.
|
||||
* @param __position A const_iterator into the %list.
|
||||
* @param __first An input iterator.
|
||||
* @param __last An input iterator.
|
||||
* @return An iterator pointing to the first element inserted
|
||||
* (or __position).
|
||||
*
|
||||
* This function will insert copies of the data in the range [@a
|
||||
* first,@a last) into the %list before the location specified by
|
||||
* @a position.
|
||||
*
|
||||
* This operation is linear in the number of elements inserted and
|
||||
* does not invalidate iterators and references.
|
||||
*/
|
||||
template<typename _InputIterator,
|
||||
typename = std::_RequireInputIter<_InputIterator>>
|
||||
iterator
|
||||
insert(const_iterator __position, _InputIterator __first,
|
||||
_InputIterator __last);
|
||||
#else
|
||||
/**
|
||||
* @brief Inserts a range into the %list.
|
||||
* @param __position An iterator into the %list.
|
||||
|
|
@ -1161,12 +1204,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* This operation is linear in the number of elements inserted and
|
||||
* does not invalidate iterators and references.
|
||||
*/
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _InputIterator,
|
||||
typename = std::_RequireInputIter<_InputIterator>>
|
||||
#else
|
||||
template<typename _InputIterator>
|
||||
#endif
|
||||
void
|
||||
insert(iterator __position, _InputIterator __first,
|
||||
_InputIterator __last)
|
||||
|
|
@ -1174,6 +1212,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
list __tmp(__first, __last, get_allocator());
|
||||
splice(__position, __tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Remove element at given position.
|
||||
|
|
@ -1275,7 +1314,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
*/
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x)
|
||||
splice(const_iterator __position, list&& __x)
|
||||
#else
|
||||
splice(iterator __position, list& __x)
|
||||
#endif
|
||||
|
|
@ -1284,16 +1323,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
{
|
||||
_M_check_equal_allocators(__x);
|
||||
|
||||
this->_M_transfer(__position, __x.begin(), __x.end());
|
||||
this->_M_transfer(__position._M_const_cast(),
|
||||
__x.begin(), __x.end());
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
void
|
||||
splice(iterator __position, list& __x)
|
||||
splice(const_iterator __position, list& __x)
|
||||
{ splice(__position, std::move(__x)); }
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Insert element from another %list.
|
||||
* @param __position Const_iterator referencing the element to
|
||||
* insert before.
|
||||
* @param __x Source list.
|
||||
* @param __i Const_iterator referencing the element to move.
|
||||
*
|
||||
* Removes the element in list @a __x referenced by @a __i and
|
||||
* inserts it into the current list before @a __position.
|
||||
*/
|
||||
void
|
||||
splice(const_iterator __position, list&& __x, const_iterator __i)
|
||||
#else
|
||||
/**
|
||||
* @brief Insert element from another %list.
|
||||
* @param __position Iterator referencing the element to insert before.
|
||||
|
|
@ -1304,13 +1358,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* inserts it into the current list before @a __position.
|
||||
*/
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x, iterator __i)
|
||||
#else
|
||||
splice(iterator __position, list& __x, iterator __i)
|
||||
#endif
|
||||
{
|
||||
iterator __j = __i;
|
||||
iterator __j = __i._M_const_cast();
|
||||
++__j;
|
||||
if (__position == __i || __position == __j)
|
||||
return;
|
||||
|
|
@ -1318,15 +1369,44 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
if (this != &__x)
|
||||
_M_check_equal_allocators(__x);
|
||||
|
||||
this->_M_transfer(__position, __i, __j);
|
||||
this->_M_transfer(__position._M_const_cast(),
|
||||
__i._M_const_cast(), __j);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Insert element from another %list.
|
||||
* @param __position Const_iterator referencing the element to
|
||||
* insert before.
|
||||
* @param __x Source list.
|
||||
* @param __i Const_iterator referencing the element to move.
|
||||
*
|
||||
* Removes the element in list @a __x referenced by @a __i and
|
||||
* inserts it into the current list before @a __position.
|
||||
*/
|
||||
void
|
||||
splice(iterator __position, list& __x, iterator __i)
|
||||
splice(const_iterator __position, list& __x, const_iterator __i)
|
||||
{ splice(__position, std::move(__x), __i); }
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Insert range from another %list.
|
||||
* @param __position Const_iterator referencing the element to
|
||||
* insert before.
|
||||
* @param __x Source list.
|
||||
* @param __first Const_iterator referencing the start of range in x.
|
||||
* @param __last Const_iterator referencing the end of range in x.
|
||||
*
|
||||
* Removes elements in the range [__first,__last) and inserts them
|
||||
* before @a __position in constant time.
|
||||
*
|
||||
* Undefined if @a __position is in [__first,__last).
|
||||
*/
|
||||
void
|
||||
splice(const_iterator __position, list&& __x, const_iterator __first,
|
||||
const_iterator __last)
|
||||
#else
|
||||
/**
|
||||
* @brief Insert range from another %list.
|
||||
* @param __position Iterator referencing the element to insert before.
|
||||
|
|
@ -1340,10 +1420,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* Undefined if @a __position is in [__first,__last).
|
||||
*/
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x, iterator __first,
|
||||
iterator __last)
|
||||
#else
|
||||
splice(iterator __position, list& __x, iterator __first,
|
||||
iterator __last)
|
||||
#endif
|
||||
|
|
@ -1353,13 +1429,29 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
if (this != &__x)
|
||||
_M_check_equal_allocators(__x);
|
||||
|
||||
this->_M_transfer(__position, __first, __last);
|
||||
this->_M_transfer(__position._M_const_cast(),
|
||||
__first._M_const_cast(),
|
||||
__last._M_const_cast());
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Insert range from another %list.
|
||||
* @param __position Const_iterator referencing the element to
|
||||
* insert before.
|
||||
* @param __x Source list.
|
||||
* @param __first Const_iterator referencing the start of range in x.
|
||||
* @param __last Const_iterator referencing the end of range in x.
|
||||
*
|
||||
* Removes elements in the range [__first,__last) and inserts them
|
||||
* before @a __position in constant time.
|
||||
*
|
||||
* Undefined if @a __position is in [__first,__last).
|
||||
*/
|
||||
void
|
||||
splice(iterator __position, list& __x, iterator __first, iterator __last)
|
||||
splice(const_iterator __position, list& __x, const_iterator __first,
|
||||
const_iterator __last)
|
||||
{ splice(__position, std::move(__x), __first, __last); }
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -403,28 +403,46 @@ namespace __debug
|
|||
insert(const_iterator __position, _Tp&& __x)
|
||||
{ return emplace(__position, std::move(__x)); }
|
||||
|
||||
void
|
||||
insert(iterator __p, initializer_list<value_type> __l)
|
||||
iterator
|
||||
insert(const_iterator __p, initializer_list<value_type> __l)
|
||||
{
|
||||
__glibcxx_check_insert(__p);
|
||||
_Base::insert(__p.base(), __l);
|
||||
return iterator(_Base::insert(__p.base(), __l), this);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
iterator
|
||||
insert(const_iterator __position, size_type __n, const _Tp& __x)
|
||||
{
|
||||
__glibcxx_check_insert(__position);
|
||||
return iterator(_Base::insert(__position.base(), __n, __x), this);
|
||||
}
|
||||
#else
|
||||
void
|
||||
insert(iterator __position, size_type __n, const _Tp& __x)
|
||||
{
|
||||
__glibcxx_check_insert(__position);
|
||||
_Base::insert(__position.base(), __n, __x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<class _InputIterator,
|
||||
typename = std::_RequireInputIter<_InputIterator>>
|
||||
iterator
|
||||
insert(const_iterator __position, _InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
__glibcxx_check_insert_range(__position, __first, __last);
|
||||
return iterator(_Base::insert(__position.base(),
|
||||
__gnu_debug::__base(__first),
|
||||
__gnu_debug::__base(__last)),
|
||||
this);
|
||||
}
|
||||
#else
|
||||
template<class _InputIterator>
|
||||
#endif
|
||||
void
|
||||
void
|
||||
insert(iterator __position, _InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
|
|
@ -432,6 +450,7 @@ namespace __debug
|
|||
_Base::insert(__position.base(), __gnu_debug::__base(__first),
|
||||
__gnu_debug::__base(__last));
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
_Base_iterator
|
||||
|
|
@ -496,7 +515,7 @@ namespace __debug
|
|||
// 23.2.2.4 list operations:
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x)
|
||||
splice(const_iterator __position, list&& __x)
|
||||
#else
|
||||
splice(iterator __position, list& __x)
|
||||
#endif
|
||||
|
|
@ -510,13 +529,13 @@ namespace __debug
|
|||
|
||||
#if __cplusplus >= 201103L
|
||||
void
|
||||
splice(iterator __position, list& __x)
|
||||
splice(const_iterator __position, list& __x)
|
||||
{ splice(__position, std::move(__x)); }
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x, iterator __i)
|
||||
splice(const_iterator __position, list&& __x, const_iterator __i)
|
||||
#else
|
||||
splice(iterator __position, list& __x, iterator __i)
|
||||
#endif
|
||||
|
|
@ -542,14 +561,14 @@ namespace __debug
|
|||
|
||||
#if __cplusplus >= 201103L
|
||||
void
|
||||
splice(iterator __position, list& __x, iterator __i)
|
||||
splice(const_iterator __position, list& __x, const_iterator __i)
|
||||
{ splice(__position, std::move(__x), __i); }
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x, iterator __first,
|
||||
iterator __last)
|
||||
splice(const_iterator __position, list&& __x, const_iterator __first,
|
||||
const_iterator __last)
|
||||
#else
|
||||
splice(iterator __position, list& __x, iterator __first,
|
||||
iterator __last)
|
||||
|
|
@ -565,14 +584,14 @@ namespace __debug
|
|||
// We used to perform the splice_alloc check: not anymore, redundant
|
||||
// after implementing the relevant bits of N1599.
|
||||
|
||||
for (_Base_iterator __tmp = __first.base();
|
||||
for (_Base_const_iterator __tmp = __first.base();
|
||||
__tmp != __last.base(); ++__tmp)
|
||||
{
|
||||
_GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
|
||||
_M_message(__gnu_debug::__msg_valid_range)
|
||||
._M_iterator(__first, "first")
|
||||
._M_iterator(__last, "last"));
|
||||
_GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position,
|
||||
_GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position.base(),
|
||||
_M_message(__gnu_debug::__msg_splice_overlap)
|
||||
._M_iterator(__tmp, "position")
|
||||
._M_iterator(__first, "first")
|
||||
|
|
@ -588,7 +607,8 @@ namespace __debug
|
|||
|
||||
#if __cplusplus >= 201103L
|
||||
void
|
||||
splice(iterator __position, list& __x, iterator __first, iterator __last)
|
||||
splice(const_iterator __position, list& __x,
|
||||
const_iterator __first, const_iterator __last)
|
||||
{ splice(__position, std::move(__x), __first, __last); }
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -916,6 +916,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
{ return this->assign(__l.begin(), __l.end()); }
|
||||
#endif // C++11
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Insert multiple characters.
|
||||
* @param __p Const_iterator referencing location in string to
|
||||
* insert at.
|
||||
* @param __n Number of characters to insert
|
||||
* @param __c The character to insert.
|
||||
* @return Iterator referencing the first inserted char.
|
||||
* @throw std::length_error If new length exceeds @c max_size().
|
||||
*
|
||||
* Inserts @a __n copies of character @a __c starting at the
|
||||
* position referenced by iterator @a __p. If adding
|
||||
* characters causes the length to exceed max_size(),
|
||||
* length_error is thrown. The value of the string doesn't
|
||||
* change if an error is thrown.
|
||||
*/
|
||||
iterator
|
||||
insert(const_iterator __p, size_type __n, _CharT __c)
|
||||
{
|
||||
_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
|
||||
const size_type __pos = __p - _M_ibegin();
|
||||
this->replace(__p, __p, __n, __c);
|
||||
return iterator(this->_M_data() + __pos);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* @brief Insert multiple characters.
|
||||
* @param __p Iterator referencing location in string to insert at.
|
||||
|
|
@ -932,7 +957,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
void
|
||||
insert(iterator __p, size_type __n, _CharT __c)
|
||||
{ this->replace(__p, __p, __n, __c); }
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Insert a range of characters.
|
||||
* @param __p Const_iterator referencing location in string to
|
||||
* insert at.
|
||||
* @param __beg Start of range.
|
||||
* @param __end End of range.
|
||||
* @return Iterator referencing the first inserted char.
|
||||
* @throw std::length_error If new length exceeds @c max_size().
|
||||
*
|
||||
* Inserts characters in range [beg,end). If adding characters
|
||||
* causes the length to exceed max_size(), length_error is
|
||||
* thrown. The value of the string doesn't change if an error
|
||||
* is thrown.
|
||||
*/
|
||||
template<class _InputIterator,
|
||||
typename = std::_RequireInputIter<_InputIterator>>
|
||||
iterator
|
||||
insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
|
||||
{
|
||||
_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
|
||||
const size_type __pos = __p - _M_ibegin();
|
||||
this->replace(__p, __p, __beg, __end);
|
||||
return iterator(this->_M_data() + __pos);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* @brief Insert a range of characters.
|
||||
* @param __p Iterator referencing location in string to insert at.
|
||||
|
|
@ -945,26 +997,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
* thrown. The value of the string doesn't change if an error
|
||||
* is thrown.
|
||||
*/
|
||||
#if __cplusplus >= 201103L
|
||||
template<class _InputIterator,
|
||||
typename = std::_RequireInputIter<_InputIterator>>
|
||||
#else
|
||||
template<class _InputIterator>
|
||||
#endif
|
||||
void
|
||||
insert(iterator __p, _InputIterator __beg, _InputIterator __end)
|
||||
{ this->replace(__p, __p, __beg, __end); }
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
/**
|
||||
* @brief Insert an initializer_list of characters.
|
||||
* @param __p Iterator referencing location in string to insert at.
|
||||
* @param __p Const_iterator referencing location in string to
|
||||
* insert at.
|
||||
* @param __l The initializer_list of characters to insert.
|
||||
* @return Iterator referencing the first inserted char.
|
||||
* @throw std::length_error If new length exceeds @c max_size().
|
||||
*/
|
||||
void
|
||||
insert(iterator __p, std::initializer_list<_CharT> __l)
|
||||
{ this->insert(__p, __l.begin(), __l.end()); }
|
||||
iterator
|
||||
insert(const_iterator __p, std::initializer_list<_CharT> __l)
|
||||
{ return this->insert(__p, __l.begin(), __l.end()); }
|
||||
#endif // C++11
|
||||
|
||||
/**
|
||||
|
|
@ -1421,7 +1471,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
template<class _InputIterator,
|
||||
typename = std::_RequireInputIter<_InputIterator>>
|
||||
__versa_string&
|
||||
replace(iterator __i1, iterator __i2,
|
||||
replace(const_iterator __i1, const_iterator __i2,
|
||||
_InputIterator __k1, _InputIterator __k2)
|
||||
{
|
||||
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
||||
|
|
@ -1447,7 +1497,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
// Specializations for the common case of pointer and iterator:
|
||||
// useful to avoid the overhead of temporary buffering in _M_replace.
|
||||
__versa_string&
|
||||
replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
|
||||
#if __cplusplus >= 201103L
|
||||
replace(const_iterator __i1, const_iterator __i2,
|
||||
_CharT* __k1, _CharT* __k2)
|
||||
#else
|
||||
replace(iterator __i1, iterator __i2,
|
||||
_CharT* __k1, _CharT* __k2)
|
||||
#endif
|
||||
{
|
||||
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
||||
&& __i2 <= _M_iend());
|
||||
|
|
@ -1457,8 +1513,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
}
|
||||
|
||||
__versa_string&
|
||||
#if __cplusplus >= 201103L
|
||||
replace(const_iterator __i1, const_iterator __i2,
|
||||
const _CharT* __k1, const _CharT* __k2)
|
||||
#else
|
||||
replace(iterator __i1, iterator __i2,
|
||||
const _CharT* __k1, const _CharT* __k2)
|
||||
#endif
|
||||
{
|
||||
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
||||
&& __i2 <= _M_iend());
|
||||
|
|
@ -1468,7 +1529,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
}
|
||||
|
||||
__versa_string&
|
||||
replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
|
||||
#if __cplusplus >= 201103L
|
||||
replace(const_iterator __i1, const_iterator __i2,
|
||||
iterator __k1, iterator __k2)
|
||||
#else
|
||||
replace(iterator __i1, iterator __i2,
|
||||
iterator __k1, iterator __k2)
|
||||
#endif
|
||||
{
|
||||
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
||||
&& __i2 <= _M_iend());
|
||||
|
|
@ -1478,8 +1545,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
}
|
||||
|
||||
__versa_string&
|
||||
#if __cplusplus >= 201103L
|
||||
replace(const_iterator __i1, const_iterator __i2,
|
||||
const_iterator __k1, const_iterator __k2)
|
||||
#else
|
||||
replace(iterator __i1, iterator __i2,
|
||||
const_iterator __k1, const_iterator __k2)
|
||||
#endif
|
||||
{
|
||||
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
|
||||
&& __i2 <= _M_iend());
|
||||
|
|
@ -1502,22 +1574,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
* of result exceeds max_size(), length_error is thrown. The
|
||||
* value of the string doesn't change if an error is thrown.
|
||||
*/
|
||||
__versa_string& replace(iterator __i1, iterator __i2,
|
||||
std::initializer_list<_CharT> __l)
|
||||
__versa_string&
|
||||
replace(const_iterator __i1, const_iterator __i2,
|
||||
std::initializer_list<_CharT> __l)
|
||||
{ return this->replace(__i1, __i2, __l.begin(), __l.end()); }
|
||||
#endif // C++11
|
||||
|
||||
private:
|
||||
template<class _Integer>
|
||||
__versa_string&
|
||||
_M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
|
||||
_Integer __val, std::__true_type)
|
||||
_M_replace_dispatch(const_iterator __i1, const_iterator __i2,
|
||||
_Integer __n, _Integer __val, std::__true_type)
|
||||
{ return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
|
||||
|
||||
template<class _InputIterator>
|
||||
__versa_string&
|
||||
_M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
|
||||
_InputIterator __k2, std::__false_type);
|
||||
_M_replace_dispatch(const_iterator __i1, const_iterator __i2,
|
||||
_InputIterator __k1, _InputIterator __k2,
|
||||
std::__false_type);
|
||||
|
||||
__versa_string&
|
||||
_M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
|
||||
|
|
|
|||
|
|
@ -81,8 +81,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
template<typename _InputIterator>
|
||||
__versa_string<_CharT, _Traits, _Alloc, _Base>&
|
||||
__versa_string<_CharT, _Traits, _Alloc, _Base>::
|
||||
_M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
|
||||
_InputIterator __k2, std::__false_type)
|
||||
_M_replace_dispatch(const_iterator __i1, const_iterator __i2,
|
||||
_InputIterator __k1, _InputIterator __k2,
|
||||
std::__false_type)
|
||||
{
|
||||
const __versa_string __s(__k1, __k2);
|
||||
const size_type __n1 = __i2 - __i1;
|
||||
|
|
|
|||
|
|
@ -363,27 +363,43 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
|||
this);
|
||||
}
|
||||
|
||||
void
|
||||
insert(iterator __position, initializer_list<value_type> __l)
|
||||
iterator
|
||||
insert(const_iterator __position, initializer_list<value_type> __l)
|
||||
{
|
||||
_M_profile_insert(this, __position, size());
|
||||
_Base::insert(__position.base(), __l);
|
||||
return iterator(_Base::insert(__position.base(), __l), this);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
iterator
|
||||
insert(const_iterator __position, size_type __n, const _Tp& __x)
|
||||
{
|
||||
_M_profile_insert(this, __position, size());
|
||||
return iterator(_Base::insert(__position.base(), __n, __x), this);
|
||||
}
|
||||
#else
|
||||
void
|
||||
insert(iterator __position, size_type __n, const _Tp& __x)
|
||||
{
|
||||
_M_profile_insert(this, __position, size());
|
||||
_Base::insert(__position.base(), __n, __x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _InputIterator,
|
||||
typename = std::_RequireInputIter<_InputIterator>>
|
||||
iterator
|
||||
insert(const_iterator __position, _InputIterator __first,
|
||||
_InputIterator __last)
|
||||
{
|
||||
_M_profile_insert(this, __position, size());
|
||||
return iterator(_Base::insert(__position.base(), __first, __last),
|
||||
this);
|
||||
}
|
||||
#else
|
||||
template<class _InputIterator>
|
||||
#endif
|
||||
void
|
||||
insert(iterator __position, _InputIterator __first,
|
||||
_InputIterator __last)
|
||||
|
|
@ -391,6 +407,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
|||
_M_profile_insert(this, __position, size());
|
||||
_Base::insert(__position.base(), __first, __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
iterator
|
||||
#if __cplusplus >= 201103L
|
||||
|
|
@ -423,7 +440,7 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
|||
// 23.2.2.4 list operations:
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x)
|
||||
splice(const_iterator __position, list&& __x)
|
||||
#else
|
||||
splice(iterator __position, list& __x)
|
||||
#endif
|
||||
|
|
@ -431,19 +448,17 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
|||
|
||||
#if __cplusplus >= 201103L
|
||||
void
|
||||
splice(iterator __position, list& __x)
|
||||
splice(const_iterator __position, list& __x)
|
||||
{ this->splice(__position, std::move(__x)); }
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
void
|
||||
splice(iterator __position, list& __x, iterator __i)
|
||||
splice(const_iterator __position, list& __x, const_iterator __i)
|
||||
{ this->splice(__position, std::move(__x), __i); }
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x, iterator __i)
|
||||
splice(const_iterator __position, list&& __x, const_iterator __i)
|
||||
#else
|
||||
splice(iterator __position, list& __x, iterator __i)
|
||||
#endif
|
||||
|
|
@ -458,8 +473,8 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
|||
|
||||
void
|
||||
#if __cplusplus >= 201103L
|
||||
splice(iterator __position, list&& __x, iterator __first,
|
||||
iterator __last)
|
||||
splice(const_iterator __position, list&& __x, const_iterator __first,
|
||||
const_iterator __last)
|
||||
#else
|
||||
splice(iterator __position, list& __x, iterator __first,
|
||||
iterator __last)
|
||||
|
|
@ -474,7 +489,8 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
|||
|
||||
#if __cplusplus >= 201103L
|
||||
void
|
||||
splice(iterator __position, list& __x, iterator __first, iterator __last)
|
||||
splice(const_iterator __position, list& __x,
|
||||
const_iterator __first, const_iterator __last)
|
||||
{ this->splice(__position, std::move(__x), __first, __last); }
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ void test01()
|
|||
{
|
||||
std::list<int> l1;
|
||||
int n = 0;
|
||||
l1.insert(l1.cbegin(), n);
|
||||
l1.insert(l1.cbegin(), 1);
|
||||
std::list<int>::iterator it = l1.insert(l1.cbegin(), n);
|
||||
it = l1.insert(l1.cbegin(), 1);
|
||||
it = l1.insert(l1.cbegin(), {2, 3});
|
||||
it = l1.insert(l1.cbegin(), 1, 4);
|
||||
it = l1.insert(l1.cbegin(), l1.begin(), l1.end());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
// { dg-options "-std=gnu++11" }
|
||||
// { dg-do compile }
|
||||
|
||||
// Copyright (C) 2013 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <list>
|
||||
|
||||
void test01()
|
||||
{
|
||||
std::list<int> l1{0, 1}, l2{2, 3};
|
||||
l1.splice(l1.cbegin(), l2);
|
||||
l2.splice(l2.cbegin(), std::move(l1));
|
||||
l1.splice(l1.cbegin(), l2, l2.cbegin());
|
||||
l2.splice(l2.cbegin(), std::move(l1), l1.cbegin());
|
||||
l1.splice(l1.cbegin(), l2, l2.cbegin(), l2.cend());
|
||||
l2.splice(l2.cbegin(), std::move(l1), l1.cbegin(), l1.cend());
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1559 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1651 }
|
||||
|
||||
#include <list>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1511 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1603 }
|
||||
|
||||
#include <list>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1511 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1603 }
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1511 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1603 }
|
||||
|
||||
#include <list>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,5 +23,8 @@
|
|||
void test01()
|
||||
{
|
||||
__gnu_cxx::__vstring vs1;
|
||||
vs1.insert(vs1.cbegin(), '1');
|
||||
__gnu_cxx::__vstring::iterator it = vs1.insert(vs1.cbegin(), '1');
|
||||
it = vs1.insert(vs1.cbegin(), 1, '2');
|
||||
it = vs1.insert(vs1.cbegin(), {'3', '4'});
|
||||
it = vs1.insert(vs1.cbegin(), vs1.begin(), vs1.end());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,8 @@
|
|||
void test01()
|
||||
{
|
||||
__gnu_cxx::__wvstring wvs1;
|
||||
wvs1.insert(wvs1.cbegin(), L'1');
|
||||
__gnu_cxx::__wvstring::iterator it = wvs1.insert(wvs1.cbegin(), L'1');
|
||||
it = wvs1.insert(wvs1.cbegin(), 1, L'2');
|
||||
it = wvs1.insert(wvs1.cbegin(), {L'3', L'4'});
|
||||
it = wvs1.insert(wvs1.cbegin(), wvs1.begin(), wvs1.end());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,6 @@ void test01()
|
|||
vs1.replace(vs1.cbegin(), vs1.cend(), "1", 1);
|
||||
vs1.replace(vs1.cbegin(), vs1.cend(), "2");
|
||||
vs1.replace(vs1.cbegin(), vs1.cend(), 1, '3');
|
||||
vs1.replace(vs1.cbegin(), vs1.cend(), vs1.begin(), vs1.end());
|
||||
vs1.replace(vs1.cbegin(), vs1.cend(), {'4', '5'});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,6 @@ void test01()
|
|||
wvs1.replace(wvs1.cbegin(), wvs1.cend(), L"1", 1);
|
||||
wvs1.replace(wvs1.cbegin(), wvs1.cend(), L"2");
|
||||
wvs1.replace(wvs1.cbegin(), wvs1.cend(), 1, L'3');
|
||||
wvs1.replace(wvs1.cbegin(), wvs1.cend(), wvs1.begin(), wvs1.end());
|
||||
wvs1.replace(wvs1.cbegin(), wvs1.cend(), {'4', '5'});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue