epoc32/include/stdapis/stlportv5/stl/_vector.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_vector.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,735 @@
     1.4 +/*
     1.5 + *
     1.6 + * Copyright (c) 1994
     1.7 + * Hewlett-Packard Company
     1.8 + *
     1.9 + * Copyright (c) 1996,1997
    1.10 + * Silicon Graphics Computer Systems, Inc.
    1.11 + *
    1.12 + * Copyright (c) 1997
    1.13 + * Moscow Center for SPARC Technology
    1.14 + *
    1.15 + * Copyright (c) 1999
    1.16 + * Boris Fomitchev
    1.17 + *
    1.18 + * This material is provided "as is", with absolutely no warranty expressed
    1.19 + * or implied. Any use is at your own risk.
    1.20 + *
    1.21 + * Permission to use or copy this software for any purpose is hereby granted
    1.22 + * without fee, provided the above notices are retained on all copies.
    1.23 + * Permission to modify the code and to distribute modified code is granted,
    1.24 + * provided the above notices are retained, and a notice that the code was
    1.25 + * modified is included with the above copyright notice.
    1.26 + *
    1.27 + */
    1.28 +
    1.29 +/* NOTE: This is an internal header file, included by other STL headers.
    1.30 + *   You should not attempt to use it directly.
    1.31 + */
    1.32 +
    1.33 +#ifndef _STLP_INTERNAL_VECTOR_H
    1.34 +#define _STLP_INTERNAL_VECTOR_H
    1.35 +
    1.36 +#ifndef _STLP_INTERNAL_ALGOBASE_H
    1.37 +#  include <stl/_algobase.h>
    1.38 +#endif
    1.39 +
    1.40 +#ifndef _STLP_INTERNAL_ALLOC_H
    1.41 +#  include <stl/_alloc.h>
    1.42 +#endif
    1.43 +
    1.44 +#ifndef _STLP_INTERNAL_ITERATOR_H
    1.45 +#  include <stl/_iterator.h>
    1.46 +#endif
    1.47 +
    1.48 +#ifndef _STLP_INTERNAL_UNINITIALIZED_H
    1.49 +#  include <stl/_uninitialized.h>
    1.50 +#endif
    1.51 +
    1.52 +_STLP_BEGIN_NAMESPACE
    1.53 +
    1.54 +// The vector base class serves one purpose, its constructor and
    1.55 +// destructor allocate (but don't initialize) storage.  This makes
    1.56 +// exception safety easier.
    1.57 +
    1.58 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.59 +
    1.60 +template <class _Tp, class _Alloc>
    1.61 +class _Vector_base {
    1.62 +public:
    1.63 +  typedef _Vector_base<_Tp, _Alloc> _Self;
    1.64 +  _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
    1.65 +  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
    1.66 +  typedef _Tp* pointer;
    1.67 +  typedef _STLP_alloc_proxy<pointer, _Tp, allocator_type> _AllocProxy;
    1.68 +
    1.69 +  _Vector_base(const _Alloc& __a)
    1.70 +    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {}
    1.71 +
    1.72 +  _Vector_base(size_t __n, const _Alloc& __a)
    1.73 +    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {
    1.74 +    _M_start = _M_end_of_storage.allocate(__n, __n);
    1.75 +    _M_finish = _M_start;
    1.76 +    _M_end_of_storage._M_data = _M_start + __n;
    1.77 +    _STLP_MPWFIX_TRY _STLP_MPWFIX_CATCH
    1.78 +  }
    1.79 +
    1.80 +  _Vector_base(__move_source<_Self> src)
    1.81 +    : _M_start(src.get()._M_start), _M_finish(src.get()._M_finish),
    1.82 +      _M_end_of_storage(__move_source<_AllocProxy>(src.get()._M_end_of_storage)) {
    1.83 +    //Set the source as empty:
    1.84 +    src.get()._M_finish = src.get()._M_end_of_storage._M_data = src.get()._M_start = 0;
    1.85 +  }
    1.86 +
    1.87 +  ~_Vector_base() {
    1.88 +    if (_M_start != _STLP_DEFAULT_CONSTRUCTED(pointer))
    1.89 +      _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start);
    1.90 +  }
    1.91 +
    1.92 +protected:
    1.93 +  void _STLP_FUNCTION_THROWS _M_throw_length_error() const;
    1.94 +  void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const;
    1.95 +
    1.96 +  pointer _M_start;
    1.97 +  pointer _M_finish;
    1.98 +  _AllocProxy _M_end_of_storage;
    1.99 +};
   1.100 +
   1.101 +#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
   1.102 +#  define vector _STLP_PTR_IMPL_NAME(vector)
   1.103 +#elif defined (_STLP_DEBUG)
   1.104 +#  define vector _STLP_NON_DBG_NAME(vector)
   1.105 +#else
   1.106 +_STLP_MOVE_TO_STD_NAMESPACE
   1.107 +#endif
   1.108 +
   1.109 +template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
   1.110 +class vector : protected _STLP_PRIV _Vector_base<_Tp, _Alloc>
   1.111 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector)
   1.112 +             , public __stlport_class<vector<_Tp, _Alloc> >
   1.113 +#endif
   1.114 +{
   1.115 +private:
   1.116 +  typedef _STLP_PRIV _Vector_base<_Tp, _Alloc> _Base;
   1.117 +  typedef vector<_Tp, _Alloc> _Self;
   1.118 +public:
   1.119 +  _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
   1.120 +  typedef typename _Base::allocator_type allocator_type;
   1.121 +
   1.122 +  typedef _Tp value_type;
   1.123 +  typedef value_type* pointer;
   1.124 +  typedef const value_type* const_pointer;
   1.125 +  typedef value_type* iterator;
   1.126 +  typedef const value_type* const_iterator;
   1.127 +
   1.128 +  typedef value_type& reference;
   1.129 +  typedef const value_type& const_reference;
   1.130 +  typedef size_t size_type;
   1.131 +  typedef ptrdiff_t difference_type;
   1.132 +  typedef random_access_iterator_tag _Iterator_category;
   1.133 +
   1.134 +  _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
   1.135 +
   1.136 +  allocator_type get_allocator() const
   1.137 +  { return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _Tp); }
   1.138 +
   1.139 +private:
   1.140 +  typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy;
   1.141 +  typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy;
   1.142 +#if !defined (_STLP_NO_MOVE_SEMANTIC)
   1.143 +  typedef typename __move_traits<_Tp>::implemented _Movable;
   1.144 +#else
   1.145 +  typedef __false_type _Movable;
   1.146 +#endif
   1.147 +
   1.148 +  // handles insertions on overflow
   1.149 +  void _M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __false_type& /*_Movable*/,
   1.150 +                              size_type __fill_len, bool __atend);
   1.151 +  void _M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __true_type& /*_Movable*/,
   1.152 +                              size_type __fill_len, bool __atend) {
   1.153 +    //We need to take care of self referencing here:
   1.154 +    if (_M_is_inside(__x)) {
   1.155 +      value_type __x_copy = __x;
   1.156 +      _M_insert_overflow_aux(__pos, __x_copy, __false_type(), __fill_len, __atend);
   1.157 +      return;
   1.158 +    }
   1.159 +    _M_insert_overflow_aux(__pos, __x, __false_type(), __fill_len, __atend);
   1.160 +  }
   1.161 +
   1.162 +  void _M_insert_overflow(pointer __pos, const _Tp& __x, const __false_type& /*_TrivialCopy*/,
   1.163 +                          size_type __fill_len, bool __atend = false)
   1.164 +  { _M_insert_overflow_aux(__pos, __x, _Movable(), __fill_len, __atend); }
   1.165 +  void _M_insert_overflow(pointer __pos, const _Tp& __x, const __true_type& /*_TrivialCopy*/,
   1.166 +                          size_type __fill_len, bool __atend = false);
   1.167 +  void _M_range_check(size_type __n) const {
   1.168 +    if (__n >= size_type(this->_M_finish - this->_M_start))
   1.169 +      this->_M_throw_out_of_range();
   1.170 +  }
   1.171 +
   1.172 +public:
   1.173 +  iterator begin()             { return this->_M_start; }
   1.174 +  const_iterator begin() const { return this->_M_start; }
   1.175 +  iterator end()               { return this->_M_finish; }
   1.176 +  const_iterator end() const   { return this->_M_finish; }
   1.177 +
   1.178 +  reverse_iterator rbegin()              { return reverse_iterator(end()); }
   1.179 +  const_reverse_iterator rbegin() const  { return const_reverse_iterator(end()); }
   1.180 +  reverse_iterator rend()                { return reverse_iterator(begin()); }
   1.181 +  const_reverse_iterator rend() const    { return const_reverse_iterator(begin()); }
   1.182 +
   1.183 +  size_type size() const        { return size_type(this->_M_finish - this->_M_start); }
   1.184 +  size_type max_size() const {
   1.185 +    size_type __vector_max_size = size_type(-1) / sizeof(_Tp);
   1.186 +    typename allocator_type::size_type __alloc_max_size = this->_M_end_of_storage.max_size();
   1.187 +    return (__alloc_max_size < __vector_max_size)?__alloc_max_size:__vector_max_size;
   1.188 +  }
   1.189 +
   1.190 +  size_type capacity() const    { return size_type(this->_M_end_of_storage._M_data - this->_M_start); }
   1.191 +  bool empty() const            { return this->_M_start == this->_M_finish; }
   1.192 +
   1.193 +  reference operator[](size_type __n) { return *(begin() + __n); }
   1.194 +  const_reference operator[](size_type __n) const { return *(begin() + __n); }
   1.195 +
   1.196 +  reference front()             { return *begin(); }
   1.197 +  const_reference front() const { return *begin(); }
   1.198 +  reference back()              { return *(end() - 1); }
   1.199 +  const_reference back() const  { return *(end() - 1); }
   1.200 +
   1.201 +  reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
   1.202 +  const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
   1.203 +
   1.204 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.205 +  explicit vector(const allocator_type& __a = allocator_type())
   1.206 +#else
   1.207 +  vector()
   1.208 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(allocator_type()) {}
   1.209 +  vector(const allocator_type& __a)
   1.210 +#endif
   1.211 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__a) {}
   1.212 +
   1.213 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.214 +private:
   1.215 +  //We always call _M_initialize with only 1 parameter. Default parameter
   1.216 +  //is used to allow explicit instanciation of vector with types with no
   1.217 +  //default constructor.
   1.218 +  void _M_initialize(size_type __n, const _Tp& __val = _STLP_DEFAULT_CONSTRUCTED(_Tp))
   1.219 +  { this->_M_finish = _STLP_PRIV __uninitialized_init(this->_M_start, __n, __val); }
   1.220 +public:
   1.221 +  explicit vector(size_type __n)
   1.222 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type())
   1.223 +  { _M_initialize(__n); }
   1.224 +  vector(size_type __n, const _Tp& __val, const allocator_type& __a = allocator_type())
   1.225 +#else
   1.226 +  explicit vector(size_type __n)
   1.227 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type())
   1.228 +  { this->_M_finish = _STLP_PRIV __uninitialized_init(this->_M_start, __n, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
   1.229 +  vector(size_type __n, const _Tp& __val)
   1.230 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type())
   1.231 +  { this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); }
   1.232 +  vector(size_type __n, const _Tp& __val, const allocator_type& __a)
   1.233 +#endif
   1.234 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, __a)
   1.235 +  { this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); }
   1.236 +
   1.237 +  vector(const _Self& __x)
   1.238 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__x.size(), __x.get_allocator())
   1.239 +  { this->_M_finish = _STLP_PRIV __ucopy_ptrs(__x.begin(), __x.end(), this->_M_start, _TrivialUCopy()); }
   1.240 +
   1.241 +  vector(__move_source<_Self> src)
   1.242 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__move_source<_Base>(src.get()))
   1.243 +  {}
   1.244 +
   1.245 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.246 +private:
   1.247 +  template <class _Integer>
   1.248 +  void _M_initialize_aux(_Integer __n, _Integer __val,
   1.249 +                         const __true_type& /*_IsIntegral*/) {
   1.250 +    size_type __real_n;
   1.251 +    this->_M_start = this->_M_end_of_storage.allocate(__n, __real_n);
   1.252 +    this->_M_end_of_storage._M_data = this->_M_start + __real_n;
   1.253 +    this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val);
   1.254 +  }
   1.255 +
   1.256 +  template <class _InputIterator>
   1.257 +  void _M_initialize_aux(_InputIterator __first, _InputIterator __last,
   1.258 +                         const __false_type& /*_IsIntegral*/)
   1.259 +  { _M_range_initialize(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); }
   1.260 +
   1.261 +public:
   1.262 +  // Check whether it's an integral type.  If so, it's not an iterator.
   1.263 +  template <class _InputIterator>
   1.264 +  vector(_InputIterator __first, _InputIterator __last,
   1.265 +               const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL )
   1.266 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__a) {
   1.267 +    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
   1.268 +    _M_initialize_aux(__first, __last, _Integral());
   1.269 +  }
   1.270 +
   1.271 +#  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
   1.272 +  template <class _InputIterator>
   1.273 +  vector(_InputIterator __first, _InputIterator __last)
   1.274 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(allocator_type()) {
   1.275 +    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
   1.276 +    _M_initialize_aux(__first, __last, _Integral());
   1.277 +  }
   1.278 +#  endif /* _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS */
   1.279 +
   1.280 +#else /* _STLP_MEMBER_TEMPLATES */
   1.281 +  vector(const _Tp* __first, const _Tp* __last,
   1.282 +         const allocator_type& __a = allocator_type())
   1.283 +    : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__last - __first, __a)
   1.284 +  { this->_M_finish = _STLP_PRIV __ucopy_ptrs(__first, __last, this->_M_start, _TrivialUCopy()); }
   1.285 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.286 +
   1.287 +  //As the vector container is a back insert oriented container it
   1.288 +  //seems rather logical to destroy elements in reverse order.
   1.289 +  ~vector() { _STLP_STD::_Destroy_Range(rbegin(), rend()); }
   1.290 +
   1.291 +  _Self& operator=(const _Self& __x);
   1.292 +
   1.293 +  void reserve(size_type __n);
   1.294 +
   1.295 +  // assign(), a generalized assignment member function.  Two
   1.296 +  // versions: one that takes a count, and one that takes a range.
   1.297 +  // The range version is a member template, so we dispatch on whether
   1.298 +  // or not the type is an integer.
   1.299 +
   1.300 +  void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); }
   1.301 +  void _M_fill_assign(size_type __n, const _Tp& __val);
   1.302 +
   1.303 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.304 +  template <class _ForwardIter>
   1.305 +  void _M_assign_aux(_ForwardIter __first, _ForwardIter __last, const forward_iterator_tag &) {
   1.306 +#else
   1.307 +  void assign(const_iterator __first, const_iterator __last) {
   1.308 +    typedef const_iterator _ForwardIter;
   1.309 +#endif
   1.310 +    const size_type __len = distance(__first, __last);
   1.311 +    if (__len > capacity()) {
   1.312 +      size_type __n = __len;
   1.313 +      iterator __tmp = _M_allocate_and_copy(__n, __first, __last);
   1.314 +      _M_clear();
   1.315 +      _M_set(__tmp, __tmp + __len, __tmp + __n);
   1.316 +    }
   1.317 +    else if (size() >= __len) {
   1.318 +      iterator __new_finish = copy(__first, __last, this->_M_start);
   1.319 +      _STLP_STD::_Destroy_Range(__new_finish, this->_M_finish);
   1.320 +      this->_M_finish = __new_finish;
   1.321 +    }
   1.322 +    else {
   1.323 +      _ForwardIter __mid = __first;
   1.324 +      advance(__mid, size());
   1.325 +      copy(__first, __mid, this->_M_start);
   1.326 +      this->_M_finish = uninitialized_copy(__mid, __last, this->_M_finish);
   1.327 +    }
   1.328 +  }
   1.329 +
   1.330 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.331 +  template <class _InputIter>
   1.332 +  void _M_assign_aux(_InputIter __first, _InputIter __last,
   1.333 +                     const input_iterator_tag &) {
   1.334 +    iterator __cur = begin();
   1.335 +    for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
   1.336 +      *__cur = *__first;
   1.337 +    if (__first == __last)
   1.338 +      erase(__cur, end());
   1.339 +    else
   1.340 +      insert(end(), __first, __last);
   1.341 +  }
   1.342 +
   1.343 +  template <class _Integer>
   1.344 +  void _M_assign_dispatch(_Integer __n, _Integer __val,
   1.345 +                          const __true_type& /*_IsIntegral*/)
   1.346 +  { _M_fill_assign(__n, __val); }
   1.347 +
   1.348 +  template <class _InputIter>
   1.349 +  void _M_assign_dispatch(_InputIter __first, _InputIter __last,
   1.350 +                          const __false_type& /*_IsIntegral*/)
   1.351 +  { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }
   1.352 +
   1.353 +  template <class _InputIterator>
   1.354 +  void assign(_InputIterator __first, _InputIterator __last) {
   1.355 +    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
   1.356 +    _M_assign_dispatch(__first, __last, _Integral());
   1.357 +  }
   1.358 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.359 +
   1.360 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.361 +  void push_back(const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) {
   1.362 +#else
   1.363 +  void push_back(const _Tp& __x) {
   1.364 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.365 +    if (this->_M_finish != this->_M_end_of_storage._M_data) {
   1.366 +      _Copy_Construct(this->_M_finish, __x);
   1.367 +      ++this->_M_finish;
   1.368 +    }
   1.369 +    else
   1.370 +      _M_insert_overflow(this->_M_finish, __x, _TrivialCopy(), 1UL, true);
   1.371 +  }
   1.372 +
   1.373 +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
   1.374 +  iterator insert(iterator __pos, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp));
   1.375 +#else
   1.376 +  iterator insert(iterator __pos, const _Tp& __x);
   1.377 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.378 +
   1.379 +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
   1.380 +  void push_back() { push_back(_STLP_DEFAULT_CONSTRUCTED(_Tp)); }
   1.381 +  iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
   1.382 +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.383 +
   1.384 +  void swap(_Self& __x) {
   1.385 +    _STLP_STD::swap(this->_M_start, __x._M_start);
   1.386 +    _STLP_STD::swap(this->_M_finish, __x._M_finish);
   1.387 +    this->_M_end_of_storage.swap(__x._M_end_of_storage);
   1.388 +  }
   1.389 +
   1.390 +private:
   1.391 +  void _M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __true_type& /*_Movable*/);
   1.392 +  void _M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __false_type& /*_Movable*/);
   1.393 +  void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x);
   1.394 +
   1.395 +  bool _M_is_inside(const value_type& __x) const {
   1.396 +    return (&__x >= this->_M_start && &__x < this->_M_finish);
   1.397 +  }
   1.398 +
   1.399 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.400 +  template <class _ForwardIterator>
   1.401 +  void _M_range_insert_realloc(iterator __pos,
   1.402 +                               _ForwardIterator __first, _ForwardIterator __last,
   1.403 +#else
   1.404 +  void _M_range_insert_realloc(iterator __pos,
   1.405 +                               const_iterator __first, const_iterator __last,
   1.406 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.407 +                               size_type __n) {
   1.408 +    const size_type __old_size = size();
   1.409 +    size_type __len = __old_size + (max)(__old_size, __n);
   1.410 +    pointer __new_start = this->_M_end_of_storage.allocate(__len, __len);
   1.411 +    pointer __new_finish = __new_start;
   1.412 +    _STLP_TRY {
   1.413 +      __new_finish = _STLP_PRIV __uninitialized_move(this->_M_start, __pos, __new_start, _TrivialUCopy(), _Movable());
   1.414 +      __new_finish = uninitialized_copy(__first, __last, __new_finish);
   1.415 +      __new_finish = _STLP_PRIV __uninitialized_move(__pos, this->_M_finish, __new_finish, _TrivialUCopy(), _Movable());
   1.416 +    }
   1.417 +    _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish),
   1.418 +                  this->_M_end_of_storage.deallocate(__new_start,__len)))
   1.419 +    _M_clear_after_move();
   1.420 +    _M_set(__new_start, __new_finish, __new_start + __len);
   1.421 +  }
   1.422 +
   1.423 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.424 +  template <class _ForwardIterator>
   1.425 +  void _M_range_insert_aux(iterator __pos,
   1.426 +                           _ForwardIterator __first, _ForwardIterator __last,
   1.427 +#else
   1.428 +  void _M_range_insert_aux(iterator __pos,
   1.429 +                           const_iterator __first, const_iterator __last,
   1.430 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.431 +                           size_type __n, const __true_type& /*_Movable*/) {
   1.432 +    iterator __src = this->_M_finish - 1;
   1.433 +    iterator __dst = __src + __n;
   1.434 +    for (; __src >= __pos; --__dst, --__src) {
   1.435 +      _STLP_STD::_Move_Construct(__dst, *__src);
   1.436 +      _STLP_STD::_Destroy_Moved(__src);
   1.437 +    }
   1.438 +    uninitialized_copy(__first, __last, __pos);
   1.439 +    this->_M_finish += __n;
   1.440 +  }
   1.441 +
   1.442 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.443 +  template <class _ForwardIterator>
   1.444 +  void _M_range_insert_aux(iterator __pos,
   1.445 +                           _ForwardIterator __first, _ForwardIterator __last,
   1.446 +#else
   1.447 +  void _M_range_insert_aux(iterator __pos,
   1.448 +                           const_iterator __first, const_iterator __last,
   1.449 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.450 +                           size_type __n, const __false_type& /*_Movable*/) {
   1.451 +    const size_type __elems_after = this->_M_finish - __pos;
   1.452 +    pointer __old_finish = this->_M_finish;
   1.453 +    if (__elems_after > __n) {
   1.454 +      _STLP_PRIV __ucopy_ptrs(this->_M_finish - __n, this->_M_finish, this->_M_finish, _TrivialUCopy());
   1.455 +      this->_M_finish += __n;
   1.456 +      _STLP_PRIV __copy_backward_ptrs(__pos, __old_finish - __n, __old_finish, _TrivialCopy());
   1.457 +      copy(__first, __last, __pos);
   1.458 +    }
   1.459 +    else {
   1.460 +#if defined ( _STLP_MEMBER_TEMPLATES )
   1.461 +      _ForwardIterator __mid = __first;
   1.462 +      advance(__mid, __elems_after);
   1.463 +#else
   1.464 +      const_pointer __mid = __first + __elems_after;
   1.465 +#endif
   1.466 +      uninitialized_copy(__mid, __last, this->_M_finish);
   1.467 +      this->_M_finish += __n - __elems_after;
   1.468 +      _STLP_PRIV __ucopy_ptrs(__pos, __old_finish, this->_M_finish, _TrivialUCopy());
   1.469 +      this->_M_finish += __elems_after;
   1.470 +      copy(__first, __mid, __pos);
   1.471 +    } /* elems_after */
   1.472 +  }
   1.473 +
   1.474 +
   1.475 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.476 +  template <class _Integer>
   1.477 +  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
   1.478 +                          const __true_type&)
   1.479 +  { _M_fill_insert(__pos, (size_type) __n, (_Tp) __val); }
   1.480 +
   1.481 +  template <class _InputIterator>
   1.482 +  void _M_insert_dispatch(iterator __pos,
   1.483 +                          _InputIterator __first, _InputIterator __last,
   1.484 +                          const __false_type&)
   1.485 +  { _M_range_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); }
   1.486 +
   1.487 +public:
   1.488 +  // Check whether it's an integral type.  If so, it's not an iterator.
   1.489 +  template <class _InputIterator>
   1.490 +  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
   1.491 +    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
   1.492 +    _M_insert_dispatch(__pos, __first, __last, _Integral());
   1.493 +  }
   1.494 +
   1.495 +private:
   1.496 +  template <class _InputIterator>
   1.497 +  void _M_range_insert(iterator __pos,
   1.498 +                       _InputIterator __first, _InputIterator __last,
   1.499 +                       const input_iterator_tag &) {
   1.500 +    for ( ; __first != __last; ++__first) {
   1.501 +      __pos = insert(__pos, *__first);
   1.502 +      ++__pos;
   1.503 +    }
   1.504 +  }
   1.505 +
   1.506 +  template <class _ForwardIterator>
   1.507 +  void _M_range_insert(iterator __pos,
   1.508 +                       _ForwardIterator __first, _ForwardIterator __last,
   1.509 +                       const forward_iterator_tag &) {
   1.510 +#else /* _STLP_MEMBER_TEMPLATES */
   1.511 +public:
   1.512 +  void insert(iterator __pos,
   1.513 +              const_iterator __first, const_iterator __last) {
   1.514 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.515 +    /* This method do not check self referencing.
   1.516 +     * Standard forbids it, checked by the debug mode.
   1.517 +     */
   1.518 +    if (__first != __last) {
   1.519 +      size_type __n = distance(__first, __last);
   1.520 +
   1.521 +      if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) {
   1.522 +        _M_range_insert_aux(__pos, __first, __last, __n, _Movable());
   1.523 +      }
   1.524 +      else {
   1.525 +        _M_range_insert_realloc(__pos, __first, __last, __n);
   1.526 +      }
   1.527 +    }
   1.528 +  }
   1.529 +
   1.530 +public:
   1.531 +  void insert (iterator __pos, size_type __n, const _Tp& __x)
   1.532 +  { _M_fill_insert(__pos, __n, __x); }
   1.533 +
   1.534 +  void pop_back() {
   1.535 +    --this->_M_finish;
   1.536 +    _STLP_STD::_Destroy(this->_M_finish);
   1.537 +  }
   1.538 +
   1.539 +private:
   1.540 +  iterator _M_erase(iterator __pos, const __true_type& /*_Movable*/) {
   1.541 +    _STLP_STD::_Destroy(__pos);
   1.542 +    iterator __dst = __pos, __src = __dst + 1;
   1.543 +    iterator __end = end();
   1.544 +    for (; __src != __end; ++__dst, ++__src) {
   1.545 +      _STLP_STD::_Move_Construct(__dst, *__src);
   1.546 +      _STLP_STD::_Destroy_Moved(__src);
   1.547 +    }
   1.548 +    this->_M_finish = __dst;
   1.549 +    return __pos;
   1.550 +  }
   1.551 +  iterator _M_erase(iterator __pos, const __false_type& /*_Movable*/) {
   1.552 +    if (__pos + 1 != end())
   1.553 +      _STLP_PRIV __copy_ptrs(__pos + 1, this->_M_finish, __pos, _TrivialCopy());
   1.554 +    --this->_M_finish;
   1.555 +    _STLP_STD::_Destroy(this->_M_finish);
   1.556 +    return __pos;
   1.557 +  }
   1.558 +  iterator _M_erase(iterator __first, iterator __last, const __true_type& /*_Movable*/) {
   1.559 +    iterator __dst = __first, __src = __last;
   1.560 +    iterator __end = end();
   1.561 +    for (; __dst != __last && __src != __end; ++__dst, ++__src) {
   1.562 +      _STLP_STD::_Destroy(__dst);
   1.563 +      _STLP_STD::_Move_Construct(__dst, *__src);
   1.564 +    }
   1.565 +    if (__dst != __last) {
   1.566 +      //There is more elements to erase than element to move:
   1.567 +      _STLP_STD::_Destroy_Range(__dst, __last);
   1.568 +      _STLP_STD::_Destroy_Moved_Range(__last, __end);
   1.569 +    }
   1.570 +    else {
   1.571 +      //There is more element to move than element to erase:
   1.572 +      for (; __src != __end; ++__dst, ++__src) {
   1.573 +        _STLP_STD::_Destroy_Moved(__dst);
   1.574 +        _STLP_STD::_Move_Construct(__dst, *__src);
   1.575 +      }
   1.576 +      _STLP_STD::_Destroy_Moved_Range(__dst, __end);
   1.577 +    }
   1.578 +    this->_M_finish = __dst;
   1.579 +    return __first;
   1.580 +  }
   1.581 +  iterator _M_erase(iterator __first, iterator __last, const __false_type& /*_Movable*/) {
   1.582 +    pointer __i = _STLP_PRIV __copy_ptrs(__last, this->_M_finish, __first, _TrivialCopy());
   1.583 +    _STLP_STD::_Destroy_Range(__i, this->_M_finish);
   1.584 +    this->_M_finish = __i;
   1.585 +    return __first;
   1.586 +  }
   1.587 +
   1.588 +public:
   1.589 +  iterator erase(iterator __pos) {
   1.590 +    return _M_erase(__pos, _Movable());
   1.591 +  }
   1.592 +  iterator erase(iterator __first, iterator __last) {
   1.593 +    if (__first == __last)
   1.594 +      return __first;
   1.595 +    return _M_erase(__first, __last, _Movable());
   1.596 +  }
   1.597 +
   1.598 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.599 +  void resize(size_type __new_size, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) {
   1.600 +#else
   1.601 +  void resize(size_type __new_size, const _Tp& __x) {
   1.602 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.603 +    if (__new_size < size())
   1.604 +      erase(begin() + __new_size, end());
   1.605 +    else
   1.606 +      insert(end(), __new_size - size(), __x);
   1.607 +  }
   1.608 +
   1.609 +#if defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.610 +  void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
   1.611 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.612 +
   1.613 +  void clear() {
   1.614 +    erase(begin(), end());
   1.615 +  }
   1.616 +
   1.617 +private:
   1.618 +  void _M_clear() {
   1.619 +    _STLP_STD::_Destroy_Range(rbegin(), rend());
   1.620 +    this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start);
   1.621 +  }
   1.622 +
   1.623 +  void _M_clear_after_move() {
   1.624 +    _STLP_STD::_Destroy_Moved_Range(rbegin(), rend());
   1.625 +    this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start);
   1.626 +  }
   1.627 +
   1.628 +  void _M_set(pointer __s, pointer __f, pointer __e) {
   1.629 +    this->_M_start = __s;
   1.630 +    this->_M_finish = __f;
   1.631 +    this->_M_end_of_storage._M_data = __e;
   1.632 +  }
   1.633 +
   1.634 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.635 +  template <class _ForwardIterator>
   1.636 +  pointer _M_allocate_and_copy(size_type& __n,
   1.637 +                               _ForwardIterator __first, _ForwardIterator __last)
   1.638 +#else /* _STLP_MEMBER_TEMPLATES */
   1.639 +  pointer _M_allocate_and_copy(size_type& __n,
   1.640 +                               const_pointer __first, const_pointer __last)
   1.641 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.642 +  {
   1.643 +    pointer __result = this->_M_end_of_storage.allocate(__n, __n);
   1.644 +    _STLP_TRY {
   1.645 +      uninitialized_copy(__first, __last, __result);
   1.646 +      return __result;
   1.647 +    }
   1.648 +    _STLP_UNWIND(this->_M_end_of_storage.deallocate(__result, __n))
   1.649 +    _STLP_RET_AFTER_THROW(__result)
   1.650 +  }
   1.651 +
   1.652 +
   1.653 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.654 +  template <class _InputIterator>
   1.655 +  void _M_range_initialize(_InputIterator __first, _InputIterator __last,
   1.656 +                           const input_iterator_tag &) {
   1.657 +    for ( ; __first != __last; ++__first)
   1.658 +      push_back(*__first);
   1.659 +  }
   1.660 +  // This function is only called by the constructor.
   1.661 +  template <class _ForwardIterator>
   1.662 +  void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
   1.663 +                           const forward_iterator_tag &) {
   1.664 +    size_type __n = distance(__first, __last);
   1.665 +    this->_M_start = this->_M_end_of_storage.allocate(__n, __n);
   1.666 +    this->_M_end_of_storage._M_data = this->_M_start + __n;
   1.667 +    this->_M_finish = uninitialized_copy(__first, __last, this->_M_start);
   1.668 +  }
   1.669 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.670 +};
   1.671 +
   1.672 +#if defined (vector)
   1.673 +#  undef vector
   1.674 +_STLP_MOVE_TO_STD_NAMESPACE
   1.675 +#endif
   1.676 +
   1.677 +_STLP_END_NAMESPACE
   1.678 +
   1.679 +#if !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.680 +#  include <stl/_vector.c>
   1.681 +#endif
   1.682 +
   1.683 +#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
   1.684 +#  include <stl/pointers/_vector.h>
   1.685 +#endif
   1.686 +
   1.687 +//We define the bool specialization before the debug interfave
   1.688 +//to benefit of the debug version of vector even for the bool
   1.689 +//specialization.
   1.690 +#if !defined (_STLP_NO_BOOL) || !defined (_STLP_NO_EXTENSIONS)
   1.691 +#  if !defined (_STLP_INTERNAL_BVECTOR_H)
   1.692 +#    include <stl/_bvector.h>
   1.693 +#  endif
   1.694 +#endif
   1.695 +
   1.696 +#if defined (_STLP_DEBUG)
   1.697 +#  include <stl/debug/_vector.h>
   1.698 +#endif
   1.699 +
   1.700 +_STLP_BEGIN_NAMESPACE
   1.701 +
   1.702 +#if !defined (_STLP_NO_BOOL) && !defined (_STLP_NO_EXTENSIONS)
   1.703 +// This typedef is non-standard.  It is provided for backward compatibility.
   1.704 +typedef vector<bool, allocator<bool> > bit_vector;
   1.705 +#endif
   1.706 +
   1.707 +#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
   1.708 +#define _STLP_TEMPLATE_CONTAINER vector<_Tp, _Alloc>
   1.709 +#include <stl/_relops_cont.h>
   1.710 +#undef _STLP_TEMPLATE_CONTAINER
   1.711 +#undef _STLP_TEMPLATE_HEADER
   1.712 +
   1.713 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
   1.714 +template <class _Tp, class _Alloc>
   1.715 +struct __move_traits<vector<_Tp, _Alloc> > {
   1.716 +  typedef __stlp_movable implemented;
   1.717 +  typedef typename __move_traits<_Alloc>::complete complete;
   1.718 +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x560)
   1.719 +  // disable incorrect "dependent type qualifier" error
   1.720 +  typedef __false_type _Ret;
   1.721 +#endif
   1.722 +};
   1.723 +
   1.724 +#  if !defined (_STLP_DEBUG)
   1.725 +template <class _Tp, class _Alloc>
   1.726 +struct _DefaultZeroValue<vector<_Tp, _Alloc> >
   1.727 +{ typedef typename __type_traits<_Alloc>::has_trivial_default_constructor _Ret; };
   1.728 +#  endif
   1.729 +
   1.730 +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
   1.731 +
   1.732 +_STLP_END_NAMESPACE
   1.733 +
   1.734 +#endif /* _STLP_VECTOR_H */
   1.735 +
   1.736 +// Local Variables:
   1.737 +// mode:C++
   1.738 +// End: