epoc32/include/tools/stlport/stl/debug/_string.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * Copyright (c) 1997-1999
     3  * Silicon Graphics Computer Systems, Inc.
     4  *
     5  * Copyright (c) 1999
     6  * Boris Fomitchev
     7  *
     8  * This material is provided "as is", with absolutely no warranty expressed
     9  * or implied. Any use is at your own risk.
    10  *
    11  * Permission to use or copy this software for any purpose is hereby granted
    12  * without fee, provided the above notices are retained on all copies.
    13  * Permission to modify the code and to distribute modified code is granted,
    14  * provided the above notices are retained, and a notice that the code was
    15  * modified is included with the above copyright notice.
    16  */
    17 
    18 #ifndef _STLP_DBG_STRING_H
    19 #define _STLP_DBG_STRING_H
    20 
    21 #ifndef _STLP_DBG_ITERATOR_H
    22 #  include <stl/debug/_iterator.h>
    23 #endif
    24 
    25 _STLP_BEGIN_NAMESPACE
    26 
    27 #define _STLP_NON_DBG_STRING_NAME _STLP_NON_DBG_NAME(str)
    28 #define _STLP_NON_DBG_STRING _STLP_PRIV _STLP_NON_DBG_STRING_NAME <_CharT, _Traits, _Alloc>
    29 
    30 #if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
    31 template <class _CharT,class _Traits, class _Alloc>
    32 inline _CharT*
    33 value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&)
    34 { return (_CharT*)0; }
    35 template <class _CharT, class _Traits, class _Alloc>
    36 inline random_access_iterator_tag
    37 iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&)
    38 { return random_access_iterator_tag(); }
    39 #endif
    40 
    41 template <class _CharT, class _Traits, class _Alloc>
    42 class basic_string :
    43 #if !defined (__DMC__)
    44                      private
    45 #else
    46                      public
    47 #endif
    48                              _STLP_PRIV _STLP_CONSTRUCT_CHECKER<_STLP_NON_DBG_STRING >
    49 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string)
    50                    , public __stlport_class<basic_string<_CharT, _Traits, _Alloc> >
    51 #endif
    52 {
    53 protected:
    54   typedef _STLP_NON_DBG_STRING _Base;
    55   typedef basic_string<_CharT, _Traits, _Alloc> _Self;
    56   typedef _STLP_PRIV _STLP_CONSTRUCT_CHECKER<_STLP_NON_DBG_STRING > _ConstructCheck;
    57   typedef typename _IsPOD<_CharT>::_Type _Char_Is_POD;
    58 
    59 public:
    60   __IMPORT_CONTAINER_TYPEDEFS(_Base)
    61   typedef typename _Base::traits_type traits_type;
    62   typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
    63   typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > > const_iterator;
    64   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
    65 
    66 public:                         // Constructor, destructor, assignment.
    67   typedef typename _Base::_Reserve_t _Reserve_t;
    68 
    69 private:
    70   _Base _M_non_dbg_impl;
    71   _STLP_PRIV __owned_list _M_iter_list;
    72 
    73   void _Invalidate_all()
    74   { _M_iter_list._Invalidate_all(); }
    75   void _Compare_Capacity (size_type __old_capacity) {
    76     if (this->capacity() > __old_capacity) {
    77       _Invalidate_all();
    78     }
    79   }
    80   void _Invalidate_iterator(const iterator& __it)
    81   { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
    82   void _Invalidate_iterators(const iterator& __f, const iterator& __l)
    83   { _STLP_PRIV __invalidate_range(&_M_iter_list, __f, __l); }
    84 
    85 public:
    86 #include <stl/_string_npos.h>
    87 
    88   allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
    89 
    90   explicit basic_string(const allocator_type& __a = allocator_type())
    91     : _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
    92 
    93   basic_string(_Reserve_t __r, size_t __n,
    94                const allocator_type& __a = allocator_type())
    95     : _M_non_dbg_impl(__r, __n, __a), _M_iter_list(&_M_non_dbg_impl) {}
    96 
    97   basic_string(const _Self& __s)
    98     : _ConstructCheck(__s),
    99       _M_non_dbg_impl(__s._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
   100 
   101   basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
   102                const allocator_type& __a = allocator_type())
   103     : _M_non_dbg_impl(__s._M_non_dbg_impl, __pos, __n, __a),
   104       _M_iter_list(&_M_non_dbg_impl) {}
   105 
   106   basic_string(const _CharT* __s, size_type __n,
   107                const allocator_type& __a = allocator_type())
   108     : _ConstructCheck(__s), _M_non_dbg_impl(__s, __n, __a),
   109       _M_iter_list(&_M_non_dbg_impl) {}
   110 
   111   basic_string(const _CharT* __s,
   112                const allocator_type& __a = allocator_type())
   113     : _ConstructCheck(__s),
   114       _M_non_dbg_impl(__s, __a), _M_iter_list(&_M_non_dbg_impl) {}
   115 
   116   basic_string(size_type __n, _CharT __c,
   117                const allocator_type& __a = allocator_type())
   118     : _M_non_dbg_impl(__n, __c, __a), _M_iter_list(&_M_non_dbg_impl) {}
   119 
   120   basic_string(__move_source<_Self> src)
   121     : _M_non_dbg_impl(__move_source<_Base >(src.get()._M_non_dbg_impl)),
   122       _M_iter_list(&_M_non_dbg_impl) {
   123 #if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
   124     src.get()._M_iter_list._Invalidate_all();
   125 #else
   126     src.get()._M_iter_list._Set_owner(_M_iter_list);
   127 #endif
   128   }
   129 
   130 #if !defined (_STLP_MEMBER_TEMPLATES) || defined(__MRC__) || defined(__SC__)
   131   basic_string(const _CharT* __f, const _CharT* __l,
   132                const allocator_type& __a = allocator_type())
   133     : _ConstructCheck(__f, __l),
   134       _M_non_dbg_impl(__f, __l, __a), _M_iter_list(&_M_non_dbg_impl) {
   135   }
   136   basic_string(const_iterator __f, const_iterator __l,
   137                const allocator_type & __a = allocator_type())
   138     : _ConstructCheck(__f, __l),
   139       _M_non_dbg_impl(__f._M_iterator, __l._M_iterator, __a), _M_iter_list(&_M_non_dbg_impl) {
   140   }
   141 #else
   142   template <class _InputIterator>
   143   basic_string(_InputIterator __f, _InputIterator __l,
   144                const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
   145     : _ConstructCheck(__f, __l),
   146       _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l), __a),
   147       _M_iter_list(&_M_non_dbg_impl) {}
   148 #  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
   149   template <class _InputIterator>
   150   basic_string(_InputIterator __f, _InputIterator __l)
   151     : _ConstructCheck(__f, __l),
   152       _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)),
   153       _M_iter_list(&_M_non_dbg_impl) {}
   154 #  endif
   155 #endif
   156 
   157 private:
   158   // constructor from non-debug version for substr
   159   basic_string (const _Base& __x)
   160     : _M_non_dbg_impl(__x), _M_iter_list(&_M_non_dbg_impl) {}
   161 
   162 public:
   163   _Self& operator=(const _Self& __s) {
   164     if (this != &__s) {
   165       assign(__s);
   166     }
   167     return *this;
   168   }
   169 
   170   _Self& operator=(const _CharT* __s) {
   171     _STLP_FIX_LITERAL_BUG(__s)
   172     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   173     return assign(__s);
   174   }
   175 
   176   _Self& operator=(_CharT __c) {
   177     return assign(1, __c);
   178   }
   179 
   180   // Iterators.
   181   iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
   182   const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
   183   iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
   184   const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
   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, capacity, etc.
   192   size_type size() const { return _M_non_dbg_impl.size(); }
   193   size_type length() const { return _M_non_dbg_impl.length(); }
   194   size_t max_size() const { return _M_non_dbg_impl.max_size(); }
   195 
   196   void resize(size_type __n, _CharT __c) {
   197     if (__n > capacity())
   198       _Invalidate_all();
   199     else if (__n < size())
   200       _Invalidate_iterators(begin() + __n, end());
   201     _M_non_dbg_impl.resize(__n, __c);
   202   }
   203   void resize(size_type __n) { resize(__n, _STLP_DEFAULT_CONSTRUCTED(_CharT)); }
   204   size_type capacity() const { return _M_non_dbg_impl.capacity(); }
   205 
   206   void reserve(size_type __s = 0) {
   207     if (__s > capacity()) _Invalidate_all();
   208     _M_non_dbg_impl.reserve(__s);
   209   }
   210 
   211   void clear() {
   212     _Invalidate_all();
   213     _M_non_dbg_impl.clear();
   214   }
   215 
   216   bool empty() const { return _M_non_dbg_impl.empty(); }
   217 
   218   const_reference operator[](size_type __n) const {
   219     _STLP_VERBOSE_ASSERT(__n <= this->size(), _StlMsg_OUT_OF_BOUNDS);
   220     return _M_non_dbg_impl[__n];
   221   }
   222 
   223   reference operator[](size_type __n) {
   224     _STLP_VERBOSE_ASSERT(__n < this->size(), _StlMsg_OUT_OF_BOUNDS)
   225     return _M_non_dbg_impl[__n];
   226   }
   227 
   228   const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
   229   reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
   230 
   231   // Append, operator+=, push_back.
   232   _Self& operator+=(const _Self& __s) { return append(__s); }
   233   _Self& operator+=(const _CharT* __s) {
   234     _STLP_FIX_LITERAL_BUG(__s)
   235     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   236     return append(__s);
   237   }
   238   _Self& operator+=(_CharT __c) { return append(1, __c); }
   239 
   240 #if defined (_STLP_MEMBER_TEMPLATES)
   241   template <class _InputIter>
   242   _Self& append(_InputIter __first, _InputIter __last) {
   243     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   244     size_type __old_capacity = capacity();
   245     _M_non_dbg_impl.append(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
   246     _Compare_Capacity(__old_capacity);
   247     return *this;
   248   }
   249 #endif
   250 
   251 #if !defined (_STLP_MEMBER_TEMPLATES) || \
   252     !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
   253   _Self& append(const _CharT* __f, const _CharT* __l) {
   254     _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   255     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
   256     size_type __old_capacity = capacity();
   257     _M_non_dbg_impl.append(__f, __l);
   258     _Compare_Capacity(__old_capacity);
   259     return *this;
   260   }
   261 
   262   _Self& append(const_iterator __f, const_iterator __l) {
   263     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
   264     size_type __old_capacity = capacity();
   265     _M_non_dbg_impl.append(__f._M_iterator, __l._M_iterator);
   266     _Compare_Capacity(__old_capacity);
   267     return *this;
   268   }
   269 #endif
   270 
   271   _Self& append(const _Self& __s) {
   272     size_type __old_capacity = capacity();
   273     _M_non_dbg_impl.append(__s._M_non_dbg_impl);
   274     _Compare_Capacity(__old_capacity);
   275     return *this;
   276   }
   277 
   278   _Self& append(const _Self& __s, size_type __pos, size_type __n) {
   279     size_type __old_capacity = capacity();
   280     _M_non_dbg_impl.append(__s._M_non_dbg_impl, __pos, __n);
   281     _Compare_Capacity(__old_capacity);
   282     return *this;
   283   }
   284 
   285   _Self& append(const _CharT* __s, size_type __n) {
   286     _STLP_FIX_LITERAL_BUG(__s)
   287     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   288     size_type __old_capacity = capacity();
   289     _M_non_dbg_impl.append(__s, __n);
   290     _Compare_Capacity(__old_capacity);
   291     return *this;
   292   }
   293 
   294   _Self& append(const _CharT* __s) {
   295     _STLP_FIX_LITERAL_BUG(__s)
   296     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   297     size_type __old_capacity = capacity();
   298     _M_non_dbg_impl.append(__s);
   299     _Compare_Capacity(__old_capacity);
   300     return *this;
   301   }
   302 
   303   _Self& append(size_type __n, _CharT __c) {
   304     size_type __old_capacity = this->capacity();
   305     _M_non_dbg_impl.append(__n, __c);
   306     _Compare_Capacity(__old_capacity);
   307     return *this;
   308   }
   309 
   310   void push_back(_CharT __c) {
   311     size_type __old_capacity = this->capacity();
   312     _M_non_dbg_impl.push_back(__c);
   313     _Compare_Capacity(__old_capacity);
   314   }
   315 
   316   void pop_back() {
   317     _Invalidate_iterator(this->end());
   318     _M_non_dbg_impl.pop_back();
   319   }
   320 
   321   // Assign
   322 private:
   323   void _M_check_assign(size_type __n) {
   324     if (__n > capacity()) {
   325       _Invalidate_all();
   326     }
   327     else if (__n < size()) {
   328       _Invalidate_iterators(begin() + __n, end());
   329     }
   330   }
   331 
   332 public:
   333   _Self& assign(const _Self& __s) {
   334     _M_check_assign(__s.size());
   335     _M_non_dbg_impl.assign(__s._M_non_dbg_impl);
   336     return *this;
   337   }
   338 
   339   _Self& assign(const _Self& __s, size_type __pos, size_type __n) {
   340     if (__pos < __s.size()) {
   341       _M_check_assign((min) (__n, __s.size() - __pos));
   342     }
   343     _M_non_dbg_impl.assign(__s._M_non_dbg_impl, __pos, __n);
   344     return *this;
   345   }
   346 
   347   _Self& assign(const _CharT* __s, size_type __n) {
   348     _STLP_FIX_LITERAL_BUG(__s)
   349     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   350     _M_check_assign((min) (_Traits::length(__s), __n));
   351     _M_non_dbg_impl.assign(__s, __s + __n);
   352     return *this;
   353   }
   354 
   355   _Self& assign(const _CharT* __s) {
   356     _STLP_FIX_LITERAL_BUG(__s)
   357     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   358     _M_check_assign(_Traits::length(__s));
   359     _M_non_dbg_impl.assign(__s);
   360     return *this;
   361   }
   362 
   363   _Self& assign(size_type __n, _CharT __c) {
   364     _M_check_assign(__n);
   365     _M_non_dbg_impl.assign(__n, __c);
   366     return *this;
   367   }
   368 
   369 #if defined(_STLP_MEMBER_TEMPLATES)
   370 private:
   371   template <class _Integer>
   372   void _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
   373     _M_check_assign(__n);
   374     _M_non_dbg_impl.assign((size_type)__n, (_CharT)__x);
   375   }
   376 
   377   template <class _InputIter>
   378   void _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/)  {
   379     _M_check_assign(distance(__f, __l));
   380     _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
   381   }
   382 public:
   383   template <class _InputIter>
   384   inline _Self& assign(_InputIter __first, _InputIter __last) {
   385     _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
   386     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   387     typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
   388     _M_assign_dispatch(__first, __last, _Integral());
   389     return *this;
   390   }
   391 #endif
   392 
   393 #if !defined (_STLP_MEMBER_TEMPLATES) || \
   394     !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
   395   _Self& assign(const _CharT* __f, const _CharT* __l) {
   396     _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   397     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
   398     _M_check_assign(distance(__f, __l));
   399     _M_non_dbg_impl.assign(__f, __l);
   400     return *this;
   401   }
   402   _Self& assign(const_iterator __f, const_iterator __l) {
   403     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
   404     _M_check_assign(distance(__f, __l));
   405     _M_non_dbg_impl.assign(__f._M_iterator, __l._M_iterator);
   406     return *this;
   407   }
   408 #endif
   409 
   410   // Insert
   411   _Self& insert(size_type __pos, const _Self& __s) {
   412     size_type __old_capacity = capacity();
   413     _M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl);
   414     _Compare_Capacity(__old_capacity);
   415     return *this;
   416   }
   417 
   418   _Self& insert(size_type __pos, const _Self& __s,
   419                 size_type __beg, size_type __n) {
   420     size_type __old_capacity = capacity();
   421     _M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl, __beg, __n);
   422     _Compare_Capacity(__old_capacity);
   423     return *this;
   424   }
   425 
   426   _Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
   427     _STLP_FIX_LITERAL_BUG(__s)
   428     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   429     size_type __old_capacity = capacity();
   430     _M_non_dbg_impl.insert(__pos, __s, __n);
   431     _Compare_Capacity(__old_capacity);
   432     return *this;
   433   }
   434 
   435   _Self& insert(size_type __pos, const _CharT* __s) {
   436     _STLP_FIX_LITERAL_BUG(__s)
   437     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   438     return insert(__pos, __s, _Traits::length(__s));
   439   }
   440 
   441   _Self& insert(size_type __pos, size_type __n, _CharT __c) {
   442     size_type __old_capacity = capacity();
   443     _M_non_dbg_impl.insert(__pos, __n, __c);
   444     _Compare_Capacity(__old_capacity);
   445     return *this;
   446   }
   447 
   448   iterator insert(iterator __p, _CharT __c) {
   449     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
   450     size_type __old_capacity = capacity();
   451     typename _Base::iterator __ret = _M_non_dbg_impl.insert(__p._M_iterator, __c);
   452     _Compare_Capacity(__old_capacity);
   453     return iterator(&_M_iter_list, __ret);
   454   }
   455 
   456   void insert(iterator __p, size_t __n, _CharT __c) {
   457     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
   458     size_type __old_capacity = capacity();
   459     _M_non_dbg_impl.insert(__p._M_iterator, __n, __c);
   460     _Compare_Capacity(__old_capacity);
   461   }
   462 
   463 #if defined (_STLP_MEMBER_TEMPLATES)
   464 private:
   465   template <class _RandomIter>
   466   void _M_insert_aux (iterator __p, _RandomIter __first, _RandomIter __last,
   467                       const __true_type& /*_IsIterator*/)
   468   { _M_non_dbg_impl.insert(__p._M_iterator, __first._M_iterator, __last._M_iterator); }
   469 
   470   template<class _InputIter>
   471   void _M_insert_aux (iterator __p, _InputIter __first, _InputIter __last,
   472                       const __false_type& /*_IsIterator*/) {
   473     _M_non_dbg_impl.insert(__p._M_iterator,
   474                            _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
   475   }
   476 
   477 public:
   478   template <class _InputIter>
   479   void insert(iterator __p, _InputIter __first, _InputIter __last) {
   480     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
   481     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
   482 
   483     /* In debug mode we are encapsulating non debug string iterators in debug one.
   484      * Doing so the non debug implementation will not check for self insertion
   485      * (x.insert(x.begin(), x.begin(), x.end()). To avoid this problem we try to
   486      * guess when _InputIter is iterator or const_iterator and in this case call
   487      * the non debug insert method with non debug string iterator.
   488      */
   489     typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
   490     typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
   491     typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
   492 
   493     size_type __old_capacity = this->capacity();
   494     _M_insert_aux(__p, __first, __last, _IsIterator());
   495     _Compare_Capacity(__old_capacity);
   496   }
   497 #endif
   498 
   499 #if !defined (_STLP_MEMBER_TEMPLATES) || \
   500     !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
   501   void insert(iterator __p, const_iterator __f, const_iterator __l) {
   502     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
   503     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l))
   504     size_type __old_capacity = capacity();
   505     _M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator);
   506     _Compare_Capacity(__old_capacity);
   507   }
   508   void insert(iterator __p, const _CharT* __f, const _CharT* __l) {
   509     _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
   510     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
   511     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f,__l))
   512     size_type __old_capacity = capacity();
   513     _M_non_dbg_impl.insert(__p._M_iterator, __f, __l);
   514     _Compare_Capacity(__old_capacity);
   515   }
   516 #endif
   517 
   518   // Erase.
   519   _Self& erase(size_type __pos = 0, size_type __n = npos) {
   520     if (__pos < size()) {
   521       _Invalidate_iterators(begin() + __pos, end());
   522     }
   523     _M_non_dbg_impl.erase(__pos, __n);
   524     return *this;
   525   }
   526   iterator erase(iterator __pos) {
   527     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
   528     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
   529     _Invalidate_iterators(__pos, end());
   530     return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
   531   }
   532   iterator erase(iterator __f, iterator __l) {
   533     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
   534     _Invalidate_iterators(__f, end());
   535     return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__f._M_iterator, __l._M_iterator));
   536   }
   537 
   538   // Substring.
   539   _Self substr(size_type __pos = 0, size_type __n = npos) const
   540   { return _M_non_dbg_impl.substr(__pos, __n); }
   541 
   542   // Replace.  (Conceptually equivalent to erase followed by insert.)
   543   _Self& replace(size_type __pos, size_type __n, const _Self& __s) {
   544     size_type __old_capacity = capacity();
   545     _M_non_dbg_impl.replace(__pos, __n, __s._M_non_dbg_impl);
   546     _Compare_Capacity(__old_capacity);
   547     return *this;
   548   }
   549 
   550   _Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
   551                  size_type __pos2, size_type __n2) {
   552     size_type __old_capacity = capacity();
   553     _M_non_dbg_impl.replace(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2);
   554     _Compare_Capacity(__old_capacity);
   555     return *this;
   556   }
   557 
   558   _Self& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) {
   559     _STLP_FIX_LITERAL_BUG(__s)
   560     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   561     size_type __old_capacity = capacity();
   562     _M_non_dbg_impl.replace(__pos, __n1, __s, __n2);
   563     _Compare_Capacity(__old_capacity);
   564     return *this;
   565   }
   566 
   567   _Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
   568     _STLP_FIX_LITERAL_BUG(__s)
   569     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   570     size_type __old_capacity = capacity();
   571     _M_non_dbg_impl.replace(__pos, __n1, __s);
   572     _Compare_Capacity(__old_capacity);
   573     return *this;
   574   }
   575 
   576   _Self& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) {
   577     size_type __old_capacity = capacity();
   578     _M_non_dbg_impl.replace(__pos, __n1, __n2, __c);
   579     _Compare_Capacity(__old_capacity);
   580     return *this;
   581   }
   582 
   583   _Self& replace(iterator __f, iterator __l, const _Self& __s) {
   584     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
   585     size_type __old_capacity = capacity();
   586     _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s._M_non_dbg_impl);
   587     _Compare_Capacity(__old_capacity);
   588     return *this;
   589   }
   590 
   591   _Self& replace(iterator __f, iterator __l, const _CharT* __s, size_type __n) {
   592     _STLP_FIX_LITERAL_BUG(__s)
   593     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
   594     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   595     size_type __old_capacity = capacity();
   596     _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s, __n);
   597     _Compare_Capacity(__old_capacity);
   598     return *this;
   599   }
   600 
   601   _Self& replace(iterator __f, iterator __l, const _CharT* __s) {
   602     _STLP_FIX_LITERAL_BUG(__s)
   603     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
   604     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   605     size_type __old_capacity = capacity();
   606     _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s);
   607     _Compare_Capacity(__old_capacity);
   608     return *this;
   609   }
   610 
   611   _Self& replace(iterator __f, iterator __l, size_type __n, _CharT __c) {
   612     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
   613     size_type __old_capacity = capacity();
   614     _M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __n, __c);
   615     _Compare_Capacity(__old_capacity);
   616     return *this;
   617   }
   618 
   619 #if defined (_STLP_MEMBER_TEMPLATES)
   620 private:
   621   template <class _RandomIter>
   622   void _M_replace_aux(iterator __first, iterator __last,
   623                       _RandomIter __f, _RandomIter __l, __true_type const& /*_IsIterator*/)
   624   { _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f._M_iterator, __l._M_iterator); }
   625 
   626   template <class _InputIter>
   627   void _M_replace_aux(iterator __first, iterator __last,
   628                       _InputIter __f, _InputIter __l, __false_type const& /*_IsIterator*/) {
   629     _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
   630                             _STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
   631   }
   632 
   633 public:
   634   template <class _InputIter>
   635   _Self& replace(iterator __first, iterator __last,
   636                  _InputIter __f, _InputIter __l) {
   637     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
   638     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
   639 
   640     /* See insert comment for reson of iterator detection.
   641      */
   642     typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
   643     typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
   644     typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
   645 
   646     size_type __old_capacity = capacity();
   647     _M_replace_aux(__first, __last, __f, __l, _IsIterator());
   648     _Compare_Capacity(__old_capacity);
   649     return *this;
   650   }
   651 #endif
   652 
   653 #if !defined (_STLP_MEMBER_TEMPLATES) || \
   654     !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
   655   _Self& replace(iterator __first, iterator __last,
   656                  const_iterator __f, const_iterator __l) {
   657     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
   658     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
   659     size_type __old_capacity = capacity();
   660     _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
   661                             __f._M_iterator, __l._M_iterator);
   662     _Compare_Capacity(__old_capacity);
   663     return *this;
   664   }
   665 
   666   _Self& replace(iterator __first, iterator __last,
   667                  const _CharT* __f, const _CharT* __l) {
   668     _STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
   669     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
   670     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
   671     size_type __old_capacity = capacity();
   672     _M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f, __l);
   673     _Compare_Capacity(__old_capacity);
   674     return *this;
   675   }
   676 #endif
   677 
   678   // Other modifier member functions.
   679   void swap(_Self& __s) {
   680     _M_iter_list._Swap_owners(__s._M_iter_list);
   681     _M_non_dbg_impl.swap(__s._M_non_dbg_impl);
   682   }
   683 
   684   int compare(const _Self& __s) const
   685   { return _M_non_dbg_impl.compare(__s._M_non_dbg_impl); }
   686   int compare(size_type __pos, size_type __n, const _Self& __s) const
   687   { return _M_non_dbg_impl.compare(__pos, __n, __s._M_non_dbg_impl); }
   688   int compare(size_type __pos1, size_type __n1, const _Self& __s,
   689               size_type __pos2, size_type __n2) const
   690   { return _M_non_dbg_impl.compare(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2); }
   691   int compare(const _CharT* __s) const {
   692     _STLP_FIX_LITERAL_BUG(__s)
   693     return _M_non_dbg_impl.compare(__s);
   694   }
   695   int compare(size_type __pos, size_type __n, const _CharT* __s) const {
   696     _STLP_FIX_LITERAL_BUG(__s)
   697     return _M_non_dbg_impl.compare(__pos, __n, __s);
   698   }
   699   int compare(size_type __pos1, size_type __n1, const _CharT* __s,
   700               size_type __n2) const {
   701     _STLP_FIX_LITERAL_BUG(__s)
   702     return _M_non_dbg_impl.compare(__pos1, __n1, __s, __n2);
   703   }
   704 
   705   // Helper functions for compare.
   706   static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
   707                                    const _CharT* __f2, const _CharT* __l2)
   708   { return _Base::_M_compare(__f1, __l1, __f2, __l2); }
   709   static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
   710                                    const _CharT* __f2, const _CharT* __l2)
   711   { return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2, __l2); }
   712   static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
   713                                    const_iterator __f2, const_iterator __l2)
   714   { return _Base::_M_compare(__f1, __l1, __f2._M_iterator, __l2._M_iterator); }
   715   static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
   716                                    const_iterator __f2, const_iterator __l2)
   717   { return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2._M_iterator, __l2._M_iterator); }
   718 
   719   const _CharT* c_str() const { return _M_non_dbg_impl.c_str(); }
   720   const _CharT* data()  const { return _M_non_dbg_impl.data(); }
   721 
   722   size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
   723   { return _M_non_dbg_impl.copy(__s, __n, __pos); }
   724 
   725   // find.
   726   size_type find(const _Self& __s, size_type __pos = 0) const
   727   { return _M_non_dbg_impl.find(__s._M_non_dbg_impl, __pos); }
   728   size_type find(const _CharT* __s, size_type __pos = 0) const {
   729     _STLP_FIX_LITERAL_BUG(__s)
   730     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   731     return _M_non_dbg_impl.find(__s, __pos);
   732   }
   733   size_type find(const _CharT* __s, size_type __pos, size_type __n) const {
   734     _STLP_FIX_LITERAL_BUG(__s)
   735     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   736     return _M_non_dbg_impl.find(__s, __pos, __n);
   737   }
   738   // WIE: Versant schema compiler 5.2.2 ICE workaround
   739   size_type find(_CharT __c) const { return find(__c, 0); }
   740   size_type find(_CharT __c, size_type __pos /* = 0 */) const
   741   { return _M_non_dbg_impl.find(__c, __pos); }
   742 
   743   // rfind.
   744   size_type rfind(const _Self& __s, size_type __pos = npos) const
   745   { return _M_non_dbg_impl.rfind(__s._M_non_dbg_impl, __pos); }
   746   size_type rfind(const _CharT* __s, size_type __pos = npos) const {
   747     _STLP_FIX_LITERAL_BUG(__s)
   748     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   749     return _M_non_dbg_impl.rfind(__s, __pos);
   750   }
   751   size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const {
   752     _STLP_FIX_LITERAL_BUG(__s)
   753     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   754     return _M_non_dbg_impl.rfind(__s, __pos, __n);
   755   }
   756   size_type rfind(_CharT __c, size_type __pos = npos) const
   757   { return _M_non_dbg_impl.rfind(__c, __pos); }
   758 
   759   // find_first_of
   760   size_type find_first_of(const _Self& __s, size_type __pos = 0) const
   761   { return _M_non_dbg_impl.find_first_of(__s._M_non_dbg_impl, __pos); }
   762   size_type find_first_of(const _CharT* __s, size_type __pos = 0) const {
   763     _STLP_FIX_LITERAL_BUG(__s)
   764     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   765     return _M_non_dbg_impl.find_first_of(__s, __pos);
   766   }
   767   size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const {
   768     _STLP_FIX_LITERAL_BUG(__s)
   769     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   770     return _M_non_dbg_impl.find_first_of(__s, __pos, __n);
   771   }
   772   size_type find_first_of(_CharT __c, size_type __pos = 0) const
   773   { return _M_non_dbg_impl.find_first_of(__c, __pos); }
   774 
   775   // find_last_of
   776   size_type find_last_of(const _Self& __s, size_type __pos = npos) const
   777   { return _M_non_dbg_impl.find_last_of(__s._M_non_dbg_impl, __pos); }
   778   size_type find_last_of(const _CharT* __s, size_type __pos = npos) const {
   779     _STLP_FIX_LITERAL_BUG(__s)
   780     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   781     return _M_non_dbg_impl.find_last_of(__s, __pos);
   782   }
   783   size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const {
   784     _STLP_FIX_LITERAL_BUG(__s)
   785     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   786     return _M_non_dbg_impl.find_last_of(__s, __pos, __n);
   787   }
   788   size_type find_last_of(_CharT __c, size_type __pos = npos) const
   789   { return _M_non_dbg_impl.rfind(__c, __pos); }
   790 
   791   // find_first_not_of
   792   size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const
   793   { return _M_non_dbg_impl.find_first_not_of(__s._M_non_dbg_impl, __pos); }
   794   size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const {
   795     _STLP_FIX_LITERAL_BUG(__s)
   796     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   797     return _M_non_dbg_impl.find_first_not_of(__s, __pos);
   798   }
   799   size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
   800     _STLP_FIX_LITERAL_BUG(__s)
   801     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   802     return _M_non_dbg_impl.find_first_not_of(__s, __pos, __n);
   803   }
   804   size_type find_first_not_of(_CharT __c, size_type __pos = 0) const
   805   { return _M_non_dbg_impl.find_first_not_of(__c, __pos); }
   806 
   807   // find_last_not_of
   808   size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const
   809   { return _M_non_dbg_impl.find_last_not_of(__s._M_non_dbg_impl, __pos); }
   810   size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const {
   811     _STLP_FIX_LITERAL_BUG(__s)
   812     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   813     return _M_non_dbg_impl.find_last_not_of(__s, __pos);
   814   }
   815   size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
   816     _STLP_FIX_LITERAL_BUG(__s)
   817     _STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
   818     return _M_non_dbg_impl.find_last_not_of(__s, __pos, __n);
   819   }
   820   size_type find_last_not_of(_CharT __c, size_type __pos = npos) const
   821   { return _M_non_dbg_impl.find_last_not_of(__c, __pos); }
   822 
   823 #if defined (_STLP_USE_TEMPLATE_EXPRESSION)
   824 #  include <stl/debug/_string_sum_methods.h>
   825 #endif /* _STLP_USE_TEMPLATE_EXPRESSION */
   826 };
   827 
   828 // This is a hook to instantiate STLport exports in a designated DLL
   829 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   830 _STLP_MOVE_TO_PRIV_NAMESPACE
   831 _STLP_EXPORT_TEMPLATE_CLASS _STLP_CONSTRUCT_CHECKER<_STLP_NON_DBG_STRING_NAME <char, char_traits<char>, allocator<char> > >;
   832 _STLP_MOVE_TO_STD_NAMESPACE
   833 _STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;
   834 #  if defined (_STLP_HAS_WCHAR_T)
   835 _STLP_MOVE_TO_PRIV_NAMESPACE
   836 _STLP_EXPORT_TEMPLATE_CLASS _STLP_CONSTRUCT_CHECKER<_STLP_NON_DBG_STRING_NAME <wchar_t, char_traits<wchar_t>, allocator<wchar_t> > >;
   837 _STLP_MOVE_TO_STD_NAMESPACE
   838 _STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
   839 #  endif
   840 #endif /* _STLP_USE_TEMPLATE_EXPORT */
   841 
   842 #undef _STLP_NON_DBG_STRING
   843 #undef _STLP_NON_DBG_STRING_NAME
   844 
   845 #if !defined (_STLP_STATIC_CONST_INIT_BUG)
   846 #  if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
   847 template <class _CharT, class _Traits, class _Alloc>
   848 const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;
   849 #  else
   850 template <class _CharT, class _Traits, class _Alloc>
   851 const size_t basic_string<_CharT, _Traits, _Alloc>::npos;
   852 #  endif
   853 #endif
   854 
   855 #if defined (basic_string)
   856 _STLP_MOVE_TO_STD_NAMESPACE
   857 #undef basic_string
   858 #endif
   859 
   860 _STLP_END_NAMESPACE
   861 
   862 #endif /* _STLP_DBG_STRING */
   863 
   864 // Local Variables:
   865 // mode:C++
   866 // End: