diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-30 16:24:30 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-30 16:24:30 +0000 |
commit | fc0701588c12a1eeeb3029ecf25a6023282d7dca (patch) | |
tree | 83347806f74e9a3b4ea1901cf1df2a4ea1238bfc /libstdc++-v3/include/debug | |
parent | f5049de703af188022f2dfe8b12f22a4fb924944 (diff) | |
download | ppe42-gcc-fc0701588c12a1eeeb3029ecf25a6023282d7dca.tar.gz ppe42-gcc-fc0701588c12a1eeeb3029ecf25a6023282d7dca.zip |
2013-06-30 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_deque.h (deque<>::insert(iterator,
size_type, const value_type&), deque<>::insert(iterator,
initializer_list<>), deque<>::insert(iterator, _InputIterator,
_InputIterator)): Adjust C++11 signatures to take a const_iterator.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
* include/debug/deque: Adjust.
* include/debug/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/vector: Likewise.
* testsuite/23_containers/deque/modifiers/insert/const_iterator.cc:
Extend.
* testsuite/23_containers/vector/bool/modifiers/insert/
const_iterator.cc: Likewise.
* testsuite/23_containers/vector/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200571 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/debug')
-rw-r--r-- | libstdc++-v3/include/debug/deque | 32 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/vector | 47 |
2 files changed, 71 insertions, 8 deletions
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/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 |