epoc32/include/stdapis/stlport/stl/_vector.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/stdapis/stlport/stl/_vector.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_vector.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,621 @@
     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_VECTOR_H
    1.35 +#define _STLP_INTERNAL_VECTOR_H
    1.36 +
    1.37 +
    1.38 +
    1.39 +# ifndef _STLP_INTERNAL_ALGOBASE_H
    1.40 +#  include <stl/_algobase.h>
    1.41 +# endif
    1.42 +
    1.43 +# ifndef _STLP_INTERNAL_ALLOC_H
    1.44 +#  include <stl/_alloc.h>
    1.45 +# endif
    1.46 +
    1.47 +# ifndef _STLP_INTERNAL_ITERATOR_H
    1.48 +#  include <stl/_iterator.h>
    1.49 +# endif
    1.50 +
    1.51 +# ifndef _STLP_INTERNAL_UNINITIALIZED_H
    1.52 +#  include <stl/_uninitialized.h>
    1.53 +# endif
    1.54 +
    1.55 +# ifndef _STLP_RANGE_ERRORS_H
    1.56 +#  include <stl/_range_errors.h>
    1.57 +# endif
    1.58 +
    1.59 +#  undef  vector
    1.60 +#  define vector __WORKAROUND_DBG_RENAME(vector)
    1.61 +
    1.62 +_STLP_BEGIN_NAMESPACE 
    1.63 +
    1.64 +// The vector base class serves two purposes.  First, its constructor
    1.65 +// and destructor allocate (but don't initialize) storage.  This makes
    1.66 +// exception safety easier.
    1.67 +
    1.68 +template <class _Tp, class _Alloc> 
    1.69 +class _Vector_base {
    1.70 +public:
    1.71 +  typedef _Vector_base<_Tp, _Alloc> _Base;
    1.72 +  _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
    1.73 +  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
    1.74 +
    1.75 +  _Vector_base(const _Alloc& __a)
    1.76 +    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {
    1.77 +    // no push here as not needed
    1.78 +  }
    1.79 +  _Vector_base(size_t __n, const _Alloc& __a)
    1.80 +    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0)
    1.81 +  {
    1.82 +    _STLP_PUSH_CLEANUP_ITEM(_Base, this)
    1.83 +    _M_start = _M_end_of_storage.allocate(__n);
    1.84 +    _M_finish = _M_start;
    1.85 +    _M_end_of_storage._M_data = _M_start + __n;
    1.86 +    _STLP_MPWFIX_TRY _STLP_MPWFIX_CATCH
    1.87 +  }
    1.88 +
    1.89 +  ~_Vector_base() { 
    1.90 +    if (_M_start !=0) 
    1.91 +    _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start); 
    1.92 +  }
    1.93 +
    1.94 +protected:
    1.95 +  _Tp* _M_start;
    1.96 +  _Tp* _M_finish;
    1.97 +  _STLP_alloc_proxy<_Tp*, _Tp, allocator_type> _M_end_of_storage;
    1.98 +};
    1.99 +
   1.100 +template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
   1.101 +class vector : public _Vector_base<_Tp, _Alloc> 
   1.102 +{
   1.103 +private:
   1.104 +  typedef _Vector_base<_Tp, _Alloc> _Base;
   1.105 +public:
   1.106 +  typedef _Tp value_type;
   1.107 +  typedef value_type* pointer;
   1.108 +  typedef const value_type* const_pointer;
   1.109 +  typedef value_type* iterator;
   1.110 +  typedef const value_type* const_iterator;
   1.111 +
   1.112 +public:
   1.113 +  typedef value_type& reference;
   1.114 +  typedef const value_type& const_reference;
   1.115 +  typedef size_t size_type;
   1.116 +  typedef ptrdiff_t difference_type;
   1.117 +  typedef random_access_iterator_tag _Iterator_category;
   1.118 +
   1.119 +  _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
   1.120 +  _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
   1.121 +  typedef typename _Vector_base<_Tp, _Alloc>::allocator_type allocator_type;
   1.122 +
   1.123 +  allocator_type get_allocator() const {
   1.124 +    return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _Tp);
   1.125 +  }
   1.126 +
   1.127 +#ifdef _STLP_USE_TRAP_LEAVE
   1.128 +public:
   1.129 +  static void* operator new (size_t __n, TLeave) { return _STLP_StackHelper<bool>::_NewLC(__n); }
   1.130 +  static void* operator new (size_t __n) { return _STLP_StackHelper<bool>::_NewLC(__n); }
   1.131 +#endif
   1.132 +
   1.133 +protected:
   1.134 +  typedef typename  __type_traits<_Tp>::has_trivial_assignment_operator _TrivialAss;
   1.135 +  typedef typename  __type_traits<_Tp>::has_trivial_assignment_operator _IsPODType;
   1.136 +
   1.137 +  // handles insertions on overflow
   1.138 +  void _M_insert_overflow(pointer __position, const _Tp& __x, const __false_type&, 
   1.139 +			  size_type __fill_len, bool __atend = false) {
   1.140 +    const size_type __old_size = size();
   1.141 +    const size_type __len = __old_size + (max)(__old_size, __fill_len);
   1.142 +    
   1.143 +    _STLP_LEAVE_VOLATILE pointer __new_start = this->_M_end_of_storage.allocate(__len);
   1.144 +    _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   1.145 +    _STLP_TRY {
   1.146 +      __new_finish = __uninitialized_copy(this->_M_start, __position, __new_start, __false_type());
   1.147 +      // handle insertion
   1.148 +      if (__fill_len == 1) {
   1.149 +        _Construct(__new_finish, __x);
   1.150 +        ++__new_finish;
   1.151 +      } else
   1.152 +        __new_finish = __uninitialized_fill_n(__new_finish, __fill_len, __x, __false_type());
   1.153 +      if (!__atend)
   1.154 +        // copy remainder
   1.155 +        __new_finish = __uninitialized_copy(__position, this->_M_finish, __new_finish, __false_type());
   1.156 +    }
   1.157 +    _STLP_UNWIND((_Destroy(__new_start,__new_finish), 
   1.158 +                  this->_M_end_of_storage.deallocate(__new_start,__len)));
   1.159 +    _M_clear();
   1.160 +    _M_set(__new_start, __new_finish, __new_start + __len);
   1.161 +  }
   1.162 +
   1.163 +  void _M_insert_overflow(pointer __position, const _Tp& __x, const __true_type&, 
   1.164 +			  size_type __fill_len, bool __atend = false) {
   1.165 +    const size_type __old_size = size();
   1.166 +    const size_type __len = __old_size + (max)(__old_size, __fill_len);
   1.167 +    
   1.168 +    pointer __new_start = this->_M_end_of_storage.allocate(__len);
   1.169 +    pointer __new_finish = (pointer)__copy_trivial(this->_M_start, __position, __new_start);
   1.170 +      // handle insertion
   1.171 +    __new_finish = fill_n(__new_finish, __fill_len, __x);
   1.172 +    if (!__atend)
   1.173 +      // copy remainder
   1.174 +      __new_finish = (pointer)__copy_trivial(__position, this->_M_finish, __new_finish);
   1.175 +    _M_clear();
   1.176 +    _M_set(__new_start, __new_finish, __new_start + __len);
   1.177 +  }
   1.178 + 
   1.179 +  void _M_range_check(size_type __n) const {
   1.180 +    if (__n >= size_type(this->_M_finish-this->_M_start))
   1.181 +      __stl_throw_out_of_range("vector");
   1.182 +  }
   1.183 +
   1.184 +public:
   1.185 +  iterator begin()             { return this->_M_start; }
   1.186 +  const_iterator begin() const { return this->_M_start; }
   1.187 +  iterator end()               { return this->_M_finish; }
   1.188 +  const_iterator end() const   { return this->_M_finish; }
   1.189 +
   1.190 +  reverse_iterator rbegin()              { return reverse_iterator(end()); }
   1.191 +  const_reverse_iterator rbegin() const  { return const_reverse_iterator(end()); }
   1.192 +  reverse_iterator rend()                { return reverse_iterator(begin()); }
   1.193 +  const_reverse_iterator rend() const    { return const_reverse_iterator(begin()); }
   1.194 +
   1.195 +  size_type size() const        { return size_type(this->_M_finish - this->_M_start); }
   1.196 +  size_type max_size() const    { return size_type(-1) / sizeof(_Tp); }
   1.197 +  size_type capacity() const    { return size_type(this->_M_end_of_storage._M_data - this->_M_start); }
   1.198 +  bool empty() const            { return this->_M_start == this->_M_finish; }
   1.199 +
   1.200 +  reference operator[](size_type __n) { return *(begin() + __n); }
   1.201 +  const_reference operator[](size_type __n) const { return *(begin() + __n); }
   1.202 +
   1.203 +  reference front()             { return *begin(); }
   1.204 +  const_reference front() const { return *begin(); }
   1.205 +  reference back()              { return *(end() - 1); }
   1.206 +  const_reference back() const  { return *(end() - 1); }
   1.207 +
   1.208 +  reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
   1.209 +  const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
   1.210 +
   1.211 +  //explicit vector(const allocator_type& __a = allocator_type()) : 
   1.212 +  vector(const allocator_type& __a = allocator_type()) : //to useimplicitly  constructor taking allocator
   1.213 +    _Vector_base<_Tp, _Alloc>(__a) {
   1.214 +    // needed for new() to work correctly
   1.215 +    _STLP_POP_IF_CHECK
   1.216 +  }
   1.217 +
   1.218 +  vector(size_type __n, const _Tp& __val,
   1.219 +         const allocator_type& __a = allocator_type()) 
   1.220 +    : _Vector_base<_Tp, _Alloc>(__n, __a) { 
   1.221 +    this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __val); 
   1.222 +    _STLP_POP_CLEANUP_ITEM
   1.223 +  }
   1.224 +
   1.225 +  explicit vector(size_type __n)
   1.226 +    : _Vector_base<_Tp, _Alloc>(__n, allocator_type() ) {
   1.227 +# ifdef _STLP_USE_TRAP_LEAVE
   1.228 +      _Tp __p;
   1.229 +      _STLP_PUSH_CLEANUP_ITEM(_Tp, &__p) 
   1.230 +      this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __p); 
   1.231 +      // unconditional for __p
   1.232 +      CleanupStack::Pop();
   1.233 +      _STLP_POP_CLEANUP_ITEM
   1.234 +# else
   1.235 +    this->_M_finish = uninitialized_fill_n(this->_M_start, __n, _Tp()); 
   1.236 +# endif
   1.237 +  }
   1.238 +
   1.239 +  vector(const vector<_Tp, _Alloc>& __x) 
   1.240 +    : _Vector_base<_Tp, _Alloc>(__x.size(), __x.get_allocator()) {
   1.241 +    this->_M_finish = __uninitialized_copy((const_pointer)__x._M_start, 
   1.242 +                                           (const_pointer)__x._M_finish, this->_M_start, _IsPODType());
   1.243 +    _STLP_POP_CLEANUP_ITEM 
   1.244 +  }
   1.245 +  
   1.246 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.247 +  template <class _Integer>
   1.248 +  void _M_initialize_aux(_Integer __n, _Integer __val, const __true_type&) {
   1.249 +    this->_M_start = this->_M_end_of_storage.allocate(__n);
   1.250 +    this->_M_end_of_storage._M_data = this->_M_start + __n; 
   1.251 +    this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __val);
   1.252 +  }
   1.253 +
   1.254 +  template <class _InputIterator>
   1.255 +  void _M_initialize_aux(_InputIterator __first, _InputIterator __last,
   1.256 +                         const __false_type&) {
   1.257 +    _M_range_initialize(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
   1.258 +  }
   1.259 +
   1.260 +  // Check whether it's an integral type.  If so, it's not an iterator.
   1.261 + # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
   1.262 +  template <class _InputIterator>
   1.263 +  vector(_InputIterator __first, _InputIterator __last) :
   1.264 +    _Vector_base<_Tp, _Alloc>(allocator_type()) {
   1.265 +    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   1.266 +    _STLP_PUSH_CLEANUP_ITEM(_Base, this) 
   1.267 +    _M_initialize_aux(__first, __last, _Integral());
   1.268 +    _STLP_POP_CLEANUP_ITEM
   1.269 +  }
   1.270 + # endif
   1.271 +  template <class _InputIterator>
   1.272 +  vector(_InputIterator __first, _InputIterator __last,
   1.273 +         const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL ) :
   1.274 +    _Vector_base<_Tp, _Alloc>(__a) {
   1.275 +    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   1.276 +    _STLP_PUSH_CLEANUP_ITEM(_Base, this) 
   1.277 +    _M_initialize_aux(__first, __last, _Integral());
   1.278 +    _STLP_POP_CLEANUP_ITEM
   1.279 +  }
   1.280 +
   1.281 +#else
   1.282 +  vector(const _Tp* __first, const _Tp* __last,
   1.283 +         const allocator_type& __a = allocator_type())
   1.284 +    : _Vector_base<_Tp, _Alloc>(__last - __first, __a) { 
   1.285 +      this->_M_finish = __uninitialized_copy(__first, __last, this->_M_start, _IsPODType()); 
   1.286 +    _STLP_POP_CLEANUP_ITEM
   1.287 +  }
   1.288 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.289 +
   1.290 +  ~vector() { _Destroy(this->_M_start, this->_M_finish); }
   1.291 +
   1.292 +  vector<_Tp, _Alloc>& operator=(const vector<_Tp, _Alloc>& __x);
   1.293 +
   1.294 +  void reserve(size_type __n);
   1.295 +
   1.296 +  // assign(), a generalized assignment member function.  Two
   1.297 +  // versions: one that takes a count, and one that takes a range.
   1.298 +  // The range version is a member template, so we dispatch on whether
   1.299 +  // or not the type is an integer.
   1.300 +
   1.301 +  void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); }
   1.302 +  void _M_fill_assign(size_type __n, const _Tp& __val);
   1.303 +  
   1.304 +#ifdef _STLP_MEMBER_TEMPLATES
   1.305 +  template <class _ForwardIter>
   1.306 +  void _M_assign_aux(_ForwardIter __first, _ForwardIter __last, const forward_iterator_tag &)
   1.307 +#else
   1.308 +  void assign(const_iterator __first, const_iterator __last)
   1.309 +#endif
   1.310 +  {
   1.311 +    size_type __len = distance(__first, __last);
   1.312 +    
   1.313 +    if (__len > capacity()) {
   1.314 +      iterator __tmp = _M_allocate_and_copy(__len, __first, __last);
   1.315 +    _M_clear();
   1.316 +    _M_set(__tmp, __tmp + __len, __tmp + __len);
   1.317 +    }
   1.318 +    else if (size() >= __len) {
   1.319 +      iterator __new_finish = copy(__first, __last, this->_M_start);
   1.320 +      _Destroy(__new_finish, this->_M_finish);
   1.321 +      this->_M_finish = __new_finish;
   1.322 +    }
   1.323 +    else {
   1.324 +# if defined ( _STLP_MEMBER_TEMPLATES )
   1.325 +          _ForwardIter __mid = __first;
   1.326 +          advance(__mid, size());
   1.327 +# else
   1.328 +          const_iterator __mid = __first + size() ;
   1.329 +# endif
   1.330 +    copy(__first, __mid, this->_M_start);
   1.331 +    this->_M_finish = __uninitialized_copy(__mid, __last, this->_M_finish, _IsPODType());
   1.332 +    }
   1.333 +  }
   1.334 +
   1.335 +#ifdef _STLP_MEMBER_TEMPLATES
   1.336 +  template <class _InputIter>
   1.337 +  void _M_assign_aux(_InputIter __first, _InputIter __last,
   1.338 +		     const input_iterator_tag &) {
   1.339 +    iterator __cur = begin();
   1.340 +    for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
   1.341 +      *__cur = *__first;
   1.342 +    if (__first == __last)
   1.343 +      erase(__cur, end());
   1.344 +    else
   1.345 +      insert(end(), __first, __last);
   1.346 +  }
   1.347 +  
   1.348 +  template <class _Integer>
   1.349 +  void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)
   1.350 +    { assign((size_type) __n, (_Tp) __val); }
   1.351 +
   1.352 +  template <class _InputIter>
   1.353 +  void _M_assign_dispatch(_InputIter __first, _InputIter __last, const __false_type&)
   1.354 +    { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }
   1.355 +
   1.356 +  template <class _InputIterator>
   1.357 +  void assign(_InputIterator __first, _InputIterator __last) {
   1.358 +    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   1.359 +    _M_assign_dispatch(__first, __last, _Integral());
   1.360 +  }
   1.361 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.362 +
   1.363 +  void push_back(const _Tp& __x) {
   1.364 +    if (this->_M_finish != this->_M_end_of_storage._M_data) {
   1.365 +      _Construct(this->_M_finish, __x);
   1.366 +      ++this->_M_finish;
   1.367 +    }
   1.368 +    else
   1.369 +      _M_insert_overflow(this->_M_finish, __x, _IsPODType(), 1UL, true);
   1.370 +  }
   1.371 +
   1.372 +  void swap(vector<_Tp, _Alloc>& __x) {
   1.373 +    _STLP_STD::swap(this->_M_start, __x._M_start);
   1.374 +    _STLP_STD::swap(this->_M_finish, __x._M_finish);
   1.375 +    _STLP_STD::swap(this->_M_end_of_storage, __x._M_end_of_storage);
   1.376 +  }
   1.377 +
   1.378 +  iterator insert(iterator __position, const _Tp& __x) {
   1.379 +    size_type __n = __position - begin();
   1.380 +    if (this->_M_finish != this->_M_end_of_storage._M_data) {
   1.381 +      if (__position == end()) {
   1.382 +        _Construct(this->_M_finish, __x);
   1.383 +        ++this->_M_finish;
   1.384 +      } else {
   1.385 +        _Construct(this->_M_finish, *(this->_M_finish - 1));
   1.386 +        ++this->_M_finish;
   1.387 +        _Tp __x_copy = __x;
   1.388 +        __copy_backward_ptrs(__position, this->_M_finish - 2, this->_M_finish - 1, _TrivialAss());
   1.389 +        *__position = __x_copy;
   1.390 +      }
   1.391 +    }
   1.392 +    else
   1.393 +      _M_insert_overflow(__position, __x, _IsPODType(), 1UL);
   1.394 +    return begin() + __n;
   1.395 +  }
   1.396 +
   1.397 +# ifndef _STLP_NO_ANACHRONISMS
   1.398 +  void push_back() { push_back(_Tp()); }
   1.399 +  iterator insert(iterator __position) { return insert(__position, _Tp()); }
   1.400 +# endif
   1.401 +
   1.402 +  void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x);
   1.403 +
   1.404 +#if defined ( _STLP_MEMBER_TEMPLATES)
   1.405 +
   1.406 +  template <class _Integer>
   1.407 +  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
   1.408 +                          const __true_type&) {
   1.409 +    _M_fill_insert(__pos, (size_type) __n, (_Tp) __val);
   1.410 +  }
   1.411 +
   1.412 +  template <class _InputIterator>
   1.413 +  void _M_insert_dispatch(iterator __pos,
   1.414 +                          _InputIterator __first, _InputIterator __last,
   1.415 +                          const __false_type&) {
   1.416 +    _M_range_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
   1.417 +  }
   1.418 +
   1.419 +  // Check whether it's an integral type.  If so, it's not an iterator.
   1.420 +  template <class _InputIterator>
   1.421 +  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
   1.422 +    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   1.423 +    _M_insert_dispatch(__pos, __first, __last, _Integral());
   1.424 +  }
   1.425 +
   1.426 +  template <class _InputIterator>
   1.427 +  void _M_range_insert(iterator __pos, 
   1.428 +		       _InputIterator __first, 
   1.429 +		       _InputIterator __last,
   1.430 +		       const input_iterator_tag &) {
   1.431 +    for ( ; __first != __last; ++__first) {
   1.432 +      __pos = insert(__pos, *__first);
   1.433 +      ++__pos;
   1.434 +    }
   1.435 +  }
   1.436 +
   1.437 +  template <class _ForwardIterator>
   1.438 +  void _M_range_insert(iterator __position,
   1.439 +                       _ForwardIterator __first,
   1.440 +                       _ForwardIterator __last,
   1.441 +                       const forward_iterator_tag &) 
   1.442 +#else /* _STLP_MEMBER_TEMPLATES */
   1.443 +  void insert(iterator __position,
   1.444 +              const_iterator __first, const_iterator __last)
   1.445 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.446 +
   1.447 +  {
   1.448 +    if (__first != __last) {
   1.449 +      size_type __n = distance(__first, __last);
   1.450 +
   1.451 +      if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) {
   1.452 +        const size_type __elems_after = this->_M_finish - __position;
   1.453 +        pointer __old_finish = this->_M_finish;
   1.454 +        if (__elems_after > __n) {
   1.455 +          __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _IsPODType());
   1.456 +          this->_M_finish += __n;
   1.457 +          __copy_backward_ptrs(__position, __old_finish - __n, __old_finish, _TrivialAss());
   1.458 +          copy(__first, __last, __position);
   1.459 +        }
   1.460 +        else {
   1.461 +# if defined ( _STLP_MEMBER_TEMPLATES )
   1.462 +          _ForwardIterator __mid = __first;
   1.463 +          advance(__mid, __elems_after);
   1.464 +# else
   1.465 +          const_pointer __mid = __first + __elems_after;
   1.466 +# endif
   1.467 +          __uninitialized_copy(__mid, __last, this->_M_finish, _IsPODType());
   1.468 +          this->_M_finish += __n - __elems_after;
   1.469 +          __uninitialized_copy(__position, __old_finish, this->_M_finish, _IsPODType());
   1.470 +          this->_M_finish += __elems_after;
   1.471 +          copy(__first, __mid, __position);
   1.472 +        } /* elems_after */
   1.473 +      }
   1.474 +      else {
   1.475 +        const size_type __old_size = size();
   1.476 +        const size_type __len = __old_size + (max)(__old_size, __n);
   1.477 +        _STLP_LEAVE_VOLATILE pointer __new_start = this->_M_end_of_storage.allocate(__len);
   1.478 +        _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   1.479 +        _STLP_TRY {
   1.480 +          __new_finish = __uninitialized_copy(this->_M_start, __position, __new_start, _IsPODType());
   1.481 +          __new_finish = __uninitialized_copy(__first, __last, __new_finish, _IsPODType());
   1.482 +          __new_finish = __uninitialized_copy(__position, this->_M_finish, __new_finish, _IsPODType());
   1.483 +        }
   1.484 +        _STLP_UNWIND((_Destroy(__new_start,__new_finish), 
   1.485 +                      this->_M_end_of_storage.deallocate(__new_start,__len)));
   1.486 +        _M_clear();
   1.487 +        _M_set(__new_start, __new_finish, __new_start + __len);
   1.488 +      }
   1.489 +    }
   1.490 +  }
   1.491 +  void insert (iterator __pos, size_type __n, const _Tp& __x)
   1.492 +  { _M_fill_insert(__pos, __n, __x); }
   1.493 +  
   1.494 +  void pop_back() {
   1.495 +    --this->_M_finish;
   1.496 +    _Destroy(this->_M_finish);
   1.497 +  }
   1.498 +  iterator erase(iterator __position) {
   1.499 +    if (__position + 1 != end())
   1.500 +      __copy_ptrs(__position + 1, this->_M_finish, __position, _TrivialAss());
   1.501 +    --this->_M_finish;
   1.502 +    _Destroy(this->_M_finish);
   1.503 +    return __position;
   1.504 +  }
   1.505 +  iterator erase(iterator __first, iterator __last) {
   1.506 +    pointer __i = __copy_ptrs(__last, this->_M_finish, __first, _TrivialAss());
   1.507 +    _Destroy(__i, this->_M_finish);
   1.508 +    this->_M_finish = __i;
   1.509 +    return __first;
   1.510 +  }
   1.511 +
   1.512 +  void resize(size_type __new_size, _Tp __x) {
   1.513 +    if (__new_size < size()) 
   1.514 +      erase(begin() + __new_size, end());
   1.515 +    else
   1.516 +      insert(end(), __new_size - size(), __x);
   1.517 +  }
   1.518 +
   1.519 +  void resize(size_type __new_size) { 
   1.520 +   resize(__new_size, _Tp());
   1.521 +  }
   1.522 +
   1.523 +  void clear() { 
   1.524 +    erase(begin(), end());
   1.525 +  }
   1.526 +
   1.527 +protected:
   1.528 +
   1.529 +  void _M_clear() {
   1.530 +    //    if (this->_M_start) {
   1.531 +    _Destroy(this->_M_start, this->_M_finish);
   1.532 +    this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start);
   1.533 +    //    }
   1.534 +  }
   1.535 +
   1.536 +  void _M_set(pointer __s, pointer __f, pointer __e) {
   1.537 +    this->_M_start = __s;
   1.538 +    this->_M_finish = __f;
   1.539 +    this->_M_end_of_storage._M_data = __e;
   1.540 +  }
   1.541 +
   1.542 +#ifdef _STLP_MEMBER_TEMPLATES
   1.543 +  template <class _ForwardIterator>
   1.544 +  pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, 
   1.545 +				_ForwardIterator __last)
   1.546 +#else /* _STLP_MEMBER_TEMPLATES */
   1.547 +  pointer _M_allocate_and_copy(size_type __n, const_pointer __first, 
   1.548 +			       const_pointer __last)
   1.549 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.550 +  {
   1.551 +    _STLP_LEAVE_VOLATILE pointer __result = this->_M_end_of_storage.allocate(__n);
   1.552 +    _STLP_TRY {
   1.553 +#if (!defined(__MRC__))		//*TY 12/17/2000 - added workaround for MrCpp. it confuses on nested try/catch block
   1.554 +      __uninitialized_copy(__first, __last, __result, _IsPODType());
   1.555 +#else
   1.556 +      uninitialized_copy(__first, __last, __result);
   1.557 +#endif
   1.558 +      //      return __result;
   1.559 +    }
   1.560 +    _STLP_UNWIND(this->_M_end_of_storage.deallocate(__result, __n));
   1.561 +    return __result;
   1.562 +  }
   1.563 +
   1.564 +
   1.565 +#ifdef _STLP_MEMBER_TEMPLATES
   1.566 +  template <class _InputIterator>
   1.567 +  void _M_range_initialize(_InputIterator __first,  
   1.568 +                           _InputIterator __last, const input_iterator_tag &) {
   1.569 +    for ( ; __first != __last; ++__first)
   1.570 +      push_back(*__first);
   1.571 +  }
   1.572 +  // This function is only called by the constructor. 
   1.573 +  template <class _ForwardIterator>
   1.574 +  void _M_range_initialize(_ForwardIterator __first,
   1.575 +                           _ForwardIterator __last, const forward_iterator_tag &) {
   1.576 +    size_type __n = distance(__first, __last);
   1.577 +    this->_M_start = this->_M_end_of_storage.allocate(__n);
   1.578 +    this->_M_end_of_storage._M_data = this->_M_start + __n;
   1.579 +    this->_M_finish = __uninitialized_copy(__first, __last, this->_M_start, _IsPODType());
   1.580 +  }
   1.581 +  
   1.582 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.583 +};
   1.584 +
   1.585 +# define _STLP_TEMPLATE_CONTAINER vector<_Tp, _Alloc>
   1.586 +# define _STLP_TEMPLATE_HEADER    template <class _Tp, class _Alloc>
   1.587 +# include <stl/_relops_cont.h>
   1.588 +# undef _STLP_TEMPLATE_CONTAINER
   1.589 +# undef _STLP_TEMPLATE_HEADER
   1.590 +
   1.591 +# if defined (_STLP_USE_TEMPLATE_EXPORT) 
   1.592 +_STLP_EXPORT_TEMPLATE_CLASS allocator<void*>;
   1.593 +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void**, void*, allocator<void*> >;
   1.594 +_STLP_EXPORT_TEMPLATE_CLASS _Vector_base<void*,allocator<void*> >;
   1.595 +_STLP_EXPORT_TEMPLATE_CLASS vector<void*,allocator<void*> >;
   1.596 +# endif
   1.597 +
   1.598 +#  undef  vector
   1.599 +#  undef  __vector__
   1.600 +#  define __vector__ __WORKAROUND_RENAME(vector)
   1.601 +
   1.602 +_STLP_END_NAMESPACE
   1.603 +
   1.604 +# if !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.605 +#  include <stl/_vector.c>
   1.606 +# endif
   1.607 +
   1.608 +#ifndef _STLP_INTERNAL_BVECTOR_H
   1.609 +# include <stl/_bvector.h>
   1.610 +#endif
   1.611 +
   1.612 +# if defined (_STLP_DEBUG)
   1.613 +#  include <stl/debug/_vector.h>
   1.614 +# endif
   1.615 +
   1.616 +# if defined (_STLP_USE_WRAPPER_FOR_ALLOC_PARAM)
   1.617 +#  include <stl/wrappers/_vector.h>
   1.618 +# endif
   1.619 +
   1.620 +#endif /* _STLP_VECTOR_H */
   1.621 +
   1.622 +// Local Variables:
   1.623 +// mode:C++
   1.624 +// End:
   1.625 +