summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/debug/safe_iterator.h
diff options
context:
space:
mode:
authorfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-19 19:39:45 +0000
committerfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-19 19:39:45 +0000
commit8e6603f8ab76dd99426cb4c423436bf0b06056d6 (patch)
tree926f16c5943ea256d7196a0439c3b6482434002d /libstdc++-v3/include/debug/safe_iterator.h
parentef3c41c78d877ac478ddaac3942243f9bd0844f3 (diff)
downloadppe42-gcc-8e6603f8ab76dd99426cb4c423436bf0b06056d6.tar.gz
ppe42-gcc-8e6603f8ab76dd99426cb4c423436bf0b06056d6.zip
2011-07-19 François Dumont <francois.cppdevs@free.fr>
* include/debug/safe_unordered_base.h, safe_unordered_sequence.h, safe_unordered_sequence.tcc, safe_local_iterator.h, safe_local_iterator.tcc: New, support for unordered sequence safe local iterators. * include/Makefile.am: Add previous files. * include/Makefile.in: Regenerate. * include/debug/unordered_map, unordered_set: Implement _Safe_unordered_sequence and expose _Safe_local_iterator. * include/debug/safe_iterator.h, safe_iterator.tcc: Refactor _Safe_iterator::_M_get_distance static method to expose it as __get_distance function and use it in _Safe_local_iterator type. * include/debug/formatter.h: Add __msg_local_iter_compare_bad _Debug_msg_id enum entry to notify invalid comparison between local iterators from different buckets. Add _Parameter constructor from _Safe_local_iterator. * include/debug/functions.h: Add __valid_range overload for _Safe_local_iterator. * src/debug.cc: Add _Safe_unordered_sequence_base and _Safe_local_iterator_base methods implementations. * config/abi/pre/gnu.ver: Add export of some _Safe_unordered_sequence_base and _Safe_local_iterator_base methods. * testsuite/util/debug/checks.h: Add use_invalid_iterator function to simulate use of a singular iterator. * testsuite/util/debug/unordered_checks.h: New, several functions to simulate classic invalid usage of unordered sequence local iterators. * testsuite/23_containers/unordered_map/debug/ use_erased_local_iterator_neg.cc, invalid_local_iterator_range_neg.cc, use_invalid_local_iterator_neg.cc, use_invalid_iterator_neg.cc, invalid_local_iterator_compare_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/ use_erased_local_iterator_neg.cc, invalid_local_iterator_range_neg.cc, use_invalid_local_iterator_neg.cc, use_invalid_iterator_neg.cc, invalid_local_iterator_compare_neg.cc: New. * testsuite/23_containers/unordered_set/debug/ use_erased_local_iterator_neg.cc, invalid_local_iterator_range_neg.cc, use_invalid_local_iterator_neg.cc, use_invalid_iterator_neg.cc, invalid_local_iterator_compare_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/ use_erased_local_iterator_neg.cc, invalid_local_iterator_range_neg.cc, use_invalid_local_iterator_neg.cc, use_invalid_iterator_neg.cc, invalid_local_iterator_compare_neg.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176487 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/debug/safe_iterator.h')
-rw-r--r--libstdc++-v3/include/debug/safe_iterator.h71
1 files changed, 37 insertions, 34 deletions
diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h
index 127c3ba72d4..016ec7b9418 100644
--- a/libstdc++-v3/include/debug/safe_iterator.h
+++ b/libstdc++-v3/include/debug/safe_iterator.h
@@ -62,6 +62,43 @@ namespace __gnu_debug
__check_singular_aux(const _Safe_iterator_base* __x)
{ return __x->_M_singular(); }
+ /** The precision to which we can calculate the distance between
+ * two iterators.
+ */
+ enum _Distance_precision
+ {
+ __dp_equality, //< Can compare iterator equality, only
+ __dp_sign, //< Can determine equality and ordering
+ __dp_exact //< Can determine distance precisely
+ };
+
+ /** Determine the distance between two iterators with some known
+ * precision.
+ */
+ template<typename _Iterator1, typename _Iterator2>
+ inline std::pair<typename std::iterator_traits<_Iterator1>::difference_type,
+ _Distance_precision>
+ __get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs,
+ std::random_access_iterator_tag)
+ { return std::make_pair(__rhs - __lhs, __dp_exact); }
+
+ template<typename _Iterator1, typename _Iterator2>
+ inline std::pair<typename std::iterator_traits<_Iterator1>::difference_type,
+ _Distance_precision>
+ __get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs,
+ std::forward_iterator_tag)
+ { return std::make_pair(__lhs == __rhs? 0 : 1, __dp_equality); }
+
+ template<typename _Iterator1, typename _Iterator2>
+ inline std::pair<typename std::iterator_traits<_Iterator1>::difference_type,
+ _Distance_precision>
+ __get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs)
+ {
+ typedef typename std::iterator_traits<_Iterator1>::iterator_category
+ _Category;
+ return __get_distance(__lhs, __rhs, _Category());
+ }
+
/** \brief Safe iterator wrapper.
*
* The class template %_Safe_iterator is a wrapper around an
@@ -78,16 +115,6 @@ namespace __gnu_debug
{
typedef _Safe_iterator _Self;
- /** The precision to which we can calculate the distance between
- * two iterators.
- */
- enum _Distance_precision
- {
- __dp_equality, //< Can compare iterator equality, only
- __dp_sign, //< Can determine equality and ordering
- __dp_exact //< Can determine distance precisely
- };
-
/// The underlying iterator
_Iterator _M_current;
@@ -380,30 +407,6 @@ namespace __gnu_debug
_M_get_sequence() const
{ return static_cast<const _Sequence*>(_M_sequence); }
- /** Determine the distance between two iterators with some known
- * precision.
- */
- template<typename _Iterator1, typename _Iterator2>
- static std::pair<difference_type, _Distance_precision>
- _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs)
- {
- typedef typename std::iterator_traits<_Iterator1>::iterator_category
- _Category;
- return _M_get_distance(__lhs, __rhs, _Category());
- }
-
- template<typename _Iterator1, typename _Iterator2>
- static std::pair<difference_type, _Distance_precision>
- _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs,
- std::random_access_iterator_tag)
- { return std::make_pair(__rhs - __lhs, __dp_exact); }
-
- template<typename _Iterator1, typename _Iterator2>
- static std::pair<difference_type, _Distance_precision>
- _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs,
- std::forward_iterator_tag)
- { return std::make_pair(__lhs == __rhs? 0 : 1, __dp_equality); }
-
/// Is this iterator equal to the sequence's begin() iterator?
bool _M_is_begin() const
{ return base() == _M_get_sequence()->_M_base().begin(); }
OpenPOWER on IntegriCloud