1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_iterator_base.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_iterator_base.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -9,13 +9,13 @@
1.4 * Copyright (c) 1997
1.5 * Moscow Center for SPARC Technology
1.6 *
1.7 - * Copyright (c) 1999
1.8 + * Copyright (c) 1999
1.9 * Boris Fomitchev
1.10 *
1.11 * This material is provided "as is", with absolutely no warranty expressed
1.12 * or implied. Any use is at your own risk.
1.13 *
1.14 - * Permission to use or copy this software for any purpose is hereby granted
1.15 + * Permission to use or copy this software for any purpose is hereby granted
1.16 * without fee, provided the above notices are retained on all copies.
1.17 * Permission to modify the code and to distribute modified code is granted,
1.18 * provided the above notices are retained, and a notice that the code was
1.19 @@ -30,18 +30,20 @@
1.20 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H
1.21 #define _STLP_INTERNAL_ITERATOR_BASE_H
1.22
1.23 -#ifndef _STLP_CSTDDEF
1.24 -# include <cstddef>
1.25 +#ifndef _STLP_INTERNAL_CSTDDEF
1.26 +# include <stl/_cstddef.h>
1.27 #endif
1.28
1.29 -# if defined (_STLP_IMPORT_VENDOR_CSTD) && ! defined (_STLP_VENDOR_GLOBAL_CSTD)
1.30 -_STLP_BEGIN_NAMESPACE
1.31 -using namespace _STLP_VENDOR_CSTD;
1.32 -_STLP_END_NAMESPACE
1.33 -#endif /* _STLP_IMPORT_VENDOR_CSTD */
1.34 +//# if defined (_STLP_IMPORT_VENDOR_CSTD) && ! defined (_STLP_VENDOR_GLOBAL_CSTD)
1.35 +//_STLP_BEGIN_NAMESPACE
1.36 +//using namespace _STLP_VENDOR_CSTD;
1.37 +//_STLP_END_NAMESPACE
1.38 +//#endif /* _STLP_IMPORT_VENDOR_CSTD */
1.39
1.40 -#ifndef __TYPE_TRAITS_H
1.41 -# include <stl/type_traits.h>
1.42 +#if !defined(_STLP_USE_OLD_HP_ITERATOR_QUERIES) && !defined(_STLP_CLASS_PARTIAL_SPECIALIZATION)
1.43 +# ifndef _STLP_TYPE_TRAITS_H
1.44 +# include <stl/type_traits.h>
1.45 +# endif
1.46 #endif
1.47
1.48 _STLP_BEGIN_NAMESPACE
1.49 @@ -53,8 +55,8 @@
1.50 struct random_access_iterator_tag : public bidirectional_iterator_tag {};
1.51
1.52
1.53 -template <class _Category, class _Tp, __DFL_TMPL_PARAM(_Distance,ptrdiff_t),
1.54 - __DFL_TMPL_PARAM(_Pointer,_Tp*), __DFL_TMPL_PARAM(_Reference,_Tp&) >
1.55 +template <class _Category, class _Tp, _STLP_DFL_TMPL_PARAM(_Distance,ptrdiff_t),
1.56 + _STLP_DFL_TMPL_PARAM(_Pointer,_Tp*), _STLP_DFL_TMPL_PARAM(_Reference,_Tp&) >
1.57 struct iterator {
1.58 typedef _Category iterator_category;
1.59 typedef _Tp value_type;
1.60 @@ -73,25 +75,30 @@
1.61 #endif
1.62 };
1.63
1.64 -# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
1.65 +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
1.66 # define _STLP_ITERATOR_CATEGORY(_It, _Tp) iterator_category(_It)
1.67 # define _STLP_DISTANCE_TYPE(_It, _Tp) distance_type(_It)
1.68 # define _STLP_VALUE_TYPE(_It, _Tp) value_type(_It)
1.69 -# else
1.70 -# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
1.71 -# define _STLP_VALUE_TYPE(_It, _Tp) (typename iterator_traits< _Tp >::value_type*)0
1.72 -# define _STLP_DISTANCE_TYPE(_It, _Tp) (typename iterator_traits< _Tp >::difference_type*)0
1.73 -# if defined (__BORLANDC__) || defined (__SUNPRO_CC) || ( defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || ( defined (__sgi) && defined (_COMPILER_VERSION)) || defined (__DMC__)
1.74 -# define _STLP_ITERATOR_CATEGORY(_It, _Tp) iterator_traits< _Tp >::iterator_category()
1.75 -# else
1.76 -# define _STLP_ITERATOR_CATEGORY(_It, _Tp) typename iterator_traits< _Tp >::iterator_category()
1.77 -# endif
1.78 +//Old HP iterator queries do not give information about the iterator
1.79 +//associated reference type so we consider that it is not a real reference.
1.80 +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()
1.81 +#else
1.82 +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
1.83 +# define _STLP_VALUE_TYPE(_It, _Tp) (typename iterator_traits< _Tp >::value_type*)0
1.84 +# define _STLP_DISTANCE_TYPE(_It, _Tp) (typename iterator_traits< _Tp >::difference_type*)0
1.85 +# if defined (__BORLANDC__) || defined (__SUNPRO_CC) || ( defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || ( defined (__sgi) && defined (_COMPILER_VERSION)) || defined (__DMC__)
1.86 +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) iterator_traits< _Tp >::iterator_category()
1.87 +# else
1.88 +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) typename iterator_traits< _Tp >::iterator_category()
1.89 +# endif
1.90 +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) _IsRefType< typename iterator_traits< _Tp >::reference >::_Ret()
1.91 # else
1.92 -# define _STLP_ITERATOR_CATEGORY(_It, _Tp) __iterator_category(_It, _IsPtrType<_Tp>::_Ret())
1.93 -# define _STLP_DISTANCE_TYPE(_It, _Tp) (ptrdiff_t*)0
1.94 -# define _STLP_VALUE_TYPE(_It, _Tp) __value_type(_It, _IsPtrType<_Tp>::_Ret() )
1.95 +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) __iterator_category(_It, _IsPtrType<_Tp>::_Ret())
1.96 +# define _STLP_DISTANCE_TYPE(_It, _Tp) (ptrdiff_t*)0
1.97 +# define _STLP_VALUE_TYPE(_It, _Tp) __value_type(_It, _IsPtrType<_Tp>::_Ret() )
1.98 +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()
1.99 # endif
1.100 -# endif
1.101 +#endif
1.102
1.103 template <class _Iterator>
1.104 struct iterator_traits {
1.105 @@ -103,18 +110,18 @@
1.106 };
1.107
1.108
1.109 -# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && ! defined (__SUNPRO_CC)
1.110 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && ! defined (__SUNPRO_CC)
1.111 # define _STLP_DIFFERENCE_TYPE(_Iterator) typename iterator_traits<_Iterator>::difference_type
1.112 -# else
1.113 +#else
1.114 # define _STLP_DIFFERENCE_TYPE(_Iterator) ptrdiff_t
1.115 -# endif
1.116 +#endif
1.117
1.118 -# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
1.119 +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
1.120
1.121 // fbp : this order keeps gcc happy
1.122 template <class _Tp>
1.123 struct iterator_traits<const _Tp*> {
1.124 - typedef random_access_iterator_tag iterator_category;
1.125 + typedef random_access_iterator_tag iterator_category;
1.126 typedef _Tp value_type;
1.127 typedef ptrdiff_t difference_type;
1.128 typedef const _Tp* pointer;
1.129 @@ -123,7 +130,7 @@
1.130
1.131 template <class _Tp>
1.132 struct iterator_traits<_Tp*> {
1.133 - typedef random_access_iterator_tag iterator_category;
1.134 + typedef random_access_iterator_tag iterator_category;
1.135 typedef _Tp value_type;
1.136 typedef ptrdiff_t difference_type;
1.137 typedef _Tp* pointer;
1.138 @@ -133,7 +140,7 @@
1.139 # if defined (__BORLANDC__)
1.140 template <class _Tp>
1.141 struct iterator_traits<_Tp* const> {
1.142 - typedef random_access_iterator_tag iterator_category;
1.143 + typedef random_access_iterator_tag iterator_category;
1.144 typedef _Tp value_type;
1.145 typedef ptrdiff_t difference_type;
1.146 typedef const _Tp* pointer;
1.147 @@ -141,25 +148,25 @@
1.148 };
1.149 # endif
1.150
1.151 -# endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
1.152 +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
1.153
1.154
1.155 -# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) \
1.156 - || (defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && ! defined (_STLP_NO_ARROW_OPERATOR))
1.157 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || \
1.158 + (defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && ! defined (_STLP_NO_ARROW_OPERATOR))
1.159 # define _STLP_POINTERS_SPECIALIZE( _TpP )
1.160 # define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(operator*()); }
1.161 -# else
1.162 +#else
1.163 # include <stl/_ptrs_specialize.h>
1.164 -# endif
1.165 +#endif
1.166
1.167 -# ifndef _STLP_USE_OLD_HP_ITERATOR_QUERIES
1.168 +#ifndef _STLP_USE_OLD_HP_ITERATOR_QUERIES
1.169 // The overloaded functions iterator_category, distance_type, and
1.170 // value_type are not part of the C++ standard. (They have been
1.171 // replaced by struct iterator_traits.) They are included for
1.172 // backward compatibility with the HP STL.
1.173 // We introduce internal names for these functions.
1.174
1.175 -# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
1.176 +# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
1.177
1.178 template <class _Iter>
1.179 inline typename iterator_traits<_Iter>::iterator_category __iterator_category(const _Iter&) {
1.180 @@ -179,10 +186,10 @@
1.181 return __STATIC_CAST(_value_type*,0);
1.182 }
1.183
1.184 -# else
1.185 +# else /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
1.186
1.187 template <class _Iter>
1.188 -inline random_access_iterator_tag
1.189 +inline random_access_iterator_tag
1.190 __iterator_category(const _Iter&, const __true_type&) {
1.191 return random_access_iterator_tag();
1.192 }
1.193 @@ -196,36 +203,36 @@
1.194
1.195
1.196 template <class _Iter>
1.197 -inline ptrdiff_t* _STLP_CALL __distance_type(const _Iter&) { return (ptrdiff_t*)(0); }
1.198 +inline ptrdiff_t* _STLP_CALL __distance_type(const _Iter&) { return __STATIC_CAST(ptrdiff_t*, 0); }
1.199
1.200 template <class _Iter>
1.201 -inline _STLP_TYPENAME_ON_RETURN_TYPE iterator_traits<_Iter>::value_type*
1.202 +inline _STLP_TYPENAME_ON_RETURN_TYPE iterator_traits<_Iter>::value_type*
1.203 __value_type(const _Iter&, const __false_type&) {
1.204 typedef typename iterator_traits<_Iter>::value_type _value_type;
1.205 return __STATIC_CAST(_value_type*,0);
1.206 }
1.207
1.208 template <class _Tp>
1.209 -inline _Tp*
1.210 +inline _Tp*
1.211 __value_type(const _Tp*, const __true_type&) {
1.212 return __STATIC_CAST(_Tp*, 0);
1.213 }
1.214
1.215 -# endif
1.216 +# endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
1.217
1.218 -#else /* old queries */
1.219 +#else /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
1.220 template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
1.221 inline _Category _STLP_CALL iterator_category(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return _Category(); }
1.222 template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
1.223 -inline _Tp* _STLP_CALL value_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return (_Tp*)(0); }
1.224 +inline _Tp* _STLP_CALL value_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Tp*, 0); }
1.225 template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
1.226 -inline _Distance* _STLP_CALL distance_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return (_Distance*)(0); }
1.227 +inline _Distance* _STLP_CALL distance_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Distance*, 0); }
1.228 template <class _Tp>
1.229 inline random_access_iterator_tag _STLP_CALL iterator_category(const _Tp*) { return random_access_iterator_tag(); }
1.230 template <class _Tp>
1.231 -inline _Tp* _STLP_CALL value_type(const _Tp*) { return (_Tp*)(0); }
1.232 +inline _Tp* _STLP_CALL value_type(const _Tp*) { return __STATIC_CAST(_Tp*, 0); }
1.233 template <class _Tp>
1.234 -inline ptrdiff_t* _STLP_CALL distance_type(const _Tp*) { return (ptrdiff_t*)(0); }
1.235 +inline ptrdiff_t* _STLP_CALL distance_type(const _Tp*) { return __STATIC_CAST(ptrdiff_t*, 0); }
1.236 #endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
1.237
1.238 # if ! defined (_STLP_NO_ANACHRONISMS)
1.239 @@ -233,7 +240,7 @@
1.240 // bidirectional_iterator, and random_access_iterator are not part of
1.241 // the C++ standard. (They have been replaced by struct iterator.)
1.242 // They are included for backward compatibility with the HP STL.
1.243 -template <class _Tp, class _Distance> struct input_iterator :
1.244 +template <class _Tp, class _Distance> struct input_iterator :
1.245 public iterator <input_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
1.246 struct output_iterator : public iterator <output_iterator_tag, void, void, void, void> {};
1.247 template <class _Tp, class _Distance> struct forward_iterator :
1.248 @@ -244,75 +251,76 @@
1.249 public iterator<random_access_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
1.250
1.251 # if defined (_STLP_BASE_MATCH_BUG) && defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
1.252 -template <class _Tp, class _Distance>
1.253 -inline input_iterator_tag _STLP_CALL
1.254 +template <class _Tp, class _Distance>
1.255 +inline input_iterator_tag _STLP_CALL
1.256 iterator_category(const input_iterator<_Tp, _Distance>&) { return input_iterator_tag(); }
1.257 inline output_iterator_tag _STLP_CALL
1.258 iterator_category(const output_iterator&) { return output_iterator_tag(); }
1.259 -template <class _Tp, class _Distance>
1.260 +template <class _Tp, class _Distance>
1.261 inline forward_iterator_tag _STLP_CALL
1.262 iterator_category(const forward_iterator<_Tp, _Distance>&) { return forward_iterator_tag(); }
1.263 -template <class _Tp, class _Distance>
1.264 -inline bidirectional_iterator_tag _STLP_CALL
1.265 +template <class _Tp, class _Distance>
1.266 +inline bidirectional_iterator_tag _STLP_CALL
1.267 iterator_category(const bidirectional_iterator<_Tp, _Distance>&) { return bidirectional_iterator_tag(); }
1.268 -template <class _Tp, class _Distance>
1.269 +template <class _Tp, class _Distance>
1.270 inline random_access_iterator_tag _STLP_CALL
1.271 iterator_category(const random_access_iterator<_Tp, _Distance>&) { return random_access_iterator_tag(); }
1.272 -template <class _Tp, class _Distance>
1.273 -inline _Tp* _STLP_CALL value_type(const input_iterator<_Tp, _Distance>&) { return (_Tp*)(0); }
1.274 -template <class _Tp, class _Distance>
1.275 -inline _Tp* _STLP_CALL value_type(const forward_iterator<_Tp, _Distance>&) { return (_Tp*)(0); }
1.276 -template <class _Tp, class _Distance>
1.277 -inline _Tp* _STLP_CALL value_type(const bidirectional_iterator<_Tp, _Distance>&) { return (_Tp*)(0); }
1.278 -template <class _Tp, class _Distance>
1.279 -inline _Tp* _STLP_CALL value_type(const random_access_iterator<_Tp, _Distance>&) { return (_Tp*)(0); }
1.280 -template <class _Tp, class _Distance>
1.281 -inline _Distance* _STLP_CALL distance_type(const input_iterator<_Tp, _Distance>&) { return (_Distance*)(0); }
1.282 -template <class _Tp, class _Distance>
1.283 -inline _Distance* _STLP_CALL distance_type(const forward_iterator<_Tp, _Distance>&) { return (_Distance*)(0); }
1.284 -template <class _Tp, class _Distance>
1.285 -inline _Distance* _STLP_CALL distance_type(const bidirectional_iterator<_Tp, _Distance>&) { return (_Distance*)(0);}
1.286 -template <class _Tp, class _Distance>
1.287 -inline _Distance* _STLP_CALL distance_type(const random_access_iterator<_Tp, _Distance>&) { return (_Distance*)(0); }
1.288 +template <class _Tp, class _Distance>
1.289 +inline _Tp* _STLP_CALL value_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
1.290 +template <class _Tp, class _Distance>
1.291 +inline _Tp* _STLP_CALL value_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
1.292 +template <class _Tp, class _Distance>
1.293 +inline _Tp* _STLP_CALL value_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
1.294 +template <class _Tp, class _Distance>
1.295 +inline _Tp* _STLP_CALL value_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
1.296 +template <class _Tp, class _Distance>
1.297 +inline _Distance* _STLP_CALL distance_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
1.298 +template <class _Tp, class _Distance>
1.299 +inline _Distance* _STLP_CALL distance_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
1.300 +template <class _Tp, class _Distance>
1.301 +inline _Distance* _STLP_CALL distance_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0);}
1.302 +template <class _Tp, class _Distance>
1.303 +inline _Distance* _STLP_CALL distance_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
1.304 # endif /* BASE_MATCH */
1.305
1.306 #endif /* _STLP_NO_ANACHRONISMS */
1.307
1.308 template <class _InputIterator, class _Distance>
1.309 inline void _STLP_CALL __distance(const _InputIterator& __first, const _InputIterator& __last,
1.310 - _Distance& __n, const input_iterator_tag &) {
1.311 + _Distance& __n, const input_iterator_tag &) {
1.312 _InputIterator __it(__first);
1.313 while (__it != __last) { ++__it; ++__n; }
1.314 }
1.315
1.316 -# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.317 +
1.318 +# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.319 template <class _ForwardIterator, class _Distance>
1.320 inline void _STLP_CALL __distance(const _ForwardIterator& __first, const _ForwardIterator& __last,
1.321 - _Distance& __n, const forward_iterator_tag &) {
1.322 + _Distance& __n, const forward_iterator_tag &) {
1.323 _ForwardIterator __it(__first);
1.324 while (__it != __last) { ++__first; ++__n; }
1.325 }
1.326
1.327 template <class _BidirectionalIterator, class _Distance>
1.328 -_STLP_INLINE_LOOP void _STLP_CALL __distance(const _BidirectionalIterator& __first,
1.329 - const _BidirectionalIterator& __last,
1.330 - _Distance& __n, const bidirectional_iterator_tag &) {
1.331 +_STLP_INLINE_LOOP void _STLP_CALL __distance(const _BidirectionalIterator& __first,
1.332 + const _BidirectionalIterator& __last,
1.333 + _Distance& __n, const bidirectional_iterator_tag &) {
1.334 _BidirectionalIterator __it(__first);
1.335 while (__it != __last) { ++__it; ++__n; }
1.336 }
1.337 # endif
1.338
1.339 template <class _RandomAccessIterator, class _Distance>
1.340 -inline void _STLP_CALL __distance(const _RandomAccessIterator& __first,
1.341 - const _RandomAccessIterator& __last,
1.342 - _Distance& __n, const random_access_iterator_tag &) {
1.343 +inline void _STLP_CALL __distance(const _RandomAccessIterator& __first,
1.344 + const _RandomAccessIterator& __last,
1.345 + _Distance& __n, const random_access_iterator_tag &) {
1.346 __n += __last - __first;
1.347 }
1.348
1.349 -#ifndef _STLP_NO_ANACHRONISMS
1.350 +#ifndef _STLP_NO_ANACHRONISMS
1.351 template <class _InputIterator, class _Distance>
1.352 -inline void _STLP_CALL distance(const _InputIterator& __first,
1.353 - const _InputIterator& __last, _Distance& __n) {
1.354 +inline void _STLP_CALL distance(const _InputIterator& __first,
1.355 + const _InputIterator& __last, _Distance& __n) {
1.356 __distance(__first, __last, __n, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
1.357 }
1.358 #endif
1.359 @@ -321,16 +329,16 @@
1.360 inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL
1.361 __distance(const _InputIterator& __first, const _InputIterator& __last, const input_iterator_tag &) {
1.362 _STLP_DIFFERENCE_TYPE(_InputIterator) __n = 0;
1.363 - _InputIterator __it(__first);
1.364 + _InputIterator __it(__first);
1.365 while (__it != __last) {
1.366 ++__it; ++__n;
1.367 }
1.368 return __n;
1.369 }
1.370
1.371 -# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.372 +# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.373 template <class _ForwardIterator>
1.374 -inline _STLP_DIFFERENCE_TYPE(_ForwardIterator) _STLP_CALL
1.375 +inline _STLP_DIFFERENCE_TYPE(_ForwardIterator) _STLP_CALL
1.376 __distance(const _ForwardIterator& __first, const _ForwardIterator& __last,
1.377 const forward_iterator_tag &)
1.378 {
1.379 @@ -340,11 +348,12 @@
1.380 ++__it; ++__n;
1.381 }
1.382 return __n;
1.383 +
1.384 }
1.385
1.386 template <class _BidirectionalIterator>
1.387 -_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) _STLP_CALL
1.388 -__distance(const _BidirectionalIterator& __first,
1.389 +_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) _STLP_CALL
1.390 +__distance(const _BidirectionalIterator& __first,
1.391 const _BidirectionalIterator& __last,
1.392 const bidirectional_iterator_tag &) {
1.393 _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) __n = 0;
1.394 @@ -365,11 +374,10 @@
1.395
1.396 template <class _InputIterator>
1.397 inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL
1.398 -distance(const _InputIterator& __first, const _InputIterator& __last) {
1.399 - return __distance(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
1.400 +distance(_InputIterator __first, _InputIterator __last) {
1.401 + return __distance(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
1.402 }
1.403
1.404 -
1.405 // fbp: those are being used for iterator/const_iterator definitions everywhere
1.406 template <class _Tp>
1.407 struct _Nonconst_traits;
1.408 @@ -379,7 +387,8 @@
1.409 typedef _Tp value_type;
1.410 typedef const _Tp& reference;
1.411 typedef const _Tp* pointer;
1.412 - typedef _Nonconst_traits<_Tp> _Non_const_traits;
1.413 + typedef _Const_traits<_Tp> _ConstTraits;
1.414 + typedef _Nonconst_traits<_Tp> _NonConstTraits;
1.415 };
1.416
1.417 template <class _Tp>
1.418 @@ -387,51 +396,119 @@
1.419 typedef _Tp value_type;
1.420 typedef _Tp& reference;
1.421 typedef _Tp* pointer;
1.422 - typedef _Nonconst_traits<_Tp> _Non_const_traits;
1.423 + typedef _Const_traits<_Tp> _ConstTraits;
1.424 + typedef _Nonconst_traits<_Tp> _NonConstTraits;
1.425 };
1.426
1.427 +/*
1.428 + * dums: A special iterator/const_iterator traits for set and multiset for which even
1.429 + * the iterator is not mutable
1.430 + */
1.431 +template <class _Tp>
1.432 +struct _Nonconst_Const_traits;
1.433 +
1.434 +template <class _Tp>
1.435 +struct _Const_Const_traits {
1.436 + typedef _Tp value_type;
1.437 + typedef const _Tp& reference;
1.438 + typedef const _Tp* pointer;
1.439 + typedef _Const_Const_traits<_Tp> _ConstTraits;
1.440 + typedef _Nonconst_Const_traits<_Tp> _NonConstTraits;
1.441 +};
1.442 +
1.443 +template <class _Tp>
1.444 +struct _Nonconst_Const_traits {
1.445 + typedef _Tp value_type;
1.446 + typedef const _Tp& reference;
1.447 + typedef const _Tp* pointer;
1.448 + typedef _Const_Const_traits<_Tp> _ConstTraits;
1.449 + typedef _Nonconst_Const_traits<_Tp> _NonConstTraits;
1.450 +};
1.451 +
1.452 +/*
1.453 + * A macro to generate a new iterator traits from one of the
1.454 + * previous one. Changing the iterator traits type make iterators
1.455 + * from different containers not comparable.
1.456 + */
1.457 +#define _STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits) \
1.458 +template <class _Tp> \
1.459 +struct _##Motif; \
1.460 +template <class _Tp> \
1.461 +struct _Const##Motif : public _STLP_STD::_Const_##Traits<_Tp> { \
1.462 + typedef _Const##Motif<_Tp> _ConstTraits; \
1.463 + typedef _##Motif<_Tp> _NonConstTraits; \
1.464 +}; \
1.465 +template <class _Tp> \
1.466 +struct _##Motif : public _STLP_STD::_Nonconst_##Traits<_Tp> { \
1.467 + typedef _Const##Motif<_Tp> _ConstTraits; \
1.468 + typedef _##Motif<_Tp> _NonConstTraits; \
1.469 +};
1.470 +
1.471 +#define _STLP_CREATE_ITERATOR_TRAITS(Motif, Traits) \
1.472 +_STLP_MOVE_TO_PRIV_NAMESPACE \
1.473 +_STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits) \
1.474 +_STLP_MOVE_TO_STD_NAMESPACE
1.475 +
1.476 +#define _STLP_CREATE_HASH_ITERATOR_TRAITS(Motif, Traits) \
1.477 +_STLP_MOVE_TO_PRIV_NAMESPACE \
1.478 +_STLP_CREATE_ITERATOR_TRAITS_BASE(NonLocal##Motif, Traits) \
1.479 +_STLP_CREATE_ITERATOR_TRAITS_BASE(Local##Motif, Traits) \
1.480 +template <class _Tp> \
1.481 +struct _##Motif { \
1.482 + typedef _ConstNonLocal##Motif<_Tp> _ConstTraits; \
1.483 + typedef _NonLocal##Motif<_Tp> _NonConstTraits; \
1.484 + typedef _ConstLocal##Motif<_Tp> _ConstLocalTraits; \
1.485 + typedef _Local##Motif<_Tp> _NonConstLocalTraits; \
1.486 +}; \
1.487 +_STLP_MOVE_TO_STD_NAMESPACE
1.488 +
1.489 +/*
1.490 # if defined (_STLP_BASE_TYPEDEF_BUG)
1.491 // this workaround is needed for SunPro 4.0.1
1.492 template <class _Traits>
1.493 -struct __cnst_traits_aux : private _Traits
1.494 -{
1.495 +struct __cnst_traits_aux : private _Traits {
1.496 typedef typename _Traits::value_type value_type;
1.497 };
1.498 # define __TRAITS_VALUE_TYPE(_Traits) __cnst_traits_aux<_Traits>::value_type
1.499 # else
1.500 # define __TRAITS_VALUE_TYPE(_Traits) _Traits::value_type
1.501 # endif
1.502 +*/
1.503
1.504 -# if defined (_STLP_MSVC)
1.505 +#if defined (_STLP_MSVC)
1.506 // MSVC specific
1.507 template <class _InputIterator, class _Dist>
1.508 -inline void _STLP_CALL _Distance(_InputIterator __first,
1.509 - _InputIterator __last, _Dist& __n) {
1.510 +inline void _STLP_CALL _Distance(_InputIterator __first,
1.511 + _InputIterator __last, _Dist& __n) {
1.512 __distance(__first, __last, __n, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
1.513 }
1.514 -# endif
1.515 +#endif
1.516
1.517 template <class _InputIter, class _Distance>
1.518 -_STLP_INLINE_LOOP void _STLP_CALL __advance(_InputIter& __i, _Distance __n, const input_iterator_tag &) {
1.519 +_STLP_INLINE_LOOP void _STLP_CALL
1.520 +__advance(_InputIter& __i, _Distance __n, const input_iterator_tag &) {
1.521 while (__n--) ++__i;
1.522 }
1.523
1.524 // fbp : added output iterator tag variant
1.525 template <class _InputIter, class _Distance>
1.526 -_STLP_INLINE_LOOP void _STLP_CALL __advance(_InputIter& __i, _Distance __n, const output_iterator_tag &) {
1.527 +_STLP_INLINE_LOOP void _STLP_CALL
1.528 +__advance(_InputIter& __i, _Distance __n, const output_iterator_tag &) {
1.529 while (__n--) ++__i;
1.530 }
1.531
1.532 -# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.533 +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
1.534 template <class _ForwardIterator, class _Distance>
1.535 -_STLP_INLINE_LOOP void _STLP_CALL __advance(_ForwardIterator& i, _Distance n, const forward_iterator_tag &) {
1.536 - while (n--) ++i;
1.537 +_STLP_INLINE_LOOP void _STLP_CALL
1.538 +__advance(_ForwardIterator& i, _Distance n, const forward_iterator_tag &) {
1.539 + while (n--) ++i;
1.540 }
1.541 -# endif
1.542 +#endif
1.543
1.544 template <class _BidirectionalIterator, class _Distance>
1.545 -_STLP_INLINE_LOOP void _STLP_CALL __advance(_BidirectionalIterator& __i, _Distance __n,
1.546 - const bidirectional_iterator_tag &) {
1.547 +_STLP_INLINE_LOOP void _STLP_CALL
1.548 +__advance(_BidirectionalIterator& __i, _Distance __n,
1.549 + const bidirectional_iterator_tag &) {
1.550 if (__n > 0)
1.551 while (__n--) ++__i;
1.552 else
1.553 @@ -439,8 +516,9 @@
1.554 }
1.555
1.556 template <class _RandomAccessIterator, class _Distance>
1.557 -inline void _STLP_CALL __advance(_RandomAccessIterator& __i, _Distance __n,
1.558 - const random_access_iterator_tag &) {
1.559 +inline void _STLP_CALL
1.560 +__advance(_RandomAccessIterator& __i, _Distance __n,
1.561 + const random_access_iterator_tag &) {
1.562 __i += __n;
1.563 }
1.564
1.565 @@ -451,9 +529,9 @@
1.566
1.567 _STLP_END_NAMESPACE
1.568
1.569 -# if defined (_STLP_DEBUG) && ! defined (_STLP_DEBUG_H)
1.570 +#if defined (_STLP_DEBUG) && !defined (_STLP_DEBUG_H)
1.571 # include <stl/debug/_debug.h>
1.572 -# endif
1.573 +#endif
1.574
1.575 #endif /* _STLP_INTERNAL_ITERATOR_BASE_H */
1.576