home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / string.stl < prev    next >
Encoding:
Text File  |  2000-01-31  |  65.6 KB  |  1,747 lines

  1. #ifndef __STRING_STL
  2. #define __STRING_STL
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. /***************************************************************************
  6.  *
  7.  * string - Declarations for the Standard Library string classes
  8.  *
  9.  ***************************************************************************
  10.  *
  11.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  12.  *
  13.  * This computer software is owned by Rogue Wave Software, Inc. and is
  14.  * protected by U.S. copyright laws and other laws and by international
  15.  * treaties.  This computer software is furnished by Rogue Wave Software,
  16.  * Inc. pursuant to a written license agreement and may be used, copied,
  17.  * transmitted, and stored only in accordance with the terms of such
  18.  * license and with the inclusion of the above copyright notice.  This
  19.  * computer software or any other copies thereof may not be provided or
  20.  * otherwise made available to any other person.
  21.  *
  22.  * U.S. Government Restricted Rights.  This computer software is provided
  23.  * with Restricted Rights.  Use, duplication, or disclosure by the
  24.  * Government is subject to restrictions as set forth in subparagraph (c)
  25.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  26.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  27.  * Commercial Computer Software รป Restricted Rights at 48 CFR 52.227-19,
  28.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  29.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  30.  *
  31.  **************************************************************************/
  32.  
  33. #ifndef __STD_STRING
  34. #define __STD_STRING
  35.  
  36. #include <stdcomp.h>
  37. #include <rw/rwstderr.h>
  38.  
  39. #ifndef _RWSTD_NO_NEW_HEADER
  40. #include <cstring>
  41. #include <cctype>
  42. #else
  43. #include <string.h>
  44. #include <ctype.h>
  45. #endif
  46.  
  47. #ifdef _HPACC_
  48. #include <wchar.h>
  49. #else
  50. #ifndef _RWSTD_NO_WIDE_CHAR
  51. #ifndef _RWSTD_NO_NEW_HEADER
  52. #include <cwchar>
  53. #include <cwctype>
  54. #else
  55. #ifndef _RWSTD_NO_WCHAR_H
  56. #include <wchar.h>
  57. #endif
  58. #ifndef _RWSTD_NO_WCTYPE_H
  59. # include <wctype.h>
  60. #endif
  61. #endif
  62. #endif
  63. #endif
  64.  
  65. #ifndef _RW_STD_IOSTREAM
  66. #include <iostream.h>
  67. #endif
  68.  
  69. #include <rw/string_ref>
  70.  
  71. #ifndef _RWSTD_NO_NAMESPACE
  72. namespace __rwstd {
  73. #endif
  74. //
  75. // Global error message declarations
  76. //
  77. #ifdef _RWSTD_LOCALIZED_ERRORS
  78.   extern const unsigned int _RWSTDExport __rwse_InvalidSizeParam;
  79.   extern const unsigned int _RWSTDExport __rwse_PosBeyondEndOfString;
  80.   extern const unsigned int _RWSTDExport __rwse_ResultLenInvalid;
  81.   extern const unsigned int _RWSTDExport __rwse_StringIndexOutOfRange;
  82.   extern const unsigned int _RWSTDExport __rwse_UnexpectedNullPtr;
  83. #else
  84.   extern const char _RWSTDExportFunc(*) __rwse_InvalidSizeParam;
  85.   extern const char _RWSTDExportFunc(*) __rwse_PosBeyondEndOfString;
  86.   extern const char _RWSTDExportFunc(*) __rwse_ResultLenInvalid;
  87.   extern const char _RWSTDExportFunc(*) __rwse_StringIndexOutOfRange;
  88.   extern const char _RWSTDExportFunc(*) __rwse_UnexpectedNullPtr;
  89. #endif
  90. #ifdef _RWSTD_NO_STATIC_DEF3
  91.   extern unsigned long _RWSTDExport __nullref[];
  92.   extern bool _RWSTDExport __nullref_initialized;
  93. #endif
  94.  
  95. #ifndef _RWSTD_NO_NAMESPACE
  96. } namespace std {
  97. #endif
  98.  
  99.   template <class charT, class traits , class Allocator >
  100.   class _RWSTDExportTemplate basic_string
  101.   {
  102.   public:
  103.  
  104.     //
  105.     //  Implementation types (see rw/string_ref)
  106.     //
  107.     // __string_ref_type is the type of the string reference that holds
  108.     // the data for a basic_string. Defining _RWSTD_NO_STRING_REF_COUNT
  109.     // gets you a basic_string that does not use reference counting at all.
  110.     //
  111. #ifndef _RWSTD_NO_STRING_REF_COUNT
  112.     typedef __RWSTD::__string_ref<charT,traits,Allocator> __string_ref_type;
  113. #else
  114.     typedef __RWSTD::__string_noref<charT,traits,Allocator> __string_ref_type;
  115. #endif
  116.     //
  117.     // __rep_type is the base class of __string_ref_type.  This type 
  118.     // defines the representation of the reference class.
  119.     //
  120.     typedef _TYPENAME __string_ref_type::__string_ref_rep_type __rep_type;
  121.     //
  122.     // __null_ref_type is the type of the null reference.  Every empty 
  123.     // string holds a reference to the same null reference object in order
  124.     // to keep the size of an empty string at sizeof(char*) -- assuming
  125.     // your compiler can handle the empty base optimization.
  126.     //
  127.     typedef __RWSTD::__null_string_ref_rep<charT,traits,Allocator,__rep_type>  __null_ref_type;
  128.  
  129.     //
  130.     // types
  131.     //
  132.     typedef traits                               traits_type;
  133.     typedef _TYPENAME traits::char_type          value_type;
  134.     typedef Allocator                            allocator_type;
  135.  
  136.   private:
  137.  
  138. #ifdef _RWSTD_ALLOCATOR
  139.     typedef Allocator  __value_alloc_type;
  140.     typedef _TYPENAME Allocator::template rebind<__string_ref_type>::other  __ref_alloc_type;
  141. #else
  142.     typedef allocator_interface<Allocator,charT>       __value_alloc_type;
  143.     typedef allocator_interface<Allocator,__string_ref_type>  __ref_alloc_type;
  144. #endif
  145.  
  146.   
  147.   public:
  148.  
  149. #ifndef _RWSTD_NO_COMPLICATED_TYPEDEF
  150.     typedef _TYPENAME _RWSTD_ALLOC_SIZE_TYPE              size_type;
  151.     typedef _TYPENAME _RWSTD_ALLOC_DIFF_TYPE              difference_type;
  152.     typedef _TYPENAME __value_alloc_type::reference       reference;
  153.     typedef _TYPENAME __value_alloc_type::const_reference const_reference;
  154.     typedef _TYPENAME __value_alloc_type::pointer         pointer;
  155.     typedef _TYPENAME __value_alloc_type::const_pointer   const_pointer;
  156.     typedef _TYPENAME __value_alloc_type::pointer         iterator;
  157.     typedef _TYPENAME __value_alloc_type::const_pointer   const_iterator;
  158. #else
  159.     typedef size_t                            size_type;
  160.     typedef ptrdiff_t                         difference_type;
  161.     typedef charT&                            reference;
  162.     typedef const charT&                      const_reference;
  163.     typedef charT*                            pointer;
  164.     typedef const charT*                      const_pointer;
  165.     typedef charT*                            iterator;
  166.     typedef const charT*                      const_iterator;
  167. #endif  //_RWSTD_NO_COMPLICATED_TYPEDEF
  168.  
  169. #ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC 
  170.     typedef _RW_STD::reverse_iterator<const_iterator> const_reverse_iterator;
  171.     typedef _RW_STD::reverse_iterator<iterator>  reverse_iterator;
  172. #else
  173.     typedef _RW_STD::reverse_iterator<const_iterator, 
  174.       random_access_iterator_tag, value_type, 
  175.       const_reference, const_pointer, difference_type>
  176.       const_reverse_iterator;
  177.     typedef _RW_STD::reverse_iterator<iterator, 
  178.       random_access_iterator_tag, value_type,
  179.       reference, pointer, difference_type>
  180.       reverse_iterator;
  181. #endif
  182.  
  183. #ifdef _RWSTD_MSC22_STATIC_INIT_BUG
  184. #define npos (size_type)-1
  185. #else
  186.     static const size_type npos;
  187. #endif
  188.  
  189.     inline _EXPLICIT basic_string (const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));
  190.  
  191. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS 
  192.     inline basic_string (void);
  193. #endif
  194.  
  195.     inline basic_string (const basic_string<charT, traits, Allocator>&);
  196.     basic_string (const basic_string<charT, traits, Allocator>&, 
  197.                   size_type, size_type _RWSTD_DEFAULT_ARG(npos), 
  198.                   const Allocator&  _RWSTD_DEFAULT_ARG(Allocator()));
  199.     basic_string (const charT*, size_type, 
  200.                   const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));
  201.     basic_string (const charT*, const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));
  202.  
  203. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  204.     basic_string (const charT*, size_type); 
  205.     basic_string (const charT*); 
  206.     basic_string (size_type n, charT c) : __data_((charT*)0,Allocator())
  207.     { __initn(n,c); }
  208. #endif
  209.  
  210. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  211.     template <class InputIterator>
  212.     basic_string (InputIterator, InputIterator, const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));
  213.     basic_string (int n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  214.       : __data_((charT*)0,alloc)
  215.     { __initn(n,c); }
  216.     basic_string (unsigned int n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  217.       : __data_((charT*)0,alloc)
  218.     { __initn(n,c); }
  219.     basic_string (long n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  220.       : __data_((charT*)0,alloc)
  221.     { __initn(n,c); }
  222.     basic_string (unsigned long n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  223.       : __data_((charT*)0,alloc)
  224.     { __initn(n,c); }
  225.     basic_string (short n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  226.       : __data_((charT*)0,alloc)
  227.     { __initn(n,c); }
  228.     basic_string (unsigned short n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  229.       : __data_((charT*)0,alloc)
  230.     { __initn(n,c); }
  231.     basic_string (char n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  232.       : __data_((charT*)0,alloc)
  233.     { __initn(n,c); }
  234.     basic_string (unsigned char n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  235.       : __data_((charT*)0,alloc)
  236.     { __initn(n,c); }
  237. #ifndef _RWSTD_NO_OVERLOAD_WCHAR
  238.     basic_string (wchar_t n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  239.       : __data_((charT*)0,alloc)
  240.     { __initn(n,c); }
  241. #endif
  242. #ifndef _RWSTD_NO_BOOL
  243.     basic_string (bool n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  244.       : __data_((charT*)0,alloc)
  245.     { __initn(n,c); }
  246. #endif
  247. #else
  248.     basic_string (size_type n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
  249.       : __data_((charT*)0,alloc)
  250.     { __initn(n,c); }
  251. #endif // _RWSTD_NO_MEMBER_TEMPLATES
  252.  
  253.     basic_string (const charT*, const charT*, const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));
  254. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  255.     basic_string (const charT*, const charT*);
  256. #endif
  257.  
  258.     ~basic_string ()
  259.     {
  260.       __unLink();
  261.     }
  262.  
  263.     basic_string<charT, traits, Allocator>& operator= (const basic_string<charT, traits, Allocator>&);
  264.     basic_string<charT, traits, Allocator>& operator= (const charT*);
  265.     inline basic_string<charT, traits, Allocator>& operator= (charT);
  266.  
  267.     //
  268.     // iterators
  269.     //
  270.     iterator begin () 
  271.     { __cow(); __pref()->__setRefCount(0); return __data_.data(); }
  272.     const_iterator begin () const  
  273.     { return __data_.data(); }
  274.     iterator end () 
  275.     { __cow(); __pref()->__setRefCount(0); return __data_.data()+length(); }
  276.     const_iterator end   () const  
  277.     { return __data_.data()+length(); }
  278.  
  279.     reverse_iterator rbegin () 
  280.     { reverse_iterator tmp(end()); return tmp; }
  281.     const_reverse_iterator rbegin () const 
  282.     { const_reverse_iterator tmp(end()); return tmp; }
  283.     reverse_iterator rend ()
  284.     { reverse_iterator tmp(begin()); return tmp; }
  285.     const_reverse_iterator rend () const 
  286.     { const_reverse_iterator tmp(begin()); return tmp; }
  287.  
  288.     //
  289.     // capacity
  290.     //
  291.     size_type size () const   { return length(); }
  292.     inline size_type length () const;
  293.     size_type max_size () const
  294.     {
  295.       return npos - sizeof(__rep_type)-2;
  296.     }
  297.     inline void resize (size_type, charT);
  298.     void resize (size_type n)
  299.     {
  300.       resize(n,__eos()); 
  301.     }
  302.     inline size_type capacity () const;
  303.     inline void reserve (size_type=0);
  304.     void clear () { erase(); }
  305.     bool empty () const  { return length() == 0; }
  306.  
  307.     //
  308.     // element access
  309.     //
  310.     inline const_reference operator[] (size_type) const;
  311.     inline reference       operator[] (size_type);
  312.     inline const_reference at (size_type) const;
  313.     inline reference       at (size_type);
  314.  
  315.     //
  316.     // modifiers
  317.     //
  318.     inline basic_string<charT, traits, Allocator>& operator+= (const basic_string<charT, traits, Allocator>&);
  319.     inline basic_string<charT, traits, Allocator>& operator+= (const charT*);
  320.     inline basic_string<charT, traits, Allocator>& operator+= (charT);
  321.  
  322.     basic_string<charT, traits, Allocator>& append (
  323.         const  basic_string<charT, traits, Allocator>&);
  324.     basic_string<charT, traits, Allocator>& append (
  325.         const basic_string<charT, traits, Allocator>&,
  326.         size_type, 
  327.         size_type);
  328.     inline basic_string<charT, traits, Allocator>& append (const charT*, size_type);
  329.     inline basic_string<charT, traits, Allocator>& append (const charT*);
  330.  
  331. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  332.     template<class InputIterator>
  333.     inline basic_string<charT, traits, Allocator>& append (InputIterator,
  334.                                                     InputIterator);
  335.     basic_string<charT, traits, Allocator>& append (int n, charT c)
  336.     { return replace(length(),0,n,c); }
  337.     basic_string<charT, traits, Allocator>& append (unsigned int n, charT c)
  338.     { return replace(length(),0,n,c); }
  339.     basic_string<charT, traits, Allocator>& append (long n, charT c)
  340.     { return replace(length(),0,n,c); }
  341.     basic_string<charT, traits, Allocator>& append (unsigned long n, charT c)
  342.     { return replace(length(),0,n,c); }
  343.     basic_string<charT, traits, Allocator>& append (short n, charT c)
  344.     { return replace(length(),0,n,c); }
  345.     basic_string<charT, traits, Allocator>& append (unsigned short n, charT c)
  346.     { return replace(length(),0,n,c); }
  347.     basic_string<charT, traits, Allocator>& append (char n, charT c)
  348.     { return replace(length(),0,n,c); }
  349.     basic_string<charT, traits, Allocator>& append (unsigned char n, charT c)
  350.     { return replace(length(),0,n,c); }
  351. #ifndef _RWSTD_NO_OVERLOAD_WCHAR
  352.     basic_string<charT, traits, Allocator>& append (wchar_t n, charT c)
  353.     { return replace(length(),0,n,c); }
  354. #endif
  355. #ifndef _RWSTD_NO_BOOL
  356.     basic_string<charT, traits, Allocator>& append (bool n, charT c)
  357.     { return replace(length(),0,n,c); }
  358. #endif
  359. #else
  360.     inline basic_string<charT, traits, Allocator>& append (const charT*,
  361.                                                     const charT*);
  362.     inline basic_string<charT, traits, Allocator>& append (size_type, charT);
  363. #endif // _RWSTD_NO_MEMBER_TEMPLATES
  364.  
  365.     inline void push_back(const charT);
  366.  
  367.     basic_string<charT, traits, Allocator>& assign (
  368.         const basic_string<charT, traits, Allocator>&);
  369.     basic_string<charT, traits, Allocator>& assign (
  370.         const basic_string<charT, traits, Allocator>&,
  371.         size_type, 
  372.         size_type);
  373.     inline basic_string<charT, traits, Allocator>& assign (const charT*, size_type);
  374.     inline basic_string<charT, traits, Allocator>& assign (const charT*);
  375. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  376.     template<class InputIterator>
  377.     inline basic_string<charT, traits, Allocator>& assign (InputIterator,
  378.                                                     InputIterator);
  379.     basic_string<charT, traits, Allocator>& assign (int n, charT c)
  380.     { return replace(0,length(),n,c); }
  381.     basic_string<charT, traits, Allocator>& assign (unsigned int n, charT c)
  382.     { return replace(0,length(),n,c); }
  383.     basic_string<charT, traits, Allocator>& assign (long n, charT c)
  384.     { return replace(0,length(),n,c); }
  385.     basic_string<charT, traits, Allocator>& assign (unsigned long n, charT c)
  386.     { return replace(0,length(),n,c); }
  387.     basic_string<charT, traits, Allocator>& assign (short n, charT c)
  388.     { return replace(0,length(),n,c); }
  389.     basic_string<charT, traits, Allocator>& assign (unsigned short n, charT c)
  390.     { return replace(0,length(),n,c); }
  391.     basic_string<charT, traits, Allocator>& assign (char n, charT c)
  392.     { return replace(0,length(),n,c); }
  393.     basic_string<charT, traits, Allocator>& assign (unsigned char n, charT c)
  394.     { return replace(0,length(),n,c); }
  395. #ifndef _RWSTD_NO_OVERLOAD_WCHAR
  396.     basic_string<charT, traits, Allocator>& assign (wchar_t n, charT c)
  397.     { return replace(0,length(),n,c); }
  398. #endif
  399. #ifndef _RWSTD_NO_BOOL
  400.     basic_string<charT, traits, Allocator>& assign (bool n, charT c)
  401.     { return replace(0,length(),n,c); }
  402. #endif
  403. #else
  404.     inline basic_string<charT, traits, Allocator>& assign (const charT*,
  405.                                                     const charT*);   
  406.     inline basic_string<charT, traits, Allocator>& assign (size_type, charT);
  407. #endif  // _RWSTD_NO_MEMBER_TEMPLATES
  408.   
  409.     basic_string<charT, traits, Allocator>& insert (size_type,
  410.                                                     const basic_string<charT, traits, Allocator>&);
  411.     basic_string<charT, traits, Allocator>& insert (
  412.         size_type,
  413.         const basic_string<charT, traits, Allocator>&,
  414.         size_type, 
  415.         size_type);
  416.     inline basic_string<charT, traits, Allocator>& insert (
  417.         size_type,
  418.         const charT*, 
  419.         size_type);
  420.     inline basic_string<charT, traits, Allocator>& insert (size_type, const charT*);
  421.     iterator insert (iterator pos, charT c)
  422.     { 
  423.       iterator tmp = __replace_aux(pos-begin(), 0, basic_string<charT, traits, Allocator>(1,c)); 
  424.       __pref()->__setRefCount(0);
  425.       return tmp;
  426.     }
  427.  
  428. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  429.     template<class InputIterator>
  430.     inline void insert (iterator, InputIterator, InputIterator);
  431.     void insert (iterator p, int n, charT c)
  432.     { replace(p-begin(),0,n,c); }
  433.     void insert (iterator p, unsigned int n, charT c)
  434.     { replace(p-begin(),0,n,c); }
  435.     void insert (iterator p, long n, charT c)
  436.     { replace(p-begin(),0,n,c); }
  437.     void insert (iterator p, unsigned long n, charT c)
  438.     { replace(p-begin(),0,n,c); }
  439.     void insert (iterator p, short n, charT c)
  440.     { replace(p-begin(),0,n,c); }
  441.     void insert (iterator p, unsigned short n, charT c)
  442.     { replace(p-begin(),0,n,c); }
  443.     void insert (iterator p, char n, charT c)
  444.     { replace(p-begin(),0,n,c); }
  445.     void insert (iterator p, unsigned char n, charT c)
  446.     { replace(p-begin(),0,n,c); }
  447.     basic_string<charT, traits, Allocator>& insert (size_type pos,int n,charT c)
  448.     { return replace(pos,0,n,c); }
  449.     basic_string<charT, traits, Allocator>& insert (size_type pos,unsigned int n,charT c)
  450.     { return replace(pos,0,n,c); }
  451.     basic_string<charT, traits, Allocator>& insert (size_type pos,long n,charT c)
  452.     { return replace(pos,0,n,c); }
  453.     basic_string<charT, traits, Allocator>& insert (size_type pos,unsigned long n,charT c)
  454.     { return replace(pos,0,n,c); }
  455.     basic_string<charT, traits, Allocator>& insert (size_type pos,short n,charT c)
  456.     { return replace(pos,0,n,c); }
  457.     basic_string<charT, traits, Allocator>& insert (size_type pos,unsigned short n,charT c)
  458.     { return replace(pos,0,n,c); }
  459.     basic_string<charT, traits, Allocator>& insert (size_type pos,char n,charT c)
  460.     { return replace(pos,0,n,c); }
  461.     basic_string<charT, traits, Allocator>& insert (size_type pos,unsigned char n,charT c)
  462.     { return replace(pos,0,n,c); }
  463. #ifndef _RWSTD_NO_OVERLOAD_WCHAR
  464.     void insert (iterator p, wchar_t n, charT c)
  465.     { replace(p-begin(),0,n,c); }
  466.     basic_string<charT, traits, Allocator>& insert (size_type pos,wchar_t n,charT c)
  467.     { return replace(pos,0,n,c); }
  468. #endif
  469. #ifndef _RWSTD_NO_BOOL
  470.     void insert (iterator p, bool n, charT c)
  471.     { replace(p-begin(),0,n,c);} 
  472.     basic_string<charT, traits, Allocator>& insert (size_type pos,bool n,charT c)
  473.     { return replace(pos,0,n,c); }
  474. #endif
  475.  
  476. #else
  477.     inline void insert (iterator, const charT*, const charT*);
  478.     inline basic_string<charT, traits, Allocator>& insert (size_type,size_type,charT);
  479.     inline void insert (iterator, size_type, charT);
  480. #endif  // _RWSTD_NO_MEMBER_TEMPLATES
  481.     
  482.     inline basic_string<charT, traits, Allocator>& erase (size_type = 0,
  483.                                                    size_type = npos);
  484.  
  485.     iterator erase (iterator it) 
  486.     { 
  487.       iterator ret = replace(it - begin(),1,(const charT *)NULL,0,0,0);
  488.       __pref()->__setRefCount(0);
  489.       return ret;
  490.     }
  491.     iterator erase (iterator first, iterator last) 
  492.     {  
  493.       iterator ret =  replace(first - begin(),last-first,(const charT *)NULL,0,0,0);
  494.       __pref()->__setRefCount(0);
  495.       return ret;
  496.     }
  497.   private:  
  498.     //
  499.     // Used for effiency
  500.     //
  501.     _TYPENAME 
  502.     basic_string<charT, traits, Allocator>::iterator replace (size_type, 
  503.                                                               size_type, 
  504.                                                               const charT*,
  505.                                                               size_type,
  506.                                                               size_type,
  507.                                                               size_type);
  508.  
  509.     _TYPENAME 
  510.     basic_string<charT, traits, Allocator>::iterator __replace_aux (
  511.         size_type, 
  512.         size_type,
  513.         const basic_string<charT, traits, Allocator>&,
  514.         size_type =0,
  515.         size_type =npos);
  516.  
  517. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  518.     template<class InputIterator>
  519.     basic_string<charT, traits, Allocator>& __replace_aux (
  520.         iterator first1, 
  521.         iterator last1,
  522.         InputIterator first2,
  523.         InputIterator last2);
  524. #endif
  525.  
  526.   public:
  527.     inline basic_string<charT, traits, Allocator>& replace (size_type, 
  528.                                                      size_type,
  529.                                                      const basic_string<charT, traits, Allocator>&);
  530.     inline basic_string<charT, traits, Allocator>& replace (size_type, 
  531.                                                      size_type,
  532.                                                      const basic_string<charT, traits, Allocator>&,
  533.                                                      size_type, 
  534.                                                      size_type);
  535.     inline basic_string<charT, traits, Allocator>& replace (size_type, 
  536.                                                      size_type, 
  537.                                                      const charT*, 
  538.                                                      size_type);
  539.     inline basic_string<charT, traits, Allocator>& replace (size_type,
  540.                                                      size_type, 
  541.                                                      const charT*);
  542.     basic_string<charT, traits, Allocator>& replace (size_type,
  543.                                                      size_type,
  544.                                                      size_type,
  545.                                                      charT);
  546.     inline basic_string<charT, traits, Allocator>& replace (iterator,
  547.                                                      iterator,
  548.                                                      const basic_string<charT, traits, Allocator>&);
  549.     inline basic_string<charT, traits, Allocator>& replace (iterator,
  550.                                                      iterator,
  551.                                                      const charT*,
  552.                                                      size_type);
  553.     inline basic_string<charT, traits, Allocator>& replace (iterator,
  554.                                                      iterator,
  555.                                                      const charT*);
  556.  
  557. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  558.     template<class InputIterator>
  559.     basic_string<charT, traits, Allocator>& replace (iterator, iterator, 
  560.                                                      InputIterator,
  561.                                                      InputIterator);
  562.     basic_string<charT, traits, Allocator>& replace (iterator first,
  563.                                                      iterator last,
  564.                                                      int n,
  565.                                                      charT c)
  566.     { return replace(first-begin(),last-first,n,c); }
  567.     basic_string<charT, traits, Allocator>& replace (iterator first,
  568.                                                      iterator last,
  569.                                                      unsigned int n,
  570.                                                      charT c)
  571.     { return replace(first-begin(),last-first,n,c); }
  572.     basic_string<charT, traits, Allocator>& replace (iterator first,
  573.                                                      iterator last,
  574.                                                      long n,
  575.                                                      charT c)
  576.     { return replace(first-begin(),last-first,n,c); }
  577.     basic_string<charT, traits, Allocator>& replace (iterator first,
  578.                                                      iterator last,
  579.                                                      unsigned long n,
  580.                                                      charT c)
  581.     { return replace(first-begin(),last-first,n,c); }
  582.     basic_string<charT, traits, Allocator>& replace (iterator first,
  583.                                                      iterator last,
  584.                                                      short n,
  585.                                                      charT c)
  586.     { return replace(first-begin(),last-first,n,c); }
  587.     basic_string<charT, traits, Allocator>& replace (iterator first,
  588.                                                      iterator last,
  589.                                                      unsigned short n,
  590.                                                      charT c)
  591.     { return replace(first-begin(),last-first,n,c); }
  592.     basic_string<charT, traits, Allocator>& replace (iterator first,
  593.                                                      iterator last,
  594.                                                      char n,
  595.                                                      charT c)
  596.     { return replace(first-begin(),last-first,n,c); }
  597.     basic_string<charT, traits, Allocator>& replace (iterator first,
  598.                                                      iterator last,
  599.                                                      unsigned char n,
  600.                                                      charT c)
  601.     { return replace(first-begin(),last-first,n,c); }
  602. #ifndef _RWSTD_NO_OVERLOAD_WCHAR
  603.     basic_string<charT, traits, Allocator>& replace (iterator first,
  604.                                                      iterator last,
  605.                                                      wchar_t n,
  606.                                                      charT c)
  607.     { return replace(first-begin(),last-first,n,c); }
  608. #endif
  609. #ifndef _RWSTD_NO_BOOL
  610.     basic_string<charT, traits, Allocator>& replace (iterator first,
  611.                                                      iterator last,
  612.                                                      bool n,
  613.                                                      charT c)
  614.     { return replace(first-begin(),last-first,n,c); }
  615. #endif
  616. #else
  617.     inline basic_string<charT, traits, Allocator>& replace (iterator, iterator, 
  618.                                                      const charT*,
  619.                                                      const charT*);
  620.     inline basic_string<charT, traits, Allocator>& replace (iterator,
  621.                                                      iterator,
  622.                                                      size_type,
  623.                                                      charT);
  624. #endif  // _RWSTD_NO_MEMBER_TEMPLATES
  625.  
  626.     size_type copy (charT*, size_type, size_type = 0) const;
  627.     basic_string<charT, traits, Allocator> copy () const; // Returns deep copy
  628.     void swap(basic_string<charT, traits, Allocator>& s)
  629.     {
  630.       charT * temp = __data_.data(); __data_ = s.__data_.data(); s.__data_ = temp;
  631.     }
  632.  
  633.     //
  634.     // string operations
  635.     //
  636.     inline const charT* c_str () const;
  637.     inline const charT* data  () const;
  638.     allocator_type get_allocator() const
  639.     {
  640.       return (allocator_type)__data_;
  641.     }
  642.  
  643.     inline size_type find (const basic_string<charT, traits, Allocator>&,
  644.                     size_type = 0) const;
  645.     size_type find (const charT*, size_type, size_type) const;
  646.     inline size_type find (const charT*, size_type = 0) const;
  647.     inline size_type find (charT, size_type = 0) const;
  648.  
  649.     inline size_type rfind (const basic_string<charT, traits, Allocator>&,
  650.                      size_type = npos) const;
  651.     size_type rfind (const charT*, size_type, size_type) const;
  652.     inline size_type rfind (const charT*, size_type = npos) const;
  653.     inline size_type rfind (charT, size_type = npos) const;
  654.  
  655.     inline size_type find_first_of (const basic_string<charT, traits, Allocator>&,
  656.                              size_type = 0) const;
  657.     size_type find_first_of (const charT*, size_type, size_type) const;
  658.     inline size_type find_first_of (const charT*, size_type = 0) const;
  659.     inline size_type find_first_of (charT, size_type = 0) const;
  660.     inline size_type find_last_of (const basic_string<charT, traits, Allocator>&,
  661.                             size_type = npos) const;
  662.     size_type find_last_of (const charT*, size_type, size_type) const;
  663.     inline size_type find_last_of (const charT*, size_type = npos) const;
  664.     inline size_type find_last_of (charT, size_type = npos) const;
  665.  
  666.     inline size_type find_first_not_of (const basic_string<charT, traits, Allocator>&,
  667.                                  size_type = 0) const;
  668.     size_type find_first_not_of (const charT*, size_type ,
  669.                                  size_type) const;
  670.     inline size_type find_first_not_of (const charT*, size_type = 0) const;
  671.     inline size_type find_first_not_of (charT, size_type = 0) const;
  672.  
  673.     inline size_type find_last_not_of (const basic_string<charT, traits, Allocator>&,
  674.                                 size_type = npos) const;
  675.     size_type find_last_not_of (const charT*, size_type, size_type) const;
  676.     inline size_type find_last_not_of (const charT*, size_type = npos) const;
  677.     inline size_type find_last_not_of (charT, size_type = npos) const;
  678.   
  679.     basic_string<charT, traits, Allocator> substr (size_type = 0,
  680.                                                    size_type = npos) const;
  681.   
  682.     inline int compare(const basic_string<charT, traits, Allocator>&) const;
  683.     int compare(size_type, size_type,
  684.                 const basic_string<charT, traits, Allocator>&) const;
  685.     int compare(size_type, size_type,
  686.                 const basic_string<charT, traits, Allocator>&,
  687.                 size_type, size_type) const;
  688.     inline int compare (const charT*) const;
  689.     int compare (size_type, size_type, const charT*, size_type) const;
  690.     inline int compare (size_type, size_type, const charT*) const;
  691.  
  692.   protected:
  693.  
  694.     size_type __getCapac () const { return __pref()->__getCapac(); }
  695.  
  696.     void __clobber (size_type); // Remove old contents
  697.     void __cow ()               // Do copy on write as necessary
  698.     { 
  699.       if (__pref()->__references() > 1) 
  700.         __clone(); 
  701.     }
  702.     void __cow (size_type nc)     // Do copy on write w/ new capacity
  703.     { 
  704.       if (__pref()->__references() > 1 || __getCapac() < nc)
  705.         __clone(nc);
  706.     }
  707.  
  708.   private:
  709.  
  710.     void __initn(size_type, charT);
  711.  
  712.     static charT __eos () { return (charT)0; }
  713.   
  714.     //
  715.     // Make a distinct copy of self
  716.     //
  717.     void __clone (); 
  718.     //
  719.     // Make a distinct copy w/ new capacity nc
  720.     //
  721.     void __clone (size_type nc);
  722.  
  723.     __string_ref_type *  __pref () const
  724.     { 
  725. #ifdef _RWSTD_SUNPRO_ANACHRONISM
  726.       return (__string_ref_type*)__data_.data() - 1;
  727. #else
  728.       return _RWSTD_STATIC_CAST(__string_ref_type*,
  729.                                 ((_RWSTD_REINTERPRET_CAST(__string_ref_type*,__data_.data())) - 1)); 
  730. #endif
  731.     }
  732.  
  733.     //
  734.     // Disconnect from ref, maybe delete it.
  735.     //
  736.     inline void      __unLink          ();   
  737.  
  738. #ifndef _RWSTD_NO_NAMESPACE
  739.     friend class __RWSTD::__string_ref<charT,traits,Allocator>;
  740. #else
  741.     friend class __string_ref<charT,traits,Allocator>;
  742. #endif
  743.  
  744.     //
  745.     // Null string ref
  746.     //
  747. #ifndef _RWSTD_NO_STATIC_DEF3
  748.     static const __null_ref_type __nullref;
  749. #endif
  750.  
  751.     static __string_ref_type * __getNullRep ()
  752.     {
  753. #ifndef _RWSTD_NO_STATIC_DEF3
  754. #  ifdef _RWSTD_NO_STATIC_CAST
  755.       return (__string_ref_type *)&__nullref;
  756. #  else
  757.       return reinterpret_cast<__string_ref_type *>
  758.              (const_cast<__null_ref_type *>(&__nullref));
  759. #  endif // _RWSTD_NO_STATIC_CAST
  760. #else
  761.       if (!__RWSTD::__nullref_initialized)
  762.       {
  763.         new (&__RWSTD::__nullref) __null_ref_type();
  764.         __RWSTD::__nullref_initialized = 1;
  765.       }
  766.       return (__string_ref_type *) &__RWSTD::__nullref[0]; 
  767. #endif // _RWSTD_NO_STATIC_DEF3
  768.     }
  769.     __string_ref_type * __getRep (size_type capac, size_type nchar);
  770.  
  771.     __RWSTD::__rw_basis<charT*,allocator_type>    __data_;                   
  772.   };
  773. //
  774. // Standard Type Definitions
  775. //
  776.   typedef basic_string<char, char_traits<char>, allocator<char> >
  777.   string;
  778.  
  779. #ifndef _RWSTD_NO_WIDE_CHAR
  780.   typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >
  781.   wstring;
  782. #endif
  783.  
  784. //
  785. // The following has to go after the declaration of the string
  786. // classes because of cross references.
  787. //
  788.  
  789. #ifndef _RWSTD_NO_NAMESPACE
  790. }
  791. #endif
  792.  
  793. #ifdef _RW_STD_EXCEPT
  794. #include <stdexcept>
  795. #endif
  796.  
  797. #if defined(_RWSTD_NO_DESTROY_BUILTIN) || defined(_RWSTD_NO_DESTROY_NONBUILTIN)
  798.  
  799. #ifndef _RWSTD_NO_NAMESPACE
  800. namespace __rwstd {
  801. #endif
  802. //
  803. // Specializations for STL destroy
  804. //
  805.   inline void __destroy (string**)    {;}
  806.   inline void __destroy (string***)   {;}
  807.   inline void __destroy (string****)  {;}
  808. #ifndef _RWSTD_NO_WIDE_CHAR
  809.   inline void __destroy (wstring**)   {;}
  810.   inline void __destroy (wstring***)  {;}
  811.   inline void __destroy (wstring****) {;}
  812. #endif
  813.  
  814. #ifndef _RWSTD_NO_NAMESPACE
  815. }
  816. #endif
  817. #endif // _RWSTD_NO_DESTROY_BUILTIN || _RWSTD_NO_DESTROY_NONBUILTIN
  818.  
  819. #ifndef _RWSTD_NO_NAMESPACE
  820. namespace std {
  821. #endif
  822.  
  823. //
  824. // Inline member functions for class basic_string
  825. //
  826.  
  827.   template <class charT, class traits , class Allocator  >
  828.   inline void basic_string<charT, traits, Allocator>::__unLink()
  829.   {
  830.     if (!__data_.data())
  831.       return;
  832.     if (__pref()->__references() == 0 || __pref()->__removeReference() == 0) 
  833.     {
  834.       __ref_alloc_type(__data_).destroy(__pref());
  835.       __value_alloc_type(__data_).
  836.         deallocate(_RWSTD_REINTERPRET_CAST(charT*,__pref()),length());
  837.       __data_ = (charT*)0;
  838.     }
  839.   }
  840.  
  841.   template <class charT, class traits , class Allocator  >
  842.   inline basic_string<charT, traits, Allocator>
  843.   ::basic_string (const Allocator& alloc) : __data_((charT*)0,alloc)
  844.   {
  845.     __data_ = __getNullRep()->data();
  846.     __getNullRep()->__addReference();
  847.   }
  848.  
  849. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  850.   template <class charT, class traits , class Allocator  >
  851.   inline basic_string<charT, traits, Allocator>
  852.   ::basic_string (void) : __data_((charT*)0,Allocator())
  853.   {
  854.     __data_ = __getNullRep()->data();
  855.     __getNullRep()->__addReference();
  856.   }
  857. #endif
  858.  
  859.   template <class charT, class traits , class Allocator  >
  860.   inline
  861.   basic_string<charT, traits, Allocator>
  862.   ::basic_string (const basic_string<charT, traits, Allocator> & s)
  863.    : __data_((charT*)0,Allocator())
  864.   {                     
  865.     if ( s.__pref()->__references() > 0 )
  866.     {                                    
  867.       __data_ = s.__data_.data();
  868.       __pref()->__addReference();
  869.     }
  870.     else
  871.     {
  872.       size_type n = s.length();
  873.       __data_  = __getRep(n, n)->data();
  874.       traits::copy(__data_.data(), s.c_str(), n);
  875.     }
  876.   }
  877.   template <class charT, class traits , class Allocator  >
  878.   inline basic_string<charT, traits, Allocator> &
  879.   basic_string<charT, traits, Allocator>::operator= (charT c)
  880.   {
  881.     replace(0,length(),1,c);
  882.     return *this;
  883.   }
  884.  
  885.   template <class charT, class traits , class Allocator  >
  886.   inline basic_string<charT, traits, Allocator> &
  887.   basic_string<charT, traits, Allocator>::operator+= (const basic_string<charT, traits, Allocator>& s)
  888.   {
  889.     return append(s);
  890.   }
  891.  
  892.   template <class charT, class traits , class Allocator  >
  893.   inline basic_string<charT, traits, Allocator> &
  894.   basic_string<charT, traits, Allocator>::operator+= (const charT* s)
  895.   {
  896.     return append(s);
  897.   }
  898.  
  899.   template <class charT, class traits , class Allocator  >
  900.   inline basic_string<charT, traits, Allocator> &
  901.   basic_string<charT, traits, Allocator>::operator+= (charT c)
  902.   {
  903.     return append((size_type) 1, c);
  904.   }
  905.  
  906.   template <class charT, class traits , class Allocator  >
  907.   inline basic_string<charT, traits, Allocator> &
  908.   basic_string<charT, traits, Allocator>::append (const charT* s, size_type n)
  909.   {
  910.     replace(size(),0,s,n,0,n);
  911.     return *this;
  912.   }
  913.  
  914.   template <class charT, class traits , class Allocator  >
  915.   inline basic_string<charT, traits, Allocator> &
  916.   basic_string<charT, traits, Allocator>::append (const charT* s)
  917.   {
  918.     replace(size(),0,s);
  919.     return *this;
  920.   }
  921.  
  922. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  923.   template<class charT, class traits , class Allocator >
  924.   template<class InputIterator>
  925.   inline basic_string<charT, traits, Allocator>& 
  926.   basic_string<charT, traits, Allocator>::append (InputIterator first, 
  927.                                                   InputIterator last )
  928.   {
  929.     replace(end(),end(),first,last);
  930.     return *this;
  931.   }
  932. #else
  933.   template <class charT, class traits , class Allocator  >
  934.   inline basic_string<charT, traits, Allocator>& 
  935.   basic_string<charT, traits, Allocator>::append (const charT* first, 
  936.                                                   const charT* last)
  937.   {
  938.     replace(size(),0,first,last-first,0,last-first);
  939.     return *this;
  940.   }
  941.  
  942.   template <class charT, class traits , class Allocator  >
  943.   inline basic_string<charT, traits, Allocator> &
  944.   basic_string<charT, traits, Allocator>::append (size_type n, charT c)
  945.   {
  946.     replace(length(),0,n,c);
  947.     return *this;
  948.   }
  949. #endif // _RWSTD_NO_MEMBER_TEMPLATES 
  950.  
  951.   template <class charT, class traits , class Allocator  >
  952.   void basic_string<charT, traits, Allocator>::push_back(const charT c)
  953.   {
  954.     replace(size(),0,1,c);
  955.   }
  956.  
  957.   template <class charT, class traits , class Allocator  >
  958.   inline basic_string<charT, traits, Allocator> &
  959.   basic_string<charT, traits, Allocator>::assign (const charT* s, size_type n)
  960.   {
  961.     replace(0, length(), s, n, 0, n);
  962.     return *this;
  963.   }
  964.  
  965.   template <class charT, class traits , class Allocator  >
  966.   inline basic_string<charT, traits, Allocator> &
  967.   basic_string<charT, traits, Allocator>::assign (const charT* s)
  968.   {
  969.     size_type len = traits::length(s);
  970.     replace(0, length(), s, len, 0, len);
  971.     return *this;
  972.   }
  973.  
  974. #ifndef _RWSTD_NO_MEMBER_TEMPLATES 
  975.   template<class charT, class traits , class Allocator >
  976.   template<class InputIterator>
  977.   inline basic_string<charT, traits, Allocator>& 
  978.   basic_string<charT, traits, Allocator>::assign (InputIterator first, 
  979.                                                   InputIterator last)
  980.   {
  981.     replace(begin(),end(),first,last);
  982.     return *this;
  983.   }
  984. #else
  985.   template <class charT, class traits , class Allocator  >
  986.   inline basic_string<charT, traits, Allocator>& 
  987.   basic_string<charT, traits, Allocator>::assign (const charT* first, 
  988.                                                   const charT* last)
  989.   {
  990.     replace(0,length(),first,last-first,0,last-first);
  991.     return *this;
  992.   }
  993.  
  994.   template <class charT, class traits , class Allocator  >
  995.   inline basic_string<charT, traits, Allocator> &
  996.   basic_string<charT, traits, Allocator>::assign (size_type n, charT c)
  997.   {
  998.     return replace(0,length(),n,c);
  999.   }
  1000. #endif // _RWSTD_NO_MEMBER_TEMPLATES 
  1001.  
  1002.   template <class charT, class traits , class Allocator  >
  1003.   inline basic_string<charT, traits, Allocator> &
  1004.   basic_string<charT, traits, Allocator>::insert (size_type pos,
  1005.                                                   const charT* s,
  1006.                                                   size_type n)
  1007.   {
  1008.     replace(pos, 0, s, n, 0, n);
  1009.     return *this;
  1010.   }
  1011.  
  1012.   template <class charT, class traits , class Allocator  >
  1013.   inline basic_string<charT, traits, Allocator> &
  1014.   basic_string<charT, traits, Allocator>::insert (size_type pos, const charT* s)
  1015.   {
  1016.     size_type len = traits::length(s);
  1017.     replace(pos, 0, s, len, 0, len);
  1018.     return *this;
  1019.   }
  1020.  
  1021. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  1022.   template<class charT, class traits , class Allocator >
  1023.   template<class InputIterator>
  1024.   inline void 
  1025.   basic_string<charT, traits, Allocator>::insert (
  1026.       iterator p, 
  1027.       InputIterator first,
  1028.       InputIterator last)
  1029.   {
  1030.     replace(p,p,first,last);
  1031.   }
  1032. #else
  1033.   template <class charT, class traits , class Allocator  >
  1034.   inline void 
  1035.   basic_string<charT, traits, Allocator>::insert (
  1036.       iterator p, 
  1037.       const charT* first,
  1038.       const charT* last)
  1039.   {
  1040.     replace(p-begin(),0,first,last-first,0,last-first);
  1041.   }
  1042.  
  1043.   template <class charT, class traits , class Allocator  >
  1044.   inline void 
  1045.   basic_string<charT, traits, Allocator>::insert (
  1046.       iterator p,
  1047.       size_type n,
  1048.       charT c)
  1049.   {
  1050.       replace(p-begin(),0,n,c);
  1051.   }
  1052.  
  1053.   template <class charT, class traits , class Allocator  >
  1054.   inline basic_string<charT, traits, Allocator> &
  1055.   basic_string<charT, traits, Allocator>::insert(size_type pos,
  1056.                                                  size_type n,
  1057.                                                  charT c)
  1058.   {
  1059.     return replace(pos,0,n,c);
  1060.   }
  1061. #endif // _RWSTD_NO_MEMBER_TEMPLATES
  1062.  
  1063.   template <class charT, class traits , class Allocator  >
  1064.   inline basic_string<charT, traits, Allocator> &
  1065.   basic_string<charT, traits, Allocator>::erase (size_type pos, size_type n)
  1066.   {
  1067.     _RWSTD_THROW(pos > length(), out_of_range,
  1068.      __RWSTD::except_msg_string(__RWSTD::__rwse_StringIndexOutOfRange,
  1069.          "basic_string::erase(size_t,size_t)", pos,length()).msgstr());
  1070.  
  1071.     size_type len = length() - pos;
  1072.     charT tmp[1];
  1073.     *tmp = 0;
  1074.     return replace(pos,n < len ? n : len, tmp,0);
  1075.   }
  1076.  
  1077.   template <class charT, class traits , class Allocator  >
  1078.   inline basic_string<charT, traits, Allocator> &
  1079.   basic_string<charT, traits, Allocator>::replace (size_type pos1,
  1080.                                                    size_type n1,
  1081.                                                    const basic_string<charT, traits, Allocator> & str, 
  1082.                                                    size_type pos2,
  1083.                                                    size_type n2)
  1084.   {
  1085.     replace(pos1, n1, str.data(), str.length(), pos2, n2);
  1086.     return *this;
  1087.   }
  1088.  
  1089.   template <class charT, class traits , class Allocator  >
  1090.   inline basic_string<charT, traits, Allocator> &
  1091.   basic_string<charT, traits, Allocator>::replace (
  1092.       size_type pos1,
  1093.       size_type n1,
  1094.       const basic_string<charT, traits, Allocator> & str)
  1095.   {
  1096.     replace(pos1, n1, str.data(), str.length(),0,str.length());
  1097.     return *this;
  1098.   }
  1099.  
  1100.   template <class charT, class traits , class Allocator  >
  1101.   inline _TYPENAME basic_string<charT, traits, Allocator>::iterator
  1102.   basic_string<charT, traits, Allocator>::__replace_aux (size_type pos1,
  1103.                                                        size_type n1,
  1104.                                                        const basic_string<charT, traits, Allocator> & str, 
  1105.                                                        size_type pos2,
  1106.                                                        size_type n2)
  1107.   {
  1108.     return replace(pos1, n1, str.data(), str.length(), pos2, n2);
  1109.   }
  1110.  
  1111.   template <class charT, class traits , class Allocator  >
  1112.   inline basic_string<charT, traits, Allocator> &
  1113.   basic_string<charT, traits, Allocator>::replace (size_type pos,
  1114.                                                    size_type n1,
  1115.                                                    const charT* s,
  1116.                                                    size_type n2)
  1117.   {
  1118.     replace(pos, n1, s, n2, 0, n2);
  1119.     return *this;
  1120.   }
  1121.  
  1122.   template <class charT, class traits , class Allocator  >
  1123.   inline basic_string<charT, traits, Allocator> &
  1124.   basic_string<charT, traits, Allocator>::replace (size_type pos,
  1125.                                                    size_type n1,
  1126.                                                    const charT* s)
  1127.   {
  1128.     size_type len = traits::length(s);
  1129.     replace(pos, n1, s, len, 0, len);
  1130.     return *this;
  1131.   }
  1132.  
  1133.   template <class charT, class traits , class Allocator  >
  1134.   inline basic_string<charT, traits, Allocator>& 
  1135.   basic_string<charT, traits, Allocator>::replace (
  1136.       iterator first,
  1137.       iterator last,
  1138.       const basic_string<charT, traits, Allocator>& str)
  1139.   {
  1140.     return replace(first - begin(), last - first, str);
  1141.   }
  1142.  
  1143.   template <class charT, class traits , class Allocator  >
  1144.   inline basic_string<charT, traits, Allocator>& 
  1145.   basic_string<charT, traits, Allocator>::replace (
  1146.       iterator first, 
  1147.       iterator last,
  1148.       const charT* s,
  1149.       size_type n)
  1150.   {
  1151.     replace(first-begin(),last-first,s,n,0,n);
  1152.     return *this;
  1153.   }
  1154.  
  1155.   template <class charT, class traits , class Allocator  >
  1156.   inline basic_string<charT, traits, Allocator>& 
  1157.   basic_string<charT, traits, Allocator>::replace (
  1158.       iterator first, 
  1159.       iterator last,
  1160.       const charT* s)
  1161.   {
  1162.     size_type len = traits::length(s);
  1163.     replace(first-begin(),last-first,s,len,0,len);
  1164.     return *this;
  1165.   }
  1166. #ifdef _RWSTD_NO_MEMBER_TEMPLATES
  1167.   template <class charT, class traits , class Allocator  >
  1168.   inline basic_string<charT, traits, Allocator>& 
  1169.   basic_string<charT, traits, Allocator>::replace (
  1170.       iterator first1, 
  1171.       iterator last1,
  1172.       const charT* first2,
  1173.       const charT* last2)
  1174.   {
  1175.     replace(first1-begin(),last1-first1,first2,last2-first2,0,last2-first2);
  1176.     return *this;
  1177.   }
  1178.  
  1179.   template <class charT, class traits , class Allocator  >
  1180.   inline basic_string<charT, traits, Allocator>& 
  1181.   basic_string<charT, traits, Allocator>::replace (
  1182.       iterator first, 
  1183.       iterator last,
  1184.       size_type n,
  1185.       charT c)
  1186.   {
  1187.     return replace(first-begin(),last-first,n,c);
  1188.   }
  1189. #endif
  1190.  
  1191.   template <class charT, class traits , class Allocator  >
  1192.   inline _TYPENAME basic_string<charT, traits,Allocator>::const_reference 
  1193.   basic_string<charT, traits, Allocator>::operator[] (size_type pos) const
  1194.   {
  1195. #ifdef _RWSTD_BOUNDS_CHECKING
  1196.     _RWSTD_THROW(pos > size(), out_of_range,
  1197.      __RWSTD::except_msg_string(__RWSTD::__rwse_PosBeyondEndOfString,
  1198.         "basic_string::operator[](size_t) const", pos,size()).msgstr());
  1199. #endif
  1200.     return __data_.data()[pos];
  1201.   }
  1202.  
  1203.   template <class charT, class traits , class Allocator  >
  1204.   inline _TYPENAME basic_string<charT, traits, Allocator>::reference
  1205.   basic_string<charT, traits, Allocator>::operator[] (size_type pos)
  1206.   {
  1207. #ifdef _RWSTD_BOUNDS_CHECKING
  1208.     _RWSTD_THROW(pos >= size(), out_of_range,
  1209.      __RWSTD::except_msg_string(__RWSTD::__rwse_PosBeyondEndOfString,
  1210.         "basic_string::operator[](size_t)", pos,size()).msgstr());
  1211. #endif
  1212.     __cow();
  1213.     __pref()->__setRefCount(0);
  1214.     return __data_.data()[pos];
  1215.   }
  1216.  
  1217.   template <class charT, class traits , class Allocator  >
  1218.   inline _TYPENAME basic_string<charT, traits, Allocator>::const_reference
  1219.   basic_string<charT, traits, Allocator>::at (size_type pos) const
  1220.   {
  1221.     _RWSTD_THROW(pos >= size(), out_of_range,
  1222.      __RWSTD::except_msg_string(__RWSTD::__rwse_PosBeyondEndOfString,
  1223.         "basic_string::at(size_t) const", pos,size()).msgstr());
  1224.  
  1225.     return __data_.data()[pos];
  1226.   }
  1227.   template <class charT, class traits , class Allocator  >
  1228.   inline _TYPENAME basic_string<charT, traits, Allocator>::reference
  1229.   basic_string<charT, traits, Allocator>::at (size_type pos)
  1230.   {
  1231.     _RWSTD_THROW(pos >= size(), out_of_range,
  1232.      __RWSTD::except_msg_string(__RWSTD::__rwse_PosBeyondEndOfString,
  1233.           "basic_string::at(size_t)", pos,size()).msgstr());
  1234.  
  1235.     __cow();
  1236.     __pref()->__setRefCount(0);
  1237.     return __data_.data()[pos];
  1238.   }
  1239.  
  1240.   template <class charT, class traits , class Allocator  >
  1241.   inline const charT* basic_string<charT, traits, Allocator>::c_str () const
  1242.   {
  1243.     return __data_.data();
  1244.   }
  1245.  
  1246.   template <class charT, class traits , class Allocator  >
  1247.   inline const charT* basic_string<charT, traits, Allocator>::data () const
  1248.   {
  1249.     return __data_.data();
  1250.   }
  1251.  
  1252.   template <class charT, class traits , class Allocator  >
  1253.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1254.   basic_string<charT, traits, Allocator>::length () const
  1255.   {
  1256.     return __pref()->__nchars_;
  1257.   }
  1258.  
  1259.   template <class charT, class traits , class Allocator  >
  1260.   inline void
  1261.   basic_string<charT, traits, Allocator>::resize (size_type n, charT c)
  1262.   {
  1263.     _RWSTD_THROW(n > max_size(), length_error,
  1264.      __RWSTD::except_msg_string(__RWSTD::__rwse_InvalidSizeParam,
  1265.         "basic_string( const charT*,size_type,const Allocator&)",n,npos).msgstr());
  1266.     if (n < length())
  1267.       erase(n,length()-n);
  1268.     else
  1269.       replace(length(),0,n-length(),c);
  1270.     __pref()->__setRefCount(1);
  1271.   }
  1272.  
  1273.   template <class charT, class traits , class Allocator  >
  1274.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1275.   basic_string<charT, traits, Allocator>::capacity () const
  1276.   {
  1277.     return __getCapac();
  1278.   }
  1279.  
  1280.   template <class charT, class traits , class Allocator  >
  1281.   inline void basic_string<charT, traits, Allocator>::reserve(size_type res_arg)
  1282.   {
  1283.      _RWSTD_THROW(res_arg > max_size(), length_error,
  1284.         __RWSTD::except_msg_string(__RWSTD::__rwse_InvalidSizeParam,
  1285.           "basic_string::reserve(size_t)",res_arg,max_size()).msgstr());
  1286.  
  1287.     if (res_arg > __getCapac()) __clone(res_arg);
  1288.   }
  1289.  
  1290.   template <class charT, class traits , class Allocator  >
  1291.   inline basic_string<charT, traits, Allocator>
  1292.   basic_string<charT, traits, Allocator>::copy () const
  1293.   {
  1294.     basic_string<charT, traits, Allocator> temp(*this); // Make referenced copy
  1295.     temp.__clone();   // Make a distinct copy
  1296.     return temp;
  1297.   }
  1298.  
  1299.   template <class charT, class traits, class Allocator >
  1300.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1301.   basic_string<charT, traits, Allocator>::find (
  1302.       const basic_string<charT, traits, Allocator>& str,
  1303.       size_type                                     pos) const
  1304.   {
  1305.     return find(str.c_str(),pos,str.length());
  1306.   }
  1307.  
  1308.   template <class charT, class traits , class Allocator  >
  1309.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1310.   basic_string<charT, traits, Allocator>::find (const charT* s,
  1311.                                                 size_type pos) const
  1312.   {
  1313.     _RWSTD_THROW(s == 0, logic_error,
  1314.      __RWSTD::except_msg_string(__RWSTD::__rwse_UnexpectedNullPtr,
  1315.        "basic_string::find(const char*,size_t) const").msgstr());
  1316.  
  1317.     if (pos > length())
  1318.       return npos;
  1319.     const charT* p = __RWSTD::rw_traits<charT,traits>::find(__data_.data()+pos,s);
  1320.     return p ? p - __data_.data() : npos;
  1321.   }
  1322.  
  1323.   template <class charT, class traits , class Allocator  >
  1324.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1325.   basic_string<charT, traits, Allocator>::find (charT c, size_type pos) const
  1326.   {
  1327.     if (pos > length())
  1328.       return npos;
  1329.     const charT* p =  traits::find(__data_.data()+pos,length()-pos,c);
  1330.     return p ? p - __data_.data() : npos;
  1331.   }
  1332.  
  1333.   template <class charT, class traits, class Allocator >
  1334.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1335.   basic_string<charT, traits, Allocator>::rfind (
  1336.       const basic_string<charT, traits, Allocator>& str,
  1337.       size_type                                     pos) const
  1338.   {
  1339.     return rfind(str.c_str(), pos, str.length());
  1340.   }
  1341.  
  1342.   template <class charT, class traits , class Allocator  >
  1343.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1344.   basic_string<charT, traits, Allocator>::rfind (const charT* s, size_type pos)
  1345.   const
  1346.   {  
  1347.     size_type len = traits::length(s);
  1348.     return rfind(s, pos,len);
  1349.   }
  1350.  
  1351.   template <class charT, class traits , class Allocator  >
  1352.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1353.   basic_string<charT, traits, Allocator>::rfind (charT c, size_type pos) const
  1354.   {
  1355.     if (pos > length())
  1356.       pos = length();
  1357.     const charT* p = __RWSTD::rw_traits<charT,traits>::rfind(__data_.data(),c,pos);
  1358.     return p ? p - __data_.data() : npos;
  1359.   }
  1360.  
  1361.   template <class charT, class traits, class Allocator >
  1362.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1363.   basic_string<charT, traits, Allocator>::find_first_of (
  1364.       const basic_string<charT, traits, Allocator>& str,
  1365.       size_type                                     pos) const
  1366.   {
  1367.     return find_first_of(str.c_str(),pos,str.length());
  1368.   }
  1369.  
  1370.   template <class charT, class traits , class Allocator  >
  1371.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1372.   basic_string<charT, traits, Allocator>::find_first_of (const charT* s,
  1373.                                                          size_type pos) const
  1374.   {
  1375.     _RWSTD_THROW(s == 0, logic_error,
  1376.      __RWSTD::except_msg_string(__RWSTD::__rwse_UnexpectedNullPtr,
  1377.         "basic_string::find_first_of(char*,size_t) const").msgstr());
  1378.  
  1379.     if (pos > length())
  1380.       return npos;
  1381.     size_type i = __RWSTD::rw_traits<charT,traits>::find_first_of(__data_.data()+pos,s) + pos;
  1382.     return i >= length() ? npos : i;
  1383.   }
  1384.  
  1385.   template <class charT, class traits , class Allocator  >
  1386.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1387.   basic_string<charT, traits, Allocator>::find_first_of (charT c, size_type pos) const
  1388.   {
  1389.     return find(c, pos);
  1390.   }
  1391.  
  1392.   template <class charT, class traits, class Allocator >
  1393.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1394.   basic_string<charT, traits, Allocator>::find_last_of (
  1395.       const basic_string<charT, traits, Allocator>& str,
  1396.       size_type                                     pos) const
  1397.   {
  1398.     return find_last_of(str.c_str(), pos,str.length());
  1399.   }
  1400.  
  1401.   template <class charT, class traits , class Allocator  >
  1402.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1403.   basic_string<charT, traits, Allocator>::find_last_of (const charT* s,
  1404.                                                         size_type pos) const
  1405.   {
  1406.     size_type len = traits::length(s);
  1407.     return find_last_of(s, pos,len);
  1408.   }
  1409.  
  1410.   template <class charT, class traits , class Allocator  >
  1411.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1412.   basic_string<charT, traits, Allocator>::find_last_of (charT c, size_type pos)
  1413.   const
  1414.   {
  1415.     return rfind(c,pos);
  1416.   }
  1417.  
  1418.   template <class charT, class traits, class Allocator >
  1419.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1420.   basic_string<charT, traits, Allocator>::find_first_not_of (
  1421.       const basic_string<charT, traits, Allocator>& str,
  1422.       size_type                                     pos) const
  1423.   {
  1424.     return find_first_not_of(str.c_str(), pos, str.length());
  1425.   }
  1426.  
  1427.   template <class charT, class traits , class Allocator  >
  1428.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1429.   basic_string<charT, traits, Allocator>::find_first_not_of (const charT* s,
  1430.                                                              size_type pos) const
  1431.   {
  1432.     _RWSTD_THROW(s == 0, logic_error,
  1433.      __RWSTD::except_msg_string(__RWSTD::__rwse_UnexpectedNullPtr,
  1434.        "basic_string::find_first_not_of(char*,size_t) const").msgstr());
  1435.  
  1436.     if (pos > length())
  1437.       return npos;
  1438.     size_type i = __RWSTD::rw_traits<charT,traits>::find_first_not_of(__data_.data()+pos,s) + pos;
  1439.     return i >= length() ? npos : i;
  1440.   }
  1441.  
  1442.   template <class charT, class traits , class Allocator  >
  1443.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1444.   basic_string<charT, traits, Allocator>::find_first_not_of (charT c,
  1445.                                                              size_type pos) const
  1446.   {
  1447.     charT tmp[2];
  1448.     *tmp = c;
  1449.     tmp[1] = 0;
  1450.     return find_first_not_of(tmp, pos);
  1451.   }
  1452.  
  1453.   template <class charT, class traits, class Allocator >
  1454.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1455.   basic_string<charT, traits, Allocator>::find_last_not_of (
  1456.       const basic_string<charT, traits, Allocator>& str,
  1457.       size_type                                     pos) const
  1458.   {
  1459.     return find_last_not_of(str.c_str(), pos, str.length());
  1460.   }
  1461.  
  1462.   template <class charT, class traits , class Allocator  >
  1463.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1464.   basic_string<charT, traits, Allocator>::find_last_not_of (const charT* s,
  1465.                                                             size_type pos) const
  1466.   {
  1467.     size_type len = traits::length(s);
  1468.     return find_last_not_of(s, pos, len);
  1469.   }
  1470.  
  1471.   template <class charT, class traits , class Allocator  >
  1472.   inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  1473.   basic_string<charT, traits, Allocator>::find_last_not_of (charT c,
  1474.                                                             size_type pos) const
  1475.   {
  1476.     charT tmp[2];
  1477.     *tmp = c;
  1478.     tmp[1] = 0;
  1479.     return find_last_not_of(tmp, pos);
  1480.   }
  1481.  
  1482.   template <class charT, class traits, class Allocator >
  1483.   inline int
  1484.   basic_string<charT, traits, Allocator>::compare (
  1485.       const basic_string<charT, traits, Allocator>& str) const
  1486.   {
  1487.     return compare(0,length(),str.c_str(),str.length());
  1488.   }
  1489.  
  1490.   template <class charT, class traits , class Allocator  >
  1491.   inline int
  1492.   basic_string<charT, traits, Allocator>::compare (size_type pos,
  1493.                                                    size_type n1,
  1494.                                                    const charT* s) const
  1495.   {
  1496.     size_type len = traits::length(s);
  1497.     return compare(pos,n1,s,len);
  1498.   }
  1499.  
  1500.   template <class charT, class traits , class Allocator  >
  1501.   inline int
  1502.   basic_string<charT, traits, Allocator>::compare (const charT* s) const
  1503.   {
  1504.     size_type len = traits::length(s);
  1505.     return compare(0,length(),s,len);
  1506.   }
  1507.  
  1508. //
  1509. // Inlined non-member operators
  1510. //
  1511.  
  1512.   template <class charT, class traits , class Allocator  >
  1513.   inline basic_string<charT, traits, Allocator> operator+(
  1514.       const basic_string<charT, traits, Allocator>& lhs,
  1515.       const basic_string<charT, traits, Allocator>& rhs)
  1516.   {
  1517.     return basic_string<charT, traits, Allocator>(lhs).append(rhs);
  1518.   }
  1519.  
  1520.   template <class charT, class traits , class Allocator  >
  1521.   inline basic_string<charT, traits, Allocator> operator+(
  1522.       const charT*                                  lhs,
  1523.       const basic_string<charT, traits, Allocator>& rhs)
  1524.   {
  1525.     return basic_string<charT, traits, Allocator>(lhs).append(rhs);
  1526.   }
  1527.  
  1528.   template <class charT, class traits , class Allocator  >
  1529.   inline basic_string<charT, traits, Allocator> operator+(
  1530.       charT lhs, const basic_string<charT, traits, Allocator>& rhs)
  1531.   {
  1532.     return basic_string<charT, traits, Allocator>(1,lhs).append(rhs);
  1533.   }
  1534.  
  1535.   template <class charT, class traits , class Allocator  >
  1536.   inline basic_string<charT, traits, Allocator> operator+(
  1537.       const basic_string<charT, traits, Allocator>& lhs,
  1538.       const charT*                                  rhs)
  1539.   {
  1540.     return basic_string<charT,traits,Allocator>(lhs).append(basic_string<charT, traits, Allocator>(rhs));
  1541.   }
  1542.  
  1543.   template <class charT, class traits , class Allocator  >
  1544.   inline basic_string<charT, traits, Allocator> operator+(
  1545.       const basic_string<charT, traits, Allocator>& lhs,
  1546.       charT                                         rhs)
  1547.   {
  1548.     return basic_string<charT,traits,Allocator>(lhs).append(basic_string<charT, traits, Allocator>(1,rhs));
  1549.   }
  1550.  
  1551.   template <class charT, class traits , class Allocator  >
  1552.   inline bool operator==(
  1553.       const basic_string<charT, traits, Allocator>& lhs,
  1554.       const basic_string<charT, traits, Allocator>& rhs)
  1555.   {
  1556.     return lhs.compare(rhs) == 0 ? true : false ;
  1557.   }
  1558.  
  1559.   template <class charT, class traits , class Allocator  >
  1560.   inline bool operator==(
  1561.       const charT*                                  lhs,
  1562.       const basic_string<charT, traits, Allocator>& rhs)
  1563.   {
  1564.     return basic_string<charT,traits,Allocator>(lhs).compare(rhs)==0?true:false;
  1565.   }
  1566.  
  1567.   template <class charT, class traits , class Allocator  >
  1568.   inline bool operator==(
  1569.       const basic_string<charT, traits, Allocator>& lhs,
  1570.       const charT*                                  rhs)
  1571.   {
  1572.     return lhs.compare(basic_string<charT,traits,Allocator>(rhs))==0?true:false;
  1573.   }
  1574.  
  1575.   template <class charT, class traits , class Allocator  >
  1576.   inline bool operator<(
  1577.       const basic_string<charT, traits, Allocator>& lhs,
  1578.       const basic_string<charT, traits, Allocator>& rhs)
  1579.   {
  1580.     return lhs.compare(rhs) < 0 ? true:false ;
  1581.   }
  1582.  
  1583.   template <class charT, class traits , class Allocator  >
  1584.   inline bool operator<(
  1585.       const charT*                                  lhs,
  1586.       const basic_string<charT, traits, Allocator>& rhs)
  1587.   {
  1588.     return basic_string<charT,traits,Allocator>(lhs).compare(rhs)<0?true:false;
  1589.   }
  1590.  
  1591.   template <class charT, class traits , class Allocator  >
  1592.   inline bool operator<(
  1593.       const basic_string<charT, traits, Allocator>& lhs,
  1594.       const charT*                                  rhs)
  1595.   {
  1596.     return lhs.compare(basic_string<charT,traits,Allocator>(rhs))<0?true:false;
  1597.   }
  1598.  
  1599. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  1600.   template <class charT, class traits , class Allocator  >
  1601.   inline bool operator!=(
  1602.       const basic_string<charT, traits, Allocator>& lhs,
  1603.       const basic_string<charT, traits, Allocator>& rhs)
  1604.   {
  1605.     return lhs.compare(rhs) != 0 ? true : false;
  1606.   }
  1607. #endif
  1608.  
  1609.   template <class charT, class traits , class Allocator  >
  1610.   inline bool operator!=(
  1611.       const charT*                                  lhs,
  1612.       const basic_string<charT, traits, Allocator>& rhs)
  1613.   {
  1614.     return basic_string<charT,traits,Allocator>(lhs).compare(rhs)!=0?true:false;
  1615.   }
  1616.  
  1617.   template <class charT, class traits , class Allocator  >
  1618.   inline bool operator!=(
  1619.       const basic_string<charT, traits, Allocator>& lhs,
  1620.       const charT*                                  rhs)
  1621.   {
  1622.     return lhs.compare(basic_string<charT,traits,Allocator>(rhs))!=0?true:false;
  1623.   }
  1624.  
  1625. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  1626.   template <class charT, class traits , class Allocator  >
  1627.   inline bool operator>(
  1628.       const basic_string<charT, traits, Allocator>& lhs,
  1629.       const basic_string<charT, traits, Allocator>& rhs)
  1630.   {
  1631.     return lhs.compare(rhs) > 0 ? true : false;
  1632.   }
  1633. #endif
  1634.  
  1635.   template <class charT, class traits , class Allocator  >
  1636.   inline bool operator>(
  1637.       const charT*                                  lhs,
  1638.       const basic_string<charT, traits, Allocator>& rhs)
  1639.   {
  1640.     return basic_string<charT,traits,Allocator>(lhs).compare(rhs)>0?true:false;
  1641.   }
  1642.  
  1643.   template <class charT, class traits , class Allocator  >
  1644.   inline bool operator>(
  1645.       const basic_string<charT, traits, Allocator>& lhs,
  1646.       const charT*                                  rhs)
  1647.   {
  1648.     return lhs.compare(basic_string<charT,traits,Allocator>(rhs))>0?true:false;
  1649.   }
  1650.  
  1651. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  1652.   template <class charT, class traits , class Allocator  >
  1653.   inline bool operator<=(
  1654.       const basic_string<charT, traits, Allocator>& lhs,
  1655.       const basic_string<charT, traits, Allocator>& rhs)
  1656.   {
  1657.     return lhs.compare(rhs) <= 0 ? true : false;
  1658.   }
  1659. #endif
  1660.  
  1661.   template <class charT, class traits , class Allocator  >
  1662.   inline bool operator<=(
  1663.       const charT*                                  lhs,
  1664.       const basic_string<charT, traits, Allocator>& rhs)
  1665.   {
  1666.     return basic_string<charT,traits,Allocator>(lhs).compare(rhs)<=0?true:false;
  1667.   }
  1668.  
  1669.   template <class charT, class traits , class Allocator  >
  1670.   inline bool operator<=(
  1671.       const basic_string<charT, traits, Allocator>& lhs,
  1672.       const charT*                                  rhs)
  1673.   {
  1674.     return lhs.compare(basic_string<charT,traits,Allocator>(rhs))<=0?true:false;
  1675.   }
  1676.  
  1677. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  1678.   template <class charT, class traits , class Allocator  >
  1679.   inline bool operator>=(
  1680.       const basic_string<charT, traits, Allocator>& lhs,
  1681.       const basic_string<charT, traits, Allocator>& rhs)
  1682.   {
  1683.     return lhs.compare(rhs) >= 0 ? true:false;
  1684.   }
  1685. #endif
  1686.  
  1687.   template <class charT, class traits , class Allocator  >
  1688.   inline bool operator>=(
  1689.       const charT*                                  lhs,
  1690.       const basic_string<charT, traits, Allocator>& rhs)
  1691.   {
  1692.     return basic_string<charT,traits,Allocator>(lhs).compare(rhs)>=0?true:false;
  1693.   }
  1694.  
  1695.   template <class charT, class traits , class Allocator  >
  1696.   inline bool operator>=(
  1697.       const basic_string<charT, traits, Allocator>& lhs,
  1698.       const charT*                                  rhs)
  1699.   {
  1700.     return lhs.compare(basic_string<charT,traits,Allocator>(rhs))>=0?true:false;
  1701.   }
  1702.  
  1703. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  1704.   template <class charT, class traits, class Allocator>
  1705.   inline void swap(basic_string<charT,traits,Allocator>& a, 
  1706.                    basic_string<charT,traits,Allocator>& b)
  1707.   {
  1708.     a.swap(b);
  1709.   }
  1710. #endif
  1711.  
  1712. #ifndef _RW_STD_IOSTREAM
  1713.  
  1714.   template<class charT, class traits , class Allocator >
  1715.   istream & _RWSTDExportTemplate operator >> (
  1716.       istream & is, basic_string<charT, traits, Allocator > & str);
  1717.  
  1718.   template<class charT, class traits , class Allocator >
  1719.   ostream& _RWSTDExportTemplate operator << (
  1720.       ostream & os, const basic_string<charT, traits, Allocator > & str);
  1721.  
  1722.   template<class Stream, class charT, class traits , class Allocator >
  1723.   Stream& _RWSTDExportTemplate getline(Stream& is, 
  1724.                                        basic_string<charT, traits,Allocator>& str, charT delim);
  1725.  
  1726.   template<class Stream, class charT, class traits , class Allocator >
  1727.   Stream& _RWSTDExportTemplate getline(Stream& is, 
  1728.                                        basic_string<charT, traits,Allocator>& str)
  1729.   { return getline(is,str,'\n'); }
  1730.  
  1731. #endif /*_RW_STD_IOSTREAM*/
  1732.  
  1733. #ifdef _RWSTD_MSC22_STATIC_INIT_BUG
  1734. #undef npos
  1735. #endif
  1736.  
  1737. #ifndef _RWSTD_NO_NAMESPACE
  1738. }
  1739. #endif
  1740.  
  1741. #ifdef _RWSTD_COMPILE_INSTANTIATE
  1742. #include <string.cc>
  1743. #endif
  1744. #endif /*defined __STD_STRING*/
  1745. #pragma option pop
  1746. #endif /* __STRING_STL */
  1747.