epoc32/include/stdapis/stlport/stl/debug/_string.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  * 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 
    19 #ifndef _STLP_DBG_STRING_H
    20 #define _STLP_DBG_STRING_H
    21 
    22 #include <stl/debug/_iterator.h>
    23 
    24 # define _STLP_DBG_STRING_BASE _Nondebug_string <_CharT, _Traits, _Alloc>
    25 
    26 _STLP_BEGIN_NAMESPACE
    27 
    28 # ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
    29 template <class _CharT,class _Traits, class _Alloc>
    30 inline _CharT*
    31 value_type(const  _DBG_iter_base< _STLP_DBG_STRING_BASE >&) {
    32 return (_CharT*)0;
    33 }
    34 template <class _CharT, class _Traits, class _Alloc>
    35 inline random_access_iterator_tag
    36 iterator_category(const  _DBG_iter_base< _STLP_DBG_STRING_BASE >&) {
    37   return random_access_iterator_tag();
    38 }
    39 # endif
    40 
    41 template <class _CharT, class _Traits, class _Alloc> 
    42 class basic_string : public _STLP_DBG_STRING_BASE {
    43 private:
    44   typedef _STLP_DBG_STRING_BASE _Base;
    45   typedef basic_string<_CharT, _Traits, _Alloc> _Self;
    46 protected:
    47   mutable __owned_list _M_iter_list;
    48 public:
    49   __IMPORT_CONTAINER_TYPEDEFS(_Base)
    50   typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
    51   typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
    52   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
    53 # ifdef _STLP_USE_NATIVE_STRING
    54   // this typedef is being used for conversions
    55   typedef _STLP_VENDOR_STD::basic_string<_CharT,_Traits, 
    56     _STLP_VENDOR_STD::allocator<_CharT> >  __std_string;
    57 # endif
    58 public:                         // Constructor, destructor, assignment.
    59   typedef typename _Base::_Reserve_t _Reserve_t;
    60 
    61   const _Base* _Get_base() const { return (const _Base*)this; }
    62   _Base* _Get_base() { return (_Base*)this; }
    63 
    64   basic_string() :_STLP_DBG_STRING_BASE(), _M_iter_list(_Get_base()) {}
    65   
    66   explicit basic_string(const allocator_type& __a): 
    67     _STLP_DBG_STRING_BASE(__a), _M_iter_list(_Get_base()) {}
    68 
    69   basic_string(_Reserve_t __r, size_t __n,
    70                const allocator_type& __a = allocator_type())
    71     : _STLP_DBG_STRING_BASE(__r, __n, __a), _M_iter_list(_Get_base()) {}
    72 
    73   basic_string(const _Self& __s): 
    74     _STLP_DBG_STRING_BASE(__s), _M_iter_list(_Get_base()) {}
    75 
    76   basic_string(const _Self& __s, size_type __pos, size_type __n = _Base::npos,
    77                const allocator_type& __a = allocator_type()):
    78     _STLP_DBG_STRING_BASE(__s, __pos, __n, __a), _M_iter_list(_Get_base()) {}
    79 
    80   basic_string(const _CharT* __s, size_type __n,
    81 		    const allocator_type& __a = allocator_type()):
    82     _STLP_DBG_STRING_BASE(__s, __n, __a), _M_iter_list(_Get_base()) {}
    83 
    84   basic_string(const _CharT* __s,
    85 		    const allocator_type& __a = allocator_type()):
    86     _STLP_DBG_STRING_BASE(__s, __a), _M_iter_list(_Get_base()) {}
    87 
    88   basic_string(size_type __n, _CharT __c,
    89 		    const allocator_type& __a = allocator_type()):
    90     _STLP_DBG_STRING_BASE(__n, __c, __a), _M_iter_list(_Get_base()) {}
    91 
    92 #if defined (_STLP_MEMBER_TEMPLATES) && !(defined(__MRC__)||(defined(__SC__) && !defined(__DMC__)))
    93 # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
    94   template <class _InputIterator>
    95   basic_string(_InputIterator __f, _InputIterator __l):
    96     _STLP_DBG_STRING_BASE(__f, __l), _M_iter_list(_Get_base()) {}
    97 #  endif
    98   template <class _InputIterator>
    99   basic_string(_InputIterator __f, _InputIterator __l,
   100 		    const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL):
   101     _STLP_DBG_STRING_BASE(__f, __l, __a), _M_iter_list(_Get_base()) {}
   102 #else /* _STLP_MEMBER_TEMPLATES */
   103   basic_string(const_iterator __f, const_iterator __l, 
   104 		    const allocator_type & __a = allocator_type()):
   105     _STLP_DBG_STRING_BASE(__f._M_iterator, __l._M_iterator, __a), 
   106      _M_iter_list(_Get_base()) {}
   107 
   108   basic_string(const _CharT* __f, const _CharT* __l,
   109                const allocator_type& __a = allocator_type()):
   110    _STLP_DBG_STRING_BASE(__f, __l, __a), _M_iter_list(_Get_base()) {}
   111 #endif
   112 
   113 # ifdef _STLP_USE_NATIVE_STRING
   114   // these conversion operations still needed for
   115   // strstream, etc.
   116   basic_string (const __std_string& __x)
   117     : _STLP_DBG_STRING_BASE(__x.begin(), __x.end()), _M_iter_list(_Get_base()) {}
   118   operator __std_string() const { return __std_string(this->data()); }
   119 # endif
   120 
   121   // constructor from non-debug version
   122   basic_string (const _Base& __x)
   123     : _STLP_DBG_STRING_BASE(__x), _M_iter_list(_Get_base()) {}
   124 
   125   _Self& operator=(const _Self& __s) {
   126     _Base::operator=(__s);
   127     return *this;
   128   }
   129 
   130   _Self& operator=(const _CharT* __s) { 
   131     _STLP_FIX_LITERAL_BUG(__s)
   132     _Base::operator=(__s);
   133     return *this;
   134   }
   135 
   136   _Self& operator=(_CharT __c) {
   137     _Base::operator=(__c);
   138     return *this;
   139   }
   140 
   141 public:                         // Iterators.
   142 
   143   iterator begin() { return iterator(&_M_iter_list, this->_M_start); }
   144   const_iterator begin() const { return const_iterator(&_M_iter_list,this->_M_start); }
   145   iterator end() { return iterator(&_M_iter_list,this->_M_finish); }
   146   const_iterator end() const { return const_iterator(&_M_iter_list,this->_M_finish); }
   147   void _M_deallocate_block() {
   148     _M_iter_list._Invalidate_all();
   149     _Base::_M_deallocate_block();
   150   }
   151 
   152   reverse_iterator rbegin()             
   153     { return reverse_iterator(iterator(&_M_iter_list,this->_M_finish)); }
   154   reverse_iterator rend()               
   155     { return reverse_iterator(iterator(&_M_iter_list,this->_M_start)); }
   156   const_reverse_iterator rbegin() const 
   157     { return const_reverse_iterator(const_iterator(&_M_iter_list,this->_M_finish)); }
   158   const_reverse_iterator rend()   const 
   159     { return const_reverse_iterator(const_iterator(&_M_iter_list,this->_M_start)); }
   160 
   161 public:                         // Size, capacity, etc.
   162 
   163   void resize(size_type __n, _CharT __c) {
   164     _Base::resize(__n, __c);
   165   }
   166   void resize(size_type __n) { resize(__n, this->_M_null()); }
   167 
   168   void reserve(size_type __s= 0) {
   169     _Base::reserve(__s);
   170   }
   171 
   172   void clear() {
   173     _M_iter_list._Invalidate_all();
   174     _Base::clear();
   175   } 
   176 
   177 public:                         // Element access.
   178 
   179   const_reference operator[](size_type __n) const
   180     { return *(begin() + __n); }
   181   reference operator[](size_type __n)
   182     { return *(begin() + __n); }
   183 
   184   const_reference at(size_type __n) const {
   185     if (__n >= this->size())
   186       this->_M_throw_out_of_range();
   187     return *(begin() + __n);
   188   }
   189 
   190   reference at(size_type __n) {
   191     if (__n >= this->size())
   192       this->_M_throw_out_of_range();
   193     return *(begin() + __n);
   194   }
   195 
   196 public:                         // Append, operator+=, push_back.
   197 
   198   _Self& operator+=(const _Self& __s) { return append(__s); }
   199   _Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); }
   200   _Self& operator+=(_CharT __c) { push_back(__c); return *this; }
   201 
   202   _Self& append(const _Self& __s) { return append(__s._M_start, __s._M_finish); }
   203 
   204   _Self& append(const _Self& __s,
   205                        size_type __pos, size_type __n)
   206   {
   207     _Base::append(__s, __pos, __n);
   208     return *this;
   209   }
   210 
   211   _Self& append(const _CharT* __s, size_type __n) 
   212     { _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s+__n); }
   213 
   214   _Self& append(const _CharT* __s) 
   215     { _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s + _Traits::length(__s)); }
   216 
   217   _Self& append(size_type __n, _CharT __c){
   218 	  _Base::append(__n, __c);
   219 	  return *this;
   220   }
   221 
   222 #ifdef _STLP_MEMBER_TEMPLATES
   223 
   224   // Check to see if _InputIterator is an integer type.  If so, then
   225   // it can't be an iterator.
   226   template <class _InputIter>
   227   _Self& append(_InputIter __first, _InputIter __last) {
   228     _Base::append(__first, __last);
   229     return *this;
   230   }
   231 
   232 #ifdef _STLP_MSVC
   233 // specialization for append
   234  template <>
   235  inline _Self& append(iterator __f, iterator __l) {
   236  _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   237   __check_range(__f, __l);
   238   _Base::append(__f._M_iterator, __l._M_iterator);
   239   return *this;
   240  }
   241 #endif
   242 
   243 #else /* _STLP_MEMBER_TEMPLATES */
   244 
   245   _Self& append(const _CharT* __first, const _CharT* __last) {
   246     _Base::append(__first, __last);
   247     return *this;
   248   }
   249 
   250   _Self& append(const_iterator __first, const_iterator __last) {
   251     _Base::append(__first._M_iterator, __last._M_iterator);
   252     return *this;
   253   }
   254 #endif /* _STLP_MEMBER_TEMPLATES */
   255 
   256   void push_back(_CharT __c) {
   257     _Base::push_back(__c);
   258   }
   259 
   260   void pop_back() {
   261     __invalidate_iterator(&_M_iter_list,end());
   262     _Base::pop_back();
   263   }
   264 
   265 
   266 public:                         // Assign
   267   
   268   _Self& assign(const _Self& __s) {
   269     _Base::assign(__s); 
   270     return *this; 
   271   }
   272 
   273   _Self& assign(const _Self& __s, 
   274                        size_type __pos, size_type __n) {
   275     _Base::assign(__s, __pos, __n);
   276     return *this;
   277   }
   278 
   279   _Self& assign(const _CharT* __s, size_type __n)
   280     { _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + __n); }
   281 
   282   _Self& assign(const _CharT* __s)
   283     { _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + _Traits::length(__s)); }
   284 
   285   _Self& assign(size_type __n, _CharT __c) {
   286     _Base::assign(__n, __c);
   287     return *this;    
   288   }
   289 
   290 #ifdef _STLP_MEMBER_TEMPLATES
   291   template <class _InputIter>
   292   inline _Self& assign(_InputIter __first, _InputIter __last) {
   293       _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
   294       __check_range(__first, __last);
   295       _Base::assign(__first, __last);
   296       return *this;    
   297   }
   298 
   299 #ifdef _STLP_MSVC
   300 // partial specialization for assign
   301 template <>
   302 inline _Self& assign(iterator __f, iterator __l) {
   303   _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   304     __check_range(__f, __l);
   305   _Base::assign(__f._M_iterator, __l._M_iterator);
   306   return *this;
   307   }
   308 #endif
   309 
   310 #else
   311   _Self& assign(const _CharT* __f, const _CharT* __l) {
   312     _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   313       __check_range(__f, __l);
   314       _Base::assign(__f, __l);
   315     return *this;
   316   }
   317   _Self& assign(const_iterator __f, const_iterator __l) {
   318 
   319       _Base::assign(__f._M_iterator, __l._M_iterator);
   320     return *this;
   321   }
   322 #endif  /* _STLP_MEMBER_TEMPLATES */
   323     
   324 public:                         // Insert
   325 
   326   _Self& insert(size_type __pos, const _Self& __s) {
   327     _Base::insert(__pos, __s);
   328     return *this;
   329   }
   330 
   331   _Self& insert(size_type __pos, const _Self& __s,
   332                        size_type __beg, size_type __n) {
   333     _Base::insert(__pos, __s, __beg, __n);
   334     return *this;
   335   }
   336 
   337   _Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
   338     _STLP_FIX_LITERAL_BUG(__s)
   339     _Base::insert(__pos, __s, __n);
   340     return *this;
   341   }
   342 
   343   _Self& insert(size_type __pos, const _CharT* __s) {
   344     _STLP_FIX_LITERAL_BUG(__s)
   345     _Base::insert(__pos, __s);      
   346     return *this;
   347   }
   348     
   349   _Self& insert(size_type __pos, size_type __n, _CharT __c) {
   350     _Base::insert(__pos, __n, __c);
   351     return *this;
   352   }
   353 
   354   iterator insert(iterator __p, _CharT __c) {
   355     _STLP_FIX_LITERAL_BUG(__p)
   356     __check_if_owner(&_M_iter_list,__p);
   357     return iterator(&_M_iter_list,_Base::insert(__p._M_iterator, __c));
   358   }
   359 
   360   void insert(iterator __p, size_t __n, _CharT __c) {
   361     __check_if_owner(&_M_iter_list,__p);
   362     _Base::insert(__p._M_iterator, __n, __c);
   363   }
   364 
   365 #ifdef _STLP_MEMBER_TEMPLATES
   366   template <class _InputIter>
   367   void insert(iterator __p, _InputIter __first, _InputIter __last) {
   368     __check_if_owner(&_M_iter_list,__p);
   369     __check_range(__first,__last);
   370     _Base::insert(__p._M_iterator, __first, __last);
   371   }
   372 #else /* _STLP_MEMBER_TEMPLATES */
   373   void insert(iterator __p, const _CharT* __first, const _CharT* __last) {
   374     _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
   375     __check_if_owner(&_M_iter_list,__p);
   376     __check_range(__first,__last);
   377     _Base::insert(__p._M_iterator, __first, __last);
   378   }
   379   void insert(iterator __p, const_iterator __first, const_iterator __last) {
   380     __check_range(__first,__last);
   381     _Base::insert(__p._M_iterator, __first._M_iterator, __last._M_iterator); 
   382   }
   383 #endif /* _STLP_MEMBER_TEMPLATES */
   384 
   385 public:                         // Erase.
   386   _Self& erase(size_type __pos = 0, size_type __n = _Base::npos) {
   387     _Base::erase(__pos, __n);
   388     return *this;
   389   }  
   390   iterator erase(iterator __position) {
   391     __check_if_owner(&_M_iter_list, __position);
   392     __invalidate_iterator(&_M_iter_list,end());
   393     return iterator(&_M_iter_list, _Base::erase(__position._M_iterator));
   394   }
   395   iterator erase(iterator __first, iterator __last) {
   396     __check_range(__first, __last)&&__check_if_owner(&_M_iter_list,__first);
   397     if (__first != __last) {
   398       __invalidate_range(&_M_iter_list, __last, end());
   399     }
   400     return iterator(&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator));   
   401   }
   402 
   403 public:                         // Substring.
   404   _Self substr(size_type __pos = 0, size_type __n = _Base::npos) const {
   405     if (__pos > this->size())
   406       this->_M_throw_out_of_range();
   407     return _Self(this->begin() + __pos, 
   408                  this->begin() + __pos + min(__n, this->size() - __pos),
   409                  allocator_type());
   410   }
   411 public:                         // Replace.  (Conceptually equivalent
   412                                 // to erase followed by insert.)
   413   _Self& replace(size_type __pos, size_type __n, 
   414                         const _Self& __s) {
   415     _Base::replace(__pos, __n, __s);
   416     return *this;
   417   }
   418 
   419   _Self& replace(size_type __pos1, size_type __n1,
   420                         const _Self& __s,
   421                         size_type __pos2, size_type __n2) {
   422     _Base::replace(__pos1, __n1, (const _Base&)__s, __pos2, __n2);
   423     return *this;
   424   }
   425 
   426   _Self& replace(size_type __pos, size_type __n1,
   427                         const _CharT* __s, size_type __n2) {    
   428     _STLP_FIX_LITERAL_BUG(__s)
   429     _Base::replace(__pos, __n1, __s, __n2);
   430     return *this;
   431   }
   432 
   433   _Self& replace(size_type __pos, size_type __n1,
   434                         const _CharT* __s) {
   435     _STLP_FIX_LITERAL_BUG(__s)
   436     _Base::replace(__pos, __n1, __s);
   437     return *this;
   438   }
   439 
   440   _Self& replace(size_type __pos, size_type __n1,
   441                         size_type __n2, _CharT __c) {
   442     _Base::replace(__pos, __n1, __n2, __c);
   443     return *this;
   444   }
   445 
   446   _Self& replace(iterator __first, iterator __last, 
   447                         const _Self& __s) { 
   448     __check_if_owner(&_M_iter_list,__first);
   449     __check_range(__first, __last);
   450     _Base::replace(__first._M_iterator, __last._M_iterator,__s);
   451     return *this;
   452   }
   453 
   454   _Self& replace(iterator __first, iterator __last,
   455                         const _CharT* __s, size_type __n) { 
   456     _STLP_FIX_LITERAL_BUG(__s)
   457     __check_if_owner(&_M_iter_list,__first);
   458     __check_range(__first, __last);
   459     _Base::replace(__first._M_iterator, __last._M_iterator,__s, __n);
   460     return *this;
   461   }
   462 
   463   _Self& replace(iterator __first, iterator __last,
   464                         const _CharT* __s) {
   465     _STLP_FIX_LITERAL_BUG(__s)
   466     __check_if_owner(&_M_iter_list,__first);
   467     __check_range(__first, __last);
   468     _Base::replace(__first._M_iterator, __last._M_iterator,__s);
   469     return *this;
   470   }
   471 
   472   _Self& replace(iterator __first, iterator __last, 
   473 		 size_type __n, _CharT __c) {
   474     __check_if_owner(&_M_iter_list,__first);
   475     __check_range(__first, __last);
   476     _Base::replace(__first._M_iterator, __last._M_iterator, __n, __c);
   477     return *this;
   478   }
   479 
   480 #ifdef _STLP_MEMBER_TEMPLATES
   481   template <class _InputIter>
   482   _Self& replace(iterator __first, iterator __last,
   483                         _InputIter __f, _InputIter __l) {
   484     __check_if_owner(&_M_iter_list, __first);
   485     __check_range(__first, __last);
   486     __check_range(__f, __l);
   487     _Base::replace(__first._M_iterator, __last._M_iterator, __f, __l);
   488     return *this;    
   489   }
   490 #else /* _STLP_MEMBER_TEMPLATES */
   491   _Self& replace(iterator __first, iterator __last,
   492 		 const _CharT* __f, const _CharT* __l) {
   493     __check_if_owner(&_M_iter_list, __first);
   494     __check_range(__first, __last);
   495     __check_range(__f, __l);
   496     _Base::replace(__first._M_iterator, __last._M_iterator, __f, __l);
   497     return *this;    
   498   }
   499  
   500   _Self& replace(iterator __first, iterator __last,
   501 		 const_iterator __f, const_iterator __l) {
   502     __check_if_owner(&_M_iter_list, __first);
   503     __check_range(__first, __last);
   504     __check_range(__f, __l);
   505     _Base::replace(__first._M_iterator, __last._M_iterator, 
   506 		   __f._M_iterator, __l._M_iterator);
   507     return *this; 
   508   } 
   509 #endif /* _STLP_MEMBER_TEMPLATES */
   510 
   511 public:                         // Other modifier member functions.
   512 
   513   void swap(_Self& __s) {
   514     _M_iter_list._Swap_owners(__s._M_iter_list);
   515     _Base::swap(__s);
   516   }
   517 };
   518 
   519 
   520 // This is a hook to instantiate STLport exports in a designated DLL
   521 # if defined (_STLP_USE_TEMPLATE_EXPORT)
   522 _STLP_EXPORT template class _STLP_CLASS_DECLSPEC basic_string<char, char_traits<char>, allocator<char> >;
   523 #  if defined (_STLP_HAS_WCHAR_T)
   524 _STLP_EXPORT template class _STLP_CLASS_DECLSPEC basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
   525 #  endif
   526 # endif /* _STLP_USE_TEMPLATE_EXPORT */
   527 
   528 
   529 // ------------------------------------------------------------
   530 // Non-member functions.
   531 
   532 template <class _CharT, class _Traits, class _Alloc>
   533 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
   534 operator+(const basic_string<_CharT,_Traits,_Alloc>& __s,
   535           const basic_string<_CharT,_Traits,_Alloc>& __y)
   536 {
   537   return basic_string<_CharT,_Traits,_Alloc>(*__s._Get_base() + *__y._Get_base());
   538 }
   539 
   540 template <class _CharT, class _Traits, class _Alloc>
   541 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
   542 operator+(const _CharT* __s,
   543           const basic_string<_CharT,_Traits,_Alloc>& __y) {
   544   _STLP_FIX_LITERAL_BUG(__s)
   545   return basic_string<_CharT,_Traits,_Alloc>(__s + *__y._Get_base());
   546 }
   547 
   548 template <class _CharT, class _Traits, class _Alloc>
   549 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
   550 operator+(_CharT __c,
   551           const basic_string<_CharT,_Traits,_Alloc>& __y) {
   552   return basic_string<_CharT,_Traits,_Alloc>(__c + *__y._Get_base());
   553 }
   554 
   555 template <class _CharT, class _Traits, class _Alloc>
   556 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
   557 operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
   558           const _CharT* __s) {
   559   _STLP_FIX_LITERAL_BUG(__s)
   560   return basic_string<_CharT,_Traits,_Alloc>(*__x._Get_base()+ __s);
   561 }
   562 
   563 template <class _CharT, class _Traits, class _Alloc>
   564 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
   565 operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
   566           const _CharT __c) {
   567   return basic_string<_CharT,_Traits,_Alloc>(*__x._Get_base() + __c);
   568 }
   569 
   570 #ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
   571 
   572 // Operator== and operator!=
   573 
   574 template <class _CharT, class _Traits, class _Alloc>
   575 inline bool _STLP_CALL
   576 operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
   577            const basic_string<_CharT,_Traits,_Alloc>& __y) {
   578   return (*__x._Get_base() == *__y._Get_base());
   579 }
   580 
   581 template <class _CharT, class _Traits, class _Alloc>
   582 inline bool _STLP_CALL
   583 operator==(const _CharT* __s,
   584            const basic_string<_CharT,_Traits,_Alloc>& __y) {
   585   _STLP_FIX_LITERAL_BUG(__s)
   586   return (__s == *__y._Get_base());
   587 }
   588 
   589 template <class _CharT, class _Traits, class _Alloc>
   590 inline bool _STLP_CALL
   591 operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
   592            const _CharT* __s) {
   593   _STLP_FIX_LITERAL_BUG(__s)
   594   return (*__x._Get_base() == __s);
   595 }
   596 
   597 // Operator< (and also >, <=, and >=).
   598 
   599 template <class _CharT, class _Traits, class _Alloc>
   600 inline bool _STLP_CALL
   601 operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
   602           const basic_string<_CharT,_Traits,_Alloc>& __y) {
   603   return (*__x._Get_base() < *__y._Get_base());
   604 }
   605 
   606 template <class _CharT, class _Traits, class _Alloc>
   607 inline bool _STLP_CALL
   608 operator<(const _CharT* __s,
   609           const basic_string<_CharT,_Traits,_Alloc>& __y) {
   610   _STLP_FIX_LITERAL_BUG(__s)
   611   return (__s < *__y._Get_base());    
   612 }
   613 
   614 template <class _CharT, class _Traits, class _Alloc>
   615 inline bool _STLP_CALL
   616 operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
   617           const _CharT* __s) {
   618   _STLP_FIX_LITERAL_BUG(__s)
   619   return (*__x._Get_base() < __s);
   620 }
   621 
   622 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
   623 
   624 template <class _CharT, class _Traits, class _Alloc>
   625 inline bool _STLP_CALL
   626 operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
   627            const basic_string<_CharT,_Traits,_Alloc>& __y) {
   628   return !(__x == __y);
   629 }
   630 
   631 template <class _CharT, class _Traits, class _Alloc>
   632 inline bool _STLP_CALL
   633 operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
   634           const basic_string<_CharT,_Traits,_Alloc>& __y) {
   635   return __y < __x;
   636 }
   637 
   638 template <class _CharT, class _Traits, class _Alloc>
   639 inline bool _STLP_CALL
   640 operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
   641            const basic_string<_CharT,_Traits,_Alloc>& __y) {
   642   return !(__y < __x);
   643 }
   644 
   645 template <class _CharT, class _Traits, class _Alloc>
   646 inline bool _STLP_CALL
   647 operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
   648            const basic_string<_CharT,_Traits,_Alloc>& __y) {
   649   return !(__x < __y);
   650 }
   651 
   652 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
   653 
   654 template <class _CharT, class _Traits, class _Alloc>
   655 inline bool _STLP_CALL
   656 operator!=(const _CharT* __s,
   657            const basic_string<_CharT,_Traits,_Alloc>& __y) {
   658   _STLP_FIX_LITERAL_BUG(__s)
   659   return !(__s == __y);
   660 }
   661 
   662 template <class _CharT, class _Traits, class _Alloc>
   663 inline bool _STLP_CALL
   664 operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
   665            const _CharT* __s) {
   666   _STLP_FIX_LITERAL_BUG(__s)
   667   return !(__x == __s);
   668 }
   669 
   670 template <class _CharT, class _Traits, class _Alloc>
   671 inline bool _STLP_CALL
   672 operator>(const _CharT* __s,
   673           const basic_string<_CharT,_Traits,_Alloc>& __y) {
   674   _STLP_FIX_LITERAL_BUG(__s)
   675   return __y < __s;
   676 }
   677 
   678 template <class _CharT, class _Traits, class _Alloc>
   679 inline bool _STLP_CALL
   680 operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
   681           const _CharT* __s) {
   682   _STLP_FIX_LITERAL_BUG(__s)
   683   return __s < __x;
   684 }
   685 
   686 template <class _CharT, class _Traits, class _Alloc>
   687 inline bool _STLP_CALL
   688 operator<=(const _CharT* __s,
   689            const basic_string<_CharT,_Traits,_Alloc>& __y) {
   690   _STLP_FIX_LITERAL_BUG(__s)
   691   return !(__y < __s);
   692 }
   693 
   694 template <class _CharT, class _Traits, class _Alloc>
   695 inline bool _STLP_CALL
   696 operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
   697            const _CharT* __s) {
   698   _STLP_FIX_LITERAL_BUG(__s)
   699   return !(__s < __x);
   700 }
   701 
   702 template <class _CharT, class _Traits, class _Alloc>
   703 inline bool _STLP_CALL
   704 operator>=(const _CharT* __s,
   705            const basic_string<_CharT,_Traits,_Alloc>& __y) {
   706   _STLP_FIX_LITERAL_BUG(__s)
   707   return !(__s < __y);
   708 }
   709 
   710 template <class _CharT, class _Traits, class _Alloc>
   711 inline bool _STLP_CALL
   712 operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
   713            const _CharT* __s) {
   714   _STLP_FIX_LITERAL_BUG(__s)
   715   return !(__x < __s);
   716 }
   717 #endif /*  if 0 */
   718 
   719 // Swap.
   720 #ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
   721 template <class _CharT, class _Traits, class _Alloc>
   722 inline void swap(basic_string<_CharT,_Traits,_Alloc>& __x,
   723                  basic_string<_CharT,_Traits,_Alloc>& __y) {
   724   __x.swap(__y);
   725 }
   726 #endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
   727 
   728 // I/O.  
   729 
   730 #ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
   731 #if defined (_STLP_USE_NEW_IOSTREAMS) && ! defined (_STLP_OWN_IOSTREAMS)
   732 
   733 template <class _CharT, class _Traits, class _Alloc>
   734 basic_ostream<_CharT, _Traits>& _STLP_CALL
   735 operator<<(basic_ostream<_CharT, _Traits>& __os, 
   736            const basic_string<_CharT,_Traits,_Alloc>& __s) {
   737   return __os << *__s._Get_base();
   738 }
   739 
   740 template <class _CharT, class _Traits, class _Alloc>
   741 basic_istream<_CharT, _Traits>&  _STLP_CALL
   742 operator>>(basic_istream<_CharT, _Traits>& __is,
   743            basic_string<_CharT,_Traits,_Alloc>& __s) {
   744     return __is >> *__s._Get_base();
   745 }
   746 
   747 #elif ! defined ( _STLP_USE_NO_IOSTREAMS )
   748 
   749 template <class _CharT, class _Traits, class _Alloc>
   750 ostream& _STLP_CALL operator<<(ostream& __os, 
   751                     const basic_string<_CharT,_Traits,_Alloc>& __s) {
   752   return __os << *__s._Get_base();
   753 }
   754 
   755 template <class _CharT, class _Traits, class _Alloc>
   756 istream& _STLP_CALL operator>>(istream& __is, basic_string<_CharT,_Traits,_Alloc>& __s) {
   757     return __is >> *__s._Get_base();
   758 }
   759 
   760 #endif /* _STLP_USE_NEW_IOSTREAMS */
   761 #endif /* if _STLP_EXTRA_OPERATORS_FOR_DEBUG */
   762 
   763 
   764 _STLP_END_NAMESPACE
   765 
   766 #endif /* _STLP_DBG_STRING */
   767 
   768 
   769 // Local Variables:
   770 // mode:C++
   771 // End:
   772