epoc32/include/stdapis/stlport/stl/_string.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/stdapis/stlport/stl/_string.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_string.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,1579 @@
     1.4 -_string.h
     1.5 +/*
     1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     1.7 + *
     1.8 + * Copyright (c) 1997-1999
     1.9 + * Silicon Graphics Computer Systems, Inc.
    1.10 + *
    1.11 + * Copyright (c) 1999 
    1.12 + * Boris Fomitchev
    1.13 + *
    1.14 + * This material is provided "as is", with absolutely no warranty expressed
    1.15 + * or implied. Any use is at your own risk.
    1.16 + *
    1.17 + * Permission to use or copy this software for any purpose is hereby granted 
    1.18 + * without fee, provided the above notices are retained on all copies.
    1.19 + * Permission to modify the code and to distribute modified code is granted,
    1.20 + * provided the above notices are retained, and a notice that the code was
    1.21 + * modified is included with the above copyright notice.
    1.22 + *
    1.23 + */
    1.24 +
    1.25 +#ifndef _STLP_STRING_H
    1.26 +#define _STLP_STRING_H
    1.27 +
    1.28 +#ifndef _STLP_MEMORY
    1.29 +# include <memory> 
    1.30 +#endif
    1.31 +
    1.32 +# ifndef _STLP_CCTYPE
    1.33 +#  include <cctype> 
    1.34 +# endif
    1.35 +
    1.36 +#ifndef _STLP_STRING_FWD_H
    1.37 +#  include <stl/_string_fwd.h> 
    1.38 +#endif
    1.39 +
    1.40 +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
    1.41 +# include <stl/_function.h> 
    1.42 +#endif
    1.43 +
    1.44 +# include <stl/_ctraits_fns.h>  
    1.45 +#ifndef _STLP_INTERNAL_ALGOBASE_H
    1.46 +# include <stl/_algobase.h> 
    1.47 +#endif
    1.48 +
    1.49 +#ifndef _STLP_INTERNAL_ITERATOR_H
    1.50 +# include <stl/_iterator.h> 
    1.51 +#endif
    1.52 +
    1.53 +#if defined( __MWERKS__ ) && ! defined (_STLP_USE_OWN_NAMESPACE)
    1.54 +
    1.55 +// MSL implementation classes expect to see the definition of streampos
    1.56 +// when this header is included. We expect this to be fixed in later MSL
    1.57 +// implementations
    1.58 +# if !defined( __MSL_CPP__ ) || __MSL_CPP__ < 0x4105
    1.59 +#  include <stl/msl_string.h> 
    1.60 +# endif
    1.61 +
    1.62 +#endif // __MWERKS__
    1.63 +
    1.64 +// Standard C++ string class.  This class has performance
    1.65 +// characteristics very much like vector<>, meaning, for example, that
    1.66 +// it does not perform reference-count or copy-on-write, and that
    1.67 +// concatenation of two strings is an O(N) operation. 
    1.68 +
    1.69 +// There are three reasons why basic_string is not identical to
    1.70 +// vector.  First, basic_string always stores a null character at the
    1.71 +// end; this makes it possible for c_str to be a fast operation.
    1.72 +// Second, the C++ standard requires basic_string to copy elements
    1.73 +// using char_traits<>::assign, char_traits<>::copy, and
    1.74 +// char_traits<>::move.  This means that all of vector<>'s low-level
    1.75 +// operations must be rewritten.  Third, basic_string<> has a lot of
    1.76 +// extra functions in its interface that are convenient but, strictly
    1.77 +// speaking, redundant.
    1.78 +
    1.79 +// Additionally, the C++ standard imposes a major restriction: according
    1.80 +// to the standard, the character type _CharT must be a POD type.  This
    1.81 +// implementation weakens that restriction, and allows _CharT to be a
    1.82 +// a user-defined non-POD type.  However, _CharT must still have a
    1.83 +// default constructor.
    1.84 +
    1.85 +_STLP_BEGIN_NAMESPACE
    1.86 +
    1.87 +# ifdef _STLP_DEBUG
    1.88 +#  define basic_string _Nondebug_string
    1.89 +# endif
    1.90 +
    1.91 +// A helper class to use a char_traits as a function object.
    1.92 +
    1.93 +template <class _Traits> struct _Not_within_traits
    1.94 +  : public unary_function<typename _Traits::char_type, bool> {
    1.95 +  typedef typename _Traits::char_type _CharT;
    1.96 +  const _CharT* _M_first;
    1.97 +  const _CharT* _M_last;
    1.98 +
    1.99 +  _Not_within_traits(const typename _Traits::char_type* __f, 
   1.100 +		     const typename _Traits::char_type* __l) 
   1.101 +    : _M_first(__f), _M_last(__l) {}
   1.102 +
   1.103 +  bool operator()(const typename _Traits::char_type& __x) const {
   1.104 +    return find_if(_M_first, _M_last, 
   1.105 +                   _Eq_char_bound<_Traits>(__x)) == _M_last;
   1.106 +  }
   1.107 +};
   1.108 +
   1.109 +
   1.110 +// -----------------------------------------------------------------------------
   1.111 +//	Symbian string-to-descriptor conversion
   1.112 +// -----------------------------------------------------------------------------
   1.113 +#ifdef _STLP_IMPLICIT_STRING_TO_DESC
   1.114 +template< typename TYPE >
   1.115 +class _DescConv;
   1.116 +
   1.117 +class _DescConv< wchar_t >
   1.118 +{
   1.119 +public:
   1.120 +
   1.121 +	typedef TPtrC16 DescT;
   1.122 +
   1.123 +	static TPtrC16 convert( const wchar_t *ptr, unsigned int len )
   1.124 +	{
   1.125 +		return TPtrC16( ptr, len );
   1.126 +	}
   1.127 +};
   1.128 +
   1.129 +class _DescConv< char >
   1.130 +{
   1.131 +public:
   1.132 +	typedef TPtrC8 DescT;
   1.133 +
   1.134 +	static TPtrC8 convert( const char *ptr, unsigned int len )
   1.135 +	{
   1.136 +		return TPtrC8( (const TUint8 *)ptr, len );
   1.137 +	}
   1.138 +};
   1.139 +#endif	// _STLP_IMPLICIT_STRING_TO_DESC
   1.140 +
   1.141 +
   1.142 +// ------------------------------------------------------------
   1.143 +// Class _String_base.  
   1.144 +
   1.145 +// _String_base is a helper class that makes it it easier to write an
   1.146 +// exception-safe version of basic_string.  The constructor allocates,
   1.147 +// but does not initialize, a block of memory.  The destructor
   1.148 +// deallocates, but does not destroy elements within, a block of
   1.149 +// memory.  The destructor assumes that _M_start either is null, or else
   1.150 +// points to a block of memory that was allocated using _String_base's 
   1.151 +// allocator and whose size is _M_end_of_storage._M_data - _M_start.
   1.152 +
   1.153 +template <class _Tp, class _Alloc> class _String_base 
   1.154 +{
   1.155 +public:
   1.156 +  _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
   1.157 +  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
   1.158 +  typedef _String_base<_Tp,_Alloc> _Base;
   1.159 +  _Tp*    _M_start;
   1.160 +  _Tp*    _M_finish;
   1.161 +  _STLP_alloc_proxy<_Tp*, _Tp, allocator_type> _M_end_of_storage;
   1.162 +  size_t  _M_stream_pos;
   1.163 +                                // Precondition: 0 < __n <= max_size().
   1.164 +  void _M_allocate_block(size_t);
   1.165 +  void _M_deallocate_block() 
   1.166 +    { _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start); }
   1.167 +  
   1.168 +  size_t max_size() const { return (size_t(-1) / sizeof(_Tp)) - 1; }
   1.169 +
   1.170 +  _String_base(const allocator_type& __a)
   1.171 +    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, (_Tp*)0), _M_stream_pos(0) {
   1.172 +    _STLP_PUSH_CLEANUP_ITEM(_Base, this)
   1.173 +  }
   1.174 +  
   1.175 +  _String_base(const allocator_type& __a, size_t __n)
   1.176 +    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, (_Tp*)0), _M_stream_pos(0)
   1.177 +    {
   1.178 +      _STLP_PUSH_CLEANUP_ITEM(_Base, this)
   1.179 +      _M_allocate_block(__n); 
   1.180 +    }
   1.181 +
   1.182 +  ~_String_base() { _M_deallocate_block(); }
   1.183 +
   1.184 +  void _M_throw_length_error() const;
   1.185 +  void _M_throw_out_of_range() const;
   1.186 +};
   1.187 +
   1.188 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
   1.189 +_STLP_EXPORT_TEMPLATE_CLASS _String_base<char, allocator<char> >;
   1.190 +#  if defined (_STLP_HAS_WCHAR_T)
   1.191 +_STLP_EXPORT_TEMPLATE_CLASS _String_base<wchar_t, allocator<wchar_t> >;
   1.192 +#  endif
   1.193 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
   1.194 +
   1.195 +// ------------------------------------------------------------
   1.196 +// Class basic_string.  
   1.197 +
   1.198 +// Class invariants:
   1.199 +// (1) [start, finish) is a valid range.
   1.200 +// (2) Each iterator in [start, finish) points to a valid object
   1.201 +//     of type value_type.
   1.202 +// (3) *finish is a valid object of type value_type; in particular,
   1.203 +//     it is value_type().
   1.204 +// (4) [finish + 1, end_of_storage) is a valid range.
   1.205 +// (5) Each iterator in [finish + 1, end_of_storage) points to 
   1.206 +//     unininitialized memory.
   1.207 +
   1.208 +// Note one important consequence: a string of length n must manage
   1.209 +// a block of memory whose size is at least n + 1.  
   1.210 +
   1.211 +struct _String_reserve_t {};
   1.212 +template <class _CharT, class _Traits, class _Alloc> 
   1.213 +#ifdef __SYMBIAN32__
   1.214 +NONSHARABLE_CLASS ( basic_string ) : public _String_base<_CharT,_Alloc> {
   1.215 +#else
   1.216 +class basic_string : public _String_base<_CharT,_Alloc> {
   1.217 +#endif
   1.218 +private:                        // Protected members inherited from base.
   1.219 +  typedef _String_base<_CharT,_Alloc> _Base;
   1.220 +  typedef basic_string<_CharT, _Traits, _Alloc> _Self;
   1.221 +  // fbp : used to optimize char/wchar_t cases, and to simplify
   1.222 +  // _STLP_DEFAULT_CONSTRUCTOR_BUG problem workaround
   1.223 +  typedef typename _Is_integer<_CharT>::_Integral _Char_Is_Integral;
   1.224 +public:
   1.225 +  typedef _CharT value_type;
   1.226 +  typedef _Traits traits_type;
   1.227 +
   1.228 +  typedef value_type* pointer;
   1.229 +  typedef const value_type* const_pointer;
   1.230 +  typedef value_type& reference;
   1.231 +  typedef const value_type& const_reference;
   1.232 +  typedef size_t size_type;
   1.233 +  typedef ptrdiff_t difference_type;
   1.234 +  typedef random_access_iterator_tag _Iterator_category;
   1.235 +
   1.236 +  typedef const value_type*                const_iterator;
   1.237 +  typedef value_type*                      iterator;
   1.238 +
   1.239 +  _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
   1.240 +
   1.241 +# if defined(_STLP_STATIC_CONST_INIT_BUG) && ! defined (__SYMBIAN32__)
   1.242 +  enum { npos = -1 };
   1.243 +# elif __GNUC__ == 2 && __GNUC_MINOR__ == 96
   1.244 +  // inline initializer conflicts with 'extern template' 
   1.245 +  static const size_t npos ;
   1.246 +# else
   1.247 +  static const size_t npos = ~(size_t)0;
   1.248 +# endif
   1.249 +
   1.250 +  typedef _String_reserve_t _Reserve_t;
   1.251 +# if defined (_STLP_USE_NATIVE_STRING) && ! defined (_STLP_DEBUG)
   1.252 +#  if (defined(__IBMCPP__) && (500 <= __IBMCPP__) && (__IBMCPP__ < 600) )
   1.253 +   // this typedef is being used for conversions
   1.254 +   typedef typename _STLP_VENDOR_STD::basic_string<_CharT,_Traits, 
   1.255 +    typename _STLP_VENDOR_STD::allocator<_CharT> > __std_string;
   1.256 +#  else
   1.257 +   // this typedef is being used for conversions
   1.258 +   typedef _STLP_VENDOR_STD::basic_string<_CharT,_Traits, 
   1.259 +    _STLP_VENDOR_STD::allocator<_CharT> > __std_string;
   1.260 +#  endif
   1.261 +# endif
   1.262 +  
   1.263 +public:                         // Constructor, destructor, assignment.
   1.264 +  typedef typename _String_base<_CharT,_Alloc>::allocator_type allocator_type;
   1.265 +
   1.266 +  allocator_type get_allocator() const {
   1.267 +    return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _CharT);
   1.268 +  }
   1.269 +
   1.270 +  _STLP_DECLSPEC basic_string();
   1.271 +
   1.272 +  explicit basic_string(const allocator_type& __a)
   1.273 +    : _String_base<_CharT,_Alloc>(__a, 8) {
   1.274 +    _M_terminate_string();
   1.275 +    _STLP_POP_CLEANUP_ITEM
   1.276 + }
   1.277 +
   1.278 +  basic_string(_Reserve_t, size_t __n,
   1.279 +               const allocator_type& __a = allocator_type())
   1.280 +    : _String_base<_CharT,_Alloc>(__a, __n + 1) { 
   1.281 +    _M_terminate_string(); 
   1.282 +    _STLP_POP_CLEANUP_ITEM
   1.283 +  }
   1.284 +
   1.285 +  _STLP_DECLSPEC basic_string(const basic_string<_CharT, _Traits, _Alloc>&);
   1.286 +
   1.287 +  basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
   1.288 +               const allocator_type& __a = allocator_type()) 
   1.289 +    : _String_base<_CharT,_Alloc>(__a) {
   1.290 +    if (__pos > __s.size())
   1.291 +      this->_M_throw_out_of_range();
   1.292 +    else
   1.293 +      _M_range_initialize(__s._M_start + __pos,
   1.294 +                          __s._M_start + __pos + (min) (__n, __s.size() - __pos));
   1.295 +    _STLP_POP_CLEANUP_ITEM
   1.296 +  }
   1.297 +
   1.298 +  basic_string(const _CharT* __s, size_type __n,
   1.299 +               const allocator_type& __a = allocator_type()) 
   1.300 +    : _String_base<_CharT,_Alloc>(__a) 
   1.301 +    { 
   1.302 +      _STLP_FIX_LITERAL_BUG(__s)
   1.303 +      _M_range_initialize(__s, __s + __n); 
   1.304 +      _STLP_POP_CLEANUP_ITEM
   1.305 +    }
   1.306 +
   1.307 +  _STLP_DECLSPEC basic_string(const _CharT* __s,
   1.308 +               const allocator_type& __a = allocator_type());
   1.309 +
   1.310 +  basic_string(size_type __n, _CharT __c,
   1.311 +               const allocator_type& __a = allocator_type())
   1.312 +    : _String_base<_CharT,_Alloc>(__a, __n + 1)
   1.313 +  {
   1.314 +    this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __c);
   1.315 +    _M_terminate_string();
   1.316 +    _STLP_POP_CLEANUP_ITEM
   1.317 +  }
   1.318 +
   1.319 +  // Check to see if _InputIterator is an integer type.  If so, then
   1.320 +  // it can't be an iterator.
   1.321 +#if defined (_STLP_MEMBER_TEMPLATES) && !(defined(__MRC__)||(defined(__SC__) && !defined(__DMC__)))		//*ty 04/30/2001 - mpw compilers choke on this ctor
   1.322 +# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
   1.323 +  template <class _InputIterator> basic_string(_InputIterator __f, _InputIterator __l)
   1.324 +    : _String_base<_CharT,_Alloc>(allocator_type())
   1.325 +  {
   1.326 +    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   1.327 +    _M_initialize_dispatch(__f, __l, _Integral());
   1.328 +    _STLP_POP_CLEANUP_ITEM
   1.329 +  }
   1.330 +# endif
   1.331 +  template <class _InputIterator> basic_string(_InputIterator __f, _InputIterator __l,
   1.332 +               const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
   1.333 +    : _String_base<_CharT,_Alloc>(__a)
   1.334 +  {
   1.335 +    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
   1.336 +    _M_initialize_dispatch(__f, __l, _Integral());
   1.337 +    _STLP_POP_CLEANUP_ITEM
   1.338 +  }
   1.339 +#else /* _STLP_MEMBER_TEMPLATES */
   1.340 +
   1.341 +  basic_string(const _CharT* __f, const _CharT* __l,
   1.342 +               const allocator_type& __a = allocator_type())
   1.343 +    : _String_base<_CharT,_Alloc>(__a)
   1.344 +  {
   1.345 +    _STLP_FIX_LITERAL_BUG(__f)  _STLP_FIX_LITERAL_BUG(__l)
   1.346 +    _M_range_initialize(__f, __l);
   1.347 +    _STLP_POP_CLEANUP_ITEM
   1.348 +  }
   1.349 +
   1.350 +#endif
   1.351 +
   1.352 +# if defined (_STLP_USE_NATIVE_STRING) && ! defined (_STLP_DEBUG)
   1.353 +  // these conversion operations still needed for
   1.354 +  // strstream, etc.
   1.355 +  basic_string (const __std_string& __x): _String_base<_CharT,_Alloc>(allocator_type())
   1.356 +    {
   1.357 +      const _CharT* __s = __x.data();
   1.358 +      _M_range_initialize(__s, __s + __x.size()); 
   1.359 +      _STLP_POP_CLEANUP_ITEM
   1.360 +    }
   1.361 +  
   1.362 +  operator __std_string() const { return __std_string(this->data(), this->size()); }
   1.363 +# endif
   1.364 +
   1.365 +  ~basic_string() { _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1); }
   1.366 +    
   1.367 +  _Self& operator=(const _Self& __s) {
   1.368 +    if (&__s != this) 
   1.369 +    	{
   1.370 +      	assign(__s._M_start, __s._M_finish);
   1.371 +	this->_M_stream_pos = __s.size();
   1.372 +    	}
   1.373 +    return *this;
   1.374 +  }
   1.375 +
   1.376 +  _Self& operator=(const _CharT* __s) { 
   1.377 +    _STLP_FIX_LITERAL_BUG(__s)
   1.378 +    return assign(__s, __s + traits_type::length(__s)); 
   1.379 +  }
   1.380 +
   1.381 +  _Self& operator=(_CharT __c)
   1.382 +    { return assign(__STATIC_CAST(size_type,1), __c); }
   1.383 +
   1.384 +  static _CharT _STLP_CALL _M_null() {
   1.385 +    return _STLP_DEFAULT_CONSTRUCTED(_CharT);
   1.386 +  }
   1.387 +
   1.388 +private:                        // Helper functions used by constructors
   1.389 +                                // and elsewhere.
   1.390 +  // fbp : simplify integer types (char, wchar)
   1.391 +  void _M_construct_null_aux(_CharT* __p, const __false_type&) {
   1.392 +    _Construct(__p);
   1.393 +  }
   1.394 +  void _M_construct_null_aux(_CharT* __p, const __true_type&) {
   1.395 +    *__p = 0;
   1.396 +  }
   1.397 +
   1.398 +  void _M_construct_null(_CharT* __p) {
   1.399 +    _M_construct_null_aux(__p, _Char_Is_Integral());
   1.400 +  }
   1.401 +
   1.402 +private:                        
   1.403 +  // Helper functions used by constructors.  It is a severe error for
   1.404 +  // any of them to be called anywhere except from within constructors.
   1.405 +
   1.406 +  void _M_terminate_string_aux(const __false_type&) {
   1.407 +    _STLP_TRY {
   1.408 +      _M_construct_null(this->_M_finish);
   1.409 +    }
   1.410 +    _STLP_UNWIND(_STLP_STD::_Destroy(this->_M_start, this->_M_finish));
   1.411 +  }
   1.412 +
   1.413 +  void _M_terminate_string_aux(const __true_type&) {
   1.414 +    *(this->_M_finish)=0;
   1.415 +  }
   1.416 +
   1.417 +  void _M_terminate_string() {
   1.418 +    _M_terminate_string_aux(_Char_Is_Integral());
   1.419 +  }
   1.420 +
   1.421 +#ifndef _STLP_MEMBER_TEMPLATES
   1.422 +  bool _M_inside(const _CharT* __s ) const {
   1.423 +    return (__s >= this->_M_start) && (__s < this->_M_finish);
   1.424 +  }
   1.425 +#else
   1.426 +  template <class _InputIter>
   1.427 +  bool _M_inside(_InputIter __i) const {
   1.428 +    const _CharT* __s = __STATIC_CAST(const _CharT*, &(*__i));
   1.429 +    return (__s >= this->_M_start) && (__s < this->_M_finish);
   1.430 +  }
   1.431 +#endif /*_STLP_MEMBER_TEMPLATES*/
   1.432 +
   1.433 +#ifdef _STLP_MEMBER_TEMPLATES
   1.434 +    
   1.435 +  template <class _InputIter> void _M_range_initialize(_InputIter __f, _InputIter __l,
   1.436 +                           const input_iterator_tag &) {
   1.437 +    this->_M_allocate_block(8);
   1.438 +    _M_construct_null(this->_M_finish);
   1.439 +    _STLP_TRY {
   1.440 +      append(__f, __l);
   1.441 +    }
   1.442 +    _STLP_UNWIND(_STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1));
   1.443 +  }
   1.444 +
   1.445 +  template <class _ForwardIter> void _M_range_initialize(_ForwardIter __f, _ForwardIter __l, 
   1.446 +                           const forward_iterator_tag &) {
   1.447 +    difference_type __n = distance(__f, __l);
   1.448 +    this->_M_allocate_block(__n + 1);
   1.449 +    this->_M_finish = uninitialized_copy(__f, __l, this->_M_start);
   1.450 +    _M_terminate_string();
   1.451 +
   1.452 +  }
   1.453 +
   1.454 +  template <class _InputIter> void _M_range_initialize(_InputIter __f, _InputIter __l) {
   1.455 +    _M_range_initialize(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
   1.456 +  }
   1.457 +
   1.458 +  template <class _Integer> void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type&) {
   1.459 +    this->_M_allocate_block(__n + 1);
   1.460 +    this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __x);
   1.461 +    _M_terminate_string();
   1.462 +  }
   1.463 +
   1.464 +  template <class _InputIter> void _M_initialize_dispatch(_InputIter __f, _InputIter __l, const __false_type&) {
   1.465 +     _M_range_initialize(__f, __l);
   1.466 +  }
   1.467 +    
   1.468 +#else /* _STLP_MEMBER_TEMPLATES */
   1.469 +
   1.470 +  void _M_range_initialize(const _CharT* __f, const _CharT* __l) {
   1.471 +    ptrdiff_t __n = __l - __f;
   1.472 +    this->_M_allocate_block(__n + 1);
   1.473 +    this->_M_finish = uninitialized_copy(__f, __l, this->_M_start);
   1.474 +    _M_terminate_string();
   1.475 +  }
   1.476 +
   1.477 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.478 +
   1.479 +#ifdef _STLP_USE_TRAP_LEAVE
   1.480 +public:
   1.481 +  static void* operator new (size_t __n, TLeave) { return _STLP_StackHelper<bool>::_NewLC(__n); }
   1.482 +  static void* operator new (size_t __n) { return _STLP_StackHelper<bool>::_NewLC(__n); }
   1.483 +#endif
   1.484 +
   1.485 +public:                         // Iterators.
   1.486 +  iterator begin()             { return this->_M_start; }
   1.487 +  iterator end()               { return this->_M_finish; }
   1.488 +  const_iterator begin() const { return this->_M_start; }
   1.489 +  const_iterator end()   const { return this->_M_finish; }  
   1.490 +
   1.491 +  reverse_iterator rbegin()             
   1.492 +    { return reverse_iterator(this->_M_finish); }
   1.493 +  reverse_iterator rend()               
   1.494 +    { return reverse_iterator(this->_M_start); }
   1.495 +  const_reverse_iterator rbegin() const 
   1.496 +    { return const_reverse_iterator(this->_M_finish); }
   1.497 +  const_reverse_iterator rend()   const 
   1.498 +    { return const_reverse_iterator(this->_M_start); }
   1.499 +
   1.500 +public:                         // Size, capacity, etc.
   1.501 +  size_type size() const { return this->_M_finish - this->_M_start; }
   1.502 +  size_type length() const { return size(); }
   1.503 +
   1.504 +  size_t max_size() const { return _Base::max_size(); }
   1.505 +
   1.506 +
   1.507 +  void resize(size_type __n, _CharT __c) {
   1.508 +    if (__n <= size())
   1.509 +      erase(begin() + __n, end());
   1.510 +    else
   1.511 +      append(__n - size(), __c);
   1.512 +  }
   1.513 +  void resize(size_type __n) { resize(__n, _M_null()); }
   1.514 +
   1.515 +  _STLP_DECLSPEC void reserve(size_type = 0);
   1.516 +
   1.517 +  size_type capacity() const { return (this->_M_end_of_storage._M_data - this->_M_start) - 1; }
   1.518 +
   1.519 +  void clear() {
   1.520 +    if (!empty()) {
   1.521 +      _Traits::assign(*(this->_M_start), _M_null());
   1.522 +      _STLP_STD::_Destroy(this->_M_start+1, this->_M_finish+1);
   1.523 +      this->_M_finish = this->_M_start;
   1.524 +    }
   1.525 +  } 
   1.526 +
   1.527 +  bool empty() const { return this->_M_start == this->_M_finish; }    
   1.528 +
   1.529 +public:                         // Element access.
   1.530 +
   1.531 +  const_reference operator[](size_type __n) const
   1.532 +    { return *(this->_M_start + __n); }
   1.533 +  reference operator[](size_type __n)
   1.534 +    { return *(this->_M_start + __n); }
   1.535 +
   1.536 +  const_reference at(size_type __n) const {
   1.537 +    if (__n >= size())
   1.538 +      this->_M_throw_out_of_range();
   1.539 +    return *(this->_M_start + __n);
   1.540 +  }
   1.541 +
   1.542 +  reference at(size_type __n) {
   1.543 +    if (__n >= size())
   1.544 +      this->_M_throw_out_of_range();
   1.545 +    return *(this->_M_start + __n);
   1.546 +  }
   1.547 +
   1.548 +public:                         // Append, operator+=, push_back.
   1.549 +
   1.550 +  _Self& operator+=(const _Self& __s) { return append(__s); }
   1.551 +  _Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); }
   1.552 +  _Self& operator+=(_CharT __c) { push_back(__c); return *this; }
   1.553 +
   1.554 +  _Self& append(const _Self& __s) 
   1.555 +    { return append(__s._M_start, __s._M_finish); }
   1.556 +
   1.557 +  _Self& append(const _Self& __s,
   1.558 +                       size_type __pos, size_type __n)
   1.559 +  {
   1.560 +    if (__pos > __s.size())
   1.561 +      this->_M_throw_out_of_range();
   1.562 +    return append(__s._M_start + __pos,
   1.563 +                  __s._M_start + __pos + (min) (__n, __s.size() - __pos));
   1.564 +  }
   1.565 +
   1.566 +  _Self& append(const _CharT* __s, size_type __n) 
   1.567 +    { _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s+__n); }
   1.568 +  _Self& append(const _CharT* __s) 
   1.569 +    { _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s + traits_type::length(__s)); }
   1.570 +  _Self& append(size_type __n, _CharT __c);
   1.571 +
   1.572 +#ifdef _STLP_MEMBER_TEMPLATES
   1.573 +
   1.574 +  // Check to see if _InputIterator is an integer type.  If so, then
   1.575 +  // it can't be an iterator.
   1.576 +  template <class _InputIter> _Self& append(_InputIter __first, _InputIter __last) {
   1.577 +    typedef typename _Is_integer<_InputIter>::_Integral _Integral;
   1.578 +    return _M_append_dispatch(__first, __last, _Integral());
   1.579 +  }
   1.580 +
   1.581 +#else /* _STLP_MEMBER_TEMPLATES */
   1.582 +
   1.583 +  _Self& append(const _CharT* __first, const _CharT* __last);
   1.584 +
   1.585 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.586 +
   1.587 +  void push_back(_CharT __c) {
   1.588 +    if (this->_M_finish + 1 == this->_M_end_of_storage._M_data)
   1.589 +      reserve(size() + (max)(size(), __STATIC_CAST(size_type,1)));
   1.590 +    _M_construct_null(this->_M_finish + 1);
   1.591 +    _Traits::assign(*(this->_M_finish), __c);
   1.592 +    ++this->_M_finish;
   1.593 +  }
   1.594 +
   1.595 +  void pop_back() {
   1.596 +    _Traits::assign(*(this->_M_finish - 1), _M_null());
   1.597 +    _STLP_STD::_Destroy(this->_M_finish);
   1.598 +    --this->_M_finish;
   1.599 +  }
   1.600 +
   1.601 +private:                        // Helper functions for append.
   1.602 +
   1.603 +#ifdef _STLP_MEMBER_TEMPLATES
   1.604 +
   1.605 +  template <class _InputIter> _Self& append(_InputIter __first, _InputIter __last, const input_iterator_tag &)
   1.606 +  {
   1.607 +	  for ( ; __first != __last ; ++__first)
   1.608 +	    push_back(*__first);
   1.609 +	  return *this;
   1.610 +	}
   1.611 +
   1.612 +  template <class _ForwardIter> _Self& append(_ForwardIter __first, _ForwardIter __last, 
   1.613 +                       const forward_iterator_tag &)  {
   1.614 +    if (__first != __last) {
   1.615 +	    const size_type __old_size = size();
   1.616 +	    difference_type __n = distance(__first, __last);
   1.617 +	    if (__STATIC_CAST(size_type,__n) > max_size() || __old_size > max_size() - __STATIC_CAST(size_type,__n))
   1.618 +	      this->_M_throw_length_error();
   1.619 +	    if (__old_size + __n > capacity()) {
   1.620 +	      const size_type __len = __old_size +
   1.621 +	                            (max)(__old_size, __STATIC_CAST(size_type,__n)) + 1;
   1.622 +	      _STLP_LEAVE_VOLATILE pointer __new_start = this->_M_end_of_storage.allocate(__len);
   1.623 +	      _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   1.624 +	      _STLP_TRY {
   1.625 +	        __new_finish = uninitialized_copy(this->_M_start, this->_M_finish, __new_start);
   1.626 +	        __new_finish = uninitialized_copy(__first, __last, __new_finish);
   1.627 +	        _M_construct_null(__new_finish);
   1.628 +	      }
   1.629 +	      _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
   1.630 +	                    this->_M_end_of_storage.deallocate(__new_start,__len)));
   1.631 +	      _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
   1.632 +	      this->_M_deallocate_block();
   1.633 +	      this->_M_start = __new_start;
   1.634 +	      this->_M_finish = __new_finish;
   1.635 +	      this->_M_end_of_storage._M_data = __new_start + __len; 
   1.636 +	    }
   1.637 +	    else {
   1.638 +	      _ForwardIter __f1 = __first;
   1.639 +	      ++__f1;
   1.640 +	      uninitialized_copy(__f1, __last, this->_M_finish + 1);
   1.641 +	      _STLP_TRY {
   1.642 +	        _M_construct_null(this->_M_finish + __n);
   1.643 +	      }
   1.644 +	      _STLP_UNWIND(_STLP_STD::_Destroy(this->_M_finish + 1, this->_M_finish + __n));
   1.645 +	      _Traits::assign(*end(), *__first);
   1.646 +	      this->_M_finish += __n;
   1.647 +	    }
   1.648 +	  }
   1.649 +	  return *this;  
   1.650 +	}
   1.651 +
   1.652 +  template <class _Integer> _Self& _M_append_dispatch(_Integer __n, _Integer __x, const __true_type&) {
   1.653 +    return append((size_type) __n, (_CharT) __x);
   1.654 +  }
   1.655 +
   1.656 +  template <class _InputIter> _Self& _M_append_dispatch(_InputIter __f, _InputIter __l,
   1.657 +                                   const __false_type&) {
   1.658 +    return append(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
   1.659 +  }
   1.660 +
   1.661 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.662 +
   1.663 +public:                         // Assign
   1.664 +  
   1.665 +  _Self& assign(const _Self& __s) 
   1.666 +    { return assign(__s._M_start, __s._M_finish); }
   1.667 +
   1.668 +  _Self& assign(const _Self& __s, 
   1.669 +                       size_type __pos, size_type __n) {
   1.670 +    if (__pos > __s.size())
   1.671 +      this->_M_throw_out_of_range();
   1.672 +    return assign(__s._M_start + __pos, 
   1.673 +                  __s._M_start + __pos + (min) (__n, __s.size() - __pos));
   1.674 +  }
   1.675 +
   1.676 +  _Self& assign(const _CharT* __s, size_type __n)
   1.677 +    { _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + __n); }
   1.678 +
   1.679 +  _Self& assign(const _CharT* __s)
   1.680 +    { _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + _Traits::length(__s)); }
   1.681 +
   1.682 +  _STLP_DECLSPEC _Self& assign(size_type __n, _CharT __c);
   1.683 +
   1.684 +#ifdef _STLP_MEMBER_TEMPLATES
   1.685 +
   1.686 +private:                        // Helper functions for assign.
   1.687 +
   1.688 +  template <class _Integer> 
   1.689 +  _Self& _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type&) {
   1.690 +    return assign((size_type) __n, (_CharT) __x);
   1.691 +  }
   1.692 +
   1.693 +  template <class _InputIter> 
   1.694 +  _Self& _M_assign_dispatch(_InputIter __f, _InputIter __l,
   1.695 +			    const __false_type&)  {
   1.696 +    pointer __cur = this->_M_start;
   1.697 +    while (__f != __l && __cur != this->_M_finish) {
   1.698 +      _Traits::assign(*__cur, *__f);
   1.699 +      ++__f;
   1.700 +      ++__cur;
   1.701 +    }
   1.702 +    if (__f == __l)
   1.703 +      erase(__cur, end());
   1.704 +    else
   1.705 +      append(__f, __l);
   1.706 +    return *this;
   1.707 +  }
   1.708 +  
   1.709 +public:
   1.710 +  // Check to see if _InputIterator is an integer type.  If so, then
   1.711 +  // it can't be an iterator.
   1.712 +  template <class _InputIter> _Self& assign(_InputIter __first, _InputIter __last) {
   1.713 +    typedef typename _Is_integer<_InputIter>::_Integral _Integral;
   1.714 +    return _M_assign_dispatch(__first, __last, _Integral());
   1.715 +  }
   1.716 +#endif  /* _STLP_MEMBER_TEMPLATES */
   1.717 +
   1.718 +  // if member templates are on, this works as specialization 
   1.719 +  _Self& assign(const _CharT* __f, const _CharT* __l)
   1.720 +  {
   1.721 +    ptrdiff_t __n = __l - __f;
   1.722 +    if (__STATIC_CAST(size_type,__n) <= size()) {
   1.723 +      _Traits::copy(this->_M_start, __f, __n);
   1.724 +      erase(begin() + __n, end());
   1.725 +    }
   1.726 +    else {
   1.727 +      _Traits::copy(this->_M_start, __f, size());
   1.728 +      append(__f + size(), __l);
   1.729 +    }
   1.730 +    return *this;
   1.731 +  }
   1.732 +  
   1.733 +public:                         // Insert
   1.734 +
   1.735 +  _Self& insert(size_type __pos, const _Self& __s) {
   1.736 +    if (__pos > size())
   1.737 +      this->_M_throw_out_of_range();
   1.738 +    if (size() > max_size() - __s.size())
   1.739 +      this->_M_throw_length_error();
   1.740 +    insert(begin() + __pos, __s._M_start, __s._M_finish);
   1.741 +    return *this;
   1.742 +  }
   1.743 +
   1.744 +  _Self& insert(size_type __pos, const _Self& __s,
   1.745 +                       size_type __beg, size_type __n) {
   1.746 +    if (__pos > size() || __beg > __s.size())
   1.747 +      this->_M_throw_out_of_range();
   1.748 +    size_type __len = (min) (__n, __s.size() - __beg);
   1.749 +    if (size() > max_size() - __len)
   1.750 +      this->_M_throw_length_error();
   1.751 +    insert(begin() + __pos,
   1.752 +           __s._M_start + __beg, __s._M_start + __beg + __len);
   1.753 +    return *this;
   1.754 +  }
   1.755 +
   1.756 +  _Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
   1.757 +    _STLP_FIX_LITERAL_BUG(__s)
   1.758 +    if (__pos > size())
   1.759 +      this->_M_throw_out_of_range();
   1.760 +    if (size() > max_size() - __n)
   1.761 +      this->_M_throw_length_error();
   1.762 +    insert(begin() + __pos, __s, __s + __n);
   1.763 +    return *this;
   1.764 +  }
   1.765 +
   1.766 +  _Self& insert(size_type __pos, const _CharT* __s) {
   1.767 +    _STLP_FIX_LITERAL_BUG(__s)
   1.768 +    if (__pos > size())
   1.769 +      this->_M_throw_out_of_range();
   1.770 +    size_type __len = _Traits::length(__s);
   1.771 +    if (size() > max_size() - __len)
   1.772 +      this->_M_throw_length_error();
   1.773 +    insert(this->_M_start + __pos, __s, __s + __len);
   1.774 +    return *this;
   1.775 +  }
   1.776 +    
   1.777 +  _Self& insert(size_type __pos, size_type __n, _CharT __c) {
   1.778 +    if (__pos > size())
   1.779 +      this->_M_throw_out_of_range();
   1.780 +    if (size() > max_size() - __n)
   1.781 +      this->_M_throw_length_error();
   1.782 +    insert(begin() + __pos, __n, __c);
   1.783 +    return *this;
   1.784 +  }
   1.785 +
   1.786 +  iterator insert(iterator __p, _CharT __c) {
   1.787 +    _STLP_FIX_LITERAL_BUG(__p)
   1.788 +    if (__p == end()) {
   1.789 +      push_back(__c);
   1.790 +      return this->_M_finish - 1;
   1.791 +    }
   1.792 +    else
   1.793 +      return _M_insert_aux(__p, __c);
   1.794 +  }
   1.795 +
   1.796 +  void insert(iterator __p, size_t __n, _CharT __c);
   1.797 +
   1.798 +#ifdef _STLP_MEMBER_TEMPLATES
   1.799 +
   1.800 +  // Check to see if _InputIterator is an integer type.  If so, then
   1.801 +  // it can't be an iterator.
   1.802 +  template <class _InputIter> void insert(iterator __p, _InputIter __first, _InputIter __last) {
   1.803 +    typedef typename _Is_integer<_InputIter>::_Integral _Integral;
   1.804 +    _M_insert_dispatch(__p, __first, __last, _Integral());
   1.805 +  }
   1.806 +
   1.807 +#else /* _STLP_MEMBER_TEMPLATES */
   1.808 +
   1.809 +  _STLP_DECLSPEC void insert(iterator __p, const _CharT* __first, const _CharT* __last);
   1.810 +
   1.811 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.812 +
   1.813 +private:                        // Helper functions for insert.
   1.814 +
   1.815 +#ifdef _STLP_MEMBER_TEMPLATES
   1.816 +
   1.817 +  template <class _InputIter> void insert(iterator __p, _InputIter __first, _InputIter __last,
   1.818 +	      const input_iterator_tag &)
   1.819 +  {
   1.820 +	  for ( ; __first != __last; ++__first) {
   1.821 +	    __p = insert(__p, *__first);
   1.822 +	    ++__p;
   1.823 +	  }
   1.824 +	}
   1.825 +
   1.826 +  template <class _ForwardIter> 
   1.827 +  void insert(iterator __position, _ForwardIter __first, _ForwardIter __last, 
   1.828 +	      const forward_iterator_tag &)  {
   1.829 +    if (__first != __last) {
   1.830 +      difference_type __n = distance(__first, __last);
   1.831 +      if (this->_M_end_of_storage._M_data - this->_M_finish >= __n + 1) {
   1.832 +	const difference_type __elems_after = this->_M_finish - __position;
   1.833 +	pointer __old_finish = this->_M_finish;
   1.834 +	if (__elems_after >= __n) {
   1.835 +	  uninitialized_copy((this->_M_finish - __n) + 1, this->_M_finish + 1,
   1.836 +			     this->_M_finish + 1);
   1.837 +	  this->_M_finish += __n;
   1.838 +	  _Traits::move(__position + __n,
   1.839 +			__position, (__elems_after - __n) + 1);
   1.840 +	  _M_move(__first, __last, __position);
   1.841 +	      }
   1.842 +	else {
   1.843 +	  _ForwardIter __mid = __first;
   1.844 +	  advance(__mid, __elems_after + 1);
   1.845 +	  uninitialized_copy(__mid, __last, this->_M_finish + 1);
   1.846 +	  this->_M_finish += __n - __elems_after;
   1.847 +	        _STLP_TRY {
   1.848 +	          uninitialized_copy(__position, __old_finish + 1, this->_M_finish);
   1.849 +	          this->_M_finish += __elems_after;
   1.850 +	        }
   1.851 +	        _STLP_UNWIND((_STLP_STD::_Destroy(__old_finish + 1, this->_M_finish), 
   1.852 +	                      this->_M_finish = __old_finish));
   1.853 +	        _M_move(__first, __mid, __position);
   1.854 +	}
   1.855 +      }
   1.856 +      else {
   1.857 +	const size_type __old_size = size();        
   1.858 +	const size_type __len
   1.859 +	  = __old_size + (max)(__old_size, __STATIC_CAST(size_type,__n)) + 1;
   1.860 +	      _STLP_LEAVE_VOLATILE pointer __new_start = this->_M_end_of_storage.allocate(__len);
   1.861 +	      _STLP_LEAVE_VOLATILE pointer __new_finish = __new_start;
   1.862 +	      _STLP_TRY {
   1.863 +	        __new_finish = uninitialized_copy(this->_M_start, __position, __new_start);
   1.864 +	        __new_finish = uninitialized_copy(__first, __last, __new_finish);
   1.865 +	        __new_finish
   1.866 +	          = uninitialized_copy(__position, this->_M_finish, __new_finish);
   1.867 +	        _M_construct_null(__new_finish);
   1.868 +	      }
   1.869 +	      _STLP_UNWIND((_STLP_STD::_Destroy(__new_start,__new_finish),
   1.870 +	                    this->_M_end_of_storage.deallocate(__new_start,__len)));
   1.871 +	      _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);
   1.872 +	      this->_M_deallocate_block();
   1.873 +	      this->_M_start = __new_start;
   1.874 +	      this->_M_finish = __new_finish;
   1.875 +	      this->_M_end_of_storage._M_data = __new_start + __len; 
   1.876 +	    }
   1.877 +    }
   1.878 +  }
   1.879 +
   1.880 +  template <class _Integer> void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x,
   1.881 +                          const __true_type&) {
   1.882 +    insert(__p, (size_type) __n, (_CharT) __x);
   1.883 +  }
   1.884 +
   1.885 +  template <class _InputIter> void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last,
   1.886 +                          const __false_type&) {
   1.887 +    insert(__p, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
   1.888 +  }
   1.889 +
   1.890 +  template <class _InputIterator> void 
   1.891 +  _M_copy(_InputIterator __first, _InputIterator __last, pointer __result) {
   1.892 +    for ( ; __first != __last; ++__first, ++__result)
   1.893 +      _Traits::assign(*__result, *__first);
   1.894 +  }
   1.895 +
   1.896 +  template <class _InputIterator>
   1.897 +  void _M_move(_InputIterator __first, _InputIterator __last, pointer __result) {
   1.898 +    //call _M_copy as being here means that __result is not within [__first, __last)
   1.899 +    for ( ; __first != __last; ++__first, ++__result)
   1.900 +      _Traits::assign(*__result, *__first);
   1.901 +  }
   1.902 +
   1.903 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.904 +
   1.905 +  pointer _M_insert_aux(pointer, _CharT);
   1.906 +
   1.907 +  void 
   1.908 +  _M_copy(const _CharT* __first, const _CharT* __last, _CharT* __result) {
   1.909 +    _Traits::copy(__result, __first, __last - __first);
   1.910 +  }
   1.911 +  void _M_move(const _CharT* __first, const _CharT* __last, _CharT* __result) {
   1.912 +    _Traits::move(__result, __first, __last - __first);
   1.913 +  }
   1.914 +
   1.915 +public:                         // Erase.
   1.916 +
   1.917 +  _Self& erase(size_type __pos = 0, size_type __n = npos) {
   1.918 +    if (__pos > size())
   1.919 +      this->_M_throw_out_of_range();
   1.920 +    erase(begin() + __pos, begin() + __pos + (min) (__n, size() - __pos));
   1.921 +    return *this;
   1.922 +  }  
   1.923 +
   1.924 +  iterator erase(iterator __position) {
   1.925 +                                // The move includes the terminating _CharT().
   1.926 +    _Traits::move(__position, __position + 1, this->_M_finish - __position);
   1.927 +    _STLP_STD::_Destroy(this->_M_finish);
   1.928 +    --this->_M_finish;
   1.929 +    return __position;
   1.930 +  }
   1.931 +
   1.932 +  iterator erase(iterator __first, iterator __last) {
   1.933 +    if (__first != __last) {
   1.934 +                                // The move includes the terminating _CharT().
   1.935 +      traits_type::move(__first, __last, (this->_M_finish - __last) + 1);
   1.936 +      pointer __new_finish = this->_M_finish - (__last - __first);
   1.937 +      _STLP_STD::_Destroy(__new_finish + 1, this->_M_finish + 1);
   1.938 +      this->_M_finish = __new_finish;
   1.939 +    }
   1.940 +    return __first;
   1.941 +  }
   1.942 +
   1.943 +public:                         // Replace.  (Conceptually equivalent
   1.944 +                                // to erase followed by insert.)
   1.945 +  _Self& replace(size_type __pos, size_type __n, 
   1.946 +                        const _Self& __s) {
   1.947 +    if (__pos > size())
   1.948 +      this->_M_throw_out_of_range();
   1.949 +    const size_type __len = (min) (__n, size() - __pos);
   1.950 +    if (size() - __len >= max_size() - __s.size())
   1.951 +      this->_M_throw_length_error();
   1.952 +    return replace(begin() + __pos, begin() + __pos + __len, 
   1.953 +                   __s._M_start, __s._M_finish);
   1.954 +  }
   1.955 +
   1.956 +  _Self& replace(size_type __pos1, size_type __n1,
   1.957 +                        const _Self& __s,
   1.958 +                        size_type __pos2, size_type __n2) {
   1.959 +    if (__pos1 > size() || __pos2 > __s.size())
   1.960 +      this->_M_throw_out_of_range();
   1.961 +    const size_type __len1 = (min) (__n1, size() - __pos1);
   1.962 +    const size_type __len2 = (min) (__n2, __s.size() - __pos2);
   1.963 +    if (size() - __len1 >= max_size() - __len2)
   1.964 +      this->_M_throw_length_error();
   1.965 +    return replace(begin() + __pos1, begin() + __pos1 + __len1,
   1.966 +                   __s._M_start + __pos2, __s._M_start + __pos2 + __len2);
   1.967 +  }
   1.968 +
   1.969 +  _Self& replace(size_type __pos, size_type __n1,
   1.970 +                        const _CharT* __s, size_type __n2) {
   1.971 +    _STLP_FIX_LITERAL_BUG(__s)
   1.972 +    if (__pos > size())
   1.973 +      this->_M_throw_out_of_range();
   1.974 +    const size_type __len = (min) (__n1, size() - __pos);
   1.975 +    if (__n2 > max_size() || size() - __len >= max_size() - __n2)
   1.976 +      this->_M_throw_length_error();
   1.977 +    return replace(begin() + __pos, begin() + __pos + __len,
   1.978 +                   __s, __s + __n2);
   1.979 +  }
   1.980 +
   1.981 +  _Self& replace(size_type __pos, size_type __n1,
   1.982 +                        const _CharT* __s) {
   1.983 +    _STLP_FIX_LITERAL_BUG(__s)
   1.984 +    if (__pos > size())
   1.985 +      this->_M_throw_out_of_range();
   1.986 +    const size_type __len = (min) (__n1, size() - __pos);
   1.987 +    const size_type __n2 = _Traits::length(__s);
   1.988 +    if (__n2 > max_size() || size() - __len >= max_size() - __n2)
   1.989 +      this->_M_throw_length_error();
   1.990 +    return replace(begin() + __pos, begin() + __pos + __len,
   1.991 +                   __s, __s + _Traits::length(__s));
   1.992 +  }
   1.993 +
   1.994 +  _Self& replace(size_type __pos, size_type __n1,
   1.995 +                        size_type __n2, _CharT __c) {
   1.996 +    if (__pos > size())
   1.997 +      this->_M_throw_out_of_range();
   1.998 +    const size_type __len = (min) (__n1, size() - __pos);
   1.999 +    if (__n2 > max_size() || size() - __len >= max_size() - __n2)
  1.1000 +      this->_M_throw_length_error();
  1.1001 +    return replace(begin() + __pos, begin() + __pos + __len, __n2, __c);
  1.1002 +  }
  1.1003 +
  1.1004 +  _Self& replace(iterator __first, iterator __last, 
  1.1005 +                        const _Self& __s) 
  1.1006 +    { return replace(__first, __last, __s._M_start, __s._M_finish); }
  1.1007 +
  1.1008 +  _Self& replace(iterator __first, iterator __last,
  1.1009 +                        const _CharT* __s, size_type __n) 
  1.1010 +    { _STLP_FIX_LITERAL_BUG(__s) return replace(__first, __last, __s, __s + __n); }
  1.1011 +
  1.1012 +  _Self& replace(iterator __first, iterator __last,
  1.1013 +                        const _CharT* __s) {
  1.1014 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1015 +    return replace(__first, __last, __s, __s + _Traits::length(__s));
  1.1016 +  }
  1.1017 +
  1.1018 +  _Self& replace(iterator __first, iterator __last, 
  1.1019 +                        size_type __n, _CharT __c);
  1.1020 +
  1.1021 +  // Check to see if _InputIterator is an integer type.  If so, then
  1.1022 +  // it can't be an iterator.
  1.1023 +#ifdef _STLP_MEMBER_TEMPLATES
  1.1024 +  template <class _InputIter> _Self& replace(iterator __first, iterator __last,
  1.1025 +                        _InputIter __f, _InputIter __l) {
  1.1026 +    typedef typename _Is_integer<_InputIter>::_Integral _Integral;
  1.1027 +    return _M_replace_dispatch(__first, __last, __f, __l,  _Integral());
  1.1028 +  }
  1.1029 +#else /* _STLP_MEMBER_TEMPLATES */
  1.1030 +  _Self& replace(iterator __first, iterator __last,
  1.1031 +		 const _CharT* __f, const _CharT* __l);
  1.1032 +#endif /* _STLP_MEMBER_TEMPLATES */
  1.1033 +
  1.1034 +private:                        // Helper functions for replace.
  1.1035 +
  1.1036 +#ifdef _STLP_MEMBER_TEMPLATES
  1.1037 +
  1.1038 +  template <class _Integer> _Self& _M_replace_dispatch(iterator __first, iterator __last,
  1.1039 +                                    _Integer __n, _Integer __x,
  1.1040 +                                    const __true_type&) {
  1.1041 +    return replace(__first, __last, (size_type) __n, (_CharT) __x);
  1.1042 +  }
  1.1043 +
  1.1044 +  template <class _InputIter> _Self& _M_replace_dispatch(iterator __first, iterator __last,
  1.1045 +                                    _InputIter __f, _InputIter __l,
  1.1046 +                                    const __false_type&) {
  1.1047 +    return replace(__first, __last, __f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
  1.1048 +  }
  1.1049 +
  1.1050 +  template <class _InputIter> _Self& replace(iterator __first, iterator __last,
  1.1051 +                        _InputIter __f, _InputIter __l, const input_iterator_tag &)  {
  1.1052 +	  for ( ; __first != __last && __f != __l; ++__first, ++__f)
  1.1053 +	    _Traits::assign(*__first, *__f);
  1.1054 +
  1.1055 +	  if (__f == __l)
  1.1056 +	    erase(__first, __last);
  1.1057 +	  else
  1.1058 +	    insert(__last, __f, __l);
  1.1059 +	  return *this;
  1.1060 +	}
  1.1061 +
  1.1062 +  template <class _InputIter>
  1.1063 +  _Self& replace(iterator __first, iterator __last,
  1.1064 +                 _InputIter __f, _InputIter __l, const random_access_iterator_tag &) {
  1.1065 +    //might be overlapping
  1.1066 +    if (_M_inside(__f)) {
  1.1067 +      difference_type __n = __l - __f;
  1.1068 +      const difference_type __len = __last - __first;
  1.1069 +      if (__len >= __n) {
  1.1070 +        _M_move(__f, __l, __first);
  1.1071 +        erase(__first + __n, __last);
  1.1072 +      }
  1.1073 +      else {
  1.1074 +        _InputIter __m = __f + __len;
  1.1075 +        if ((__l <= __first) || (__f >= __last)) {
  1.1076 +				  //no overlap:
  1.1077 +          _M_copy(__f, __m, __first);
  1.1078 +          insert(__last, __m, __l);
  1.1079 +        }
  1.1080 +        else {
  1.1081 +				  //we have to take care of reallocation:
  1.1082 +				  const difference_type __off_dest = __first - this->begin();
  1.1083 +				  const difference_type __off_src = __f - this->begin();
  1.1084 +				  insert(__last, __m, __l);
  1.1085 +				  _Traits::move(begin() + __off_dest, begin() + __off_src, __n);
  1.1086 +        }
  1.1087 +      }
  1.1088 +      return *this;
  1.1089 +    }
  1.1090 +	  else {
  1.1091 +		  return replace(__first, __last, __f, __l, forward_iterator_tag());
  1.1092 +	  }
  1.1093 +  }
  1.1094 +
  1.1095 +
  1.1096 +  template <class _ForwardIter> _Self& replace(iterator __first, iterator __last,
  1.1097 +                        _ForwardIter __f, _ForwardIter __l, 
  1.1098 +                        const forward_iterator_tag &)  {
  1.1099 +	  difference_type __n = distance(__f, __l);
  1.1100 +	  const difference_type __len = __last - __first;
  1.1101 +	  if (__len >= __n) {
  1.1102 +	    _M_copy(__f, __l, __first);
  1.1103 +	    erase(__first + __n, __last);
  1.1104 +	  }
  1.1105 +	  else {
  1.1106 +	    _ForwardIter __m = __f;
  1.1107 +	    advance(__m, __len);
  1.1108 +	    _M_copy(__f, __m, __first);
  1.1109 +	    insert(__last, __m, __l);
  1.1110 +	  }
  1.1111 +	  return *this;
  1.1112 +	}
  1.1113 +
  1.1114 +#endif /* _STLP_MEMBER_TEMPLATES */
  1.1115 +
  1.1116 +public:                         // Other modifier member functions.
  1.1117 +
  1.1118 +  size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const {
  1.1119 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1120 +    if (__pos > size())
  1.1121 +      this->_M_throw_out_of_range();
  1.1122 +    const size_type __len = (min) (__n, size() - __pos);
  1.1123 +    _Traits::copy(__s, this->_M_start + __pos, __len);
  1.1124 +    return __len;
  1.1125 +  }
  1.1126 +
  1.1127 +  void swap(_Self& __s) {
  1.1128 +    _STLP_STD::swap(this->_M_start, __s._M_start);
  1.1129 +    _STLP_STD::swap(this->_M_finish, __s._M_finish);
  1.1130 +    _STLP_STD::swap(this->_M_end_of_storage, __s._M_end_of_storage);
  1.1131 +  }
  1.1132 +
  1.1133 +public:                         // Conversion to C string.
  1.1134 +
  1.1135 +  const _CharT* c_str() const { return this->_M_start; }
  1.1136 +  const _CharT* data()  const { return this->_M_start; }
  1.1137 +
  1.1138 +public:                         // find.
  1.1139 +
  1.1140 +  size_type find(const _Self& __s, size_type __pos = 0) const 
  1.1141 +    { return find(__s._M_start, __pos, __s.size()); }
  1.1142 +
  1.1143 +  size_type find(const _CharT* __s, size_type __pos = 0) const 
  1.1144 +    { _STLP_FIX_LITERAL_BUG(__s) return find(__s, __pos, _Traits::length(__s)); }
  1.1145 +
  1.1146 +  _STLP_DECLSPEC size_type find(const _CharT* __s, size_type __pos, size_type __n) const;
  1.1147 +
  1.1148 +  // WIE: Versant schema compiler 5.2.2 ICE workaround
  1.1149 +  size_type find(_CharT __c) const
  1.1150 +    { return find(__c, 0) ; }
  1.1151 +  size_type find(_CharT __c, size_type __pos /* = 0 */) const;
  1.1152 +
  1.1153 +public:                         // rfind.
  1.1154 +
  1.1155 +  size_type rfind(const _Self& __s, size_type __pos = npos) const 
  1.1156 +    { return rfind(__s._M_start, __pos, __s.size()); }
  1.1157 +
  1.1158 +  size_type rfind(const _CharT* __s, size_type __pos = npos) const 
  1.1159 +    { _STLP_FIX_LITERAL_BUG(__s) return rfind(__s, __pos, _Traits::length(__s)); }
  1.1160 +
  1.1161 +  _STLP_DECLSPEC size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const;
  1.1162 +  _STLP_DECLSPEC size_type rfind(_CharT __c, size_type __pos = npos) const;
  1.1163 +
  1.1164 +public:                         // find_first_of
  1.1165 +  
  1.1166 +  size_type find_first_of(const _Self& __s, size_type __pos = 0) const 
  1.1167 +    { return find_first_of(__s._M_start, __pos, __s.size()); }
  1.1168 +
  1.1169 +  size_type find_first_of(const _CharT* __s, size_type __pos = 0) const 
  1.1170 +    { _STLP_FIX_LITERAL_BUG(__s) return find_first_of(__s, __pos, _Traits::length(__s)); }
  1.1171 +
  1.1172 +  _STLP_DECLSPEC size_type find_first_of(const _CharT* __s, size_type __pos, 
  1.1173 +                          size_type __n) const;
  1.1174 +
  1.1175 +  size_type find_first_of(_CharT __c, size_type __pos = 0) const 
  1.1176 +    { return find(__c, __pos); }
  1.1177 +
  1.1178 +public:                         // find_last_of
  1.1179 +
  1.1180 +  size_type find_last_of(const _Self& __s,
  1.1181 +                         size_type __pos = npos) const
  1.1182 +    { return find_last_of(__s._M_start, __pos, __s.size()); }
  1.1183 +
  1.1184 +  size_type find_last_of(const _CharT* __s, size_type __pos = npos) const 
  1.1185 +    { _STLP_FIX_LITERAL_BUG(__s) return find_last_of(__s, __pos, _Traits::length(__s)); }
  1.1186 +
  1.1187 +  _STLP_DECLSPEC size_type find_last_of(const _CharT* __s, size_type __pos, 
  1.1188 +                         size_type __n) const;
  1.1189 +
  1.1190 +  size_type find_last_of(_CharT __c, size_type __pos = npos) const {
  1.1191 +    return rfind(__c, __pos);
  1.1192 +  }
  1.1193 +
  1.1194 +public:                         // find_first_not_of
  1.1195 +
  1.1196 +  size_type find_first_not_of(const _Self& __s, 
  1.1197 +                              size_type __pos = 0) const 
  1.1198 +    { return find_first_not_of(__s._M_start, __pos, __s.size()); }
  1.1199 +
  1.1200 +  size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const 
  1.1201 +    { _STLP_FIX_LITERAL_BUG(__s) return find_first_not_of(__s, __pos, _Traits::length(__s)); }
  1.1202 +
  1.1203 +  _STLP_DECLSPEC size_type find_first_not_of(const _CharT* __s, size_type __pos,
  1.1204 +                              size_type __n) const;
  1.1205 +
  1.1206 +  _STLP_DECLSPEC size_type find_first_not_of(_CharT __c, size_type __pos = 0) const;
  1.1207 +
  1.1208 +public:                         // find_last_not_of
  1.1209 +
  1.1210 +  size_type find_last_not_of(const _Self& __s, 
  1.1211 +                             size_type __pos = npos) const
  1.1212 +    { return find_last_not_of(__s._M_start, __pos, __s.size()); }
  1.1213 +
  1.1214 +  size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const
  1.1215 +    { _STLP_FIX_LITERAL_BUG(__s) return find_last_not_of(__s, __pos, _Traits::length(__s)); }
  1.1216 +
  1.1217 +  _STLP_DECLSPEC size_type find_last_not_of(const _CharT* __s, size_type __pos,
  1.1218 +                             size_type __n) const;
  1.1219 +
  1.1220 +  _STLP_DECLSPEC size_type find_last_not_of(_CharT __c, size_type __pos = npos) const;
  1.1221 +
  1.1222 +public:                         // Substring.
  1.1223 +
  1.1224 +  _Self substr(size_type __pos = 0, size_type __n = npos) const {
  1.1225 +    if (__pos > size())
  1.1226 +      this->_M_throw_out_of_range();
  1.1227 +    return _Self(this->_M_start + __pos, 
  1.1228 +                        this->_M_start + __pos + (min) (__n, size() - __pos));
  1.1229 +  }
  1.1230 +
  1.1231 +public:                         // Compare
  1.1232 +
  1.1233 +  int compare(const _Self& __s) const 
  1.1234 +    { return _M_compare(this->_M_start, this->_M_finish, __s._M_start, __s._M_finish); }
  1.1235 +
  1.1236 +  int compare(size_type __pos1, size_type __n1,
  1.1237 +              const _Self& __s) const {
  1.1238 +    if (__pos1 > size())
  1.1239 +      this->_M_throw_out_of_range();
  1.1240 +    return _M_compare(this->_M_start + __pos1, 
  1.1241 +                      this->_M_start + __pos1 + (min) (__n1, size() - __pos1),
  1.1242 +                      __s._M_start, __s._M_finish);
  1.1243 +  }
  1.1244 +    
  1.1245 +  int compare(size_type __pos1, size_type __n1,
  1.1246 +              const _Self& __s,
  1.1247 +              size_type __pos2, size_type __n2) const {
  1.1248 +    if (__pos1 > size() || __pos2 > __s.size())
  1.1249 +      this->_M_throw_out_of_range();
  1.1250 +    return _M_compare(this->_M_start + __pos1, 
  1.1251 +                      this->_M_start + __pos1 + (min) (__n1, size() - __pos1),
  1.1252 +                      __s._M_start + __pos2, 
  1.1253 +                      __s._M_start + __pos2 + (min) (__n2, __s.size() - __pos2));
  1.1254 +  }
  1.1255 +
  1.1256 +  int compare(const _CharT* __s) const {
  1.1257 +    _STLP_FIX_LITERAL_BUG(__s) 
  1.1258 +      return _M_compare(this->_M_start, this->_M_finish, __s, __s + _Traits::length(__s));
  1.1259 +  }
  1.1260 +
  1.1261 +  int compare(size_type __pos1, size_type __n1, const _CharT* __s) const {
  1.1262 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1263 +    if (__pos1 > size())
  1.1264 +      this->_M_throw_out_of_range();
  1.1265 +    return _M_compare(this->_M_start + __pos1, 
  1.1266 +                      this->_M_start + __pos1 + (min) (__n1, size() - __pos1),
  1.1267 +                      __s, __s + _Traits::length(__s));
  1.1268 +  }
  1.1269 +
  1.1270 +  int compare(size_type __pos1, size_type __n1, const _CharT* __s,
  1.1271 +              size_type __n2) const {
  1.1272 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1273 +    if (__pos1 > size())
  1.1274 +      this->_M_throw_out_of_range();
  1.1275 +    return _M_compare(this->_M_start + __pos1, 
  1.1276 +                      this->_M_start + __pos1 + (min) (__n1, size() - __pos1),
  1.1277 +                      __s, __s + __n2);
  1.1278 +  }
  1.1279 +
  1.1280 +public:                        // Helper functions for compare.
  1.1281 +  
  1.1282 +  static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
  1.1283 +                        const _CharT* __f2, const _CharT* __l2) {
  1.1284 +    const ptrdiff_t __n1 = __l1 - __f1;
  1.1285 +    const ptrdiff_t __n2 = __l2 - __f2;
  1.1286 +    const int cmp = _Traits::compare(__f1, __f2, (min) (__n1, __n2));
  1.1287 +    return cmp != 0 ? cmp : (__n1 < __n2 ? -1 : (__n1 > __n2 ? 1 : 0));
  1.1288 +  }
  1.1289 +
  1.1290 +#ifdef _STLP_IMPLICIT_STRING_TO_DESC
  1.1291 +public:
  1.1292 +	operator _DescConv<_CharT>::DescT() const
  1.1293 +	{
  1.1294 +		return _DescConv<_CharT>::convert( c_str(), size() );
  1.1295 +	}
  1.1296 +
  1.1297 +#endif	// _STLP_IMPLICIT_STRING_TO_DESC
  1.1298 +};
  1.1299 +
  1.1300 +#if ! defined (_STLP_STATIC_CONST_INIT_BUG) && \
  1.1301 +  __GNUC__ == 2 && __GNUC_MINOR__ == 96
  1.1302 +template <class _CharT, class _Traits, class _Alloc>
  1.1303 +const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;
  1.1304 +#endif
  1.1305 +
  1.1306 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
  1.1307 +_STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;
  1.1308 +#  if defined (_STLP_HAS_WCHAR_T)
  1.1309 +_STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
  1.1310 +#  endif
  1.1311 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
  1.1312 +
  1.1313 +// ------------------------------------------------------------
  1.1314 +// Non-member functions.
  1.1315 +
  1.1316 +template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
  1.1317 +operator+(const basic_string<_CharT,_Traits,_Alloc>& __s,
  1.1318 +          const basic_string<_CharT,_Traits,_Alloc>& __y)
  1.1319 +{
  1.1320 +  typedef basic_string<_CharT,_Traits,_Alloc> _Str;
  1.1321 +  typedef typename _Str::_Reserve_t _Reserve_t;
  1.1322 +# ifdef __GNUC__
  1.1323 +  // gcc counts this as a function
  1.1324 +  _Str __result  = _Str(_Reserve_t(),__s.size() + __y.size());
  1.1325 +# else
  1.1326 +  _Str __result(_Reserve_t(), __s.size() + __y.size());
  1.1327 +# endif
  1.1328 +  __result.append(__s);
  1.1329 +  __result.append(__y);
  1.1330 +  return __result;
  1.1331 +}
  1.1332 +
  1.1333 +# if defined (__GNUC__) || defined (__MLCCPP__)
  1.1334 +#  define _STLP_INIT_AMBIGUITY 1
  1.1335 +# endif
  1.1336 +
  1.1337 +template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
  1.1338 +operator+(const _CharT* __s,
  1.1339 +          const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1340 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1341 +  typedef basic_string<_CharT,_Traits,_Alloc> _Str;
  1.1342 +  typedef typename _Str::_Reserve_t _Reserve_t;
  1.1343 +  const size_t __n = _Traits::length(__s);
  1.1344 +# ifdef _STLP_INIT_AMBIGUITY
  1.1345 +  _Str __result = _Str(_Reserve_t(), __n + __y.size());
  1.1346 +# else
  1.1347 +  _Str __result(_Reserve_t(), __n + __y.size());
  1.1348 +# endif
  1.1349 +  __result.append(__s, __s + __n);
  1.1350 +  __result.append(__y);
  1.1351 +  return __result;
  1.1352 +}
  1.1353 +
  1.1354 +template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
  1.1355 +operator+(_CharT __c,
  1.1356 +          const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1357 +  typedef basic_string<_CharT,_Traits,_Alloc> _Str;
  1.1358 +  typedef typename _Str::_Reserve_t _Reserve_t;
  1.1359 +# ifdef _STLP_INIT_AMBIGUITY
  1.1360 +  _Str __result = _Str(_Reserve_t(), 1 + __y.size());
  1.1361 +# else
  1.1362 +  _Str __result(_Reserve_t(), 1 + __y.size());
  1.1363 +# endif
  1.1364 +  __result.push_back(__c);
  1.1365 +  __result.append(__y);
  1.1366 +  return __result;
  1.1367 +}
  1.1368 +
  1.1369 +template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
  1.1370 +operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1371 +          const _CharT* __s) {
  1.1372 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1373 +  typedef basic_string<_CharT,_Traits,_Alloc> _Str;
  1.1374 +  typedef typename _Str::_Reserve_t _Reserve_t;
  1.1375 +  const size_t __n = _Traits::length(__s);
  1.1376 +# ifdef _STLP_INIT_AMBIGUITY
  1.1377 +  _Str __result = _Str(_Reserve_t(), __x.size() + __n, __x.get_allocator());
  1.1378 +# else
  1.1379 +  _Str __result(_Reserve_t(), __x.size() + __n, __x.get_allocator());
  1.1380 +# endif
  1.1381 +  __result.append(__x);
  1.1382 +  __result.append(__s, __s + __n);
  1.1383 +  return __result;
  1.1384 +}
  1.1385 +
  1.1386 +template <class _CharT, class _Traits, class _Alloc> inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
  1.1387 +operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1388 +          const _CharT __c) {
  1.1389 +  typedef basic_string<_CharT,_Traits,_Alloc> _Str;
  1.1390 +  typedef typename _Str::_Reserve_t _Reserve_t;
  1.1391 +# ifdef _STLP_INIT_AMBIGUITY
  1.1392 +  _Str __result = _Str(_Reserve_t(), __x.size() + 1, __x.get_allocator());
  1.1393 +# else
  1.1394 +  _Str __result(_Reserve_t(), __x.size() + 1, __x.get_allocator());
  1.1395 +# endif
  1.1396 +  __result.append(__x);
  1.1397 +  __result.push_back(__c);
  1.1398 +  return __result;
  1.1399 +}
  1.1400 +
  1.1401 +# undef _STLP_INIT_AMBIGUITY
  1.1402 +
  1.1403 +// Operator== and operator!=
  1.1404 +
  1.1405 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1406 +operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1407 +           const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1408 +  return __x.size() == __y.size() && _Traits::compare(__x.data(), __y.data(), __x.size()) == 0;
  1.1409 +}
  1.1410 +
  1.1411 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1412 +operator==(const _CharT* __s,
  1.1413 +           const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1414 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1415 +  size_t __n = _Traits::length(__s);
  1.1416 +  return __n == __y.size() && _Traits::compare(__s, __y.data(), __n) == 0;
  1.1417 +}
  1.1418 +
  1.1419 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1420 +operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1421 +           const _CharT* __s) {
  1.1422 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1423 +  size_t __n = _Traits::length(__s);
  1.1424 +  return __x.size() == __n && _Traits::compare(__x.data(), __s, __n) == 0;
  1.1425 +}
  1.1426 +
  1.1427 +// Operator< (and also >, <=, and >=).
  1.1428 +
  1.1429 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1430 +operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1431 +          const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1432 +  return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), 
  1.1433 +		 __y.begin(), __y.end()) < 0;
  1.1434 +}
  1.1435 +
  1.1436 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1437 +operator<(const _CharT* __s,
  1.1438 +          const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1439 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1440 +  size_t __n = _Traits::length(__s);
  1.1441 +  return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__s, __s + __n, __y.begin(), __y.end()) < 0;
  1.1442 +}
  1.1443 +
  1.1444 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1445 +operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1446 +          const _CharT* __s) {
  1.1447 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1448 +  size_t __n = _Traits::length(__s);
  1.1449 +  return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), __s, __s + __n) < 0;
  1.1450 +}
  1.1451 +
  1.1452 +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
  1.1453 +
  1.1454 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1455 +operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1456 +           const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1457 +  return !(__x == __y);
  1.1458 +}
  1.1459 +
  1.1460 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1461 +operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1462 +          const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1463 +  return __y < __x;
  1.1464 +}
  1.1465 +
  1.1466 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1467 +operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1468 +           const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1469 +  return !(__y < __x);
  1.1470 +}
  1.1471 +
  1.1472 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1473 +operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1474 +           const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1475 +  return !(__x < __y);
  1.1476 +}
  1.1477 +
  1.1478 +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
  1.1479 +
  1.1480 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL 
  1.1481 +operator!=(const _CharT* __s,
  1.1482 +           const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1483 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1484 +  return !(__s == __y);
  1.1485 +}
  1.1486 +
  1.1487 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL 
  1.1488 +operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1489 +           const _CharT* __s) {
  1.1490 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1491 +  return !(__x == __s);
  1.1492 +}
  1.1493 +
  1.1494 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1495 +operator>(const _CharT* __s,
  1.1496 +          const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1497 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1498 +  return __y < __s;
  1.1499 +}
  1.1500 +
  1.1501 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1502 +operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1503 +          const _CharT* __s) {
  1.1504 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1505 +  return __s < __x;
  1.1506 +}
  1.1507 +
  1.1508 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1509 +operator<=(const _CharT* __s,
  1.1510 +           const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1511 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1512 +  return !(__y < __s);
  1.1513 +}
  1.1514 +
  1.1515 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1516 +operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1517 +           const _CharT* __s) {
  1.1518 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1519 +  return !(__s < __x);
  1.1520 +}
  1.1521 +
  1.1522 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1523 +operator>=(const _CharT* __s,
  1.1524 +           const basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1525 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1526 +  return !(__s < __y);
  1.1527 +}
  1.1528 +
  1.1529 +template <class _CharT, class _Traits, class _Alloc> inline bool _STLP_CALL
  1.1530 +operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1531 +           const _CharT* __s) {
  1.1532 +  _STLP_FIX_LITERAL_BUG(__s)
  1.1533 +  return !(__x < __s);
  1.1534 +}
  1.1535 +
  1.1536 +
  1.1537 +// Swap.
  1.1538 +
  1.1539 +#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
  1.1540 +
  1.1541 +template <class _CharT, class _Traits, class _Alloc> inline void _STLP_CALL
  1.1542 +swap(basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1543 +     basic_string<_CharT,_Traits,_Alloc>& __y) {
  1.1544 +  __x.swap(__y);
  1.1545 +}
  1.1546 +
  1.1547 +#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
  1.1548 +
  1.1549 +template <class _CharT, class _Traits, class _Alloc> void  _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,
  1.1550 +                    _CharT* __buf,
  1.1551 +                    size_t __n);
  1.1552 +
  1.1553 +# undef basic_string
  1.1554 +
  1.1555 +#if defined(_STLP_WINCE)
  1.1556 +// A couple of functions to transfer between ASCII/Unicode
  1.1557 +
  1.1558 +wstring __ASCIIToWide(const char *ascii);
  1.1559 +string __WideToASCII(const wchar_t *wide);
  1.1560 +#endif
  1.1561 +
  1.1562 +_STLP_END_NAMESPACE
  1.1563 +
  1.1564 +# ifdef _STLP_DEBUG
  1.1565 +#  include <stl/debug/_string.h> 
  1.1566 +# endif
  1.1567 +
  1.1568 +# if !defined (_STLP_LINK_TIME_INSTANTIATION)
  1.1569 +#  include <stl/_string.c> 
  1.1570 +# endif
  1.1571 +
  1.1572 +#ifndef _STLP_NO_IOSTREAMS
  1.1573 +# include <stl/_string_io.h>  
  1.1574 +#endif
  1.1575 +
  1.1576 +# include <stl/_string_hash.h>  
  1.1577 +
  1.1578 +#endif /* _STLP_STRING_H */
  1.1579 +
  1.1580 +
  1.1581 +// Local Variables:
  1.1582 +// mode:C++
  1.1583 +// End: