1.1 --- a/epoc32/include/stdapis/stlport/stl/debug/_vector.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/debug/_vector.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,300 @@
1.4 -_vector.h
1.5 +/*
1.6 + *
1.7 + * Copyright (c) 1994
1.8 + * Hewlett-Packard Company
1.9 + *
1.10 + * Copyright (c) 1996,1997
1.11 + * Silicon Graphics Computer Systems, Inc.
1.12 + *
1.13 + * Copyright (c) 1997
1.14 + * Moscow Center for SPARC Technology
1.15 + *
1.16 + * Copyright (c) 1999
1.17 + * Boris Fomitchev
1.18 + *
1.19 + * This material is provided "as is", with absolutely no warranty expressed
1.20 + * or implied. Any use is at your own risk.
1.21 + *
1.22 + * Permission to use or copy this software for any purpose is hereby granted
1.23 + * without fee, provided the above notices are retained on all copies.
1.24 + * Permission to modify the code and to distribute modified code is granted,
1.25 + * provided the above notices are retained, and a notice that the code was
1.26 + * modified is included with the above copyright notice.
1.27 + *
1.28 + */
1.29 +
1.30 +/* NOTE: This is an internal header file, included by other STL headers.
1.31 + * You should not attempt to use it directly.
1.32 + */
1.33 +
1.34 +#ifndef _STLP_INTERNAL_DBG_VECTOR_H
1.35 +#define _STLP_INTERNAL_DBG_VECTOR_H
1.36 +
1.37 +#include <stl/debug/_iterator.h>
1.38 +
1.39 +# ifndef _STLP_USE_WRAPPER_FOR_ALLOC_PARAM
1.40 +# undef _DBG_vector
1.41 +# define _DBG_vector vector
1.42 +# endif
1.43 +
1.44 +# define _STLP_DBG_VECTOR_BASE __WORKAROUND_DBG_RENAME(vector) <_Tp, _Alloc>
1.45 +
1.46 +_STLP_BEGIN_NAMESPACE
1.47 +
1.48 +# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
1.49 +template <class _Tp, class _Alloc>
1.50 +inline _Tp*
1.51 +value_type(const _DBG_iter_base< _STLP_DBG_VECTOR_BASE >&) {
1.52 + return (_Tp*)0;
1.53 +}
1.54 +template <class _Tp, class _Alloc>
1.55 +inline random_access_iterator_tag
1.56 +iterator_category(const _DBG_iter_base< _STLP_DBG_VECTOR_BASE >&) {
1.57 + return random_access_iterator_tag();
1.58 +}
1.59 +# endif
1.60 +
1.61 +template <class _Tp, class _NcIt>
1.62 +struct _Vector_nonconst_traits
1.63 +{
1.64 + typedef _Nonconst_traits<_Tp> _BaseT;
1.65 + typedef _Tp value_type;
1.66 + typedef _Tp& reference;
1.67 + typedef _Tp* pointer;
1.68 + typedef _Vector_nonconst_traits<_Tp, _NcIt> _Non_const_traits;
1.69 +};
1.70 +
1.71 +template <class _Tp, class _NcIt>
1.72 +struct _Vector_const_traits
1.73 +{
1.74 + typedef _Const_traits<_Tp> _BaseT;
1.75 + typedef _Tp value_type;
1.76 + typedef const _Tp& reference;
1.77 + typedef const _Tp* pointer;
1.78 + typedef _Vector_nonconst_traits<_Tp, _NcIt> _Non_const_traits;
1.79 +};
1.80 +
1.81 +_STLP_TEMPLATE_NULL
1.82 +struct _Vector_nonconst_traits<bool, _Bit_iterator>
1.83 +{
1.84 + typedef _Bit_iterator::value_type value_type;
1.85 + typedef _Bit_iterator::reference reference;
1.86 + typedef _Bit_iterator::pointer pointer;
1.87 + typedef _Vector_nonconst_traits<bool, _Bit_iterator> _Non_const_traits;
1.88 +};
1.89 +
1.90 +_STLP_TEMPLATE_NULL
1.91 +struct _Vector_const_traits<bool, _Bit_iterator>
1.92 +{
1.93 + typedef _Bit_const_iterator::value_type value_type;
1.94 + typedef _Bit_const_iterator::reference reference;
1.95 + typedef _Bit_const_iterator::pointer pointer;
1.96 + typedef _Vector_nonconst_traits<bool, _Bit_iterator> _Non_const_traits;
1.97 +};
1.98 +
1.99 +template <class _Tp, _STLP_DBG_ALLOCATOR_SELECT(_Tp) >
1.100 +class _DBG_vector : public _STLP_DBG_VECTOR_BASE {
1.101 +private:
1.102 + typedef _STLP_DBG_VECTOR_BASE _Base;
1.103 + typedef _DBG_vector<_Tp, _Alloc> _Self;
1.104 + mutable __owned_list _M_iter_list;
1.105 +
1.106 +public:
1.107 +
1.108 + __IMPORT_CONTAINER_TYPEDEFS(_Base)
1.109 +
1.110 + typedef _DBG_iter<_Base,
1.111 + _Vector_nonconst_traits<value_type, typename _Base::iterator> > iterator;
1.112 +
1.113 + typedef _DBG_iter<_Base,
1.114 + _Vector_const_traits<value_type, typename _Base::iterator> > const_iterator;
1.115 +
1.116 + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
1.117 +
1.118 + iterator begin() { return iterator(&_M_iter_list, this->_M_start); }
1.119 + const_iterator begin() const { return const_iterator(&_M_iter_list, this->_M_start); }
1.120 + iterator end() { return iterator(&_M_iter_list, this->_M_finish); }
1.121 + const_iterator end() const { return const_iterator(&_M_iter_list, this->_M_finish); }
1.122 +
1.123 + reverse_iterator rbegin()
1.124 + { return reverse_iterator(end()); }
1.125 + const_reverse_iterator rbegin() const
1.126 + { return const_reverse_iterator(end()); }
1.127 + reverse_iterator rend()
1.128 + { return reverse_iterator(begin()); }
1.129 + const_reverse_iterator rend() const
1.130 + { return const_reverse_iterator(begin()); }
1.131 +
1.132 + reference operator[](size_type __n) {
1.133 + _STLP_VERBOSE_ASSERT(__n < _Base::size(), _StlMsg_OUT_OF_BOUNDS)
1.134 + return _Base::operator[](__n);
1.135 + }
1.136 +
1.137 + const_reference operator[](size_type __n) const {
1.138 + _STLP_VERBOSE_ASSERT(__n < _Base::size(), _StlMsg_OUT_OF_BOUNDS)
1.139 + return _Base::operator[](__n);
1.140 + }
1.141 +
1.142 + _Base* _Get_base() { return (_Base*)this; }
1.143 + const _Base* _Get_base() const { return (const _Base*)this; }
1.144 +
1.145 + explicit _DBG_vector(const allocator_type& __a = allocator_type())
1.146 + : _STLP_DBG_VECTOR_BASE(__a), _M_iter_list((const _Base*)this) {}
1.147 +
1.148 + _DBG_vector(size_type __n, const _Tp& __value,
1.149 + const allocator_type& __a = allocator_type())
1.150 + : _STLP_DBG_VECTOR_BASE(__n, __value, __a), _M_iter_list((const _Base*)this) {}
1.151 +
1.152 + explicit _DBG_vector(size_type __n)
1.153 + : _STLP_DBG_VECTOR_BASE(__n), _M_iter_list((const _Base*)this) {}
1.154 +
1.155 +
1.156 + _DBG_vector(const _Self& __x)
1.157 + : _STLP_DBG_VECTOR_BASE(__x), _M_iter_list((const _Base*)this) {}
1.158 +
1.159 +#if defined (_STLP_MEMBER_TEMPLATES)
1.160 +# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
1.161 + template <class _InputIterator>
1.162 + _DBG_vector(_InputIterator __first, _InputIterator __last):
1.163 + _STLP_DBG_VECTOR_BASE(__first, __last), _M_iter_list((const _Base*)this) {}
1.164 +# endif
1.165 + template <class _InputIterator>
1.166 + _DBG_vector(_InputIterator __first, _InputIterator __last,
1.167 + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) :
1.168 + _STLP_DBG_VECTOR_BASE(__first, __last, __a), _M_iter_list((const _Base*)this) {}
1.169 +
1.170 +#else
1.171 + _DBG_vector(const _Tp* __first, const _Tp* __last,
1.172 + const allocator_type& __a = allocator_type())
1.173 + : _STLP_DBG_VECTOR_BASE(__first, __last, __a), _M_iter_list((const _Base*)this) {}
1.174 +
1.175 + // mysterious VC++ bug ?
1.176 + _DBG_vector(const_iterator __first, const_iterator __last ,
1.177 + const allocator_type& __a = allocator_type())
1.178 + : _STLP_DBG_VECTOR_BASE(__first._M_iterator, __last._M_iterator, __a),
1.179 + _M_iter_list((const _Base*)this) { }
1.180 +
1.181 +#endif /* _STLP_MEMBER_TEMPLATES */
1.182 +
1.183 + _Self& operator=(const _Self& __x) {
1.184 + _M_iter_list._Invalidate_all();
1.185 + (_Base&)*this = (const _Base&)__x;
1.186 + return *this;
1.187 + }
1.188 +
1.189 + reference front() { return *begin(); }
1.190 + const_reference front() const { return *begin(); }
1.191 +
1.192 + reference back() {
1.193 + iterator __tmp = end();
1.194 + --__tmp;
1.195 + return *__tmp;
1.196 + }
1.197 + const_reference back() const {
1.198 + const_iterator __tmp = end();
1.199 + --__tmp;
1.200 + return *__tmp;
1.201 + }
1.202 +
1.203 + void swap(_Self& __x) {
1.204 + _M_iter_list._Swap_owners(__x._M_iter_list);
1.205 + _Base::swap((_Base&)__x);
1.206 + }
1.207 +
1.208 + iterator insert(iterator __position, const _Tp& __x) {
1.209 + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
1.210 + if (this->size()+1 > this->capacity()) _M_iter_list._Invalidate_all();
1.211 + return iterator(&_M_iter_list, _Base::insert(__position._M_iterator, __x));
1.212 + }
1.213 +
1.214 + iterator insert(iterator __position) {
1.215 + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
1.216 + if (this->size()+1 > this->capacity()) _M_iter_list._Invalidate_all();
1.217 + return iterator(&_M_iter_list, _Base::insert(__position._M_iterator));
1.218 + }
1.219 +
1.220 +#ifdef _STLP_MEMBER_TEMPLATES
1.221 + // Check whether it's an integral type. If so, it's not an iterator.
1.222 + template <class _InputIterator>
1.223 + void insert(iterator __position, _InputIterator __first, _InputIterator __last) {
1.224 + _STLP_DEBUG_CHECK(__check_range(__first,__last))
1.225 + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
1.226 + size_type __n = distance(__first, __last);
1.227 + if (this->size()+__n > this->capacity()) _M_iter_list._Invalidate_all();
1.228 + _Base::insert(__position._M_iterator, __first, __last);
1.229 + }
1.230 +#else /* _STLP_MEMBER_TEMPLATES */
1.231 + void insert(iterator __position,
1.232 + const_iterator __first, const_iterator __last) {
1.233 + _STLP_DEBUG_CHECK(__check_range(__first,__last))
1.234 + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
1.235 + size_type __n = distance(__first, __last);
1.236 + if (this->size()+__n > this->capacity()) _M_iter_list._Invalidate_all();
1.237 + _Base::insert(__position._M_iterator,
1.238 + __first._M_iterator, __last._M_iterator);
1.239 + }
1.240 +
1.241 + void insert (iterator __position, const_pointer __first, const_pointer __last) {
1.242 + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
1.243 + _STLP_DEBUG_CHECK(__check_range(__first,__last))
1.244 + size_type __n = distance(__first, __last);
1.245 + if (this->size()+__n > this->capacity()) _M_iter_list._Invalidate_all();
1.246 + _Base::insert(__position._M_iterator, __first, __last);
1.247 +}
1.248 +#endif /* _STLP_MEMBER_TEMPLATES */
1.249 +
1.250 + void insert (iterator __position, size_type __n, const _Tp& __x){
1.251 + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
1.252 + if (this->size()+__n > this->capacity()) _M_iter_list._Invalidate_all();
1.253 + _Base::insert(__position._M_iterator, __n, __x);
1.254 + }
1.255 +
1.256 + void pop_back() {
1.257 + _STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER)
1.258 + __invalidate_iterator(&_M_iter_list,end());
1.259 + _Base::pop_back();
1.260 + }
1.261 + iterator erase(iterator __position) {
1.262 + _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
1.263 + _STLP_VERBOSE_ASSERT(__position._M_iterator !=this->_M_finish,_StlMsg_ERASE_PAST_THE_END)
1.264 + __invalidate_range(&_M_iter_list, __position+1, end());
1.265 + return iterator(&_M_iter_list,_Base::erase(__position._M_iterator));
1.266 + }
1.267 + iterator erase(iterator __first, iterator __last) {
1.268 + _STLP_DEBUG_CHECK(__check_range(__first,__last, begin(), end()))
1.269 + __invalidate_range(&_M_iter_list, __first._M_iterator == this->_M_finish ?
1.270 + __first : __first+1, end());
1.271 + return iterator(&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator));
1.272 + }
1.273 + void clear() {
1.274 + _M_iter_list._Invalidate_all();
1.275 + _Base::clear();
1.276 + }
1.277 + void push_back(const _Tp& __x) {
1.278 + if (this->size()+1 > this->capacity()) _M_iter_list._Invalidate_all();
1.279 + _Base::push_back(__x);
1.280 + }
1.281 +};
1.282 +
1.283 +#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
1.284 +#define _STLP_TEMPLATE_CONTAINER _DBG_vector<_Tp, _Alloc>
1.285 +#define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DBG_VECTOR_BASE
1.286 +#include <stl/debug/_relops_cont.h>
1.287 +#undef _STLP_TEMPLATE_CONTAINER_BASE
1.288 +#undef _STLP_TEMPLATE_CONTAINER
1.289 +#undef _STLP_TEMPLATE_HEADER
1.290 +
1.291 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.292 + _STLP_EXPORT_TEMPLATE_CLASS _DBG_vector <void*,allocator<void*> >;
1.293 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.294 +
1.295 +_STLP_END_NAMESPACE
1.296 +
1.297 +# undef _STLP_DBG_VECTOR_BASE
1.298 +# undef _DBG_vector
1.299 +
1.300 +#endif /* _STLP_DBG_VECTOR_H */
1.301 +
1.302 +// Local Variables:
1.303 +// mode:C++
1.304 +// End: