summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/debug/vector
diff options
context:
space:
mode:
authorfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-25 20:53:39 +0000
committerfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-25 20:53:39 +0000
commit8e9bca591d9307979fde531663fb4d34da242aae (patch)
tree655bd05d685adc6a2c1cc45fb794a00e1ae25b76 /libstdc++-v3/include/debug/vector
parent39bf7c517034933b46170285a64bafbd95cf0861 (diff)
downloadppe42-gcc-8e9bca591d9307979fde531663fb4d34da242aae.tar.gz
ppe42-gcc-8e9bca591d9307979fde531663fb4d34da242aae.zip
2010-11-25 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Introduce a mutex pool in get_safe_base_mutex. Move code used to manipulate sequence safe iterators from safe iterator methods to safe sequence ones. Remove usage of safe iterator mutex, keep _Safe_iterator_base::_M_get_mutex for library backward binary compatibility. * src/Makefile.am: Build debug.cc in gnu++0x mode for _Hash_impl usage. * src/Makefile.in: Regenerate * include/debug/safe_base.h: Add _Safe_iterator_base _M_invalidate and _M_reset. Add _Safe_sequence_base _M_attach, _M_attach_single, _M_detach and _M_detach_single. * include/debug.safe_iterator.h, safe_iterator.tcc: Remove _Safe_iterator _M_invalidate and _M_invalidate_single. Implement all methods in terms of normal iterators rather than safe ones. * include/debug/safe_sequence.h: Replace _Safe_sequence _M_transfe_iter with _M_transfer_from_if taking the source sequence and a predicate signaling when a safe iterator shall be transfered. Add _Equal_to predicate. * include/debug/safe_sequence.tcc: New. * include/Makefile.am: Adjust. * include/Makefile.in: Regenerate. * include/debug/forward_list: Swap safe iterators in move constructor. Do not invalidate before begin in _M_invalidate_all method. Reimplement safe methods using normal iterators rather than safe ones. * include/debug/set.h, unordered_map, multiset.h, vector, unordered_set, deque, map.h, list, multimap.h: Reimplement safe method using normal iterators rather than safe ones. * testsuite/23_containers/forward_list/debug/clear.cc, swap.cc, move_constructor.cc, splice_after.cc, splice_after1.cc, splice_after2.cc, splice_after3.cc, splice_after4.cc: New. * testsuite/23_containers/vector/debug/multithreaded_swap.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167152 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/debug/vector')
-rw-r--r--libstdc++-v3/include/debug/vector61
1 files changed, 34 insertions, 27 deletions
diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector
index 9004f2902ae..322c170289a 100644
--- a/libstdc++-v3/include/debug/vector
+++ b/libstdc++-v3/include/debug/vector
@@ -49,16 +49,17 @@ namespace __debug
typedef _GLIBCXX_STD_D::vector<_Tp, _Allocator> _Base;
typedef __gnu_debug::_Safe_sequence<vector> _Safe_base;
+ typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
- typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
+ typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
public:
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
- typedef __gnu_debug::_Safe_iterator<typename _Base::iterator,vector>
+ typedef __gnu_debug::_Safe_iterator<_Base_iterator,vector>
iterator;
- typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,vector>
+ typedef __gnu_debug::_Safe_iterator<_Base_const_iterator,vector>
const_iterator;
typedef typename _Base::size_type size_type;
@@ -246,7 +247,7 @@ namespace __debug
{
bool __realloc = _M_requires_reallocation(__sz);
if (__sz < this->size())
- this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
+ this->_M_invalidate_after_nth(__sz);
_Base::resize(__sz);
if (__realloc)
this->_M_invalidate_all();
@@ -258,7 +259,7 @@ namespace __debug
{
bool __realloc = _M_requires_reallocation(__sz);
if (__sz < this->size())
- this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
+ this->_M_invalidate_after_nth(__sz);
_Base::resize(__sz, __c);
if (__realloc)
this->_M_invalidate_all();
@@ -270,7 +271,7 @@ namespace __debug
{
bool __realloc = _M_requires_reallocation(__sz);
if (__sz < this->size())
- this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
+ this->_M_invalidate_after_nth(__sz);
_Base::resize(__sz, __c);
if (__realloc)
this->_M_invalidate_all();
@@ -388,8 +389,7 @@ namespace __debug
pop_back()
{
__glibcxx_check_nonempty();
- iterator __victim = end() - 1;
- __victim._M_invalidate();
+ this->_M_invalidate_if(_Equal(--_Base::end()));
_Base::pop_back();
}
@@ -400,13 +400,13 @@ namespace __debug
{
__glibcxx_check_insert(__position);
bool __realloc = _M_requires_reallocation(this->size() + 1);
- difference_type __offset = __position - begin();
- typename _Base::iterator __res = _Base::emplace(__position.base(),
- std::forward<_Args>(__args)...);
+ difference_type __offset = __position.base() - _Base::begin();
+ _Base_iterator __res = _Base::emplace(__position.base(),
+ std::forward<_Args>(__args)...);
if (__realloc)
this->_M_invalidate_all();
else
- this->_M_invalidate_if(_After_nth(__offset, _M_base().begin()));
+ this->_M_invalidate_after_nth(__offset);
_M_update_guaranteed_capacity();
return iterator(__res, this);
}
@@ -417,12 +417,12 @@ namespace __debug
{
__glibcxx_check_insert(__position);
bool __realloc = _M_requires_reallocation(this->size() + 1);
- difference_type __offset = __position - begin();
- typename _Base::iterator __res = _Base::insert(__position.base(),__x);
+ difference_type __offset = __position.base() - _Base::begin();
+ _Base_iterator __res = _Base::insert(__position.base(), __x);
if (__realloc)
this->_M_invalidate_all();
else
- this->_M_invalidate_if(_After_nth(__offset, _M_base().begin()));
+ this->_M_invalidate_after_nth(__offset);
_M_update_guaranteed_capacity();
return iterator(__res, this);
}
@@ -444,12 +444,12 @@ namespace __debug
{
__glibcxx_check_insert(__position);
bool __realloc = _M_requires_reallocation(this->size() + __n);
- difference_type __offset = __position - begin();
+ difference_type __offset = __position.base() - _Base::begin();
_Base::insert(__position.base(), __n, __x);
if (__realloc)
this->_M_invalidate_all();
else
- this->_M_invalidate_if(_After_nth(__offset, _M_base().begin()));
+ this->_M_invalidate_after_nth(__offset);
_M_update_guaranteed_capacity();
}
@@ -463,15 +463,15 @@ namespace __debug
/* 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. */
- typename _Base::iterator __old_begin = _M_base().begin();
- difference_type __offset = __position - begin();
+ _Base_iterator __old_begin = _M_base().begin();
+ difference_type __offset = __position.base() - _Base::begin();
_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_if(_After_nth(__offset, _M_base().begin()));
+ this->_M_invalidate_after_nth(__offset);
_M_update_guaranteed_capacity();
}
@@ -479,9 +479,9 @@ namespace __debug
erase(iterator __position)
{
__glibcxx_check_erase(__position);
- difference_type __offset = __position - begin();
- typename _Base::iterator __res = _Base::erase(__position.base());
- this->_M_invalidate_if(_After_nth(__offset, _M_base().begin()));
+ difference_type __offset = __position.base() - _Base::begin();
+ _Base_iterator __res = _Base::erase(__position.base());
+ this->_M_invalidate_after_nth(__offset);
return iterator(__res, this);
}
@@ -492,10 +492,10 @@ namespace __debug
// 151. can't currently clear() empty container
__glibcxx_check_erase_range(__first, __last);
- difference_type __offset = __first - begin();
- typename _Base::iterator __res = _Base::erase(__first.base(),
- __last.base());
- this->_M_invalidate_if(_After_nth(__offset, _M_base().begin()));
+ difference_type __offset = __first.base() - _Base::begin();
+ _Base_iterator __res = _Base::erase(__first.base(),
+ __last.base());
+ this->_M_invalidate_after_nth(__offset);
return iterator(__res, this);
}
@@ -534,6 +534,13 @@ namespace __debug
if (this->size() > _M_guaranteed_capacity)
_M_guaranteed_capacity = this->size();
}
+
+ void
+ _M_invalidate_after_nth(difference_type __n)
+ {
+ typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
+ this->_M_invalidate_if(_After_nth(__n, _Base::begin()));
+ }
};
template<typename _Tp, typename _Alloc>
OpenPOWER on IntegriCloud