1.1 --- a/epoc32/include/stdapis/stlport/stl/debug/_iterator.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/debug/_iterator.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,394 @@
1.4 -_iterator.h
1.5 +/*
1.6 + *
1.7 + * Copyright (c) 1997
1.8 + * Moscow Center for SPARC Technology
1.9 + *
1.10 + * Copyright (c) 1999
1.11 + * Boris Fomitchev
1.12 + *
1.13 + * This material is provided "as is", with absolutely no warranty expressed
1.14 + * or implied. Any use is at your own risk.
1.15 + *
1.16 + * Permission to use or copy this software for any purpose is hereby granted
1.17 + * without fee, provided the above notices are retained on all copies.
1.18 + * Permission to modify the code and to distribute modified code is granted,
1.19 + * provided the above notices are retained, and a notice that the code was
1.20 + * modified is included with the above copyright notice.
1.21 + *
1.22 + */
1.23 +
1.24 +#ifndef _STLP_DBG_ITERATOR_H
1.25 +# define _STLP_DBG_ITERATOR_H
1.26 +
1.27 +# include <stl/_pair.h>
1.28 +# include <stl/_alloc.h>
1.29 +
1.30 +# define _STLP_DBG_ALLOCATOR_SELECT( _Tp ) _STLP_DEFAULT_ALLOCATOR_SELECT( _Tp )
1.31 +
1.32 +_STLP_BEGIN_NAMESPACE
1.33 +
1.34 +//============================================================
1.35 +
1.36 +template <class _Iterator>
1.37 +void _Decrement(_Iterator& __it, const bidirectional_iterator_tag &) {
1.38 + --__it;
1.39 +}
1.40 +
1.41 +template <class _Iterator>
1.42 +void _Decrement(_Iterator& __it, const random_access_iterator_tag &) {
1.43 + --__it;
1.44 +}
1.45 +
1.46 +template <class _Iterator>
1.47 +void _Decrement(_Iterator& __it, const forward_iterator_tag &) {
1.48 + _STLP_ASSERT(0)
1.49 +}
1.50 +
1.51 +template <class _Iterator>
1.52 +void _Advance(_Iterator&, ptrdiff_t, const forward_iterator_tag &) {
1.53 + _STLP_ASSERT(0)
1.54 +}
1.55 +
1.56 +template <class _Iterator>
1.57 +void _Advance(_Iterator& __it, ptrdiff_t, const bidirectional_iterator_tag &) {
1.58 + _STLP_ASSERT(0)
1.59 +}
1.60 +
1.61 +template <class _Iterator>
1.62 +void _Advance(_Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) {
1.63 + __it += __n;
1.64 +}
1.65 +
1.66 +template <class _Iterator>
1.67 +ptrdiff_t _DBG_distance(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &) {
1.68 + return __x - __y;
1.69 +}
1.70 +
1.71 +template <class _Iterator>
1.72 +ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const forward_iterator_tag &) {
1.73 + _STLP_ASSERT(0)
1.74 + return 0;
1.75 +}
1.76 +
1.77 +template <class _Iterator>
1.78 +ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) {
1.79 + _STLP_ASSERT(0)
1.80 + return 0;
1.81 +}
1.82 +
1.83 +template <class _Iterator>
1.84 +bool _CompareIt(const _Iterator&, const _Iterator&, const forward_iterator_tag &) {
1.85 + _STLP_ASSERT(0)
1.86 + return false;
1.87 +}
1.88 +
1.89 +template <class _Iterator>
1.90 +bool _CompareIt(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) {
1.91 + _STLP_ASSERT(0)
1.92 + return false;
1.93 +}
1.94 +
1.95 +template <class _Iterator>
1.96 +bool _CompareIt(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &) {
1.97 + return __x < __y;
1.98 +}
1.99 +
1.100 +
1.101 +template <class _Iterator>
1.102 +bool _Dereferenceable(_Iterator __it) {
1.103 + return (__it._Get_container_ptr() !=0) && !(__it._M_iterator == (__it._Get_container_ptr())->end());
1.104 +}
1.105 +
1.106 +
1.107 +template <class _Iterator>
1.108 +bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const forward_iterator_tag &) {
1.109 + return (__n == 1) && _Dereferenceable(__it);
1.110 +}
1.111 +
1.112 +template <class _Iterator>
1.113 +bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const bidirectional_iterator_tag &) {
1.114 + typedef typename _Iterator::_Container_type __container_type;
1.115 + __container_type* __c = __it._Get_container_ptr();
1.116 + return (__c!=0) && ((__n == 1 && __it._M_iterator != __c->end() ) ||
1.117 + (__n == -1 && __it._M_iterator != __c->begin()));
1.118 +}
1.119 +
1.120 +template <class _Iterator>
1.121 +bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) {
1.122 + typedef typename _Iterator::_Container_type __container_type;
1.123 + __container_type* __c = __it._Get_container_ptr();
1.124 + if (!__c) return false;
1.125 + ptrdiff_t __new_pos = (__it._M_iterator - __c->begin()) + __n;
1.126 + return (__new_pos >=0) && (__STATIC_CAST(typename __container_type::size_type,__new_pos) <=__c->size());
1.127 +}
1.128 +
1.129 +
1.130 +template <class _Container>
1.131 +struct _DBG_iter_base : public __owned_link {
1.132 +public:
1.133 + typedef typename _Container::value_type value_type;
1.134 + typedef typename _Container::reference reference;
1.135 + typedef typename _Container::pointer pointer;
1.136 + typedef ptrdiff_t difference_type;
1.137 + //private:
1.138 + typedef typename _Container::iterator _Nonconst_iterator;
1.139 + typedef typename _Container::const_iterator _Const_iterator;
1.140 + typedef _Container _Container_type;
1.141 +
1.142 +# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
1.143 + typedef typename iterator_traits<_Const_iterator>::iterator_category _Iterator_category;
1.144 +# else
1.145 + typedef typename _Container::_Iterator_category _Iterator_category;
1.146 +# endif
1.147 + typedef _Iterator_category iterator_category;
1.148 +
1.149 + _DBG_iter_base() : __owned_link(0) {}
1.150 + _DBG_iter_base(const __owned_list* __c, const _Const_iterator& __it) :
1.151 +# ifdef __HP_aCC
1.152 + __owned_link(__c), _M_iterator(*__REINTERPRET_CAST(const _Nonconst_iterator *, &__it)) {}
1.153 +# else
1.154 + __owned_link(__c), _M_iterator(*(const _Nonconst_iterator*)&__it) {}
1.155 +# endif
1.156 + _Container* _Get_container_ptr() const {
1.157 + return (_Container*)__stl_debugger::_Get_container_ptr(this);
1.158 + }
1.159 +
1.160 + void __increment() {
1.161 + _STLP_DEBUG_CHECK(_Incrementable(*this,1,_Iterator_category()))
1.162 + ++_M_iterator;
1.163 + }
1.164 +
1.165 + void __decrement() {
1.166 + _STLP_DEBUG_CHECK(_Incrementable(*this,-1,_Iterator_category()))
1.167 + _Decrement(_M_iterator, _Iterator_category());
1.168 + }
1.169 +
1.170 + void __advance(difference_type __n) {
1.171 + _STLP_DEBUG_CHECK(_Incrementable(*this,__n, _Iterator_category()))
1.172 + _Advance(_M_iterator,__n, _Iterator_category());
1.173 + }
1.174 +
1.175 +// protected:
1.176 + _Nonconst_iterator _M_iterator;
1.177 +};
1.178 +
1.179 +template <class _Container>
1.180 +ptrdiff_t operator-(const _DBG_iter_base<_Container>& __x,
1.181 + const _DBG_iter_base<_Container>& __y ) {
1.182 + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Iterator_category;
1.183 + _STLP_DEBUG_CHECK(__check_same_owner(__x, __y))
1.184 + return _DBG_distance(__x._M_iterator,__y._M_iterator, _Iterator_category());
1.185 +}
1.186 +
1.187 +template <class _Container, class _Traits>
1.188 +struct _DBG_iter_mid : public _DBG_iter_base<_Container>
1.189 +{
1.190 + typedef _DBG_iter_mid<_Container, typename _Traits::_Non_const_traits> _Nonconst_self;
1.191 + typedef typename _Container::iterator _Nonconst_iterator;
1.192 + typedef typename _Container::const_iterator _Const_iterator;
1.193 +
1.194 + _DBG_iter_mid() {}
1.195 +
1.196 + explicit _DBG_iter_mid(const _Nonconst_self& __it) :
1.197 + _DBG_iter_base<_Container>(__it) {}
1.198 +
1.199 + _DBG_iter_mid(const __owned_list* __c, const _Const_iterator& __it) :
1.200 + _DBG_iter_base<_Container>(__c, __it) {}
1.201 +};
1.202 +
1.203 +template <class _Container, class _Traits>
1.204 +struct _DBG_iter : public _DBG_iter_mid<_Container, _Traits> {
1.205 + typedef _DBG_iter_base<_Container> _Base;
1.206 +public:
1.207 + typedef typename _Base::value_type value_type;
1.208 + typedef typename _Base::difference_type difference_type;
1.209 + typedef typename _Traits::reference reference;
1.210 + typedef typename _Traits::pointer pointer;
1.211 +
1.212 +private:
1.213 + typedef typename _Base::_Nonconst_iterator _Nonconst_iterator;
1.214 + typedef typename _Base::_Const_iterator _Const_iterator;
1.215 +
1.216 + typedef _DBG_iter<_Container, _Traits> _Self;
1.217 + typedef _DBG_iter_mid<_Container, typename _Traits::_Non_const_traits> _Nonconst_mid;
1.218 +
1.219 +public:
1.220 +
1.221 +# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
1.222 + typedef typename _Base::iterator_category iterator_category;
1.223 +# endif
1.224 + typedef typename _Base::_Iterator_category _Iterator_category;
1.225 +
1.226 +public:
1.227 + _DBG_iter() {}
1.228 + // boris : real type of iter would be nice
1.229 + _DBG_iter(const __owned_list* __c, const _Const_iterator& __it) :
1.230 + _DBG_iter_mid<_Container, _Traits>(__c, __it) {}
1.231 +
1.232 + // This allows conversions from iterator to const_iterator without being
1.233 + // redundant with the copy constructor below.
1.234 + _DBG_iter(const _Nonconst_mid& __rhs) :
1.235 + _DBG_iter_mid<_Container, _Traits>(__rhs) {}
1.236 +
1.237 + _DBG_iter(const _Self& __rhs) :
1.238 + _DBG_iter_mid<_Container, _Traits>(__rhs) {}
1.239 +
1.240 + // This allows conversions from iterator to const_iterator without being
1.241 + // redundant with the copy assignment operator below.
1.242 + _Self& operator=(const _Nonconst_mid& __rhs)
1.243 + {
1.244 + (_Base&)*this = __rhs;
1.245 + return *this;
1.246 + }
1.247 +
1.248 + _Self& operator=(const _Self& __rhs)
1.249 + {
1.250 + (_Base&)*this = __rhs;
1.251 + return *this;
1.252 + }
1.253 +
1.254 + reference operator*() const {
1.255 + _STLP_DEBUG_CHECK(_Dereferenceable(*this))
1.256 + return *this->_M_iterator;
1.257 + }
1.258 +
1.259 + _STLP_DEFINE_ARROW_OPERATOR
1.260 +
1.261 + _Self& operator++() {
1.262 + this->__increment();
1.263 + return *this;
1.264 + }
1.265 + _Self operator++(int) {
1.266 + _Self __tmp = *this;
1.267 + this->__increment();
1.268 + return __tmp;
1.269 + }
1.270 + _Self& operator--() {
1.271 + this->__decrement();
1.272 + return *this;
1.273 + }
1.274 + _Self operator--(int) {
1.275 + _Self __tmp = *this;
1.276 + this->__decrement();
1.277 + return __tmp;
1.278 + }
1.279 +
1.280 + _Self& operator+=(difference_type __n) {
1.281 + this->__advance(__n);
1.282 + return *this;
1.283 + }
1.284 +
1.285 + _Self& operator-=(difference_type __n) {
1.286 + this->__advance(-__n);
1.287 + return *this;
1.288 + }
1.289 + _Self operator+(difference_type __n) const {
1.290 + _Self __tmp(*this);
1.291 + __tmp.__advance(__n);
1.292 + return __tmp;
1.293 + }
1.294 + _Self operator-(difference_type __n) const {
1.295 + _Self __tmp(*this);
1.296 + __tmp.__advance(-__n);
1.297 + return __tmp;
1.298 + }
1.299 + reference operator[](difference_type __n) const { return *(*this + __n); }
1.300 +};
1.301 +
1.302 +template <class _Container>
1.303 +inline bool
1.304 +operator==(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
1.305 + _STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
1.306 + return __x._M_iterator==__y._M_iterator;
1.307 +}
1.308 +
1.309 +template <class _Container>
1.310 +inline bool
1.311 +operator<(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
1.312 + _STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
1.313 + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
1.314 + return _CompareIt(__x._M_iterator , __y._M_iterator, _Category());
1.315 +}
1.316 +
1.317 +template <class _Container>
1.318 +inline bool
1.319 +operator>(const _DBG_iter_base<_Container>& __x,
1.320 + const _DBG_iter_base<_Container>& __y) {
1.321 + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
1.322 + return _CompareIt(__y._M_iterator , __x._M_iterator, _Category());
1.323 +}
1.324 +
1.325 +template <class _Container>
1.326 +inline bool
1.327 +operator>=(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
1.328 + _STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
1.329 + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
1.330 + return !_CompareIt(__x._M_iterator , __y._M_iterator, _Category());
1.331 +}
1.332 +
1.333 +template <class _Container>
1.334 +inline bool
1.335 +operator<=(const _DBG_iter_base<_Container>& __x,
1.336 + const _DBG_iter_base<_Container>& __y) {
1.337 + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
1.338 + return !_CompareIt(__y._M_iterator , __x._M_iterator, _Category());
1.339 +}
1.340 +
1.341 +template <class _Container>
1.342 +inline bool
1.343 +operator!=(const _DBG_iter_base<_Container>& __x,
1.344 + const _DBG_iter_base<_Container>& __y) {
1.345 + _STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
1.346 + return __x._M_iterator != __y._M_iterator;
1.347 +}
1.348 +
1.349 +//------------------------------------------
1.350 +
1.351 +template <class _Container, class _Traits>
1.352 +inline _DBG_iter<_Container, _Traits>
1.353 +operator+(ptrdiff_t __n, const _DBG_iter<_Container, _Traits>& __it) {
1.354 + _DBG_iter<_Container, _Traits> __tmp(__it);
1.355 + return __tmp += __n;
1.356 +}
1.357 +
1.358 +
1.359 +# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
1.360 +# if defined (_STLP_NESTED_TYPE_PARAM_BUG) \
1.361 + || ( defined (__SUNPRO_CC) && __SUNPRO_CC < 0x600) \
1.362 + || ( defined (_STLP_MSVC) && (_STLP_MSVC < 1100) )
1.363 +# define _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS 1
1.364 +# endif
1.365 +
1.366 +template <class _Container>
1.367 +inline ptrdiff_t*
1.368 +distance_type(const _DBG_iter_base<_Container>&) { return (ptrdiff_t*) 0; }
1.369 +
1.370 +# if !defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
1.371 +template <class _Container>
1.372 +inline _STLP_TYPENAME_ON_RETURN_TYPE _DBG_iter_base<_Container>::value_type*
1.373 +value_type(const _DBG_iter_base<_Container>&) {
1.374 + typedef typename _DBG_iter_base<_Container>::value_type _Val;
1.375 + return (_Val*)0;
1.376 +}
1.377 +
1.378 +template <class _Container>
1.379 +inline _STLP_TYPENAME_ON_RETURN_TYPE _DBG_iter_base<_Container>::_Iterator_category
1.380 +iterator_category(const _DBG_iter_base<_Container>&) {
1.381 + typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
1.382 + return _Category();
1.383 +}
1.384 +# endif
1.385 +
1.386 +# endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
1.387 +
1.388 +# define _Get_iter(__x) __x
1.389 +# define _Debug_iter(__x, __y) __y
1.390 +
1.391 +_STLP_END_NAMESPACE
1.392 +
1.393 +#endif /* INTERNAL_H */
1.394 +
1.395 +// Local Variables:
1.396 +// mode:C++
1.397 +// End:
1.398 +