Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
4 * Moscow Center for SPARC Technology
9 * This material is provided "as is", with absolutely no warranty expressed
10 * or implied. Any use is at your own risk.
12 * Permission to use or copy this software for any purpose is hereby granted
13 * without fee, provided the above notices are retained on all copies.
14 * Permission to modify the code and to distribute modified code is granted,
15 * provided the above notices are retained, and a notice that the code was
16 * modified is included with the above copyright notice.
20 #ifndef _STLP_DBG_ITERATOR_H
21 # define _STLP_DBG_ITERATOR_H
23 # include <stl/_pair.h>
24 # include <stl/_alloc.h>
26 # define _STLP_DBG_ALLOCATOR_SELECT( _Tp ) _STLP_DEFAULT_ALLOCATOR_SELECT( _Tp )
30 //============================================================
32 template <class _Iterator>
33 void _Decrement(_Iterator& __it, const bidirectional_iterator_tag &) {
37 template <class _Iterator>
38 void _Decrement(_Iterator& __it, const random_access_iterator_tag &) {
42 template <class _Iterator>
43 void _Decrement(_Iterator& __it, const forward_iterator_tag &) {
47 template <class _Iterator>
48 void _Advance(_Iterator&, ptrdiff_t, const forward_iterator_tag &) {
52 template <class _Iterator>
53 void _Advance(_Iterator& __it, ptrdiff_t, const bidirectional_iterator_tag &) {
57 template <class _Iterator>
58 void _Advance(_Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) {
62 template <class _Iterator>
63 ptrdiff_t _DBG_distance(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &) {
67 template <class _Iterator>
68 ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const forward_iterator_tag &) {
73 template <class _Iterator>
74 ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) {
79 template <class _Iterator>
80 bool _CompareIt(const _Iterator&, const _Iterator&, const forward_iterator_tag &) {
85 template <class _Iterator>
86 bool _CompareIt(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) {
91 template <class _Iterator>
92 bool _CompareIt(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &) {
97 template <class _Iterator>
98 bool _Dereferenceable(_Iterator __it) {
99 return (__it._Get_container_ptr() !=0) && !(__it._M_iterator == (__it._Get_container_ptr())->end());
103 template <class _Iterator>
104 bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const forward_iterator_tag &) {
105 return (__n == 1) && _Dereferenceable(__it);
108 template <class _Iterator>
109 bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const bidirectional_iterator_tag &) {
110 typedef typename _Iterator::_Container_type __container_type;
111 __container_type* __c = __it._Get_container_ptr();
112 return (__c!=0) && ((__n == 1 && __it._M_iterator != __c->end() ) ||
113 (__n == -1 && __it._M_iterator != __c->begin()));
116 template <class _Iterator>
117 bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) {
118 typedef typename _Iterator::_Container_type __container_type;
119 __container_type* __c = __it._Get_container_ptr();
120 if (!__c) return false;
121 ptrdiff_t __new_pos = (__it._M_iterator - __c->begin()) + __n;
122 return (__new_pos >=0) && (__STATIC_CAST(typename __container_type::size_type,__new_pos) <=__c->size());
126 template <class _Container>
127 struct _DBG_iter_base : public __owned_link {
129 typedef typename _Container::value_type value_type;
130 typedef typename _Container::reference reference;
131 typedef typename _Container::pointer pointer;
132 typedef ptrdiff_t difference_type;
134 typedef typename _Container::iterator _Nonconst_iterator;
135 typedef typename _Container::const_iterator _Const_iterator;
136 typedef _Container _Container_type;
138 # ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
139 typedef typename iterator_traits<_Const_iterator>::iterator_category _Iterator_category;
141 typedef typename _Container::_Iterator_category _Iterator_category;
143 typedef _Iterator_category iterator_category;
145 _DBG_iter_base() : __owned_link(0) {}
146 _DBG_iter_base(const __owned_list* __c, const _Const_iterator& __it) :
148 __owned_link(__c), _M_iterator(*__REINTERPRET_CAST(const _Nonconst_iterator *, &__it)) {}
150 __owned_link(__c), _M_iterator(*(const _Nonconst_iterator*)&__it) {}
152 _Container* _Get_container_ptr() const {
153 return (_Container*)__stl_debugger::_Get_container_ptr(this);
157 _STLP_DEBUG_CHECK(_Incrementable(*this,1,_Iterator_category()))
162 _STLP_DEBUG_CHECK(_Incrementable(*this,-1,_Iterator_category()))
163 _Decrement(_M_iterator, _Iterator_category());
166 void __advance(difference_type __n) {
167 _STLP_DEBUG_CHECK(_Incrementable(*this,__n, _Iterator_category()))
168 _Advance(_M_iterator,__n, _Iterator_category());
172 _Nonconst_iterator _M_iterator;
175 template <class _Container>
176 ptrdiff_t operator-(const _DBG_iter_base<_Container>& __x,
177 const _DBG_iter_base<_Container>& __y ) {
178 typedef typename _DBG_iter_base<_Container>::_Iterator_category _Iterator_category;
179 _STLP_DEBUG_CHECK(__check_same_owner(__x, __y))
180 return _DBG_distance(__x._M_iterator,__y._M_iterator, _Iterator_category());
183 template <class _Container, class _Traits>
184 struct _DBG_iter_mid : public _DBG_iter_base<_Container>
186 typedef _DBG_iter_mid<_Container, typename _Traits::_Non_const_traits> _Nonconst_self;
187 typedef typename _Container::iterator _Nonconst_iterator;
188 typedef typename _Container::const_iterator _Const_iterator;
192 explicit _DBG_iter_mid(const _Nonconst_self& __it) :
193 _DBG_iter_base<_Container>(__it) {}
195 _DBG_iter_mid(const __owned_list* __c, const _Const_iterator& __it) :
196 _DBG_iter_base<_Container>(__c, __it) {}
199 template <class _Container, class _Traits>
200 struct _DBG_iter : public _DBG_iter_mid<_Container, _Traits> {
201 typedef _DBG_iter_base<_Container> _Base;
203 typedef typename _Base::value_type value_type;
204 typedef typename _Base::difference_type difference_type;
205 typedef typename _Traits::reference reference;
206 typedef typename _Traits::pointer pointer;
209 typedef typename _Base::_Nonconst_iterator _Nonconst_iterator;
210 typedef typename _Base::_Const_iterator _Const_iterator;
212 typedef _DBG_iter<_Container, _Traits> _Self;
213 typedef _DBG_iter_mid<_Container, typename _Traits::_Non_const_traits> _Nonconst_mid;
217 # ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
218 typedef typename _Base::iterator_category iterator_category;
220 typedef typename _Base::_Iterator_category _Iterator_category;
224 // boris : real type of iter would be nice
225 _DBG_iter(const __owned_list* __c, const _Const_iterator& __it) :
226 _DBG_iter_mid<_Container, _Traits>(__c, __it) {}
228 // This allows conversions from iterator to const_iterator without being
229 // redundant with the copy constructor below.
230 _DBG_iter(const _Nonconst_mid& __rhs) :
231 _DBG_iter_mid<_Container, _Traits>(__rhs) {}
233 _DBG_iter(const _Self& __rhs) :
234 _DBG_iter_mid<_Container, _Traits>(__rhs) {}
236 // This allows conversions from iterator to const_iterator without being
237 // redundant with the copy assignment operator below.
238 _Self& operator=(const _Nonconst_mid& __rhs)
240 (_Base&)*this = __rhs;
244 _Self& operator=(const _Self& __rhs)
246 (_Base&)*this = __rhs;
250 reference operator*() const {
251 _STLP_DEBUG_CHECK(_Dereferenceable(*this))
252 return *this->_M_iterator;
255 _STLP_DEFINE_ARROW_OPERATOR
257 _Self& operator++() {
261 _Self operator++(int) {
266 _Self& operator--() {
270 _Self operator--(int) {
276 _Self& operator+=(difference_type __n) {
277 this->__advance(__n);
281 _Self& operator-=(difference_type __n) {
282 this->__advance(-__n);
285 _Self operator+(difference_type __n) const {
287 __tmp.__advance(__n);
290 _Self operator-(difference_type __n) const {
292 __tmp.__advance(-__n);
295 reference operator[](difference_type __n) const { return *(*this + __n); }
298 template <class _Container>
300 operator==(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
301 _STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
302 return __x._M_iterator==__y._M_iterator;
305 template <class _Container>
307 operator<(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
308 _STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
309 typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
310 return _CompareIt(__x._M_iterator , __y._M_iterator, _Category());
313 template <class _Container>
315 operator>(const _DBG_iter_base<_Container>& __x,
316 const _DBG_iter_base<_Container>& __y) {
317 typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
318 return _CompareIt(__y._M_iterator , __x._M_iterator, _Category());
321 template <class _Container>
323 operator>=(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
324 _STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
325 typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
326 return !_CompareIt(__x._M_iterator , __y._M_iterator, _Category());
329 template <class _Container>
331 operator<=(const _DBG_iter_base<_Container>& __x,
332 const _DBG_iter_base<_Container>& __y) {
333 typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
334 return !_CompareIt(__y._M_iterator , __x._M_iterator, _Category());
337 template <class _Container>
339 operator!=(const _DBG_iter_base<_Container>& __x,
340 const _DBG_iter_base<_Container>& __y) {
341 _STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
342 return __x._M_iterator != __y._M_iterator;
345 //------------------------------------------
347 template <class _Container, class _Traits>
348 inline _DBG_iter<_Container, _Traits>
349 operator+(ptrdiff_t __n, const _DBG_iter<_Container, _Traits>& __it) {
350 _DBG_iter<_Container, _Traits> __tmp(__it);
355 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
356 # if defined (_STLP_NESTED_TYPE_PARAM_BUG) \
357 || ( defined (__SUNPRO_CC) && __SUNPRO_CC < 0x600) \
358 || ( defined (_STLP_MSVC) && (_STLP_MSVC < 1100) )
359 # define _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS 1
362 template <class _Container>
364 distance_type(const _DBG_iter_base<_Container>&) { return (ptrdiff_t*) 0; }
366 # if !defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
367 template <class _Container>
368 inline _STLP_TYPENAME_ON_RETURN_TYPE _DBG_iter_base<_Container>::value_type*
369 value_type(const _DBG_iter_base<_Container>&) {
370 typedef typename _DBG_iter_base<_Container>::value_type _Val;
374 template <class _Container>
375 inline _STLP_TYPENAME_ON_RETURN_TYPE _DBG_iter_base<_Container>::_Iterator_category
376 iterator_category(const _DBG_iter_base<_Container>&) {
377 typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
382 # endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
384 # define _Get_iter(__x) __x
385 # define _Debug_iter(__x, __y) __y
389 #endif /* INTERNAL_H */