home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / _vector.h < prev    next >
C/C++ Source or Header  |  2002-02-02  |  21KB  |  592 lines

  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.  
  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.   }
  74.   _Vector_base(size_t __n, const _Alloc& __a)
  75.     : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0)
  76.   {
  77.     _M_start = _M_end_of_storage.allocate(__n);
  78.     _M_finish = _M_start;
  79.     _M_end_of_storage._M_data = _M_start + __n;
  80.     _STLP_MPWFIX_TRY _STLP_MPWFIX_CATCH
  81.   }
  82.  
  83.   ~_Vector_base() { 
  84.     if (_M_start !=0) 
  85.     _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start); 
  86.   }
  87.  
  88. protected:
  89.   _Tp* _M_start;
  90.   _Tp* _M_finish;
  91.   _STLP_alloc_proxy<_Tp*, _Tp, allocator_type> _M_end_of_storage;
  92. };
  93.  
  94. template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
  95. class vector : public _Vector_base<_Tp, _Alloc> 
  96. {
  97. private:
  98.   typedef _Vector_base<_Tp, _Alloc> _Base;
  99. public:
  100.   typedef _Tp value_type;
  101.   typedef value_type* pointer;
  102.   typedef const value_type* const_pointer;
  103.   typedef value_type* iterator;
  104.   typedef const value_type* const_iterator;
  105.  
  106. public:
  107.   typedef value_type& reference;
  108.   typedef const value_type& const_reference;
  109.   typedef size_t size_type;
  110.   typedef ptrdiff_t difference_type;
  111.   typedef random_access_iterator_tag _Iterator_category;
  112.  
  113.   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
  114.   _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
  115.   typedef typename _Vector_base<_Tp, _Alloc>::allocator_type allocator_type;
  116.  
  117.   allocator_type get_allocator() const {
  118.     return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _Tp);
  119.   }
  120. protected:
  121.   typedef typename  __type_traits<_Tp>::has_trivial_assignment_operator _TrivialAss;
  122.   typedef typename  __type_traits<_Tp>::has_trivial_assignment_operator _IsPODType;
  123.  
  124.   // handles insertions on overflow
  125.   void _M_insert_overflow(pointer __position, const _Tp& __x, const __false_type&, 
  126.               size_type __fill_len, bool __atend = false) {
  127.     const size_type __old_size = size();
  128.     const size_type __len = __old_size + (max)(__old_size, __fill_len);
  129.     
  130.     pointer __new_start = this->_M_end_of_storage.allocate(__len);
  131.     pointer __new_finish = __new_start;
  132.     _STLP_TRY {
  133.       __new_finish = __uninitialized_copy(this->_M_start, __position, __new_start, __false_type());
  134.       // handle insertion
  135.       if (__fill_len == 1) {
  136.         _Construct(__new_finish, __x);
  137.         ++__new_finish;
  138.       } else
  139.         __new_finish = __uninitialized_fill_n(__new_finish, __fill_len, __x, __false_type());
  140.       if (!__atend)
  141.         // copy remainder
  142.         __new_finish = __uninitialized_copy(__position, this->_M_finish, __new_finish, __false_type());
  143.     }
  144.     _STLP_UNWIND((_Destroy(__new_start,__new_finish), 
  145.                   this->_M_end_of_storage.deallocate(__new_start,__len)));
  146.     _M_clear();
  147.     _M_set(__new_start, __new_finish, __new_start + __len);
  148.   }
  149.  
  150.   void _M_insert_overflow(pointer __position, const _Tp& __x, const __true_type&, 
  151.               size_type __fill_len, bool __atend = false) {
  152.     const size_type __old_size = size();
  153.     const size_type __len = __old_size + (max)(__old_size, __fill_len);
  154.     
  155.     pointer __new_start = this->_M_end_of_storage.allocate(__len);
  156.     pointer __new_finish = (pointer)__copy_trivial(this->_M_start, __position, __new_start);
  157.       // handle insertion
  158.     __new_finish = fill_n(__new_finish, __fill_len, __x);
  159.     if (!__atend)
  160.       // copy remainder
  161.       __new_finish = (pointer)__copy_trivial(__position, this->_M_finish, __new_finish);
  162.     _M_clear();
  163.     _M_set(__new_start, __new_finish, __new_start + __len);
  164.   }
  165.  
  166.   void _M_range_check(size_type __n) const {
  167.     if (__n >= size_type(this->_M_finish-this->_M_start))
  168.       __stl_throw_out_of_range("vector");
  169.   }
  170.  
  171. public:
  172.   iterator begin()             { return this->_M_start; }
  173.   const_iterator begin() const { return this->_M_start; }
  174.   iterator end()               { return this->_M_finish; }
  175.   const_iterator end() const   { return this->_M_finish; }
  176.  
  177.   reverse_iterator rbegin()              { return reverse_iterator(end()); }
  178.   const_reverse_iterator rbegin() const  { return const_reverse_iterator(end()); }
  179.   reverse_iterator rend()                { return reverse_iterator(begin()); }
  180.   const_reverse_iterator rend() const    { return const_reverse_iterator(begin()); }
  181.  
  182.   size_type size() const        { return size_type(this->_M_finish - this->_M_start); }
  183.   size_type max_size() const    { return size_type(-1) / sizeof(_Tp); }
  184.   size_type capacity() const    { return size_type(this->_M_end_of_storage._M_data - this->_M_start); }
  185.   bool empty() const            { return this->_M_start == this->_M_finish; }
  186.  
  187.   reference operator[](size_type __n) { return *(begin() + __n); }
  188.   const_reference operator[](size_type __n) const { return *(begin() + __n); }
  189.  
  190.   reference front()             { return *begin(); }
  191.   const_reference front() const { return *begin(); }
  192.   reference back()              { return *(end() - 1); }
  193.   const_reference back() const  { return *(end() - 1); }
  194.  
  195.   reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
  196.   const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
  197.  
  198.   explicit vector(const allocator_type& __a = allocator_type()) : 
  199.     _Vector_base<_Tp, _Alloc>(__a) {}
  200.  
  201.   vector(size_type __n, const _Tp& __val,
  202.          const allocator_type& __a = allocator_type()) 
  203.     : _Vector_base<_Tp, _Alloc>(__n, __a) { 
  204.     this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __val); 
  205.   }
  206.  
  207.   explicit vector(size_type __n)
  208.     : _Vector_base<_Tp, _Alloc>(__n, allocator_type() ) {
  209.     this->_M_finish = uninitialized_fill_n(this->_M_start, __n, _Tp()); 
  210.   }
  211.  
  212.   vector(const vector<_Tp, _Alloc>& __x) 
  213.     : _Vector_base<_Tp, _Alloc>(__x.size(), __x.get_allocator()) { 
  214.     this->_M_finish = __uninitialized_copy((const_pointer)__x._M_start, 
  215.                                            (const_pointer)__x._M_finish, this->_M_start, _IsPODType());
  216.   }
  217.   
  218. #if defined (_STLP_MEMBER_TEMPLATES)
  219.  
  220.   template <class _Integer>
  221.   void _M_initialize_aux(_Integer __n, _Integer __val, const __true_type&) {
  222.     this->_M_start = this->_M_end_of_storage.allocate(__n);
  223.     this->_M_end_of_storage._M_data = this->_M_start + __n; 
  224.     this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __val);
  225.   }
  226.  
  227.   template <class _InputIterator>
  228.   void _M_initialize_aux(_InputIterator __first, _InputIterator __last,
  229.                          const __false_type&) {
  230.     _M_range_initialize(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
  231.   }
  232.  
  233.   // Check whether it's an integral type.  If so, it's not an iterator.
  234.  # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
  235.   template <class _InputIterator>
  236.   vector(_InputIterator __first, _InputIterator __last) :
  237.     _Vector_base<_Tp, _Alloc>(allocator_type()) {
  238.     typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
  239.     _M_initialize_aux(__first, __last, _Integral());
  240.   }
  241.  # endif
  242.   template <class _InputIterator>
  243.   vector(_InputIterator __first, _InputIterator __last,
  244.          const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL ) :
  245.     _Vector_base<_Tp, _Alloc>(__a) {
  246.     typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
  247.     _M_initialize_aux(__first, __last, _Integral());
  248.   }
  249.  
  250. #else
  251.   vector(const _Tp* __first, const _Tp* __last,
  252.          const allocator_type& __a = allocator_type())
  253.     : _Vector_base<_Tp, _Alloc>(__last - __first, __a) { 
  254.       this->_M_finish = __uninitialized_copy(__first, __last, this->_M_start, _IsPODType()); 
  255.   }
  256. #endif /* _STLP_MEMBER_TEMPLATES */
  257.  
  258.   ~vector() { _Destroy(this->_M_start, this->_M_finish); }
  259.  
  260.   vector<_Tp, _Alloc>& operator=(const vector<_Tp, _Alloc>& __x);
  261.  
  262.   void reserve(size_type __n);
  263.  
  264.   // assign(), a generalized assignment member function.  Two
  265.   // versions: one that takes a count, and one that takes a range.
  266.   // The range version is a member template, so we dispatch on whether
  267.   // or not the type is an integer.
  268.  
  269.   void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); }
  270.   void _M_fill_assign(size_type __n, const _Tp& __val);
  271.   
  272. #ifdef _STLP_MEMBER_TEMPLATES
  273.   template <class _ForwardIter>
  274.   void _M_assign_aux(_ForwardIter __first, _ForwardIter __last, const forward_iterator_tag &)
  275. #else
  276.   void assign(const_iterator __first, const_iterator __last)
  277. #endif
  278.   {
  279.     size_type __len = distance(__first, __last);
  280.     
  281.     if (__len > capacity()) {
  282.       iterator __tmp = _M_allocate_and_copy(__len, __first, __last);
  283.     _M_clear();
  284.     _M_set(__tmp, __tmp + __len, __tmp + __len);
  285.     }
  286.     else if (size() >= __len) {
  287.       iterator __new_finish = copy(__first, __last, this->_M_start);
  288.       _Destroy(__new_finish, this->_M_finish);
  289.       this->_M_finish = __new_finish;
  290.     }
  291.     else {
  292. # if defined ( _STLP_MEMBER_TEMPLATES )
  293.           _ForwardIter __mid = __first;
  294.           advance(__mid, size());
  295. # else
  296.           const_iterator __mid = __first + size() ;
  297. # endif
  298.     copy(__first, __mid, this->_M_start);
  299.     this->_M_finish = __uninitialized_copy(__mid, __last, this->_M_finish, _IsPODType());
  300.     }
  301.   }
  302.  
  303. #ifdef _STLP_MEMBER_TEMPLATES
  304.   template <class _InputIter>
  305.   void _M_assign_aux(_InputIter __first, _InputIter __last,
  306.              const input_iterator_tag &) {
  307.     iterator __cur = begin();
  308.     for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
  309.       *__cur = *__first;
  310.     if (__first == __last)
  311.       erase(__cur, end());
  312.     else
  313.       insert(end(), __first, __last);
  314.   }
  315.   
  316.   template <class _Integer>
  317.   void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)
  318.     { assign((size_type) __n, (_Tp) __val); }
  319.  
  320.   template <class _InputIter>
  321.   void _M_assign_dispatch(_InputIter __first, _InputIter __last, const __false_type&)
  322.     { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }
  323.  
  324.   template <class _InputIterator>
  325.   void assign(_InputIterator __first, _InputIterator __last) {
  326.     typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
  327.     _M_assign_dispatch(__first, __last, _Integral());
  328.   }
  329. #endif /* _STLP_MEMBER_TEMPLATES */
  330.  
  331.   void push_back(const _Tp& __x) {
  332.     if (this->_M_finish != this->_M_end_of_storage._M_data) {
  333.       _Construct(this->_M_finish, __x);
  334.       ++this->_M_finish;
  335.     }
  336.     else
  337.       _M_insert_overflow(this->_M_finish, __x, _IsPODType(), 1UL, true);
  338.   }
  339.  
  340.   void swap(vector<_Tp, _Alloc>& __x) {
  341.     _STLP_STD::swap(this->_M_start, __x._M_start);
  342.     _STLP_STD::swap(this->_M_finish, __x._M_finish);
  343.     _STLP_STD::swap(this->_M_end_of_storage, __x._M_end_of_storage);
  344.   }
  345.  
  346.   iterator insert(iterator __position, const _Tp& __x) {
  347.     size_type __n = __position - begin();
  348.     if (this->_M_finish != this->_M_end_of_storage._M_data) {
  349.       if (__position == end()) {
  350.         _Construct(this->_M_finish, __x);
  351.         ++this->_M_finish;
  352.       } else {
  353.         _Construct(this->_M_finish, *(this->_M_finish - 1));
  354.         ++this->_M_finish;
  355.         _Tp __x_copy = __x;
  356.         __copy_backward_ptrs(__position, this->_M_finish - 2, this->_M_finish - 1, _TrivialAss());
  357.         *__position = __x_copy;
  358.       }
  359.     }
  360.     else
  361.       _M_insert_overflow(__position, __x, _IsPODType(), 1UL);
  362.     return begin() + __n;
  363.   }
  364.  
  365. # ifndef _STLP_NO_ANACHRONISMS
  366.   void push_back() { push_back(_Tp()); }
  367.   iterator insert(iterator __position) { return insert(__position, _Tp()); }
  368. # endif
  369.  
  370.   void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x);
  371.  
  372. #if defined ( _STLP_MEMBER_TEMPLATES)
  373.  
  374.   template <class _Integer>
  375.   void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
  376.                           const __true_type&) {
  377.     _M_fill_insert(__pos, (size_type) __n, (_Tp) __val);
  378.   }
  379.  
  380.   template <class _InputIterator>
  381.   void _M_insert_dispatch(iterator __pos,
  382.                           _InputIterator __first, _InputIterator __last,
  383.                           const __false_type&) {
  384.     _M_range_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
  385.   }
  386.  
  387.   // Check whether it's an integral type.  If so, it's not an iterator.
  388.   template <class _InputIterator>
  389.   void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
  390.     typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
  391.     _M_insert_dispatch(__pos, __first, __last, _Integral());
  392.   }
  393.  
  394.   template <class _InputIterator>
  395.   void _M_range_insert(iterator __pos, 
  396.                _InputIterator __first, 
  397.                _InputIterator __last,
  398.                const input_iterator_tag &) {
  399.     for ( ; __first != __last; ++__first) {
  400.       __pos = insert(__pos, *__first);
  401.       ++__pos;
  402.     }
  403.   }
  404.  
  405.   template <class _ForwardIterator>
  406.   void _M_range_insert(iterator __position,
  407.                        _ForwardIterator __first,
  408.                        _ForwardIterator __last,
  409.                        const forward_iterator_tag &) 
  410. #else /* _STLP_MEMBER_TEMPLATES */
  411.   void insert(iterator __position,
  412.               const_iterator __first, const_iterator __last)
  413. #endif /* _STLP_MEMBER_TEMPLATES */
  414.  
  415.   {
  416.     if (__first != __last) {
  417.       size_type __n = distance(__first, __last);
  418.  
  419.       if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) {
  420.         const size_type __elems_after = this->_M_finish - __position;
  421.         pointer __old_finish = this->_M_finish;
  422.         if (__elems_after > __n) {
  423.           __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _IsPODType());
  424.           this->_M_finish += __n;
  425.           __copy_backward_ptrs(__position, __old_finish - __n, __old_finish, _TrivialAss());
  426.           copy(__first, __last, __position);
  427.         }
  428.         else {
  429. # if defined ( _STLP_MEMBER_TEMPLATES )
  430.           _ForwardIterator __mid = __first;
  431.           advance(__mid, __elems_after);
  432. # else
  433.           const_pointer __mid = __first + __elems_after;
  434. # endif
  435.           __uninitialized_copy(__mid, __last, this->_M_finish, _IsPODType());
  436.           this->_M_finish += __n - __elems_after;
  437.           __uninitialized_copy(__position, __old_finish, this->_M_finish, _IsPODType());
  438.           this->_M_finish += __elems_after;
  439.           copy(__first, __mid, __position);
  440.         } /* elems_after */
  441.       }
  442.       else {
  443.         const size_type __old_size = size();
  444.         const size_type __len = __old_size + (max)(__old_size, __n);
  445.         pointer __new_start = this->_M_end_of_storage.allocate(__len);
  446.         pointer __new_finish = __new_start;
  447.         _STLP_TRY {
  448.           __new_finish = __uninitialized_copy(this->_M_start, __position, __new_start, _IsPODType());
  449.           __new_finish = __uninitialized_copy(__first, __last, __new_finish, _IsPODType());
  450.           __new_finish = __uninitialized_copy(__position, this->_M_finish, __new_finish, _IsPODType());
  451.         }
  452.         _STLP_UNWIND((_Destroy(__new_start,__new_finish), 
  453.                       this->_M_end_of_storage.deallocate(__new_start,__len)));
  454.         _M_clear();
  455.         _M_set(__new_start, __new_finish, __new_start + __len);
  456.       }
  457.     }
  458.   }
  459.   void insert (iterator __pos, size_type __n, const _Tp& __x)
  460.   { _M_fill_insert(__pos, __n, __x); }
  461.   
  462.   void pop_back() {
  463.     --this->_M_finish;
  464.     _Destroy(this->_M_finish);
  465.   }
  466.   iterator erase(iterator __position) {
  467.     if (__position + 1 != end())
  468.       __copy_ptrs(__position + 1, this->_M_finish, __position, _TrivialAss());
  469.     --this->_M_finish;
  470.     _Destroy(this->_M_finish);
  471.     return __position;
  472.   }
  473.   iterator erase(iterator __first, iterator __last) {
  474.     pointer __i = __copy_ptrs(__last, this->_M_finish, __first, _TrivialAss());
  475.     _Destroy(__i, this->_M_finish);
  476.     this->_M_finish = __i;
  477.     return __first;
  478.   }
  479.  
  480.   void resize(size_type __new_size, const _Tp& __x) {
  481.     if (__new_size < size()) 
  482.       erase(begin() + __new_size, end());
  483.     else
  484.       insert(end(), __new_size - size(), __x);
  485.   }
  486.   void resize(size_type __new_size) { resize(__new_size, _Tp()); }
  487.   void clear() { 
  488.     erase(begin(), end());
  489.   }
  490.  
  491. protected:
  492.  
  493.   void _M_clear() {
  494.     //    if (this->_M_start) {
  495.     _Destroy(this->_M_start, this->_M_finish);
  496.     this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start);
  497.     //    }
  498.   }
  499.  
  500.   void _M_set(pointer __s, pointer __f, pointer __e) {
  501.     this->_M_start = __s;
  502.     this->_M_finish = __f;
  503.     this->_M_end_of_storage._M_data = __e;
  504.   }
  505.  
  506. #ifdef _STLP_MEMBER_TEMPLATES
  507.   template <class _ForwardIterator>
  508.   pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, 
  509.                 _ForwardIterator __last)
  510. #else /* _STLP_MEMBER_TEMPLATES */
  511.   pointer _M_allocate_and_copy(size_type __n, const_pointer __first, 
  512.                    const_pointer __last)
  513. #endif /* _STLP_MEMBER_TEMPLATES */
  514.   {
  515.     pointer __result = this->_M_end_of_storage.allocate(__n);
  516.     _STLP_TRY {
  517. #if !defined(__MRC__)        //*TY 12/17/2000 - added workaround for MrCpp. it confuses on nested try/catch block
  518.       __uninitialized_copy(__first, __last, __result, _IsPODType());
  519. #else
  520.       uninitialized_copy(__first, __last, __result);
  521. #endif
  522.       return __result;
  523.     }
  524.     _STLP_UNWIND(this->_M_end_of_storage.deallocate(__result, __n));
  525. # ifdef _STLP_THROW_RETURN_BUG
  526.     return __result;
  527. # endif
  528.   }
  529.  
  530.  
  531. #ifdef _STLP_MEMBER_TEMPLATES
  532.   template <class _InputIterator>
  533.   void _M_range_initialize(_InputIterator __first,  
  534.                            _InputIterator __last, const input_iterator_tag &) {
  535.     for ( ; __first != __last; ++__first)
  536.       push_back(*__first);
  537.   }
  538.   // This function is only called by the constructor. 
  539.   template <class _ForwardIterator>
  540.   void _M_range_initialize(_ForwardIterator __first,
  541.                            _ForwardIterator __last, const forward_iterator_tag &) {
  542.     size_type __n = distance(__first, __last);
  543.     this->_M_start = this->_M_end_of_storage.allocate(__n);
  544.     this->_M_end_of_storage._M_data = this->_M_start + __n;
  545.     this->_M_finish = __uninitialized_copy(__first, __last, this->_M_start, _IsPODType());
  546.   }
  547.   
  548. #endif /* _STLP_MEMBER_TEMPLATES */
  549. };
  550.  
  551. # define _STLP_TEMPLATE_CONTAINER vector<_Tp, _Alloc>
  552. # define _STLP_TEMPLATE_HEADER    template <class _Tp, class _Alloc>
  553. # include <stl/_relops_cont.h>
  554. # undef _STLP_TEMPLATE_CONTAINER
  555. # undef _STLP_TEMPLATE_HEADER
  556.  
  557. # if defined (_STLP_USE_TEMPLATE_EXPORT) 
  558. _STLP_EXPORT_TEMPLATE_CLASS allocator<void*>;
  559. _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void**, void*, allocator<void*> >;
  560. _STLP_EXPORT_TEMPLATE_CLASS _Vector_base<void*,allocator<void*> >;
  561. _STLP_EXPORT_TEMPLATE_CLASS vector<void*,allocator<void*> >;
  562. # endif
  563.  
  564. #  undef  vector
  565. #  undef  __vector__
  566. #  define __vector__ __WORKAROUND_RENAME(vector)
  567.  
  568. _STLP_END_NAMESPACE
  569.  
  570. # if !defined (_STLP_LINK_TIME_INSTANTIATION)
  571. #  include <stl/_vector.c>
  572. # endif
  573.  
  574. #ifndef _STLP_INTERNAL_BVECTOR_H
  575. # include <stl/_bvector.h>
  576. #endif
  577.  
  578. # if defined (_STLP_DEBUG)
  579. #  include <stl/debug/_vector.h>
  580. # endif
  581.  
  582. # if defined (_STLP_USE_WRAPPER_FOR_ALLOC_PARAM)
  583. #  include <stl/wrappers/_vector.h>
  584. # endif
  585.  
  586. #endif /* _STLP_VECTOR_H */
  587.  
  588. // Local Variables:
  589. // mode:C++
  590. // End:
  591.  
  592.