// -*- C++ -*-
/***************************************************************************
 *
 * string - Declarations for the Standard Library string classes
 *
 ***************************************************************************
 *    
 *  Copyright 2000 Compaq Computer Corporation
 *
 *  COMPAQ Registered in U.S. Patent and Trademark Office.
 *
 *  Confidential computer software. Valid license from Compaq required for
 *  possession, use or copying. Consistent with FAR 12.211 and 12.212,
 *  Commercial Computer Software, Computer Software Documentation, and
 *  Technical Data for Commercial Items are licensed to the U.S. Government
 *  under vendor's standard commercial license.
 *
 ****************************************************************************
 *
 * (c) Copyright 1994, 1998 Rogue Wave Software, Inc.
 * ALL RIGHTS RESERVED
 *
 * The software and information contained herein are proprietary to, and
 * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
 * intends to preserve as trade secrets such software and information.
 * This software is furnished pursuant to a written license agreement and
 * may be used, copied, transmitted, and stored only in accordance with
 * the terms of such license and with the inclusion of the above copyright
 * notice.  This software and information or any other copies thereof may
 * not be provided or otherwise made available to any other person.
 *
 * Notwithstanding any other lease or license that may pertain to, or
 * accompany the delivery of, this computer software and information, the
 * rights of the Government regarding its use, reproduction and disclosure
 * are as set forth in Section 52.227-19 of the FARS Computer
 * Software-Restricted Rights clause.
 * 
 * Use, duplication, or disclosure by the Government is subject to
 * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
 * Technical Data and Computer Software clause at DFARS 252.227-7013.
 * Contractor/Manufacturer is Rogue Wave Software, Inc.,
 * P.O. Box 2328, Corvallis, Oregon 97339.
 *
 * This computer software and information is distributed with "restricted
 * rights."  Use, duplication or disclosure is subject to restrictions as
 * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
 * Computer Software-Restricted Rights (April 1985)."  If the Clause at
 * 18-52.227-74 "Rights in Data General" is specified in the contract,
 * then the "Alternate III" clause applies.
 *
 **************************************************************************/

#ifndef __STD_STRING
#define __STD_STRING

#include <stdcomp>
#if defined(__DECCXX) && !defined(__DECFIXCXXL1200)
#include <limits>
#endif
#include <rwstderr>

#ifndef _RWSTD_NO_NEW_HEADER
#include <cstring>
#include <cctype>
#else
#include <string.h>
#include <ctype.h>
#endif

#ifndef _RWSTD_NO_WIDE_CHAR
#ifndef _RWSTD_NO_NEW_HEADER
#include <cwchar>
#include <cwctype>
#else
#ifndef _RWSTD_NO_WCHAR_H
#include <wchar.h>
#endif
#ifndef _RWSTD_NO_WCTYPE_H
# include <wctype.h>
#endif
#endif
#endif

#ifndef _RW_STD_IOSTREAM
#include <iostream.h>
#endif

#include <string_ref>


#if defined(__DECCXX)
#   ifdef __PRAGMA_ENVIRONMENT
#      pragma __environment __save
#      pragma __environment __cxx_header_defaults
#   endif
#endif

#if defined(__VMS) && defined(__DECCXX) && !defined(__DECFIXCXXL1158)
#pragma __extern_prefix __save
#pragma __extern_prefix "CXXL$" 
#endif


#ifndef _RWSTD_NO_NAMESPACE
namespace _RWrwstd {
#endif
//
// Global error message declarations
//
#ifdef _RWSTD_LOCALIZED_ERRORS
  extern const unsigned int _RWSTDExport _RWrwse_InvalidSizeParam;
  extern const unsigned int _RWSTDExport _RWrwse_PosBeyondEndOfString;
  extern const unsigned int _RWSTDExport _RWrwse_ResultLenInvalid;
  extern const unsigned int _RWSTDExport _RWrwse_StringIndexOutOfRange;
  extern const unsigned int _RWSTDExport _RWrwse_UnexpectedNullPtr;
#else
  extern const char _RWSTDExportFunc(*) _RWrwse_InvalidSizeParam;
  extern const char _RWSTDExportFunc(*) _RWrwse_PosBeyondEndOfString;
  extern const char _RWSTDExportFunc(*) _RWrwse_ResultLenInvalid;
  extern const char _RWSTDExportFunc(*) _RWrwse_StringIndexOutOfRange;
  extern const char _RWSTDExportFunc(*) _RWrwse_UnexpectedNullPtr;
#endif


#ifndef _RWSTD_NO_NAMESPACE
} namespace std {
#endif

#ifdef _RWSTD_NO_STATIC_DEF3
  extern unsigned long _RWSTDExport _RWnullref[];
  extern bool _RWSTDExport _RWnullref_initialized;
#endif

  template <class charT, class traits , class Allocator >
  class _RWSTDExportTemplate basic_string
  {
  public:

    //
    //  Implementation types (see rw/string_ref)
    //
    // _RWstring_ref_type is the type of the string reference that 
    // holds the data for a basic_string. Defining _RWSTD_NO_STRING_REF_CONT
    // gets you a basic_string that does not use reference counting
    // at all.
    //
#ifndef _RWSTD_NO_STRING_REF_COUNT
    typedef __RWSTD::_RWstring_ref<charT,traits,Allocator> _RWstring_ref_type;
#else
    typedef __RWSTD::_RWstring_noref<charT,traits,Allocator> _RWstring_ref_type;
#endif
    //
    // _RWrep_type is the base class of _RWstring_ref_type.  This type 
    // defines the representation of the reference class.
    //
    typedef _TYPENAME _RWstring_ref_type::_RWstring_ref_rep_type _RWrep_type;
    //
    // _RWnull_ref_type is the type of the null reference.  Every empty 
    // string holds a reference to the same null reference object in order
    // to keep the size of an empty string at sizeof(char*) -- assuming
    // your compiler can handle the empty base optimization.
    //
    typedef __RWSTD::_RWnull_string_ref_rep<charT,traits,Allocator,_RWrep_type>  _RWnull_ref_type;

    //
    // types
    //
    typedef traits                               traits_type;
    typedef _TYPENAME traits::char_type          value_type;
    typedef Allocator                            allocator_type;

  private:

#ifdef _RWSTD_ALLOCATOR
    typedef Allocator  _RWvalue_alloc_type;
    typedef _TYPENAME Allocator::template rebind<_RWstring_ref_type>::other  _RWref_alloc_type;
#else
    typedef allocator_interface<Allocator,charT>       _RWvalue_alloc_type;
    typedef allocator_interface<Allocator,_RWstring_ref_type>  _RWref_alloc_type;
#endif

  
  public:

#ifndef _RWSTD_NO_COMPLICATED_TYPEDEF
    typedef _TYPENAME _RWSTD_ALLOC_SIZE_TYPE              size_type;
    typedef _TYPENAME _RWSTD_ALLOC_DIFF_TYPE              difference_type;
    typedef _TYPENAME _RWvalue_alloc_type::reference       reference;
    typedef _TYPENAME _RWvalue_alloc_type::const_reference const_reference;
    typedef _TYPENAME _RWvalue_alloc_type::pointer         pointer;
    typedef _TYPENAME _RWvalue_alloc_type::const_pointer   const_pointer;
#if defined(__DECCXX) && !defined(__DECFIXCXXL1082)
    typedef charT* iterator;
    typedef const charT* const_iterator;
#else
    typedef _TYPENAME _RWvalue_alloc_type::pointer         iterator;
    typedef _TYPENAME _RWvalue_alloc_type::const_pointer   const_iterator;
#endif
#else
    typedef size_t                            size_type;
    typedef ptrdiff_t                         difference_type;
    typedef charT&                            reference;
    typedef const charT&                      const_reference;
    typedef charT*                            pointer;
    typedef const charT*                      const_pointer;
    typedef charT*                            iterator;
    typedef const charT*                      const_iterator;
#endif  //_RWSTD_NO_COMPLICATED_TYPEDEF

#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC 
    typedef _RW_STD::reverse_iterator<const_iterator> const_reverse_iterator;
    typedef _RW_STD::reverse_iterator<iterator>  reverse_iterator;
#else
    typedef _RW_STD::reverse_iterator<const_iterator, 
      random_access_iterator_tag, value_type, 
      const_reference, const_pointer, difference_type>
      const_reverse_iterator;
    typedef _RW_STD::reverse_iterator<iterator, 
      random_access_iterator_tag, value_type,
      reference, pointer, difference_type>
      reverse_iterator;
#endif

#ifdef _RWSTD_MSC22_STATIC_INIT_BUG
#define npos (size_type)-1
#else
    static const size_type npos;
#endif

    inline _EXPLICIT basic_string (const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));

#ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS 
    inline basic_string (void);
#endif

    inline basic_string (const basic_string<charT, traits, Allocator>&);
    basic_string (const basic_string<charT, traits, Allocator>&, 
                  size_type, size_type _RWSTD_DEFAULT_ARG(npos), 
                  const Allocator&  _RWSTD_DEFAULT_ARG(Allocator()));
    basic_string (const charT*, size_type, 
                  const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));
    basic_string (const charT*, const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));

#ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
    basic_string (const charT*, size_type); 
    basic_string (const charT*); 
    basic_string (size_type n, charT c) : _RWdata_((charT*)0,Allocator())
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
#endif

#ifndef _RWSTD_NO_MEMBER_TEMPLATES
    template <class InputIterator>
    basic_string (InputIterator, InputIterator, const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));
    basic_string (int n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
    basic_string (unsigned int n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
    basic_string (long n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
    basic_string (unsigned long n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
    basic_string (short n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
    basic_string (unsigned short n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
    basic_string (char n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
    basic_string (unsigned char n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
#ifndef _RWSTD_NO_OVERLOAD_WCHAR
    basic_string (wchar_t n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
#endif
#ifndef _RWSTD_NO_BOOL
    basic_string (bool n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
#endif
#else
    basic_string (size_type n, charT c, const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator()))
      : _RWdata_((charT*)0,alloc)
#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    { _RWinitn(n,c); }
#else
    { _RWinit_n(n,c); }
#endif
#endif // _RWSTD_NO_MEMBER_TEMPLATES

    basic_string (const charT*, const charT*, const Allocator& _RWSTD_DEFAULT_ARG(Allocator()));
#ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
    basic_string (const charT*, const charT*);
#endif

    ~basic_string ()
    {
      _RWunLink();
    }

    basic_string<charT, traits, Allocator>& operator= (const basic_string<charT, traits, Allocator>&);
    basic_string<charT, traits, Allocator>& operator= (const charT*);
    inline basic_string<charT, traits, Allocator>& operator= (charT);

    //
    // iterators
    //
    iterator begin () 
    { _RWcow(); _RWpref()->_RWsetRefCount(0); return _RWdata_.data(); }
    const_iterator begin () const  
    { return _RWdata_.data(); }
    iterator end () 
    { _RWcow(); _RWpref()->_RWsetRefCount(0); return _RWdata_.data()+length(); }
    const_iterator end   () const  
    { return _RWdata_.data()+length(); }

    reverse_iterator rbegin () 
    { reverse_iterator tmp(end()); return tmp; }
    const_reverse_iterator rbegin () const 
    { const_reverse_iterator tmp(end()); return tmp; }
    reverse_iterator rend ()
    { reverse_iterator tmp(begin()); return tmp; }
    const_reverse_iterator rend () const 
    { const_reverse_iterator tmp(begin()); return tmp; }

    //
    // capacity
    //
    size_type size () const   { return length(); }
    inline size_type length () const;
    size_type max_size () const
    {
      return npos - sizeof(_RWrep_type)-2;
    }
    inline void resize (size_type, charT);
    void resize (size_type n)
    {
      resize(n,_RWeos()); 
    }
    inline size_type capacity () const;
    inline void reserve (size_type=0);
    void clear () { erase(); }
    bool empty () const  { return length() == 0; }

    //
    // element access
    //
    inline const_reference operator[] (size_type) const;
    inline reference       operator[] (size_type);
    inline const_reference at (size_type) const;
    inline reference       at (size_type);

    //
    // modifiers
    //
    inline basic_string<charT, traits, Allocator>& operator+= (const basic_string<charT, traits, Allocator>&);
    inline basic_string<charT, traits, Allocator>& operator+= (const charT*);
    inline basic_string<charT, traits, Allocator>& operator+= (charT);

    basic_string<charT, traits, Allocator>& append (
        const  basic_string<charT, traits, Allocator>&);
    basic_string<charT, traits, Allocator>& append (
        const basic_string<charT, traits, Allocator>&,
        size_type, 
        size_type);
    inline basic_string<charT, traits, Allocator>& append (const charT*, size_type);
    inline basic_string<charT, traits, Allocator>& append (const charT*);

#ifndef _RWSTD_NO_MEMBER_TEMPLATES
    template<class InputIterator>
    inline basic_string<charT, traits, Allocator>& append (InputIterator,
                                                    InputIterator);

#if defined(__DECCXX) && !defined(__DECFIXCXXL1200)
    template<class InputIterator>
    basic_string& append (InputIterator __first, InputIterator __last,
                          _RWSTD_DISPATCH_INT (false)) {
        // unnamed arg is used for overload resolution
        // _RWSTD_COMPILE_ASSERT (sizeof (*__first));
        return replace (end (), end (), __first, __last), *this;
    }

    basic_string& append (size_type __n, value_type __c,
                          _RWSTD_DISPATCH_INT (true)) {
        // unnamed arg is used for overload resolution
        return replace (size (), 0, __n, __c);
    }
#endif
    basic_string<charT, traits, Allocator>& append (int n, charT c)
    { return replace(length(),0,n,c); }
    basic_string<charT, traits, Allocator>& append (unsigned int n, charT c)
    { return replace(length(),0,n,c); }
    basic_string<charT, traits, Allocator>& append (long n, charT c)
    { return replace(length(),0,n,c); }
    basic_string<charT, traits, Allocator>& append (unsigned long n, charT c)
    { return replace(length(),0,n,c); }
    basic_string<charT, traits, Allocator>& append (short n, charT c)
    { return replace(length(),0,n,c); }
    basic_string<charT, traits, Allocator>& append (unsigned short n, charT c)
    { return replace(length(),0,n,c); }
    basic_string<charT, traits, Allocator>& append (char n, charT c)
    { return replace(length(),0,n,c); }
    basic_string<charT, traits, Allocator>& append (unsigned char n, charT c)
    { return replace(length(),0,n,c); }
#ifndef _RWSTD_NO_OVERLOAD_WCHAR
    basic_string<charT, traits, Allocator>& append (wchar_t n, charT c)
    { return replace(length(),0,n,c); }
#endif
#ifndef _RWSTD_NO_BOOL
    basic_string<charT, traits, Allocator>& append (bool n, charT c)
    { return replace(length(),0,n,c); }
#endif
#else
    inline basic_string<charT, traits, Allocator>& append (const charT*,
                                                    const charT*);
    inline basic_string<charT, traits, Allocator>& append (size_type, charT);
#endif // _RWSTD_NO_MEMBER_TEMPLATES

    inline void push_back(const charT);

    basic_string<charT, traits, Allocator>& assign (
        const basic_string<charT, traits, Allocator>&);
    basic_string<charT, traits, Allocator>& assign (
        const basic_string<charT, traits, Allocator>&,
        size_type, 
        size_type);
    inline basic_string<charT, traits, Allocator>& assign (const charT*, size_type);
    inline basic_string<charT, traits, Allocator>& assign (const charT*);


#ifndef _RWSTD_NO_MEMBER_TEMPLATES
    template<class InputIterator>
    inline basic_string<charT, traits, Allocator>& assign (InputIterator,
                                                    InputIterator);

#if defined(__DECCXX) && !defined(__DECFIXCXXL1200)
    template<class _InputIterator>
    basic_string& assign (_InputIterator __first, _InputIterator __last,
                          _RWSTD_DISPATCH_INT (false)) {
        // unnamed arg is used for overload resolution
        // _RWSTD_COMPILE_ASSERT (sizeof (*__first));
        return replace (begin (), end (), __first, __last);
    }

    basic_string& assign (size_type __n, value_type __c,
                          _RWSTD_DISPATCH_INT (true)) {
        // unnamed arg is used for overload resolution
        return replace (0, size (), __n, __c);
    }
#endif

    basic_string<charT, traits, Allocator>& assign (int n, charT c)
    { return replace(0,length(),n,c); }
    basic_string<charT, traits, Allocator>& assign (unsigned int n, charT c)
    { return replace(0,length(),n,c); }
    basic_string<charT, traits, Allocator>& assign (long n, charT c)
    { return replace(0,length(),n,c); }
    basic_string<charT, traits, Allocator>& assign (unsigned long n, charT c)
    { return replace(0,length(),n,c); }
    basic_string<charT, traits, Allocator>& assign (short n, charT c)
    { return replace(0,length(),n,c); }
    basic_string<charT, traits, Allocator>& assign (unsigned short n, charT c)
    { return replace(0,length(),n,c); }
    basic_string<charT, traits, Allocator>& assign (char n, charT c)
    { return replace(0,length(),n,c); }
    basic_string<charT, traits, Allocator>& assign (unsigned char n, charT c)
    { return replace(0,length(),n,c); }
#ifndef _RWSTD_NO_OVERLOAD_WCHAR
    basic_string<charT, traits, Allocator>& assign (wchar_t n, charT c)
    { return replace(0,length(),n,c); }
#endif
#ifndef _RWSTD_NO_BOOL
    basic_string<charT, traits, Allocator>& assign (bool n, charT c)
    { return replace(0,length(),n,c); }
#endif
#else
    inline basic_string<charT, traits, Allocator>& assign (const charT*,
                                                    const charT*);   
    inline basic_string<charT, traits, Allocator>& assign (size_type, charT);
#endif  // _RWSTD_NO_MEMBER_TEMPLATES
  
    basic_string<charT, traits, Allocator>& insert (size_type,
                                                    const basic_string<charT, traits, Allocator>&);
    basic_string<charT, traits, Allocator>& insert (
        size_type,
        const basic_string<charT, traits, Allocator>&,
        size_type, 
        size_type);
    inline basic_string<charT, traits, Allocator>& insert (
        size_type,
        const charT*, 
        size_type);
    inline basic_string<charT, traits, Allocator>& insert (size_type, const charT*);
    iterator insert (iterator pos, charT c)
    { 
      iterator tmp = _RWreplace_aux(pos-begin(), 0, basic_string<charT, traits, Allocator>(1,c)); 
      _RWpref()->_RWsetRefCount(0);
      return tmp;
    }

#ifndef _RWSTD_NO_MEMBER_TEMPLATES
    template<class InputIterator>
    inline void insert (iterator, InputIterator, InputIterator);

#if defined(__DECCXX) && !defined(__DECFIXCXXL1200)
    template <class _InputIterator>
    void insert (iterator __p, _InputIterator __first, _InputIterator __last,
                 _RWSTD_DISPATCH_INT (false)) {
        // unnamed arg is used for overload resolution
        // _RWSTD_COMPILE_ASSERT (sizeof (*__first));
        replace (__p, __p, __first, __last);
    }

    void insert (iterator __p, size_type __n, value_type __c,
                 _RWSTD_DISPATCH_INT (true)) {
        // unnamed arg is used for overload resolution
        replace (__p - begin(), 0, __n, __c);
    }
#endif
    void insert (iterator p, int n, charT c)
    { replace(p-begin(),0,n,c); }
    void insert (iterator p, unsigned int n, charT c)
    { replace(p-begin(),0,n,c); }
    void insert (iterator p, long n, charT c)
    { replace(p-begin(),0,n,c); }
    void insert (iterator p, unsigned long n, charT c)
    { replace(p-begin(),0,n,c); }
    void insert (iterator p, short n, charT c)
    { replace(p-begin(),0,n,c); }
    void insert (iterator p, unsigned short n, charT c)
    { replace(p-begin(),0,n,c); }
    void insert (iterator p, char n, charT c)
    { replace(p-begin(),0,n,c); }
    void insert (iterator p, unsigned char n, charT c)
    { replace(p-begin(),0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,int n,charT c)
    { return replace(pos,0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,unsigned int n,charT c)
    { return replace(pos,0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,long n,charT c)
    { return replace(pos,0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,unsigned long n,charT c)
    { return replace(pos,0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,short n,charT c)
    { return replace(pos,0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,unsigned short n,charT c)
    { return replace(pos,0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,char n,charT c)
    { return replace(pos,0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,unsigned char n,charT c)
    { return replace(pos,0,n,c); }
#ifndef _RWSTD_NO_OVERLOAD_WCHAR
    void insert (iterator p, wchar_t n, charT c)
    { replace(p-begin(),0,n,c); }
    basic_string<charT, traits, Allocator>& insert (size_type pos,wchar_t n,charT c)
    { return replace(pos,0,n,c); }
#endif
#ifndef _RWSTD_NO_BOOL
    void insert (iterator p, bool n, charT c)
    { replace(p-begin(),0,n,c);} 
    basic_string<charT, traits, Allocator>& insert (size_type pos,bool n,charT c)
    { return replace(pos,0,n,c); }
#endif

#else
    inline void insert (iterator, const charT*, const charT*);
    inline basic_string<charT, traits, Allocator>& insert (size_type,size_type,charT);
    inline void insert (iterator, size_type, charT);
#endif  // _RWSTD_NO_MEMBER_TEMPLATES
    
    inline basic_string<charT, traits, Allocator>& erase (size_type = 0,
                                                   size_type = npos);

    iterator erase (iterator it) 
    { 
#if defined(__DECCXX) && !defined(__DECFIXCXXL1112)
      iterator ret = replace(it - begin(),1,(charT *) NULL,0,0,0);
#else
      iterator ret = replace(it - begin(),1,NULL,0,0,0);
#endif
      _RWpref()->_RWsetRefCount(0);
      return ret;
    }
    iterator erase (iterator first, iterator last) 
    {  
#if defined(__DECCXX) && !defined(__DECFIXCXXL1112)
      iterator ret =  replace(first - begin(),last-first,(charT *)NULL,0,0,0);
#else
      iterator ret =  replace(first - begin(),last-first,NULL,0,0,0);
#endif
      _RWpref()->_RWsetRefCount(0);
      return ret;
    }


  private:  
    //
    // Used for effiency
    //
    _TYPENAME 
    basic_string<charT, traits, Allocator>::iterator replace (size_type, 
                                                              size_type, 
                                                              const charT*,
                                                              size_type,
                                                              size_type,
                                                              size_type);

    _TYPENAME 
    basic_string<charT, traits, Allocator>::iterator _RWreplace_aux (
        size_type, 
        size_type,
        const basic_string<charT, traits, Allocator>&,
        size_type =0,
        size_type =npos);

#ifndef _RWSTD_NO_MEMBER_TEMPLATES
    template<class InputIterator>
    basic_string<charT, traits, Allocator>& _RWreplace_aux (
        iterator first1, 
        iterator last1,
        InputIterator first2,
        InputIterator last2);
#endif

  public:
    inline basic_string<charT, traits, Allocator>& replace (size_type, 
                                                     size_type,
                                                     const basic_string<charT, traits, Allocator>&);
    inline basic_string<charT, traits, Allocator>& replace (size_type, 
                                                     size_type,
                                                     const basic_string<charT, traits, Allocator>&,
                                                     size_type, 
                                                     size_type);
    inline basic_string<charT, traits, Allocator>& replace (size_type, 
                                                     size_type, 
                                                     const charT*, 
                                                     size_type);
    inline basic_string<charT, traits, Allocator>& replace (size_type,
                                                     size_type, 
                                                     const charT*);
    basic_string<charT, traits, Allocator>& replace (size_type,
                                                     size_type,
                                                     size_type,
                                                     charT);
    inline basic_string<charT, traits, Allocator>& replace (iterator,
                                                     iterator,
                                                     const basic_string<charT, traits, Allocator>&);
    inline basic_string<charT, traits, Allocator>& replace (iterator,
                                                     iterator,
                                                     const charT*,
                                                     size_type);
    inline basic_string<charT, traits, Allocator>& replace (iterator,
                                                     iterator,
                                                     const charT*);

#ifndef _RWSTD_NO_MEMBER_TEMPLATES
    template<class InputIterator>
    basic_string<charT, traits, Allocator>& replace (iterator, iterator, 
                                                     InputIterator,
                                                     InputIterator);

#if defined(__DECCXX) && !defined(__DECFIXCXXL1200)
    template<class _InputIterator>
    basic_string& replace (iterator, iterator,
                           _InputIterator, _InputIterator,
                           _RWSTD_DISPATCH_INT (false));


    basic_string& replace (iterator __first, iterator __last,
                           size_type __n, value_type __c,
                           _RWSTD_DISPATCH_INT (true)) {
        // unnamed arg is used for overload resolution
        return replace (__first - begin (), __last - __first, __n, __c);
    }
#endif
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     int n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     unsigned int n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     long n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     unsigned long n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     short n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     unsigned short n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     char n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     unsigned char n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
#ifndef _RWSTD_NO_OVERLOAD_WCHAR
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     wchar_t n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
#endif
#ifndef _RWSTD_NO_BOOL
    basic_string<charT, traits, Allocator>& replace (iterator first,
                                                     iterator last,
                                                     bool n,
                                                     charT c)
    { return replace(first-begin(),last-first,n,c); }
#endif
#else
    inline basic_string<charT, traits, Allocator>& replace (iterator, iterator, 
                                                     const charT*,
                                                     const charT*);
    inline basic_string<charT, traits, Allocator>& replace (iterator,
                                                     iterator,
                                                     size_type,
                                                     charT);
#endif  // _RWSTD_NO_MEMBER_TEMPLATES

    size_type copy (charT*, size_type, size_type = 0) const;
    basic_string<charT, traits, Allocator> copy () const; // Returns deep copy
    void swap(basic_string<charT, traits, Allocator>& s)
    {
      charT * temp = _RWdata_.data(); _RWdata_ = s._RWdata_.data(); s._RWdata_ = temp;
    }

    //
    // string operations
    //
    inline const charT* c_str () const;
    inline const charT* data  () const;
    allocator_type get_allocator() const
    {
      return (allocator_type)_RWdata_;
    }

    inline size_type find (const basic_string<charT, traits, Allocator>&,
                    size_type = 0) const;
    size_type find (const charT*, size_type, size_type) const;
    inline size_type find (const charT*, size_type = 0) const;
    inline size_type find (charT, size_type = 0) const;

    inline size_type rfind (const basic_string<charT, traits, Allocator>&,
                     size_type = npos) const;
    size_type rfind (const charT*, size_type, size_type) const;
    inline size_type rfind (const charT*, size_type = npos) const;
    inline size_type rfind (charT, size_type = npos) const;

    inline size_type find_first_of (const basic_string<charT, traits, Allocator>&,
                             size_type = 0) const;
    size_type find_first_of (const charT*, size_type, size_type) const;
    inline size_type find_first_of (const charT*, size_type = 0) const;
    inline size_type find_first_of (charT, size_type = 0) const;
    inline size_type find_last_of (const basic_string<charT, traits, Allocator>&,
                            size_type = npos) const;
    size_type find_last_of (const charT*, size_type, size_type) const;
    inline size_type find_last_of (const charT*, size_type = npos) const;
    inline size_type find_last_of (charT, size_type = npos) const;

    inline size_type find_first_not_of (const basic_string<charT, traits, Allocator>&,
                                 size_type = 0) const;
    size_type find_first_not_of (const charT*, size_type ,
                                 size_type) const;
    inline size_type find_first_not_of (const charT*, size_type = 0) const;
    inline size_type find_first_not_of (charT, size_type = 0) const;

    inline size_type find_last_not_of (const basic_string<charT, traits, Allocator>&,
                                size_type = npos) const;
    size_type find_last_not_of (const charT*, size_type, size_type) const;
    inline size_type find_last_not_of (const charT*, size_type = npos) const;
    inline size_type find_last_not_of (charT, size_type = npos) const;
  
    basic_string<charT, traits, Allocator> substr (size_type = 0,
                                                   size_type = npos) const;
  
    inline int compare(const basic_string<charT, traits, Allocator>&) const;
    int compare(size_type, size_type,
                const basic_string<charT, traits, Allocator>&) const;
    int compare(size_type, size_type,
                const basic_string<charT, traits, Allocator>&,
                size_type, size_type) const;
    inline int compare (const charT*) const;
    int compare (size_type, size_type, const charT*, size_type) const;
    inline int compare (size_type, size_type, const charT*) const;

  protected:

    size_type _RWgetCapac () const { return _RWpref()->_RWgetCapac(); }

    void _RWclobber (size_type); // Remove old contents
    void _RWcow ()               // Do copy on write as necessary
    { 
      if (_RWpref()->_RWreferences() > 1) 
        _RWclone(); 
    }
    void _RWcow (size_type nc)     // Do copy on write w/ new capacity
    { 
      if (_RWpref()->_RWreferences() > 1 || _RWgetCapac() < nc)
        _RWclone(nc);
    }

  private:

#if defined(__DECCXX) && !defined(__DECFIXCXXL957)
    void _RWinitn(size_type, charT);
#else
    void _RWinit_n(size_type, charT);
#endif

    static charT _RWeos () { return (charT)0; }
  
    //
    // Make a distinct copy of self
    //
    void _RWclone (); 
    //
    // Make a distinct copy w/ new capacity nc
    //
    void _RWclone (size_type nc);

    _RWstring_ref_type *  _RWpref () const
    { 
#ifdef _RWSTD_SUNPRO_ANACHRONISM
      return (_RWstring_ref_type*)_RWdata_.data() - 1;
#else
      return _RWSTD_STATIC_CAST(_RWstring_ref_type*,
                                ((_RWSTD_REINTERPRET_CAST(_RWstring_ref_type*,_RWdata_.data())) - 1)); 
#endif
    }

    //
    // Disconnect from ref, maybe delete it.
    //
    inline void      _RWunLink          ();   

#ifndef _RWSTD_NO_NAMESPACE
    friend class __RWSTD::_RWstring_ref<charT,traits,Allocator>;
#else
    friend class _RWstring_ref<charT,traits,Allocator>;
#endif

    //
    // Null string ref
    //
#ifndef _RWSTD_NO_STATIC_DEF3
    static const _RWnull_ref_type _RWnullref;
#endif

    static _RWstring_ref_type * _RWgetNullRep ()
    {
#ifndef _RWSTD_NO_STATIC_DEF3
#  ifdef _RWSTD_NO_STATIC_CAST
      return (_RWstring_ref_type *)&_RWnullref;
#  else
      return reinterpret_cast<_RWstring_ref_type *>
             (const_cast<_RWnull_ref_type *>(&_RWnullref));
#  endif // _RWSTD_NO_STATIC_CAST
#else
      if (!__RWSTD::_RWnullref_initialized)
      {
        new (&__RWSTD::_RWnullref) _RWnull_ref_type();
        __RWSTD::_RWnullref_initialized = 1;
      }
      return (_RWstring_ref_type *) &__RWSTD::_RWnullref[0]; 
#endif // _RWSTD_NO_STATIC_DEF3
    }
    _RWstring_ref_type * _RWgetRep (size_type capac, size_type nchar);

    __RWSTD::_RWrw_basis<charT*,allocator_type>    _RWdata_;                   
  };


//
// Standard Type Definitions
//
  typedef basic_string<char, char_traits<char>, allocator<char> >
  string;

#ifndef _RWSTD_NO_WIDE_CHAR
  typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >
  wstring;
#endif



//
// The following has to go after the declaration of the string
// classes because of cross references.
//

#ifndef _RWSTD_NO_NAMESPACE
}
#endif

#ifdef _RW_STD_EXCEPT
#if defined(__VMS) && defined(__DECCXX) && !defined(__DECFIXCXXL1158)
#   pragma __extern_prefix __restore
#endif
#include <stdexcept>
#if defined(__VMS) && defined(__DECCXX) && !defined(__DECFIXCXXL1158)
#pragma __extern_prefix __save
#pragma __extern_prefix "CXXL$" 
#endif
#endif

#if defined(_RWSTD_NO_DESTROY_BUILTIN) || defined(_RWSTD_NO_DESTROY_NONBUILTIN)

#ifndef _RWSTD_NO_NAMESPACE
namespace _RWrwstd {
#endif
//
// Specializations for STL destroy
//
  inline void _RWdestroy (string**)    {;}
  inline void _RWdestroy (string***)   {;}
  inline void _RWdestroy (string****)  {;}
#ifndef _RWSTD_NO_WIDE_CHAR
  inline void _RWdestroy (wstring**)   {;}
  inline void _RWdestroy (wstring***)  {;}
  inline void _RWdestroy (wstring****) {;}
#endif

#ifndef _RWSTD_NO_NAMESPACE
}
#endif
#endif // _RWSTD_NO_DESTROY_BUILTIN || _RWSTD_NO_DESTROY_NONBUILTIN

#ifndef _RWSTD_NO_NAMESPACE
namespace std {
#endif

//
// Inline member functions for class basic_string
//

  template <class charT, class traits , class Allocator  >
  inline void basic_string<charT, traits, Allocator>::_RWunLink()
  {
    if (!_RWdata_.data())
      return;
    if (_RWpref()->_RWreferences() == 0 || _RWpref()->_RWremoveReference() == 0) 
    {
      _RWref_alloc_type(_RWdata_).destroy(_RWpref());
      _RWvalue_alloc_type(_RWdata_).
#if defined(__DECCXX) && !defined(__DECFIXCXXL1082)
        deallocate(_RWSTD_REINTERPRET_CAST(_TYPENAME Allocator::pointer,_RWpref()),length());
#else
        deallocate(_RWSTD_REINTERPRET_CAST(charT*,_RWpref()),length());
#endif
      _RWdata_ = (charT*)0;
    }
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>
  ::basic_string (const Allocator& alloc) : _RWdata_((charT*)0,alloc)
  {
    _RWdata_ = _RWgetNullRep()->data();
    _RWgetNullRep()->_RWaddReference();
  }

#ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>
  ::basic_string (void) : _RWdata_((charT*)0,Allocator())
  {
    _RWdata_ = _RWgetNullRep()->data();
    _RWgetNullRep()->_RWaddReference();
  }
#endif

  template <class charT, class traits , class Allocator  >
  inline
  basic_string<charT, traits, Allocator>
  ::basic_string (const basic_string<charT, traits, Allocator> & s)
   : _RWdata_((charT*)0,Allocator())
  {                     
    if ( s._RWpref()->_RWreferences() > 0 )
    {                                    
      _RWdata_ = s._RWdata_.data();
      _RWpref()->_RWaddReference();
    }
    else
    {
      size_type n = s.length();
      _RWdata_  = _RWgetRep(n, n)->data();
      traits::copy(_RWdata_.data(), s.c_str(), n);
    }
  }


  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::operator= (charT c)
  {
    replace(0,length(),1,c);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::operator+= (const basic_string<charT, traits, Allocator>& s)
  {
    return append(s);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::operator+= (const charT* s)
  {
    return append(s);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::operator+= (charT c)
  {
    return append((size_type) 1, c);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::append (const charT* s, size_type n)
  {
    replace(size(),0,s,n,0,n);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::append (const charT* s)
  {
    replace(size(),0,s);
    return *this;
  }

#ifndef _RWSTD_NO_MEMBER_TEMPLATES

  template<class charT, class traits , class Allocator >
  template<class InputIterator>
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::append (InputIterator first, 
                                                  InputIterator last )
  {
#if defined(__DECCXX) && !defined(__DECFIXCXXL1200)
    return append (first, last, _RWSTD_DISPATCH (InputIterator));
#else
    replace(end(),end(),first,last);
#endif
    return *this;
  }
#else
  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::append (const charT* first, 
                                                  const charT* last)
  {
    replace(size(),0,first,last-first,0,last-first);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::append (size_type n, charT c)
  {
    replace(length(),0,n,c);
    return *this;
  }
#endif // _RWSTD_NO_MEMBER_TEMPLATES 

  template <class charT, class traits , class Allocator  >
  void basic_string<charT, traits, Allocator>::push_back(const charT c)
  {
    replace(size(),0,1,c);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::assign (const charT* s, size_type n)
  {
    replace(0, length(), s, n, 0, n);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::assign (const charT* s)
  {
    size_type len = traits::length(s);
    replace(0, length(), s, len, 0, len);
    return *this;
  }

#ifndef _RWSTD_NO_MEMBER_TEMPLATES 
  template<class charT, class traits , class Allocator >
  template<class InputIterator>
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::assign (InputIterator first, 
                                                  InputIterator last)
  {
#if defined(__DECCXX) && !defined(__DECFIXCXXL1200)
    // resolves to assign (size_type, value_type) if _InputIterator
    // is any integral type (even not an exact match, such as char)
    // the cast to int is necessary to prevent an exact match
    return assign (first, last, _RWSTD_DISPATCH (InputIterator));
#else
    replace(begin(),end(),first,last);
#endif
    return *this;
  }
#else
  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::assign (const charT* first, 
                                                  const charT* last)
  {
    replace(0,length(),first,last-first,0,last-first);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::assign (size_type n, charT c)
  {
    return replace(0,length(),n,c);
  }
#endif // _RWSTD_NO_MEMBER_TEMPLATES 

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::insert (size_type pos,
                                                  const charT* s,
                                                  size_type n)
  {
    replace(pos, 0, s, n, 0, n);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::insert (size_type pos, const charT* s)
  {
    size_type len = traits::length(s);
    replace(pos, 0, s, len, 0, len);
    return *this;
  }

#ifndef _RWSTD_NO_MEMBER_TEMPLATES
  template<class charT, class traits , class Allocator >
  template<class InputIterator>
  inline void 
  basic_string<charT, traits, Allocator>::insert (
      iterator p, 
      InputIterator first,
      InputIterator last)
  {
#if defined(__DECCXX) && !defined(__DECFIXCXXL1200)
    // resolves to insert (iterator, size_type, value_type)
    // if _InputIterator is any integral type (even not an exact match,
    // such as char)
    // the cast to int is necessary to avoid an exact match
    insert (p, first, last, _RWSTD_DISPATCH (InputIterator));
#else
    replace(p,p,first,last);
#endif
  }
#else
  template <class charT, class traits , class Allocator  >
  inline void 
  basic_string<charT, traits, Allocator>::insert (
      iterator p, 
      const charT* first,
      const charT* last)
  {
    replace(p-begin(),0,first,last-first,0,last-first);
  }

  template <class charT, class traits , class Allocator  >
  inline void 
  basic_string<charT, traits, Allocator>::insert (
      iterator p,
      size_type n,
      charT c)
  {
      replace(p-begin(),0,n,c);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::insert(size_type pos,
                                                 size_type n,
                                                 charT c)
  {
    return replace(pos,0,n,c);
  }
#endif // _RWSTD_NO_MEMBER_TEMPLATES

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::erase (size_type pos, size_type n)
  {
    _RWSTD_THROW(pos > length(), out_of_range,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_StringIndexOutOfRange,
         "basic_string::erase(size_t,size_t)", pos,length()).msgstr());

    size_type len = length() - pos;
    charT tmp[1];
    *tmp = 0;
    return replace(pos,n < len ? n : len, tmp,0);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::replace (size_type pos1,
                                                   size_type n1,
                                                   const basic_string<charT, traits, Allocator> & str, 
                                                   size_type pos2,
                                                   size_type n2)
  {
    replace(pos1, n1, str.data(), str.length(), pos2, n2);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::replace (
      size_type pos1,
      size_type n1,
      const basic_string<charT, traits, Allocator> & str)
  {
    replace(pos1, n1, str.data(), str.length(),0,str.length());
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::iterator
  basic_string<charT, traits, Allocator>::_RWreplace_aux (size_type pos1,
                                                       size_type n1,
                                                       const basic_string<charT, traits, Allocator> & str, 
                                                       size_type pos2,
                                                       size_type n2)
  {
    return replace(pos1, n1, str.data(), str.length(), pos2, n2);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::replace (size_type pos,
                                                   size_type n1,
                                                   const charT* s,
                                                   size_type n2)
  {
    replace(pos, n1, s, n2, 0, n2);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> &
  basic_string<charT, traits, Allocator>::replace (size_type pos,
                                                   size_type n1,
                                                   const charT* s)
  {
    size_type len = traits::length(s);
    replace(pos, n1, s, len, 0, len);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::replace (
      iterator first,
      iterator last,
      const basic_string<charT, traits, Allocator>& str)
  {
    return replace(first - begin(), last - first, str);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::replace (
      iterator first, 
      iterator last,
      const charT* s,
      size_type n)
  {
    replace(first-begin(),last-first,s,n,0,n);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::replace (
      iterator first, 
      iterator last,
      const charT* s)
  {
    size_type len = traits::length(s);
    replace(first-begin(),last-first,s,len,0,len);
    return *this;
  }


#ifdef _RWSTD_NO_MEMBER_TEMPLATES
  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::replace (
      iterator first1, 
      iterator last1,
      const charT* first2,
      const charT* last2)
  {
    replace(first1-begin(),last1-first1,first2,last2-first2,0,last2-first2);
    return *this;
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>& 
  basic_string<charT, traits, Allocator>::replace (
      iterator first, 
      iterator last,
      size_type n,
      charT c)
  {
    return replace(first-begin(),last-first,n,c);
  }
#endif

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits,Allocator>::const_reference 
  basic_string<charT, traits, Allocator>::operator[] (size_type pos) const
  {
#ifdef _RWSTD_BOUNDS_CHECKING
    _RWSTD_THROW(pos > size(), out_of_range,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_PosBeyondEndOfString,
        "basic_string::operator[](size_t) const", pos,size()).msgstr());
#endif
#if defined(__DECCXX) && !defined(__DECFIXCXXL1082)
    return reinterpret_cast<reference> (_RWdata_.data()[pos]);
#else
    return _RWdata_.data()[pos];
#endif
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::reference
  basic_string<charT, traits, Allocator>::operator[] (size_type pos)
  {
#ifdef _RWSTD_BOUNDS_CHECKING
    _RWSTD_THROW(pos >= size(), out_of_range,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_PosBeyondEndOfString,
        "basic_string::operator[](size_t)", pos,size()).msgstr());
#endif
    _RWcow();
    _RWpref()->_RWsetRefCount(0);
#if defined(__DECCXX) && !defined(__DECFIXCXXL1082)
    return reinterpret_cast<reference> (_RWdata_.data()[pos]);
#else
    return _RWdata_.data()[pos];
#endif
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::const_reference
  basic_string<charT, traits, Allocator>::at (size_type pos) const
  {
    _RWSTD_THROW(pos >= size(), out_of_range,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_PosBeyondEndOfString,
        "basic_string::at(size_t) const", pos,size()).msgstr());

#if defined(__DECCXX) && !defined(__DECFIXCXXL1082)
    return reinterpret_cast<reference> (_RWdata_.data()[pos]);
#else
    return _RWdata_.data()[pos];
#endif
  }


  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::reference
  basic_string<charT, traits, Allocator>::at (size_type pos)
  {
    _RWSTD_THROW(pos >= size(), out_of_range,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_PosBeyondEndOfString,
          "basic_string::at(size_t)", pos,size()).msgstr());

    _RWcow();
    _RWpref()->_RWsetRefCount(0);
#if defined(__DECCXX) && !defined(__DECFIXCXXL1082)
    return reinterpret_cast<reference> (_RWdata_.data()[pos]);
#else
    return _RWdata_.data()[pos];
#endif
  }

  template <class charT, class traits , class Allocator  >
  inline const charT* basic_string<charT, traits, Allocator>::c_str () const
  {
    return _RWdata_.data();
  }

  template <class charT, class traits , class Allocator  >
  inline const charT* basic_string<charT, traits, Allocator>::data () const
  {
    return _RWdata_.data();
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::length () const
  {
    return _RWpref()->_RWnchars_;
  }

  template <class charT, class traits , class Allocator  >
  inline void
  basic_string<charT, traits, Allocator>::resize (size_type n, charT c)
  {
    _RWSTD_THROW(n > max_size(), length_error,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_InvalidSizeParam,
        "basic_string( const charT*,size_type,const Allocator&)",n,npos).msgstr());
    if (n < length())
      erase(n,length()-n);
    else
#if defined(__DECCXX) && !defined(__DECFIXCXXL1007)
     replace(length(),0,n-length(),c);
#else
     replace(length(),0,n,c);
#endif
    _RWpref()->_RWsetRefCount(1);
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::capacity () const
  {
    return _RWgetCapac();
  }

  template <class charT, class traits , class Allocator  >
  inline void basic_string<charT, traits, Allocator>::reserve(size_type res_arg)
  {
     _RWSTD_THROW(res_arg > max_size(), length_error,
        __RWSTD::except_msg_string(__RWSTD::_RWrwse_InvalidSizeParam,
          "basic_string::reserve(size_t)",res_arg,max_size()).msgstr());

    if (res_arg > _RWgetCapac()) _RWclone(res_arg);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator>
  basic_string<charT, traits, Allocator>::copy () const
  {
    basic_string<charT, traits, Allocator> temp(*this); // Make referenced copy
    temp._RWclone();   // Make a distinct copy
    return temp;
  }

  template <class charT, class traits, class Allocator >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find (
      const basic_string<charT, traits, Allocator>& str,
      size_type                                     pos) const
  {
    return find(str.c_str(),pos,str.length());
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find (const charT* s,
                                                size_type pos) const
  {
    _RWSTD_THROW(s == 0, logic_error,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_UnexpectedNullPtr,
       "basic_string::find(const char*,size_t) const").msgstr());

    if (pos > length())
      return npos;
    const charT* p = __RWSTD::rw_traits<charT,traits>::find(_RWdata_.data()+pos,s);
    return p ? p - _RWdata_.data() : npos;
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find (charT c, size_type pos) const
  {
    if (pos > length())
      return npos;
    const charT* p =  traits::find(_RWdata_.data()+pos,length()-pos,c);
    return p ? p - _RWdata_.data() : npos;
  }

  template <class charT, class traits, class Allocator >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::rfind (
      const basic_string<charT, traits, Allocator>& str,
      size_type                                     pos) const
  {
    return rfind(str.c_str(), pos, str.length());
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::rfind (const charT* s, size_type pos)
  const
  {  
    size_type len = traits::length(s);
    return rfind(s, pos,len);
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::rfind (charT c, size_type pos) const
  {
    if (pos > length())
      pos = length();
    const charT* p = __RWSTD::rw_traits<charT,traits>::rfind(_RWdata_.data(),c,pos);
    return p ? p - _RWdata_.data() : npos;
  }

  template <class charT, class traits, class Allocator >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_first_of (
      const basic_string<charT, traits, Allocator>& str,
      size_type                                     pos) const
  {
    return find_first_of(str.c_str(),pos,str.length());
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_first_of (const charT* s,
                                                         size_type pos) const
  {
    _RWSTD_THROW(s == 0, logic_error,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_UnexpectedNullPtr,
        "basic_string::find_first_of(char*,size_t) const").msgstr());

    if (pos > length())
      return npos;
    size_type i = __RWSTD::rw_traits<charT,traits>::find_first_of(_RWdata_.data()+pos,s) + pos;
    return i >= length() ? npos : i;
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_first_of (charT c, size_type pos) const
  {
    return find(c, pos);
  }

  template <class charT, class traits, class Allocator >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_last_of (
      const basic_string<charT, traits, Allocator>& str,
      size_type                                     pos) const
  {
    return find_last_of(str.c_str(), pos,str.length());
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_last_of (const charT* s,
                                                        size_type pos) const
  {
    size_type len = traits::length(s);
    return find_last_of(s, pos,len);
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_last_of (charT c, size_type pos)
  const
  {
    return rfind(c,pos);
  }

  template <class charT, class traits, class Allocator >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_first_not_of (
      const basic_string<charT, traits, Allocator>& str,
      size_type                                     pos) const
  {
    return find_first_not_of(str.c_str(), pos, str.length());
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_first_not_of (const charT* s,
                                                             size_type pos) const
  {
    _RWSTD_THROW(s == 0, logic_error,
     __RWSTD::except_msg_string(__RWSTD::_RWrwse_UnexpectedNullPtr,
       "basic_string::find_first_not_of(char*,size_t) const").msgstr());

    if (pos > length())
      return npos;
    size_type i = __RWSTD::rw_traits<charT,traits>::find_first_not_of(_RWdata_.data()+pos,s) + pos;
    return i >= length() ? npos : i;
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_first_not_of (charT c,
                                                             size_type pos) const
  {
#if defined(__DECCXX) && !defined(__DECFIXCXXL1316)
    return find_first_not_of(&c, pos, 1);
#else
    charT tmp[2];
    *tmp = c;
    tmp[1] = 0;
    return find_first_not_of(tmp, pos);
#endif
  }

  template <class charT, class traits, class Allocator >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_last_not_of (
      const basic_string<charT, traits, Allocator>& str,
      size_type                                     pos) const
  {
    return find_last_not_of(str.c_str(), pos, str.length());
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_last_not_of (const charT* s,
                                                            size_type pos) const
  {
    size_type len = traits::length(s);
    return find_last_not_of(s, pos, len);
  }

  template <class charT, class traits , class Allocator  >
  inline _TYPENAME basic_string<charT, traits, Allocator>::size_type
  basic_string<charT, traits, Allocator>::find_last_not_of (charT c,
                                                            size_type pos) const
  {
    charT tmp[2];
    *tmp = c;
    tmp[1] = 0;
    return find_last_not_of(tmp, pos);
  }

  template <class charT, class traits, class Allocator >
  inline int
  basic_string<charT, traits, Allocator>::compare (
      const basic_string<charT, traits, Allocator>& str) const
  {
    return compare(0,length(),str.c_str(),str.length());
  }

  template <class charT, class traits , class Allocator  >
  inline int
  basic_string<charT, traits, Allocator>::compare (size_type pos,
                                                   size_type n1,
                                                   const charT* s) const
  {
    size_type len = traits::length(s);
    return compare(pos,n1,s,len);
  }

  template <class charT, class traits , class Allocator  >
  inline int
  basic_string<charT, traits, Allocator>::compare (const charT* s) const
  {
    size_type len = traits::length(s);
    return compare(0,length(),s,len);
  }

//
// Inlined non-member operators
//

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> operator+(
      const basic_string<charT, traits, Allocator>& lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT, traits, Allocator>(lhs).append(rhs);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> operator+(
      const charT*                                  lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT, traits, Allocator>(lhs).append(rhs);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> operator+(
      charT lhs, const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT, traits, Allocator>(1,lhs).append(rhs);
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> operator+(
      const basic_string<charT, traits, Allocator>& lhs,
      const charT*                                  rhs)
  {
    return basic_string<charT,traits,Allocator>(lhs).append(basic_string<charT, traits, Allocator>(rhs));
  }

  template <class charT, class traits , class Allocator  >
  inline basic_string<charT, traits, Allocator> operator+(
      const basic_string<charT, traits, Allocator>& lhs,
      charT                                         rhs)
  {
    return basic_string<charT,traits,Allocator>(lhs).append(basic_string<charT, traits, Allocator>(1,rhs));
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator==(
      const basic_string<charT, traits, Allocator>& lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return lhs.compare(rhs) == 0 ? true : false ;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator==(
      const charT*                                  lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT,traits,Allocator>(lhs).compare(rhs)==0?true:false;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator==(
      const basic_string<charT, traits, Allocator>& lhs,
      const charT*                                  rhs)
  {
    return lhs.compare(basic_string<charT,traits,Allocator>(rhs))==0?true:false;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator<(
      const basic_string<charT, traits, Allocator>& lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return lhs.compare(rhs) < 0 ? true:false ;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator<(
      const charT*                                  lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT,traits,Allocator>(lhs).compare(rhs)<0?true:false;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator<(
      const basic_string<charT, traits, Allocator>& lhs,
      const charT*                                  rhs)
  {
    return lhs.compare(basic_string<charT,traits,Allocator>(rhs))<0?true:false;
  }

#if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  template <class charT, class traits , class Allocator  >
  inline bool operator!=(
      const basic_string<charT, traits, Allocator>& lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return lhs.compare(rhs) != 0 ? true : false;
  }
#endif

  template <class charT, class traits , class Allocator  >
  inline bool operator!=(
      const charT*                                  lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT,traits,Allocator>(lhs).compare(rhs)!=0?true:false;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator!=(
      const basic_string<charT, traits, Allocator>& lhs,
      const charT*                                  rhs)
  {
    return lhs.compare(basic_string<charT,traits,Allocator>(rhs))!=0?true:false;
  }

#if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  template <class charT, class traits , class Allocator  >
  inline bool operator>(
      const basic_string<charT, traits, Allocator>& lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return lhs.compare(rhs) > 0 ? true : false;
  }
#endif

  template <class charT, class traits , class Allocator  >
  inline bool operator>(
      const charT*                                  lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT,traits,Allocator>(lhs).compare(rhs)>0?true:false;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator>(
      const basic_string<charT, traits, Allocator>& lhs,
      const charT*                                  rhs)
  {
    return lhs.compare(basic_string<charT,traits,Allocator>(rhs))>0?true:false;
  }

#if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  template <class charT, class traits , class Allocator  >
  inline bool operator<=(
      const basic_string<charT, traits, Allocator>& lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return lhs.compare(rhs) <= 0 ? true : false;
  }
#endif

  template <class charT, class traits , class Allocator  >
  inline bool operator<=(
      const charT*                                  lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT,traits,Allocator>(lhs).compare(rhs)<=0?true:false;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator<=(
      const basic_string<charT, traits, Allocator>& lhs,
      const charT*                                  rhs)
  {
    return lhs.compare(basic_string<charT,traits,Allocator>(rhs))<=0?true:false;
  }

#if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  template <class charT, class traits , class Allocator  >
  inline bool operator>=(
      const basic_string<charT, traits, Allocator>& lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return lhs.compare(rhs) >= 0 ? true:false;
  }
#endif

  template <class charT, class traits , class Allocator  >
  inline bool operator>=(
      const charT*                                  lhs,
      const basic_string<charT, traits, Allocator>& rhs)
  {
    return basic_string<charT,traits,Allocator>(lhs).compare(rhs)>=0?true:false;
  }

  template <class charT, class traits , class Allocator  >
  inline bool operator>=(
      const basic_string<charT, traits, Allocator>& lhs,
      const charT*                                  rhs)
  {
    return lhs.compare(basic_string<charT,traits,Allocator>(rhs))>=0?true:false;
  }

#if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  template <class charT, class traits, class Allocator>
  inline void swap(basic_string<charT,traits,Allocator>& a, 
                   basic_string<charT,traits,Allocator>& b)
  {
    a.swap(b);
  }
#endif

#ifndef _RW_STD_IOSTREAM

  template<class charT, class traits , class Allocator >
  istream & _RWSTDExportTemplate operator >> (
      istream & is, basic_string<charT, traits, Allocator > & str);

  template<class charT, class traits , class Allocator >
  ostream& _RWSTDExportTemplate operator << (
      ostream & os, const basic_string<charT, traits, Allocator > & str);

  template<class Stream, class charT, class traits , class Allocator >
  Stream& _RWSTDExportTemplate getline(Stream& is, 
                                       basic_string<charT, traits,Allocator>& str, charT delim);

  template<class Stream, class charT, class traits , class Allocator >
  Stream& _RWSTDExportTemplate getline(Stream& is, 
                                       basic_string<charT, traits,Allocator>& str)
  { return getline(is,str,'\n'); }

#endif /*_RW_STD_IOSTREAM*/

#ifdef _RWSTD_MSC22_STATIC_INIT_BUG
#undef npos
#endif

#ifndef _RWSTD_NO_NAMESPACE
}
#endif


#ifndef __FORCE_INSTANTIATIONS
// basic_string instantiations
#pragma do_not_instantiate const std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size_type std::basic_string<char, std::char_traits<char>, std::allocator<char> >::npos
#pragma do_not_instantiate const std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size_type std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<char> >::npos 
#ifndef _RWSTD_NO_STRING_REF_COUNT
#pragma do_not_instantiate std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(const char *, const std::allocator<char> &)
#pragma do_not_instantiate std::basic_string<char, std::char_traits<char>, std::allocator<char> > &std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(const std::basic_string<char, std::char_traits<char>, std::allocator<char> > &)
#pragma do_not_instantiate std::basic_string<char, std::char_traits<char>, std::allocator<char> > &std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(const char *)
#pragma do_not_instantiate char * std::basic_string<char, std::char_traits<char>, std::allocator<char> >::replace(size_t, size_t, const char *, size_t, size_t, size_t)
#pragma do_not_instantiate _RWrwstd::_RWstring_ref<char, std::char_traits<char>, std::allocator<char> > *std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_RWgetRep(size_t, size_t)
#pragma do_not_instantiate const _RWrwstd::_RWnull_string_ref_rep<char,std::char_traits<char >, std::allocator<char >,_RWrwstd::_RWstring_ref_rep<std::allocator<char > > > std::basic_string<char, std::char_traits<char >, std::allocator<char> >::_RWnullref
#endif
#pragma do_not_instantiate const std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::size_type std::basic_string<wchar_t,std::char_traits<wchar_t >, std::allocator<wchar_t > >::npos 
#ifndef _RWSTD_NO_STRING_REF_COUNT
#pragma do_not_instantiate const _RWrwstd::_RWnull_string_ref_rep<wchar_t,std::char_traits<wchar_t >, std::allocator<wchar_t >,_RWrwstd::_RWstring_ref_rep<std::allocator<wchar_t > > > std::basic_string<wchar_t, std::char_traits<wchar_t >,std::allocator<wchar_t > >::_RWnullref
#endif
#endif

#if defined(__VMS) && defined(__DECCXX) && !defined(__DECFIXCXXL1158)
#   pragma __extern_prefix __restore
#endif

#ifdef _RWSTD_COMPILE_INSTANTIATE
#include <string.cc>
#endif

#if defined(__DECCXX)
#   ifdef __PRAGMA_ENVIRONMENT
#      pragma __environment __restore
#   endif
#endif

#endif /*defined __STD_STRING*/
