epoc32/include/stdapis/stlport/stl/_vector.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /*
     2  *
     3  * Copyright (c) 1994
     4  * Hewlett-Packard Company
     5  *
     6  * Copyright (c) 1996,1997
     7  * Silicon Graphics Computer Systems, Inc.
     8  *
     9  * Copyright (c) 1997
    10  * Moscow Center for SPARC Technology
    11  *
    12  * Copyright (c) 1999 
    13  * Boris Fomitchev
    14  *
    15  * This material is provided "as is", with absolutely no warranty expressed
    16  * or implied. Any use is at your own risk.
    17  *
    18  * Permission to use or copy this software for any purpose is hereby granted 
    19  * without fee, provided the above notices are retained on all copies.
    20  * Permission to modify the code and to distribute modified code is granted,
    21  * provided the above notices are retained, and a notice that the code was
    22  * modified is included with the above copyright notice.
    23  *
    24  */
    25 
    26 /* NOTE: This is an internal header file, included by other STL headers.
    27  *   You should not attempt to use it directly.
    28  */
    29 
    30 #ifndef _STLP_INTERNAL_VECTOR_H
    31 #define _STLP_INTERNAL_VECTOR_H
    32 
    33 
    34 
    35 # ifndef _STLP_INTERNAL_ALGOBASE_H
    36 #  include <stl/_algobase.h>
    37 # endif
    38 
    39 # ifndef _STLP_INTERNAL_ALLOC_H
    40 #  include <stl/_alloc.h>
    41 # endif
    42 
    43 # ifndef _STLP_INTERNAL_ITERATOR_H
    44 #  include <stl/_iterator.h>
    45 # endif
    46 
    47 # ifndef _STLP_INTERNAL_UNINITIALIZED_H
    48 #  include <stl/_uninitialized.h>
    49 # endif
    50 
    51 # ifndef _STLP_RANGE_ERRORS_H
    52 #  include <stl/_range_errors.h>
    53 # endif
    54 
    55 #  undef  vector
    56 #  define vector __WORKAROUND_DBG_RENAME(vector)
    57 
    58 _STLP_BEGIN_NAMESPACE 
    59 
    60 // The vector base class serves two purposes.  First, its constructor
    61 // and destructor allocate (but don't initialize) storage.  This makes
    62 // exception safety easier.
    63 
    64 template <class _Tp, class _Alloc> 
    65 class _Vector_base {
    66 public:
    67   typedef _Vector_base<_Tp, _Alloc> _Base;
    68   _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
    69   typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
    70 
    71   _Vector_base(const _Alloc& __a)
    72     : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {
    73     // no push here as not needed
    74   }
    75   _Vector_base(size_t __n, const _Alloc& __a)
    76     : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0)
    77   {
    78     _STLP_PUSH_CLEANUP_ITEM(_Base, this)
    79     _M_start = _M_end_of_storage.allocate(__n);
    80     _M_finish = _M_start;
    81     _M_end_of_storage._M_data = _M_start + __n;
    82     _STLP_MPWFIX_TRY _STLP_MPWFIX_CATCH
    83   }
    84 
    85   ~_Vector_base() { 
    86     if (_M_start !=0) 
    87     _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start); 
    88   }
    89 
    90 protected:
    91   _Tp* _M_start;
    92   _Tp* _M_finish;
    93   _STLP_alloc_proxy<_Tp*, _Tp, allocator_type> _M_end_of_storage;
    94 };
    95 
    96 template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
    97 class vector : public _Vector_base<_Tp, _Alloc> 
    98 {
    99 private:
   100   typedef _Vector_base<_Tp, _Alloc> _Base;
   101 public:
   102   typedef _Tp value_type;
   103   typedef value_type* pointer;
   104   typedef const value_type* const_pointer;
   105   typedef value_type* iterator;
   106   typedef const value_type* const_iterator;
   107 
   108 public:
   109   typedef value_type& reference;
   110   typedef const value_type& const_reference;
   111   typedef size_t size_type;
   112   typedef ptrdiff_t difference_type;
   113   typedef random_access_iterator_tag _Iterator_category;
   114 
   115   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
   116   _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
   117   typedef typename _Vector_base<_Tp, _Alloc>::allocator_type allocator_type;
   118 
   119   allocator_type get_allocator() const {
   120     return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _Tp);
   121   }
   122 
   123 #ifdef _STLP_USE_TRAP_LEAVE
   124 public:
   125   static void* operator new (size_t __n, TLeave) { return _STLP_StackHelper<bool>::_NewLC(__n); }
   126   static void* operator new (size_t __n) { return _STLP_StackHelper<bool>::_NewLC(__n); }
   127 #endif
   128 
   129 protected:
   130   typedef typename  __type_traits<_Tp>::has_trivial_assignment_operator _TrivialAss;
   131   typedef typename  __type_traits<_Tp>::has_trivial_assignment_operator _IsPODType;
   132 
   133   // handles insertions on overflow
   134   void _M_insert_overflow(pointer __position, const _Tp& __x, const __false_type&, 
   135 			  size_type __fill_len, bool __atend = false) {
   136     const size_type __old_size = size();
   137     const size_type __len = __old_size + (max)(__old_size, __fill_len);
   138     
   139     _STLP_LEAVE_VOLATILE pointer __new_start = this->_M_end_of_storage.allocate(__len);
   140     _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   141     _STLP_TRY {
   142       __new_finish = __uninitialized_copy(this->_M_start, __position, __new_start, __false_type());
   143       // handle insertion
   144       if (__fill_len == 1) {
   145         _Construct(__new_finish, __x);
   146         ++__new_finish;
   147       } else
   148         __new_finish = __uninitialized_fill_n(__new_finish, __fill_len, __x, __false_type());
   149       if (!__atend)
   150         // copy remainder
   151         __new_finish = __uninitialized_copy(__position, this->_M_finish, __new_finish, __false_type());
   152     }
   153     _STLP_UNWIND((_Destroy(__new_start,__new_finish), 
   154                   this->_M_end_of_storage.deallocate(__new_start,__len)));
   155     _M_clear();
   156     _M_set(__new_start, __new_finish, __new_start + __len);
   157   }
   158 
   159   void _M_insert_overflow(pointer __position, const _Tp& __x, const __true_type&, 
   160 			  size_type __fill_len, bool __atend = false) {
   161     const size_type __old_size = size();
   162     const size_type __len = __old_size + (max)(__old_size, __fill_len);
   163     
   164     pointer __new_start = this->_M_end_of_storage.allocate(__len);
   165     pointer __new_finish = (pointer)__copy_trivial(this->_M_start, __position, __new_start);
   166       // handle insertion
   167     __new_finish = fill_n(__new_finish, __fill_len, __x);
   168     if (!__atend)
   169       // copy remainder
   170       __new_finish = (pointer)__copy_trivial(__position, this->_M_finish, __new_finish);
   171     _M_clear();
   172     _M_set(__new_start, __new_finish, __new_start + __len);
   173   }
   174  
   175   void _M_range_check(size_type __n) const {
   176     if (__n >= size_type(this->_M_finish-this->_M_start))
   177       __stl_throw_out_of_range("vector");
   178   }
   179 
   180 public:
   181   iterator begin()             { return this->_M_start; }
   182   const_iterator begin() const { return this->_M_start; }
   183   iterator end()               { return this->_M_finish; }
   184   const_iterator end() const   { return this->_M_finish; }
   185 
   186   reverse_iterator rbegin()              { return reverse_iterator(end()); }
   187   const_reverse_iterator rbegin() const  { return const_reverse_iterator(end()); }
   188   reverse_iterator rend()                { return reverse_iterator(begin()); }
   189   const_reverse_iterator rend() const    { return const_reverse_iterator(begin()); }
   190 
   191   size_type size() const        { return size_type(this->_M_finish - this->_M_start); }
   192   size_type max_size() const    { return size_type(-1) / sizeof(_Tp); }
   193   size_type capacity() const    { return size_type(this->_M_end_of_storage._M_data - this->_M_start); }
   194   bool empty() const            { return this->_M_start == this->_M_finish; }
   195 
   196   reference operator[](size_type __n) { return *(begin() + __n); }
   197   const_reference operator[](size_type __n) const { return *(begin() + __n); }
   198 
   199   reference front()             { return *begin(); }
   200   const_reference front() const { return *begin(); }
   201   reference back()              { return *(end() - 1); }
   202   const_reference back() const  { return *(end() - 1); }
   203 
   204   reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
   205   const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
   206 
   207   //explicit vector(const allocator_type& __a = allocator_type()) : 
   208   vector(const allocator_type& __a = allocator_type()) : //to useimplicitly  constructor taking allocator
   209     _Vector_base<_Tp, _Alloc>(__a) {
   210     // needed for new() to work correctly
   211     _STLP_POP_IF_CHECK
   212   }
   213 
   214   vector(size_type __n, const _Tp& __val,
   215          const allocator_type& __a = allocator_type()) 
   216     : _Vector_base<_Tp, _Alloc>(__n, __a) { 
   217     this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __val); 
   218     _STLP_POP_CLEANUP_ITEM
   219   }
   220 
   221   explicit vector(size_type __n)
   222     : _Vector_base<_Tp, _Alloc>(__n, allocator_type() ) {
   223 # ifdef _STLP_USE_TRAP_LEAVE
   224       _Tp __p;
   225       _STLP_PUSH_CLEANUP_ITEM(_Tp, &__p) 
   226       this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __p); 
   227       // unconditional for __p
   228       CleanupStack::Pop();
   229       _STLP_POP_CLEANUP_ITEM
   230 # else
   231     this->_M_finish = uninitialized_fill_n(this->_M_start, __n, _Tp()); 
   232 # endif
   233   }
   234 
   235   vector(const vector<_Tp, _Alloc>& __x) 
   236     : _Vector_base<_Tp, _Alloc>(__x.size(), __x.get_allocator()) {
   237     this->_M_finish = __uninitialized_copy((const_pointer)__x._M_start, 
   238                                            (const_pointer)__x._M_finish, this->_M_start, _IsPODType());
   239     _STLP_POP_CLEANUP_ITEM 
   240   }
   241   
   242 #if defined (_STLP_MEMBER_TEMPLATES)
   243   template <class _Integer>
   244   void _M_initialize_aux(_Integer __n, _Integer __val, const __true_type&) {
   245     this->_M_start = this->_M_end_of_storage.allocate(__n);
   246     this->_M_end_of_storage._M_data = this->_M_start + __n; 
   247     this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __val);
   248   }
   249 
   250   template <class _InputIterator>
   251   void _M_initialize_aux(_InputIterator __first, _InputIterator __last,
   252                          const __false_type&) {
   253     _M_range_initialize(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
   254   }
   255 
   256   // Check whether it's an integral type.  If so, it's not an iterator.
   257  # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
   258   template <class _InputIterator>
   259   vector(_InputIterator __first, _InputIterator __last) :
   260     _Vector_base<_Tp, _Alloc>(allocator_type()) {
   261     typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   262     _STLP_PUSH_CLEANUP_ITEM(_Base, this) 
   263     _M_initialize_aux(__first, __last, _Integral());
   264     _STLP_POP_CLEANUP_ITEM
   265   }
   266  # endif
   267   template <class _InputIterator>
   268   vector(_InputIterator __first, _InputIterator __last,
   269          const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL ) :
   270     _Vector_base<_Tp, _Alloc>(__a) {
   271     typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   272     _STLP_PUSH_CLEANUP_ITEM(_Base, this) 
   273     _M_initialize_aux(__first, __last, _Integral());
   274     _STLP_POP_CLEANUP_ITEM
   275   }
   276 
   277 #else
   278   vector(const _Tp* __first, const _Tp* __last,
   279          const allocator_type& __a = allocator_type())
   280     : _Vector_base<_Tp, _Alloc>(__last - __first, __a) { 
   281       this->_M_finish = __uninitialized_copy(__first, __last, this->_M_start, _IsPODType()); 
   282     _STLP_POP_CLEANUP_ITEM
   283   }
   284 #endif /* _STLP_MEMBER_TEMPLATES */
   285 
   286   ~vector() { _Destroy(this->_M_start, this->_M_finish); }
   287 
   288   vector<_Tp, _Alloc>& operator=(const vector<_Tp, _Alloc>& __x);
   289 
   290   void reserve(size_type __n);
   291 
   292   // assign(), a generalized assignment member function.  Two
   293   // versions: one that takes a count, and one that takes a range.
   294   // The range version is a member template, so we dispatch on whether
   295   // or not the type is an integer.
   296 
   297   void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); }
   298   void _M_fill_assign(size_type __n, const _Tp& __val);
   299   
   300 #ifdef _STLP_MEMBER_TEMPLATES
   301   template <class _ForwardIter>
   302   void _M_assign_aux(_ForwardIter __first, _ForwardIter __last, const forward_iterator_tag &)
   303 #else
   304   void assign(const_iterator __first, const_iterator __last)
   305 #endif
   306   {
   307     size_type __len = distance(__first, __last);
   308     
   309     if (__len > capacity()) {
   310       iterator __tmp = _M_allocate_and_copy(__len, __first, __last);
   311     _M_clear();
   312     _M_set(__tmp, __tmp + __len, __tmp + __len);
   313     }
   314     else if (size() >= __len) {
   315       iterator __new_finish = copy(__first, __last, this->_M_start);
   316       _Destroy(__new_finish, this->_M_finish);
   317       this->_M_finish = __new_finish;
   318     }
   319     else {
   320 # if defined ( _STLP_MEMBER_TEMPLATES )
   321           _ForwardIter __mid = __first;
   322           advance(__mid, size());
   323 # else
   324           const_iterator __mid = __first + size() ;
   325 # endif
   326     copy(__first, __mid, this->_M_start);
   327     this->_M_finish = __uninitialized_copy(__mid, __last, this->_M_finish, _IsPODType());
   328     }
   329   }
   330 
   331 #ifdef _STLP_MEMBER_TEMPLATES
   332   template <class _InputIter>
   333   void _M_assign_aux(_InputIter __first, _InputIter __last,
   334 		     const input_iterator_tag &) {
   335     iterator __cur = begin();
   336     for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
   337       *__cur = *__first;
   338     if (__first == __last)
   339       erase(__cur, end());
   340     else
   341       insert(end(), __first, __last);
   342   }
   343   
   344   template <class _Integer>
   345   void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)
   346     { assign((size_type) __n, (_Tp) __val); }
   347 
   348   template <class _InputIter>
   349   void _M_assign_dispatch(_InputIter __first, _InputIter __last, const __false_type&)
   350     { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }
   351 
   352   template <class _InputIterator>
   353   void assign(_InputIterator __first, _InputIterator __last) {
   354     typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   355     _M_assign_dispatch(__first, __last, _Integral());
   356   }
   357 #endif /* _STLP_MEMBER_TEMPLATES */
   358 
   359   void push_back(const _Tp& __x) {
   360     if (this->_M_finish != this->_M_end_of_storage._M_data) {
   361       _Construct(this->_M_finish, __x);
   362       ++this->_M_finish;
   363     }
   364     else
   365       _M_insert_overflow(this->_M_finish, __x, _IsPODType(), 1UL, true);
   366   }
   367 
   368   void swap(vector<_Tp, _Alloc>& __x) {
   369     _STLP_STD::swap(this->_M_start, __x._M_start);
   370     _STLP_STD::swap(this->_M_finish, __x._M_finish);
   371     _STLP_STD::swap(this->_M_end_of_storage, __x._M_end_of_storage);
   372   }
   373 
   374   iterator insert(iterator __position, const _Tp& __x) {
   375     size_type __n = __position - begin();
   376     if (this->_M_finish != this->_M_end_of_storage._M_data) {
   377       if (__position == end()) {
   378         _Construct(this->_M_finish, __x);
   379         ++this->_M_finish;
   380       } else {
   381         _Construct(this->_M_finish, *(this->_M_finish - 1));
   382         ++this->_M_finish;
   383         _Tp __x_copy = __x;
   384         __copy_backward_ptrs(__position, this->_M_finish - 2, this->_M_finish - 1, _TrivialAss());
   385         *__position = __x_copy;
   386       }
   387     }
   388     else
   389       _M_insert_overflow(__position, __x, _IsPODType(), 1UL);
   390     return begin() + __n;
   391   }
   392 
   393 # ifndef _STLP_NO_ANACHRONISMS
   394   void push_back() { push_back(_Tp()); }
   395   iterator insert(iterator __position) { return insert(__position, _Tp()); }
   396 # endif
   397 
   398   void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x);
   399 
   400 #if defined ( _STLP_MEMBER_TEMPLATES)
   401 
   402   template <class _Integer>
   403   void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
   404                           const __true_type&) {
   405     _M_fill_insert(__pos, (size_type) __n, (_Tp) __val);
   406   }
   407 
   408   template <class _InputIterator>
   409   void _M_insert_dispatch(iterator __pos,
   410                           _InputIterator __first, _InputIterator __last,
   411                           const __false_type&) {
   412     _M_range_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
   413   }
   414 
   415   // Check whether it's an integral type.  If so, it's not an iterator.
   416   template <class _InputIterator>
   417   void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
   418     typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   419     _M_insert_dispatch(__pos, __first, __last, _Integral());
   420   }
   421 
   422   template <class _InputIterator>
   423   void _M_range_insert(iterator __pos, 
   424 		       _InputIterator __first, 
   425 		       _InputIterator __last,
   426 		       const input_iterator_tag &) {
   427     for ( ; __first != __last; ++__first) {
   428       __pos = insert(__pos, *__first);
   429       ++__pos;
   430     }
   431   }
   432 
   433   template <class _ForwardIterator>
   434   void _M_range_insert(iterator __position,
   435                        _ForwardIterator __first,
   436                        _ForwardIterator __last,
   437                        const forward_iterator_tag &) 
   438 #else /* _STLP_MEMBER_TEMPLATES */
   439   void insert(iterator __position,
   440               const_iterator __first, const_iterator __last)
   441 #endif /* _STLP_MEMBER_TEMPLATES */
   442 
   443   {
   444     if (__first != __last) {
   445       size_type __n = distance(__first, __last);
   446 
   447       if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) {
   448         const size_type __elems_after = this->_M_finish - __position;
   449         pointer __old_finish = this->_M_finish;
   450         if (__elems_after > __n) {
   451           __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _IsPODType());
   452           this->_M_finish += __n;
   453           __copy_backward_ptrs(__position, __old_finish - __n, __old_finish, _TrivialAss());
   454           copy(__first, __last, __position);
   455         }
   456         else {
   457 # if defined ( _STLP_MEMBER_TEMPLATES )
   458           _ForwardIterator __mid = __first;
   459           advance(__mid, __elems_after);
   460 # else
   461           const_pointer __mid = __first + __elems_after;
   462 # endif
   463           __uninitialized_copy(__mid, __last, this->_M_finish, _IsPODType());
   464           this->_M_finish += __n - __elems_after;
   465           __uninitialized_copy(__position, __old_finish, this->_M_finish, _IsPODType());
   466           this->_M_finish += __elems_after;
   467           copy(__first, __mid, __position);
   468         } /* elems_after */
   469       }
   470       else {
   471         const size_type __old_size = size();
   472         const size_type __len = __old_size + (max)(__old_size, __n);
   473         _STLP_LEAVE_VOLATILE pointer __new_start = this->_M_end_of_storage.allocate(__len);
   474         _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   475         _STLP_TRY {
   476           __new_finish = __uninitialized_copy(this->_M_start, __position, __new_start, _IsPODType());
   477           __new_finish = __uninitialized_copy(__first, __last, __new_finish, _IsPODType());
   478           __new_finish = __uninitialized_copy(__position, this->_M_finish, __new_finish, _IsPODType());
   479         }
   480         _STLP_UNWIND((_Destroy(__new_start,__new_finish), 
   481                       this->_M_end_of_storage.deallocate(__new_start,__len)));
   482         _M_clear();
   483         _M_set(__new_start, __new_finish, __new_start + __len);
   484       }
   485     }
   486   }
   487   void insert (iterator __pos, size_type __n, const _Tp& __x)
   488   { _M_fill_insert(__pos, __n, __x); }
   489   
   490   void pop_back() {
   491     --this->_M_finish;
   492     _Destroy(this->_M_finish);
   493   }
   494   iterator erase(iterator __position) {
   495     if (__position + 1 != end())
   496       __copy_ptrs(__position + 1, this->_M_finish, __position, _TrivialAss());
   497     --this->_M_finish;
   498     _Destroy(this->_M_finish);
   499     return __position;
   500   }
   501   iterator erase(iterator __first, iterator __last) {
   502     pointer __i = __copy_ptrs(__last, this->_M_finish, __first, _TrivialAss());
   503     _Destroy(__i, this->_M_finish);
   504     this->_M_finish = __i;
   505     return __first;
   506   }
   507 
   508   void resize(size_type __new_size, _Tp __x) {
   509     if (__new_size < size()) 
   510       erase(begin() + __new_size, end());
   511     else
   512       insert(end(), __new_size - size(), __x);
   513   }
   514 
   515   void resize(size_type __new_size) { 
   516    resize(__new_size, _Tp());
   517   }
   518 
   519   void clear() { 
   520     erase(begin(), end());
   521   }
   522 
   523 protected:
   524 
   525   void _M_clear() {
   526     //    if (this->_M_start) {
   527     _Destroy(this->_M_start, this->_M_finish);
   528     this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start);
   529     //    }
   530   }
   531 
   532   void _M_set(pointer __s, pointer __f, pointer __e) {
   533     this->_M_start = __s;
   534     this->_M_finish = __f;
   535     this->_M_end_of_storage._M_data = __e;
   536   }
   537 
   538 #ifdef _STLP_MEMBER_TEMPLATES
   539   template <class _ForwardIterator>
   540   pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, 
   541 				_ForwardIterator __last)
   542 #else /* _STLP_MEMBER_TEMPLATES */
   543   pointer _M_allocate_and_copy(size_type __n, const_pointer __first, 
   544 			       const_pointer __last)
   545 #endif /* _STLP_MEMBER_TEMPLATES */
   546   {
   547     _STLP_LEAVE_VOLATILE pointer __result = this->_M_end_of_storage.allocate(__n);
   548     _STLP_TRY {
   549 #if (!defined(__MRC__))		//*TY 12/17/2000 - added workaround for MrCpp. it confuses on nested try/catch block
   550       __uninitialized_copy(__first, __last, __result, _IsPODType());
   551 #else
   552       uninitialized_copy(__first, __last, __result);
   553 #endif
   554       //      return __result;
   555     }
   556     _STLP_UNWIND(this->_M_end_of_storage.deallocate(__result, __n));
   557     return __result;
   558   }
   559 
   560 
   561 #ifdef _STLP_MEMBER_TEMPLATES
   562   template <class _InputIterator>
   563   void _M_range_initialize(_InputIterator __first,  
   564                            _InputIterator __last, const input_iterator_tag &) {
   565     for ( ; __first != __last; ++__first)
   566       push_back(*__first);
   567   }
   568   // This function is only called by the constructor. 
   569   template <class _ForwardIterator>
   570   void _M_range_initialize(_ForwardIterator __first,
   571                            _ForwardIterator __last, const forward_iterator_tag &) {
   572     size_type __n = distance(__first, __last);
   573     this->_M_start = this->_M_end_of_storage.allocate(__n);
   574     this->_M_end_of_storage._M_data = this->_M_start + __n;
   575     this->_M_finish = __uninitialized_copy(__first, __last, this->_M_start, _IsPODType());
   576   }
   577   
   578 #endif /* _STLP_MEMBER_TEMPLATES */
   579 };
   580 
   581 # define _STLP_TEMPLATE_CONTAINER vector<_Tp, _Alloc>
   582 # define _STLP_TEMPLATE_HEADER    template <class _Tp, class _Alloc>
   583 # include <stl/_relops_cont.h>
   584 # undef _STLP_TEMPLATE_CONTAINER
   585 # undef _STLP_TEMPLATE_HEADER
   586 
   587 # if defined (_STLP_USE_TEMPLATE_EXPORT) 
   588 _STLP_EXPORT_TEMPLATE_CLASS allocator<void*>;
   589 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void**, void*, allocator<void*> >;
   590 _STLP_EXPORT_TEMPLATE_CLASS _Vector_base<void*,allocator<void*> >;
   591 _STLP_EXPORT_TEMPLATE_CLASS vector<void*,allocator<void*> >;
   592 # endif
   593 
   594 #  undef  vector
   595 #  undef  __vector__
   596 #  define __vector__ __WORKAROUND_RENAME(vector)
   597 
   598 _STLP_END_NAMESPACE
   599 
   600 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
   601 #  include <stl/_vector.c>
   602 # endif
   603 
   604 #ifndef _STLP_INTERNAL_BVECTOR_H
   605 # include <stl/_bvector.h>
   606 #endif
   607 
   608 # if defined (_STLP_DEBUG)
   609 #  include <stl/debug/_vector.h>
   610 # endif
   611 
   612 # if defined (_STLP_USE_WRAPPER_FOR_ALLOC_PARAM)
   613 #  include <stl/wrappers/_vector.h>
   614 # endif
   615 
   616 #endif /* _STLP_VECTOR_H */
   617 
   618 // Local Variables:
   619 // mode:C++
   620 // End:
   621