summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-07-03 11:40:08 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-07-03 11:40:08 +0000
commit6983fe1e36db7532af100486b526f4131926025b (patch)
tree92a4c336516c44b56768d1319d2fe84c13b85e98 /libstdc++-v3/include
parentf33a0367d52b7cd93be9089eee3ccebb8b9e687d (diff)
downloadgcc-6983fe1e36db7532af100486b526f4131926025b.tar.gz
2013-07-03 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 200637 using svnmerge.py git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@200641 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/hashtable.h68
-rw-r--r--libstdc++-v3/include/bits/hashtable_policy.h37
-rw-r--r--libstdc++-v3/include/bits/list.tcc34
-rw-r--r--libstdc++-v3/include/bits/stl_bvector.h26
-rw-r--r--libstdc++-v3/include/bits/stl_deque.h52
-rw-r--r--libstdc++-v3/include/bits/stl_list.h138
-rw-r--r--libstdc++-v3/include/bits/stl_vector.h60
-rw-r--r--libstdc++-v3/include/debug/deque32
-rw-r--r--libstdc++-v3/include/debug/list48
-rw-r--r--libstdc++-v3/include/debug/vector47
-rw-r--r--libstdc++-v3/include/ext/vstring.h106
-rw-r--r--libstdc++-v3/include/ext/vstring.tcc5
-rw-r--r--libstdc++-v3/include/profile/deque28
-rw-r--r--libstdc++-v3/include/profile/list42
-rw-r--r--libstdc++-v3/include/profile/vector75
15 files changed, 636 insertions, 162 deletions
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index 8ce264ed72e..9b586b01e24 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -225,7 +225,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using __node_base = typename __hashtable_base::__node_base;
using __bucket_type = typename __hashtable_base::__bucket_type;
using __ireturn_type = typename __hashtable_base::__ireturn_type;
- using __iconv_type = typename __hashtable_base::__iconv_type;
using __map_base = __detail::_Map_base<_Key, _Value, _Alloc, _ExtractKey,
_Equal, _H1, _H2, _Hash,
@@ -680,7 +679,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Insert node with hash code __code. Take ownership of the node,
// deallocate it on exception.
iterator
- _M_insert_multi_node(__hash_code __code, __node_type* __n);
+ _M_insert_multi_node(__node_type* __hint,
+ __hash_code __code, __node_type* __n);
template<typename... _Args>
std::pair<iterator, bool>
@@ -688,7 +688,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename... _Args>
iterator
- _M_emplace(std::false_type, _Args&&... __args);
+ _M_emplace(std::false_type __uk, _Args&&... __args)
+ { return _M_emplace(cend(), __uk, std::forward<_Args>(__args)...); }
+
+ // Emplace with hint, useless when keys are unique.
+ template<typename... _Args>
+ iterator
+ _M_emplace(const_iterator, std::true_type __uk, _Args&&... __args)
+ { return _M_emplace(__uk, std::forward<_Args>(__args)...).first; }
+
+ template<typename... _Args>
+ iterator
+ _M_emplace(const_iterator, std::false_type, _Args&&... __args);
template<typename _Arg>
std::pair<iterator, bool>
@@ -696,7 +707,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Arg>
iterator
- _M_insert(_Arg&&, std::false_type);
+ _M_insert(_Arg&& __arg, std::false_type __uk)
+ { return _M_insert(cend(), std::forward<_Arg>(__arg), __uk); }
+
+ // Insert with hint, not used when keys are unique.
+ template<typename _Arg>
+ iterator
+ _M_insert(const_iterator, _Arg&& __arg, std::true_type __uk)
+ { return _M_insert(std::forward<_Arg>(__arg), __uk).first; }
+
+ // Insert with hint when keys are not unique.
+ template<typename _Arg>
+ iterator
+ _M_insert(const_iterator, _Arg&&, std::false_type);
size_type
_M_erase(std::true_type, const key_type&);
@@ -716,8 +739,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename... _Args>
iterator
- emplace_hint(const_iterator, _Args&&... __args)
- { return __iconv_type()(emplace(std::forward<_Args>(__args)...)); }
+ emplace_hint(const_iterator __hint, _Args&&... __args)
+ {
+ return _M_emplace(__hint, __unique_keys(),
+ std::forward<_Args>(__args)...);
+ }
// Insert member functions via inheritance.
@@ -1642,7 +1668,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Traits>::iterator
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
- _M_emplace(std::false_type, _Args&&... __args)
+ _M_emplace(const_iterator __hint, std::false_type, _Args&&... __args)
{
// First build the node to get its hash code.
__node_type* __node = _M_allocate_node(std::forward<_Args>(__args)...);
@@ -1658,7 +1684,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__throw_exception_again;
}
- return _M_insert_multi_node(__code, __node);
+ return _M_insert_multi_node(__hint._M_cur, __code, __node);
}
template<typename _Key, typename _Value,
@@ -1710,7 +1736,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Traits>::iterator
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
- _M_insert_multi_node(__hash_code __code, __node_type* __node)
+ _M_insert_multi_node(__node_type* __hint, __hash_code __code,
+ __node_type* __node)
{
const __rehash_state& __saved_state = _M_rehash_policy._M_state();
std::pair<bool, std::size_t> __do_rehash
@@ -1725,13 +1752,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const key_type& __k = this->_M_extract()(__node->_M_v());
size_type __bkt = _M_bucket_index(__k, __code);
- // Find the node before an equivalent one.
- __node_base* __prev = _M_find_before_node(__bkt, __k, __code);
+ // Find the node before an equivalent one or use hint if it exists and
+ // if it is equivalent.
+ __node_base* __prev
+ = __builtin_expect(__hint != nullptr, false)
+ && this->_M_equals(__k, __code, __hint)
+ ? __hint
+ : _M_find_before_node(__bkt, __k, __code);
if (__prev)
{
// Insert after the node before the equivalent one.
__node->_M_nxt = __prev->_M_nxt;
__prev->_M_nxt = __node;
+ if (__builtin_expect(__prev == __hint, false))
+ // hint might be the last bucket node, in this case we need to
+ // update next bucket.
+ if (__node->_M_nxt
+ && !this->_M_equals(__k, __code, __node->_M_next()))
+ {
+ size_type __next_bkt = _M_bucket_index(__node->_M_next());
+ if (__next_bkt != __bkt)
+ _M_buckets[__next_bkt] = __node;
+ }
}
else
// The inserted node has no equivalent in the
@@ -1786,7 +1828,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Traits>::iterator
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
_H1, _H2, _Hash, _RehashPolicy, _Traits>::
- _M_insert(_Arg&& __v, std::false_type)
+ _M_insert(const_iterator __hint, _Arg&& __v, std::false_type)
{
// First compute the hash code so that we don't do anything if it
// throws.
@@ -1795,7 +1837,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Second allocate new node so that we don't rehash if it throws.
__node_type* __node = _M_allocate_node(std::forward<_Arg>(__v));
- return _M_insert_multi_node(__code, __node);
+ return _M_insert_multi_node(__hint._M_cur, __code, __node);
}
template<typename _Key, typename _Value,
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index 1c76af0ac66..2ae0efa08b5 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -612,7 +612,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using __unique_keys = typename __hashtable_base::__unique_keys;
using __ireturn_type = typename __hashtable_base::__ireturn_type;
- using __iconv_type = typename __hashtable_base::__iconv_type;
__hashtable&
_M_conjure_hashtable()
@@ -626,8 +625,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
iterator
- insert(const_iterator, const value_type& __v)
- { return __iconv_type()(insert(__v)); }
+ insert(const_iterator __hint, const value_type& __v)
+ {
+ __hashtable& __h = _M_conjure_hashtable();
+ return __h._M_insert(__hint, __v, __unique_keys());
+ }
void
insert(initializer_list<value_type> __l)
@@ -711,8 +713,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
iterator
- insert(const_iterator, value_type&& __v)
- { return insert(std::move(__v)).first; }
+ insert(const_iterator __hint, value_type&& __v)
+ {
+ __hashtable& __h = this->_M_conjure_hashtable();
+ return __h._M_insert(__hint, std::move(__v), __unique_keys());
+ }
};
/// Specialization.
@@ -745,9 +750,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
iterator
- insert(const_iterator, value_type&& __v)
- { return insert(std::move(__v)); }
- };
+ insert(const_iterator __hint, value_type&& __v)
+ {
+ __hashtable& __h = this->_M_conjure_hashtable();
+ return __h._M_insert(__hint, std::move(__v), __unique_keys());
+ }
+ };
/// Specialization.
template<typename _Key, typename _Value, typename _Alloc,
@@ -769,7 +777,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using __unique_keys = typename __base_type::__unique_keys;
using __hashtable = typename __base_type::__hashtable;
using __ireturn_type = typename __base_type::__ireturn_type;
- using __iconv_type = typename __base_type::__iconv_type;
using __base_type::insert;
@@ -792,8 +799,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Pair, typename = _IFconsp<_Pair>>
iterator
- insert(const_iterator, _Pair&& __v)
- { return __iconv_type()(insert(std::forward<_Pair>(__v))); }
+ insert(const_iterator __hint, _Pair&& __v)
+ {
+ __hashtable& __h = this->_M_conjure_hashtable();
+ return __h._M_emplace(__hint, __unique_keys(),
+ std::forward<_Pair>(__v));
+ }
};
/**
@@ -1470,10 +1481,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using __ireturn_type = typename std::conditional<__unique_keys::value,
std::pair<iterator, bool>,
iterator>::type;
-
- using __iconv_type = typename std::conditional<__unique_keys::value,
- _Select1st, _Identity
- >::type;
private:
using _EqualEBO = _Hashtable_ebo_helper<0, _Equal>;
using _EqualHelper = _Equal_helper<_Key, _Value, _ExtractKey, _Equal,
diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc
index 4f82e35c921..4d8ce2351e8 100644
--- a/libstdc++-v3/include/bits/list.tcc
+++ b/libstdc++-v3/include/bits/list.tcc
@@ -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>::
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 489d819f06f..887ea16ae55 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -881,10 +881,15 @@ template<typename _Alloc>
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
- void
- insert(iterator __position,
+ iterator
+ insert(const_iterator __position,
_InputIterator __first, _InputIterator __last)
- { _M_insert_dispatch(__position, __first, __last, __false_type()); }
+ {
+ difference_type __offset = __position - cbegin();
+ _M_insert_dispatch(__position._M_const_cast(),
+ __first, __last, __false_type());
+ return begin() + __offset;
+ }
#else
template<typename _InputIterator>
void
@@ -896,13 +901,24 @@ template<typename _Alloc>
}
#endif
+#if __cplusplus >= 201103L
+ iterator
+ insert(const_iterator __position, size_type __n, const bool& __x)
+ {
+ difference_type __offset = __position - cbegin();
+ _M_fill_insert(__position._M_const_cast(), __n, __x);
+ return begin() + __offset;
+ }
+#else
void
insert(iterator __position, size_type __n, const bool& __x)
{ _M_fill_insert(__position, __n, __x); }
+#endif
#if __cplusplus >= 201103L
- void insert(iterator __p, initializer_list<bool> __l)
- { this->insert(__p, __l.begin(), __l.end()); }
+ iterator
+ insert(const_iterator __p, initializer_list<bool> __l)
+ { return this->insert(__p, __l.begin(), __l.end()); }
#endif
void
diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h
index a03ba256b53..a4656734469 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -1517,11 +1517,30 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* initializer_list @a __l into the %deque before the location
* specified by @a __p. This is known as <em>list insert</em>.
*/
- 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 %deque.
+ * @param __position A const_iterator into the %deque.
+ * @param __n Number of elements to be inserted.
+ * @param __x Data to be inserted.
+ * @return An iterator that points to the inserted data.
+ *
+ * This function will insert a specified number of copies of the given
+ * data before the location specified by @a __position.
+ */
+ iterator
+ insert(const_iterator __position, size_type __n, const value_type& __x)
+ {
+ difference_type __offset = __position - cbegin();
+ _M_fill_insert(__position._M_const_cast(), __n, __x);
+ return begin() + __offset;
+ }
+#else
/**
* @brief Inserts a number of copies of given data into the %deque.
* @param __position An iterator into the %deque.
@@ -1534,25 +1553,42 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void
insert(iterator __position, size_type __n, const value_type& __x)
{ _M_fill_insert(__position, __n, __x); }
+#endif
+#if __cplusplus >= 201103L
/**
* @brief Inserts a range into the %deque.
- * @param __position An iterator into the %deque.
+ * @param __position A const_iterator into the %deque.
* @param __first An input iterator.
* @param __last An input iterator.
+ * @return An iterator that points to the inserted data.
*
* This function will insert copies of the data in the range
* [__first,__last) into the %deque before the location specified
* by @a __position. This is known as <em>range insert</em>.
*/
-#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
- void
- insert(iterator __position, _InputIterator __first,
+ iterator
+ insert(const_iterator __position, _InputIterator __first,
_InputIterator __last)
- { _M_insert_dispatch(__position, __first, __last, __false_type()); }
+ {
+ difference_type __offset = __position - cbegin();
+ _M_insert_dispatch(__position._M_const_cast(),
+ __first, __last, __false_type());
+ return begin() + __offset;
+ }
#else
+ /**
+ * @brief Inserts a range into the %deque.
+ * @param __position An iterator into the %deque.
+ * @param __first An input iterator.
+ * @param __last An input iterator.
+ *
+ * This function will insert copies of the data in the range
+ * [__first,__last) into the %deque before the location specified
+ * by @a __position. This is known as <em>range insert</em>.
+ */
template<typename _InputIterator>
void
insert(iterator __position, _InputIterator __first,
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index 7c3eb159aba..5e8312dc6ff 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -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,12 +1167,16 @@ _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 An iterator 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
@@ -1161,12 +1185,26 @@ _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>>
+ iterator
+ insert(const_iterator __position, _InputIterator __first,
+ _InputIterator __last);
#else
+ /**
+ * @brief Inserts a range into the %list.
+ * @param __position An iterator into the %list.
+ * @param __first An input iterator.
+ * @param __last An input iterator.
+ *
+ * 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>
-#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
diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h
index a403b4f83bb..726693918a3 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -1015,11 +1015,34 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %vector and if it is frequently used the user should
* consider using std::list.
*/
- void
- insert(iterator __position, initializer_list<value_type> __l)
- { this->insert(__position, __l.begin(), __l.end()); }
+ iterator
+ insert(const_iterator __position, initializer_list<value_type> __l)
+ { return this->insert(__position, __l.begin(), __l.end()); }
#endif
+#if __cplusplus >= 201103L
+ /**
+ * @brief Inserts a number of copies of given data into the %vector.
+ * @param __position A const_iterator into the %vector.
+ * @param __n Number of elements to be inserted.
+ * @param __x Data to be inserted.
+ * @return An iterator that points to the inserted data.
+ *
+ * This function will insert a specified number of copies of
+ * the given data before the location specified by @a position.
+ *
+ * Note that this kind of operation could be expensive for a
+ * %vector and if it is frequently used the user should
+ * consider using std::list.
+ */
+ iterator
+ insert(const_iterator __position, size_type __n, const value_type& __x)
+ {
+ difference_type __offset = __position - cbegin();
+ _M_fill_insert(__position._M_const_cast(), __n, __x);
+ return begin() + __offset;
+ }
+#else
/**
* @brief Inserts a number of copies of given data into the %vector.
* @param __position An iterator into the %vector.
@@ -1036,12 +1059,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void
insert(iterator __position, size_type __n, const value_type& __x)
{ _M_fill_insert(__position, __n, __x); }
+#endif
+#if __cplusplus >= 201103L
/**
* @brief Inserts a range into the %vector.
- * @param __position An iterator into the %vector.
+ * @param __position A const_iterator into the %vector.
* @param __first An input iterator.
* @param __last An input iterator.
+ * @return An iterator that points to the inserted data.
*
* This function will insert copies of the data in the range
* [__first,__last) into the %vector before the location specified
@@ -1051,14 +1077,32 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %vector and if it is frequently used the user should
* consider using std::list.
*/
-#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
- void
- insert(iterator __position, _InputIterator __first,
+ iterator
+ insert(const_iterator __position, _InputIterator __first,
_InputIterator __last)
- { _M_insert_dispatch(__position, __first, __last, __false_type()); }
+ {
+ difference_type __offset = __position - cbegin();
+ _M_insert_dispatch(__position._M_const_cast(),
+ __first, __last, __false_type());
+ return begin() + __offset;
+ }
#else
+ /**
+ * @brief Inserts a range into the %vector.
+ * @param __position An iterator into the %vector.
+ * @param __first An input iterator.
+ * @param __last An input iterator.
+ *
+ * This function will insert copies of the data in the range
+ * [__first,__last) into the %vector before the location specified
+ * by @a pos.
+ *
+ * Note that this kind of operation could be expensive for a
+ * %vector and if it is frequently used the user should
+ * consider using std::list.
+ */
template<typename _InputIterator>
void
insert(iterator __position, _InputIterator __first,
diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque
index 638bf1cd3ca..e5e902dfc7b 100644
--- a/libstdc++-v3/include/debug/deque
+++ b/libstdc++-v3/include/debug/deque
@@ -411,14 +411,26 @@ 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 __position, initializer_list<value_type> __l)
{
- _Base::insert(__p, __l);
+ __glibcxx_check_insert(__position);
+ _Base_iterator __res = _Base::insert(__position.base(), __l);
this->_M_invalidate_all();
+ return iterator(__res, this);
}
#endif
+#if __cplusplus >= 201103L
+ iterator
+ insert(const_iterator __position, size_type __n, const _Tp& __x)
+ {
+ __glibcxx_check_insert(__position);
+ _Base_iterator __res = _Base::insert(__position.base(), __n, __x);
+ this->_M_invalidate_all();
+ return iterator(__res, this);
+ }
+#else
void
insert(iterator __position, size_type __n, const _Tp& __x)
{
@@ -426,13 +438,24 @@ namespace __debug
_Base::insert(__position.base(), __n, __x);
this->_M_invalidate_all();
}
+#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);
+ _Base_iterator __res = _Base::insert(__position.base(),
+ __gnu_debug::__base(__first),
+ __gnu_debug::__base(__last));
+ this->_M_invalidate_all();
+ return iterator(__res, this);
+ }
#else
template<class _InputIterator>
-#endif
void
insert(iterator __position,
_InputIterator __first, _InputIterator __last)
@@ -442,6 +465,7 @@ namespace __debug
__gnu_debug::__base(__last));
this->_M_invalidate_all();
}
+#endif
void
pop_front()
diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list
index c175de01f23..1ae8507ca86 100644
--- a/libstdc++-v3/include/debug/list
+++ b/libstdc++-v3/include/debug/list
@@ -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
diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector
index f55dc67ede0..7b28177c2a0 100644
--- a/libstdc++-v3/include/debug/vector
+++ b/libstdc++-v3/include/debug/vector
@@ -471,11 +471,27 @@ namespace __debug
insert(const_iterator __position, _Tp&& __x)
{ return emplace(__position, std::move(__x)); }
- void
- insert(iterator __position, initializer_list<value_type> __l)
- { this->insert(__position, __l.begin(), __l.end()); }
+ iterator
+ insert(const_iterator __position, initializer_list<value_type> __l)
+ { return this->insert(__position, __l.begin(), __l.end()); }
#endif
+#if __cplusplus >= 201103L
+ iterator
+ insert(const_iterator __position, size_type __n, const _Tp& __x)
+ {
+ __glibcxx_check_insert(__position);
+ bool __realloc = _M_requires_reallocation(this->size() + __n);
+ difference_type __offset = __position.base() - _Base::cbegin();
+ _Base_iterator __res = _Base::insert(__position.base(), __n, __x);
+ if (__realloc)
+ this->_M_invalidate_all();
+ else
+ this->_M_invalidate_after_nth(__offset);
+ _M_update_guaranteed_capacity();
+ return iterator(__res, this);
+ }
+#else
void
insert(iterator __position, size_type __n, const _Tp& __x)
{
@@ -489,13 +505,35 @@ namespace __debug
this->_M_invalidate_after_nth(__offset);
_M_update_guaranteed_capacity();
}
+#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);
+
+ /* Hard to guess if invalidation will occur, because __last
+ - __first can't be calculated in all cases, so we just
+ punt here by checking if it did occur. */
+ _Base_iterator __old_begin = _M_base().begin();
+ difference_type __offset = __position.base() - _Base::cbegin();
+ _Base_iterator __res = _Base::insert(__position.base(),
+ __gnu_debug::__base(__first),
+ __gnu_debug::__base(__last));
+
+ if (_M_base().begin() != __old_begin)
+ this->_M_invalidate_all();
+ else
+ this->_M_invalidate_after_nth(__offset);
+ _M_update_guaranteed_capacity();
+ return iterator(__res, this);
+ }
#else
template<class _InputIterator>
-#endif
void
insert(iterator __position,
_InputIterator __first, _InputIterator __last)
@@ -516,6 +554,7 @@ namespace __debug
this->_M_invalidate_after_nth(__offset);
_M_update_guaranteed_capacity();
}
+#endif
iterator
#if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index c78f2146a13..43edb53b41c 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -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,12 +957,16 @@ _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 Iterator referencing location in string to insert at.
+ * @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
@@ -945,26 +974,47 @@ _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>>
+ 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.
+ * @param __beg Start of range.
+ * @param __end End of range.
+ * @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>
-#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,
diff --git a/libstdc++-v3/include/ext/vstring.tcc b/libstdc++-v3/include/ext/vstring.tcc
index 2dcd295cfb8..0a80c26fd89 100644
--- a/libstdc++-v3/include/ext/vstring.tcc
+++ b/libstdc++-v3/include/ext/vstring.tcc
@@ -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;
diff --git a/libstdc++-v3/include/profile/deque b/libstdc++-v3/include/profile/deque
index 0ec98386bae..c46618e27e4 100644
--- a/libstdc++-v3/include/profile/deque
+++ b/libstdc++-v3/include/profile/deque
@@ -344,31 +344,35 @@ namespace __profile
insert(const_iterator __position, _Tp&& __x)
{ return emplace(__position, std::move(__x)); }
- void
- insert(iterator __p, initializer_list<value_type> __l)
- {
- _Base::insert(__p, __l);
- }
+ iterator
+ insert(const_iterator __p, initializer_list<value_type> __l)
+ { return _Base::insert(__p, __l); }
#endif
+#if __cplusplus >= 201103L
+ iterator
+ insert(const_iterator __position, size_type __n, const _Tp& __x)
+ { return _Base::insert(__position, __n, __x); }
+#else
void
insert(iterator __position, size_type __n, const _Tp& __x)
- {
- _Base::insert(__position, __n, __x);
- }
+ { _Base::insert(__position, __n, __x); }
+#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ iterator
+ insert(const_iterator __position,
+ _InputIterator __first, _InputIterator __last)
+ { return _Base::insert(__position, __first, __last); }
#else
template<typename _InputIterator>
-#endif
void
insert(iterator __position,
_InputIterator __first, _InputIterator __last)
- {
- _Base::insert(__position, __first, __last);
- }
+ { _Base::insert(__position, __first, __last); }
+#endif
void
pop_front()
diff --git a/libstdc++-v3/include/profile/list b/libstdc++-v3/include/profile/list
index 3a68bf7493a..ac09aa3db26 100644
--- a/libstdc++-v3/include/profile/list
+++ b/libstdc++-v3/include/profile/list
@@ -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
diff --git a/libstdc++-v3/include/profile/vector b/libstdc++-v3/include/profile/vector
index de058d0d814..3ef04ff0a7c 100644
--- a/libstdc++-v3/include/profile/vector
+++ b/libstdc++-v3/include/profile/vector
@@ -44,6 +44,9 @@ namespace __profile
{
typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base;
+ typedef typename _Base::iterator _Base_iterator;
+ typedef typename _Base::const_iterator _Base_const_iterator;
+
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
#endif
@@ -52,9 +55,9 @@ namespace __profile
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
- typedef __iterator_tracker<typename _Base::iterator, vector>
+ typedef __iterator_tracker<_Base_iterator, vector>
iterator;
- typedef __iterator_tracker<typename _Base::const_iterator, vector>
+ typedef __iterator_tracker<_Base_const_iterator, vector>
const_iterator;
typedef typename _Base::size_type size_type;
@@ -361,7 +364,7 @@ namespace __profile
__profcxx_vector_insert(this, __position.base() - _Base::begin(),
this->size());
size_type __old_size = this->capacity();
- typename _Base::iterator __res = _Base::insert(__position.base(), __x);
+ _Base_iterator __res = _Base::insert(__position.base(), __x);
_M_profile_resize(this, __old_size, this->capacity());
return iterator(__res, this);
}
@@ -370,10 +373,10 @@ namespace __profile
iterator
insert(const_iterator __position, _Tp&& __x)
{
- __profcxx_vector_insert(this, __position.base() - _Base::begin(),
+ __profcxx_vector_insert(this, __position.base() - _Base::cbegin(),
this->size());
size_type __old_size = this->capacity();
- typename _Base::iterator __res = _Base::insert(__position.base(), __x);
+ _Base_iterator __res = _Base::insert(__position.base(), __x);
_M_profile_resize(this, __old_size, this->capacity());
return iterator(__res, this);
}
@@ -382,15 +385,14 @@ namespace __profile
iterator
emplace(const_iterator __position, _Args&&... __args)
{
- typename _Base::iterator __res
- = _Base::emplace(__position.base(),
- std::forward<_Args>(__args)...);
+ _Base_iterator __res = _Base::emplace(__position.base(),
+ std::forward<_Args>(__args)...);
return iterator(__res, this);
}
- void
- insert(iterator __position, initializer_list<value_type> __l)
- { this->insert(__position, __l.begin(), __l.end()); }
+ iterator
+ insert(const_iterator __position, initializer_list<value_type> __l)
+ { return this->insert(__position, __l.begin(), __l.end()); }
#endif
#if __cplusplus >= 201103L
@@ -404,12 +406,24 @@ namespace __profile
void
swap(vector& __x)
#if __cplusplus >= 201103L
- noexcept(_Alloc_traits::_S_nothrow_swap())
+ noexcept(_Alloc_traits::_S_nothrow_swap())
#endif
{
_Base::swap(__x);
}
+#if __cplusplus >= 201103L
+ iterator
+ insert(const_iterator __position, size_type __n, const _Tp& __x)
+ {
+ __profcxx_vector_insert(this, __position.base() - _Base::cbegin(),
+ this->size());
+ size_type __old_size = this->capacity();
+ _Base_iterator __res = _Base::insert(__position, __n, __x);
+ _M_profile_resize(this, __old_size, this->capacity());
+ return iterator(__res, this);
+ }
+#else
void
insert(iterator __position, size_type __n, const _Tp& __x)
{
@@ -419,23 +433,35 @@ namespace __profile
_Base::insert(__position, __n, __x);
_M_profile_resize(this, __old_size, this->capacity());
}
+#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ iterator
+ insert(const_iterator __position,
+ _InputIterator __first, _InputIterator __last)
+ {
+ __profcxx_vector_insert(this, __position.base() - _Base::cbegin(),
+ this->size());
+ size_type __old_size = this->capacity();
+ _Base_iterator __res = _Base::insert(__position, __first, __last);
+ _M_profile_resize(this, __old_size, this->capacity());
+ return iterator(__res, this);
+ }
#else
template<typename _InputIterator>
+ void
+ insert(iterator __position,
+ _InputIterator __first, _InputIterator __last)
+ {
+ __profcxx_vector_insert(this, __position.base() - _Base::begin(),
+ this->size());
+ size_type __old_size = this->capacity();
+ _Base::insert(__position, __first, __last);
+ _M_profile_resize(this, __old_size, this->capacity());
+ }
#endif
- void
- insert(iterator __position,
- _InputIterator __first, _InputIterator __last)
- {
- __profcxx_vector_insert(this, __position.base()-_Base::begin(),
- this->size());
- size_type __old_size = this->capacity();
- _Base::insert(__position, __first, __last);
- _M_profile_resize(this, __old_size, this->capacity());
- }
iterator
#if __cplusplus >= 201103L
@@ -444,7 +470,7 @@ namespace __profile
erase(iterator __position)
#endif
{
- typename _Base::iterator __res = _Base::erase(__position.base());
+ _Base_iterator __res = _Base::erase(__position.base());
return iterator(__res, this);
}
@@ -457,8 +483,7 @@ namespace __profile
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
- typename _Base::iterator __res = _Base::erase(__first.base(),
- __last.base());
+ _Base_iterator __res = _Base::erase(__first.base(), __last.base());
return iterator(__res, this);
}