epoc32/include/tools/stlport/stl/_string.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_string.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,1416 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997-1999
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Copyright (c) 1999
     1.9 + * Boris Fomitchev
    1.10 + *
    1.11 + * This material is provided "as is", with absolutely no warranty expressed
    1.12 + * or implied. Any use is at your own risk.
    1.13 + *
    1.14 + * Permission to use or copy this software for any purpose is hereby granted
    1.15 + * without fee, provided the above notices are retained on all copies.
    1.16 + * Permission to modify the code and to distribute modified code is granted,
    1.17 + * provided the above notices are retained, and a notice that the code was
    1.18 + * modified is included with the above copyright notice.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +#ifndef _STLP_INTERNAL_STRING_H
    1.23 +#define _STLP_INTERNAL_STRING_H
    1.24 +
    1.25 +#ifndef _STLP_INTERNAL_ALLOC_H
    1.26 +#  include <stl/_alloc.h>
    1.27 +#endif
    1.28 +
    1.29 +#ifndef _STLP_STRING_FWD_H
    1.30 +#  include <stl/_string_fwd.h>
    1.31 +#endif
    1.32 +
    1.33 +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
    1.34 +#  include <stl/_function_base.h>
    1.35 +#endif
    1.36 +
    1.37 +#ifndef _STLP_INTERNAL_ALGOBASE_H
    1.38 +#  include <stl/_algobase.h>
    1.39 +#endif
    1.40 +
    1.41 +#ifndef _STLP_INTERNAL_ITERATOR_H
    1.42 +#  include <stl/_iterator.h>
    1.43 +#endif
    1.44 +
    1.45 +#ifndef _STLP_INTERNAL_UNINITIALIZED_H
    1.46 +#  include <stl/_uninitialized.h>
    1.47 +#endif
    1.48 +
    1.49 +#if defined (_STLP_USE_TEMPLATE_EXPRESSION)
    1.50 +#  include <stl/_string_sum.h>
    1.51 +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */
    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 +#endif // __MWERKS__
    1.62 +
    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.
    1.71 + * First, basic_string can always stores a null character
    1.72 + * at the end (macro dependent); this makes it possible for c_str to
    1.73 + * be a fast operation.
    1.74 + * Second, the C++ standard requires basic_string to copy elements
    1.75 + * using char_traits<>::assign, char_traits<>::copy, and
    1.76 + * char_traits<>::move.  This means that all of vector<>'s low-level
    1.77 + * operations must be rewritten.  Third, basic_string<> has a lot of
    1.78 + * extra functions in its interface that are convenient but, strictly
    1.79 + * speaking, redundant.
    1.80 +
    1.81 + * Additionally, the C++ standard imposes a major restriction: according
    1.82 + * to the standard, the character type _CharT must be a POD type.  This
    1.83 + * implementation weakens that restriction, and allows _CharT to be a
    1.84 + * a user-defined non-POD type.  However, _CharT must still have a
    1.85 + * default constructor.
    1.86 + */
    1.87 +
    1.88 +#include <stl/_string_base.h>
    1.89 +
    1.90 +_STLP_BEGIN_NAMESPACE
    1.91 +
    1.92 +// ------------------------------------------------------------
    1.93 +// Class basic_string.
    1.94 +
    1.95 +// Class invariants:
    1.96 +// (1) [start, finish) is a valid range.
    1.97 +// (2) Each iterator in [start, finish) points to a valid object
    1.98 +//     of type value_type.
    1.99 +// (3) *finish is a valid object of type value_type; when
   1.100 +//     value_type is not a POD it is value_type().
   1.101 +// (4) [finish + 1, end_of_storage) is a valid range.
   1.102 +// (5) Each iterator in [finish + 1, end_of_storage) points to
   1.103 +//     unininitialized memory.
   1.104 +
   1.105 +// Note one important consequence: a string of length n must manage
   1.106 +// a block of memory whose size is at least n + 1.
   1.107 +
   1.108 +struct _String_reserve_t {};
   1.109 +
   1.110 +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   1.111 +#  define basic_string _STLP_NO_MEM_T_NAME(str)
   1.112 +#elif defined (_STLP_DEBUG)
   1.113 +#  define basic_string _STLP_NON_DBG_NAME(str)
   1.114 +#endif
   1.115 +
   1.116 +#if defined (basic_string)
   1.117 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.118 +#endif
   1.119 +
   1.120 +template <class _CharT, class _Traits, class _Alloc>
   1.121 +class basic_string : protected _STLP_PRIV _String_base<_CharT,_Alloc>
   1.122 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string)
   1.123 +                   , public __stlport_class<basic_string<_CharT, _Traits, _Alloc> >
   1.124 +#endif
   1.125 +{
   1.126 +protected:                        // Protected members inherited from base.
   1.127 +  typedef _STLP_PRIV _String_base<_CharT,_Alloc> _Base;
   1.128 +  typedef basic_string<_CharT, _Traits, _Alloc> _Self;
   1.129 +  // fbp : used to optimize char/wchar_t cases, and to simplify
   1.130 +  // _STLP_DEF_CONST_PLCT_NEW_BUG problem workaround
   1.131 +  typedef typename _IsIntegral<_CharT>::_Ret _Char_Is_Integral;
   1.132 +  typedef typename _IsPOD<_CharT>::_Type _Char_Is_POD;
   1.133 +  typedef random_access_iterator_tag r_a_i_t;
   1.134 +
   1.135 +public:
   1.136 +  typedef _CharT value_type;
   1.137 +  typedef _Traits traits_type;
   1.138 +
   1.139 +  typedef value_type* pointer;
   1.140 +  typedef const value_type* const_pointer;
   1.141 +  typedef value_type& reference;
   1.142 +  typedef const value_type& const_reference;
   1.143 +  typedef typename _Base::size_type size_type;
   1.144 +  typedef ptrdiff_t difference_type;
   1.145 +  typedef random_access_iterator_tag _Iterator_category;
   1.146 +
   1.147 +  typedef const value_type* const_iterator;
   1.148 +  typedef value_type*       iterator;
   1.149 +
   1.150 +  _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
   1.151 +
   1.152 +#include <stl/_string_npos.h>
   1.153 +
   1.154 +  typedef _String_reserve_t _Reserve_t;
   1.155 +
   1.156 +public:                         // Constructor, destructor, assignment.
   1.157 +  typedef typename _Base::allocator_type allocator_type;
   1.158 +
   1.159 +  allocator_type get_allocator() const
   1.160 +  { return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _CharT); }
   1.161 +
   1.162 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.163 +  explicit basic_string(const allocator_type& __a = allocator_type())
   1.164 +#else
   1.165 +  basic_string()
   1.166 +      : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), _Base::_DEFAULT_SIZE)
   1.167 +  { _M_terminate_string(); }
   1.168 +  explicit basic_string(const allocator_type& __a)
   1.169 +#endif
   1.170 +      : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, _Base::_DEFAULT_SIZE)
   1.171 +  { _M_terminate_string(); }
   1.172 +
   1.173 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.174 +  basic_string(_Reserve_t, size_t __n,
   1.175 +               const allocator_type& __a = allocator_type())
   1.176 +#else
   1.177 +  basic_string(_Reserve_t, size_t __n)
   1.178 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), __n + 1)
   1.179 +  { _M_terminate_string(); }
   1.180 +  basic_string(_Reserve_t, size_t __n, const allocator_type& __a)
   1.181 +#endif
   1.182 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, __n + 1)
   1.183 +  { _M_terminate_string(); }
   1.184 +
   1.185 +  basic_string(const _Self&);
   1.186 +
   1.187 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.188 +  basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
   1.189 +               const allocator_type& __a = allocator_type())
   1.190 +#else
   1.191 +  basic_string(const _Self& __s, size_type __pos)
   1.192 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
   1.193 +    if (__pos > __s.size())
   1.194 +      this->_M_throw_out_of_range();
   1.195 +    else
   1.196 +      _M_range_initialize(__s._M_Start() + __pos, __s._M_Finish());
   1.197 +  }
   1.198 +  basic_string(const _Self& __s, size_type __pos, size_type __n)
   1.199 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
   1.200 +    if (__pos > __s.size())
   1.201 +      this->_M_throw_out_of_range();
   1.202 +    else
   1.203 +      _M_range_initialize(__s._M_Start() + __pos,
   1.204 +                          __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));
   1.205 +  }
   1.206 +  basic_string(const _Self& __s, size_type __pos, size_type __n,
   1.207 +               const allocator_type& __a)
   1.208 +#endif
   1.209 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
   1.210 +    if (__pos > __s.size())
   1.211 +      this->_M_throw_out_of_range();
   1.212 +    else
   1.213 +      _M_range_initialize(__s._M_Start() + __pos,
   1.214 +                          __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));
   1.215 +  }
   1.216 +
   1.217 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.218 +  basic_string(const _CharT* __s, size_type __n,
   1.219 +               const allocator_type& __a = allocator_type())
   1.220 +#else
   1.221 +  basic_string(const _CharT* __s, size_type __n)
   1.222 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
   1.223 +      _STLP_FIX_LITERAL_BUG(__s)
   1.224 +      _M_range_initialize(__s, __s + __n);
   1.225 +    }
   1.226 +  basic_string(const _CharT* __s, size_type __n, const allocator_type& __a)
   1.227 +#endif
   1.228 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
   1.229 +      _STLP_FIX_LITERAL_BUG(__s)
   1.230 +      _M_range_initialize(__s, __s + __n);
   1.231 +    }
   1.232 +
   1.233 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.234 +  basic_string(const _CharT* __s,
   1.235 +               const allocator_type& __a = allocator_type());
   1.236 +#else
   1.237 +  basic_string(const _CharT* __s);
   1.238 +  basic_string(const _CharT* __s, const allocator_type& __a);
   1.239 +#endif
   1.240 +
   1.241 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.242 +  basic_string(size_type __n, _CharT __c,
   1.243 +               const allocator_type& __a = allocator_type())
   1.244 +#else
   1.245 +  basic_string(size_type __n, _CharT __c)
   1.246 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), __n + 1) {
   1.247 +#  if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.248 +    if (this->_M_using_static_buf()) {
   1.249 +      _Traits::assign(this->_M_Start(), __n, __c);
   1.250 +      this->_M_finish = this->_M_Start() + __n;
   1.251 +    }
   1.252 +    else
   1.253 +#  endif
   1.254 +    this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __c);
   1.255 +    _M_terminate_string();
   1.256 +  }
   1.257 +  basic_string(size_type __n, _CharT __c, const allocator_type& __a)
   1.258 +#endif
   1.259 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, __n + 1) {
   1.260 +#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.261 +    if (this->_M_using_static_buf()) {
   1.262 +      _Traits::assign(this->_M_Start(), __n, __c);
   1.263 +      this->_M_finish = this->_M_Start() + __n;
   1.264 +    }
   1.265 +    else
   1.266 +#endif
   1.267 +    this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __c);
   1.268 +    _M_terminate_string();
   1.269 +  }
   1.270 +
   1.271 +  basic_string(__move_source<_Self> src)
   1.272 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(__move_source<_Base>(src.get())) {}
   1.273 +
   1.274 +  // Check to see if _InputIterator is an integer type.  If so, then
   1.275 +  // it can't be an iterator.
   1.276 +#if defined (_STLP_MEMBER_TEMPLATES) && !(defined (__MRC__) || (defined(__SC__) && !defined(__DMC__))) //*ty 04/30/2001 - mpw compilers choke on this ctor
   1.277 +#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   1.278 +  template <class _InputIterator>
   1.279 +  basic_string(_InputIterator __f, _InputIterator __l,
   1.280 +               const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
   1.281 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
   1.282 +    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
   1.283 +    _M_initialize_dispatch(__f, __l, _Integral());
   1.284 +  }
   1.285 +#    if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
   1.286 +  template <class _InputIterator>
   1.287 +  basic_string(_InputIterator __f, _InputIterator __l)
   1.288 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
   1.289 +    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
   1.290 +    _M_initialize_dispatch(__f, __l, _Integral());
   1.291 +  }
   1.292 +#    endif
   1.293 +#  else
   1.294 +  /* We need an additionnal constructor to build an empty string without
   1.295 +   * any allocation or termination char*/
   1.296 +protected:
   1.297 +  struct _CalledFromWorkaround_t {};
   1.298 +  basic_string(_CalledFromWorkaround_t, const allocator_type &__a)
   1.299 +    : _String_base<_CharT,_Alloc>(__a) {}
   1.300 +public:
   1.301 +#  endif /* _STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND */
   1.302 +#endif /* !__MRC__ || (__SC__ && !__DMC__) */
   1.303 +
   1.304 +#if !(defined (_STLP_MEMBER_TEMPLATES) && !(defined (__MRC__) || (defined (__SC__) && !defined (__DMC__)))) || \
   1.305 +    !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS) || \
   1.306 +     defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   1.307 +  basic_string(const _CharT* __f, const _CharT* __l,
   1.308 +               const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
   1.309 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
   1.310 +    _STLP_FIX_LITERAL_BUG(__f)  _STLP_FIX_LITERAL_BUG(__l)
   1.311 +    _M_range_initialize(__f, __l);
   1.312 +  }
   1.313 +#  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
   1.314 +  basic_string(const _CharT* __f, const _CharT* __l)
   1.315 +    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
   1.316 +    _STLP_FIX_LITERAL_BUG(__f)  _STLP_FIX_LITERAL_BUG(__l)
   1.317 +    _M_range_initialize(__f, __l);
   1.318 +  }
   1.319 +#  endif
   1.320 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.321 +
   1.322 +private:
   1.323 +  template <class _InputIter>
   1.324 +  void _M_range_initialize(_InputIter __f, _InputIter __l,
   1.325 +                           const input_iterator_tag &__tag) {
   1.326 +    this->_M_allocate_block();
   1.327 +    _M_construct_null(this->_M_Finish());
   1.328 +    _STLP_TRY {
   1.329 +      _M_appendT(__f, __l, __tag);
   1.330 +    }
   1.331 +    _STLP_UNWIND(this->_M_destroy_range())
   1.332 +  }
   1.333 +
   1.334 +  template <class _ForwardIter>
   1.335 +  void _M_range_initialize(_ForwardIter __f, _ForwardIter __l,
   1.336 +                           const forward_iterator_tag &) {
   1.337 +    difference_type __n = distance(__f, __l);
   1.338 +    this->_M_allocate_block(__n + 1);
   1.339 +#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.340 +    if (this->_M_using_static_buf()) {
   1.341 +      _M_copyT(__f, __l, this->_M_Start());
   1.342 +      this->_M_finish = this->_M_Start() + __n;
   1.343 +    }
   1.344 +    else
   1.345 +#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.346 +    this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start());
   1.347 +    this->_M_terminate_string();
   1.348 +  }
   1.349 +
   1.350 +  template <class _InputIter>
   1.351 +  void _M_range_initializeT(_InputIter __f, _InputIter __l) {
   1.352 +    _M_range_initialize(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
   1.353 +  }
   1.354 +
   1.355 +  template <class _Integer>
   1.356 +  void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
   1.357 +    this->_M_allocate_block(__n + 1);
   1.358 +#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.359 +    if (this->_M_using_static_buf()) {
   1.360 +      _Traits::assign(this->_M_Start(), __n, __x);
   1.361 +      this->_M_finish = this->_M_Start() + __n;
   1.362 +    }
   1.363 +    else
   1.364 +#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.365 +    this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __x);
   1.366 +    this->_M_terminate_string();
   1.367 +  }
   1.368 +
   1.369 +  template <class _InputIter>
   1.370 +  void _M_initialize_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
   1.371 +    _M_range_initializeT(__f, __l);
   1.372 +  }
   1.373 +
   1.374 +public:
   1.375 +  ~basic_string()
   1.376 +  { this->_M_destroy_range(); }
   1.377 +
   1.378 +  _Self& operator=(const _Self& __s) {
   1.379 +    if (&__s != this)
   1.380 +      _M_assign(__s._M_Start(), __s._M_Finish());
   1.381 +    return *this;
   1.382 +  }
   1.383 +
   1.384 +  _Self& operator=(const _CharT* __s) {
   1.385 +    _STLP_FIX_LITERAL_BUG(__s)
   1.386 +    return _M_assign(__s, __s + traits_type::length(__s));
   1.387 +  }
   1.388 +
   1.389 +  _Self& operator=(_CharT __c)
   1.390 +  { return assign(__STATIC_CAST(size_type,1), __c); }
   1.391 +
   1.392 +protected:
   1.393 +
   1.394 +  static _CharT _STLP_CALL _M_null()
   1.395 +  { return _STLP_DEFAULT_CONSTRUCTED(_CharT); }
   1.396 +
   1.397 +protected:                     // Helper functions used by constructors
   1.398 +                               // and elsewhere.
   1.399 +  // fbp : simplify integer types (char, wchar)
   1.400 +  void _M_construct_null_aux(_CharT* __p, const __false_type& /*_Is_Integral*/) const {
   1.401 +#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.402 +    if (this->_M_using_static_buf())
   1.403 +      _Traits::assign(*__p, _M_null());
   1.404 +    else
   1.405 +#endif /*_STLP_USE_SHORT_STRING_OPTIM*/
   1.406 +    _STLP_STD::_Construct(__p);
   1.407 +  }
   1.408 +  void _M_construct_null_aux(_CharT* __p, const __true_type& /*_Is_Integral*/) const
   1.409 +  { *__p = 0; }
   1.410 +
   1.411 +  void _M_force_construct_null(_CharT*, const __true_type& /* _Is_POD */) const
   1.412 +  { /*Nothing to do*/ }
   1.413 +  void _M_force_construct_null(_CharT* __p, const __false_type& /* _Is_POD */) const
   1.414 +  { _M_construct_null_aux(__p, _Char_Is_Integral()); }
   1.415 +
   1.416 +  void _M_construct_null(_CharT* __p) const {
   1.417 +    typedef __false_type _Answer;
   1.418 +
   1.419 +    _M_force_construct_null(__p, _Answer());
   1.420 +  }
   1.421 +
   1.422 +protected:
   1.423 +  // Helper functions used by constructors.  It is a severe error for
   1.424 +  // any of them to be called anywhere except from within constructors.
   1.425 +  void _M_terminate_string_aux(const __false_type& __is_integral) {
   1.426 +    _STLP_TRY {
   1.427 +      _M_construct_null_aux(this->_M_Finish(), __is_integral);
   1.428 +    }
   1.429 +    _STLP_UNWIND(this->_M_destroy_range(0,0))
   1.430 +  }
   1.431 +
   1.432 +  void _M_terminate_string_aux(const __true_type& __is_integral)
   1.433 +  { _M_construct_null_aux(this->_M_Finish(), __is_integral); }
   1.434 +
   1.435 +  void _M_force_terminate_string(const __true_type& /* _Is_POD */)
   1.436 +  { /*Nothing to do*/ }
   1.437 +  void _M_force_terminate_string(const __false_type& /* _Is_POD */)
   1.438 +  { _M_terminate_string_aux(_Char_Is_Integral()); }
   1.439 +
   1.440 +  void _M_terminate_string() {
   1.441 +    typedef __false_type _Answer;
   1.442 +
   1.443 +    _M_force_terminate_string(_Answer());
   1.444 +  }
   1.445 +
   1.446 +  bool _M_inside(const _CharT* __s) const {
   1.447 +    _STLP_FIX_LITERAL_BUG(__s)
   1.448 +    return (__s >= this->_M_Start()) && (__s < this->_M_Finish());
   1.449 +  }
   1.450 +
   1.451 +  void _M_range_initialize(const _CharT* __f, const _CharT* __l) {
   1.452 +    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   1.453 +    ptrdiff_t __n = __l - __f;
   1.454 +    this->_M_allocate_block(__n + 1);
   1.455 +#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.456 +    if (this->_M_using_static_buf()) {
   1.457 +      _M_copy(__f, __l, this->_M_Start());
   1.458 +      this->_M_finish = this->_M_Start() + __n;
   1.459 +    }
   1.460 +    else
   1.461 +#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.462 +    this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start());
   1.463 +    _M_terminate_string();
   1.464 +  }
   1.465 +
   1.466 +public:                         // Iterators.
   1.467 +  iterator begin()             { return this->_M_Start(); }
   1.468 +  iterator end()               { return this->_M_Finish(); }
   1.469 +  const_iterator begin() const { return this->_M_Start(); }
   1.470 +  const_iterator end()   const { return this->_M_Finish(); }
   1.471 +
   1.472 +  reverse_iterator rbegin()
   1.473 +    { return reverse_iterator(this->_M_Finish()); }
   1.474 +  reverse_iterator rend()
   1.475 +    { return reverse_iterator(this->_M_Start()); }
   1.476 +  const_reverse_iterator rbegin() const
   1.477 +    { return const_reverse_iterator(this->_M_Finish()); }
   1.478 +  const_reverse_iterator rend()   const
   1.479 +    { return const_reverse_iterator(this->_M_Start()); }
   1.480 +
   1.481 +public:                         // Size, capacity, etc.
   1.482 +  size_type size() const { return this->_M_Finish() - this->_M_Start(); }
   1.483 +  size_type length() const { return size(); }
   1.484 +  size_t max_size() const { return _Base::max_size(); }
   1.485 +
   1.486 +  void resize(size_type __n, _CharT __c) {
   1.487 +    if (__n <= size())
   1.488 +      erase(begin() + __n, end());
   1.489 +    else
   1.490 +      append(__n - size(), __c);
   1.491 +  }
   1.492 +
   1.493 +  void resize(size_type __n) { resize(__n, _M_null()); }
   1.494 +
   1.495 +  void reserve(size_type = 0);
   1.496 +
   1.497 +  size_type capacity() const
   1.498 +  { return (this->_M_end_of_storage._M_data - this->_M_Start()) - 1; }
   1.499 +
   1.500 +  void clear() {
   1.501 +    if (!empty()) {
   1.502 +      _Traits::assign(*(this->_M_Start()), _M_null());
   1.503 +      this->_M_destroy_range(1);
   1.504 +      this->_M_finish = this->_M_Start();
   1.505 +    }
   1.506 +  }
   1.507 +
   1.508 +  bool empty() const { return this->_M_Start() == this->_M_Finish(); }
   1.509 +
   1.510 +public:                         // Element access.
   1.511 +
   1.512 +  const_reference operator[](size_type __n) const
   1.513 +  { return *(this->_M_Start() + __n); }
   1.514 +  reference operator[](size_type __n)
   1.515 +  { return *(this->_M_Start() + __n); }
   1.516 +
   1.517 +  const_reference at(size_type __n) const {
   1.518 +    if (__n >= size())
   1.519 +      this->_M_throw_out_of_range();
   1.520 +    return *(this->_M_Start() + __n);
   1.521 +  }
   1.522 +
   1.523 +  reference at(size_type __n) {
   1.524 +    if (__n >= size())
   1.525 +      this->_M_throw_out_of_range();
   1.526 +    return *(this->_M_Start() + __n);
   1.527 +  }
   1.528 +
   1.529 +public:                         // Append, operator+=, push_back.
   1.530 +
   1.531 +  _Self& operator+=(const _Self& __s) { return append(__s); }
   1.532 +  _Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); }
   1.533 +  _Self& operator+=(_CharT __c) { push_back(__c); return *this; }
   1.534 +
   1.535 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.536 +#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   1.537 +private: // Helper functions for append.
   1.538 +  template <class _InputIter>
   1.539 +  _Self& _M_appendT(_InputIter __first, _InputIter __last,
   1.540 +                    const input_iterator_tag &) {
   1.541 +    for ( ; __first != __last ; ++__first)
   1.542 +      push_back(*__first);
   1.543 +    return *this;
   1.544 +  }
   1.545 +
   1.546 +  template <class _ForwardIter>
   1.547 +  _Self& _M_appendT(_ForwardIter __first, _ForwardIter __last,
   1.548 +                    const forward_iterator_tag &) {
   1.549 +    if (__first != __last) {
   1.550 +      const size_type __old_size = this->size();
   1.551 +      difference_type __n = distance(__first, __last);
   1.552 +      if (__STATIC_CAST(size_type,__n) > this->max_size() || __old_size > this->max_size() - __STATIC_CAST(size_type,__n))
   1.553 +        this->_M_throw_length_error();
   1.554 +      if (__old_size + __n > this->capacity()) {
   1.555 +        size_type __len = __old_size + (max)(__old_size, __STATIC_CAST(size_type,__n)) + 1;
   1.556 +        pointer __new_start = this->_M_end_of_storage.allocate(__len, __len);
   1.557 +        pointer __new_finish = __new_start;
   1.558 +        _STLP_TRY {
   1.559 +          __new_finish = uninitialized_copy(this->_M_Start(), this->_M_Finish(), __new_start);
   1.560 +          __new_finish = uninitialized_copy(__first, __last, __new_finish);
   1.561 +          _M_construct_null(__new_finish);
   1.562 +        }
   1.563 +        _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish),
   1.564 +          this->_M_end_of_storage.deallocate(__new_start, __len)))
   1.565 +          this->_M_destroy_range();
   1.566 +        this->_M_deallocate_block();
   1.567 +        this->_M_reset(__new_start, __new_finish, __new_start + __len);
   1.568 +      }
   1.569 +      else {
   1.570 +        _ForwardIter __f1 = __first;
   1.571 +        ++__f1;
   1.572 +#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.573 +        if (this->_M_using_static_buf())
   1.574 +          _M_copyT(__f1, __last, this->_M_Finish() + 1);
   1.575 +        else
   1.576 +#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.577 +          uninitialized_copy(__f1, __last, this->_M_Finish() + 1);
   1.578 +        _STLP_TRY {
   1.579 +          _M_construct_null(this->_M_Finish() + __n);
   1.580 +        }
   1.581 +        _STLP_UNWIND(this->_M_destroy_ptr_range(this->_M_Finish() + 1, this->_M_Finish() + __n))
   1.582 +        _Traits::assign(*this->_M_finish, *__first);
   1.583 +        this->_M_finish += __n;
   1.584 +      }
   1.585 +    }
   1.586 +    return *this;
   1.587 +  }
   1.588 +
   1.589 +  template <class _Integer>
   1.590 +  _Self& _M_append_dispatch(_Integer __n, _Integer __x, const __true_type& /*Integral*/)
   1.591 +  { return append((size_type) __n, (_CharT) __x); }
   1.592 +
   1.593 +  template <class _InputIter>
   1.594 +  _Self& _M_append_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*Integral*/)
   1.595 +  { return _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); }
   1.596 +
   1.597 +public:
   1.598 +  // Check to see if _InputIterator is an integer type.  If so, then
   1.599 +  // it can't be an iterator.
   1.600 +  template <class _InputIter>
   1.601 +  _Self& append(_InputIter __first, _InputIter __last) {
   1.602 +    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
   1.603 +    return _M_append_dispatch(__first, __last, _Integral());
   1.604 +  }
   1.605 +#  endif
   1.606 +#endif
   1.607 +
   1.608 +protected:
   1.609 +  _Self& _M_append(const _CharT* __first, const _CharT* __last);
   1.610 +
   1.611 +public:
   1.612 +#if !defined (_STLP_MEMBER_TEMPLATES) || \
   1.613 +    !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
   1.614 +#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   1.615 +  _Self& append(const _CharT* __first, const _CharT* __last) {
   1.616 +    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
   1.617 +    return _M_append(__first, __last);
   1.618 +  }
   1.619 +#  endif
   1.620 +#endif
   1.621 +
   1.622 +  _Self& append(const _Self& __s)
   1.623 +  { return _M_append(__s._M_Start(), __s._M_Finish()); }
   1.624 +
   1.625 +  _Self& append(const _Self& __s,
   1.626 +                size_type __pos, size_type __n) {
   1.627 +    if (__pos > __s.size())
   1.628 +      this->_M_throw_out_of_range();
   1.629 +    return _M_append(__s._M_Start() + __pos,
   1.630 +                     __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));
   1.631 +  }
   1.632 +
   1.633 +  _Self& append(const _CharT* __s, size_type __n)
   1.634 +  { _STLP_FIX_LITERAL_BUG(__s) return _M_append(__s, __s+__n); }
   1.635 +  _Self& append(const _CharT* __s)
   1.636 +  { _STLP_FIX_LITERAL_BUG(__s) return _M_append(__s, __s + traits_type::length(__s)); }
   1.637 +  _Self& append(size_type __n, _CharT __c);
   1.638 +
   1.639 +public:
   1.640 +  void push_back(_CharT __c) {
   1.641 +    if (this->_M_Finish() + 1 == this->_M_end_of_storage._M_data)
   1.642 +      reserve(size() + (max)(size(), __STATIC_CAST(size_type,1)));
   1.643 +    _M_construct_null(this->_M_Finish() + 1);
   1.644 +    _Traits::assign(*(this->_M_Finish()), __c);
   1.645 +    ++this->_M_finish;
   1.646 +  }
   1.647 +
   1.648 +  void pop_back() {
   1.649 +    _Traits::assign(*(this->_M_Finish() - 1), _M_null());
   1.650 +    this->_M_destroy_back();
   1.651 +    --this->_M_finish;
   1.652 +  }
   1.653 +
   1.654 +public:                         // Assign
   1.655 +  _Self& assign(const _Self& __s)
   1.656 +  { return _M_assign(__s._M_Start(), __s._M_Finish()); }
   1.657 +
   1.658 +  _Self& assign(const _Self& __s,
   1.659 +                size_type __pos, size_type __n) {
   1.660 +    if (__pos > __s.size())
   1.661 +      this->_M_throw_out_of_range();
   1.662 +    return _M_assign(__s._M_Start() + __pos,
   1.663 +                     __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));
   1.664 +  }
   1.665 +
   1.666 +  _Self& assign(const _CharT* __s, size_type __n)
   1.667 +  { _STLP_FIX_LITERAL_BUG(__s) return _M_assign(__s, __s + __n); }
   1.668 +
   1.669 +  _Self& assign(const _CharT* __s)
   1.670 +  { _STLP_FIX_LITERAL_BUG(__s) return _M_assign(__s, __s + _Traits::length(__s)); }
   1.671 +
   1.672 +  _Self& assign(size_type __n, _CharT __c);
   1.673 +
   1.674 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.675 +#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   1.676 +private:                        // Helper functions for assign.
   1.677 +  template <class _Integer>
   1.678 +  _Self& _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/)
   1.679 +  { return assign((size_type) __n, (_CharT) __x); }
   1.680 +
   1.681 +  template <class _InputIter>
   1.682 +  _Self& _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
   1.683 +    pointer __cur = this->_M_Start();
   1.684 +    while (__f != __l && __cur != this->_M_Finish()) {
   1.685 +      _Traits::assign(*__cur, *__f);
   1.686 +      ++__f;
   1.687 +      ++__cur;
   1.688 +    }
   1.689 +    if (__f == __l)
   1.690 +      erase(__cur, this->end());
   1.691 +    else
   1.692 +      _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
   1.693 +    return *this;
   1.694 +  }
   1.695 +
   1.696 +public:
   1.697 +  // Check to see if _InputIterator is an integer type.  If so, then
   1.698 +  // it can't be an iterator.
   1.699 +  template <class _InputIter>
   1.700 +  _Self& assign(_InputIter __first, _InputIter __last) {
   1.701 +    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
   1.702 +    return _M_assign_dispatch(__first, __last, _Integral());
   1.703 +  }
   1.704 +#  endif
   1.705 +#endif
   1.706 +
   1.707 +protected:
   1.708 +  _Self& _M_assign(const _CharT* __f, const _CharT* __l);
   1.709 +
   1.710 +public:
   1.711 +
   1.712 +#if !defined (_STLP_MEMBER_TEMPLATES) || \
   1.713 +    !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
   1.714 +#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   1.715 +  _Self& assign(const _CharT* __f, const _CharT* __l) {
   1.716 +    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   1.717 +    return _M_assign(__f, __l);
   1.718 +  }
   1.719 +#  endif
   1.720 +#endif
   1.721 +
   1.722 +public:                         // Insert
   1.723 +
   1.724 +  _Self& insert(size_type __pos, const _Self& __s) {
   1.725 +    if (__pos > size())
   1.726 +      this->_M_throw_out_of_range();
   1.727 +    if (size() > max_size() - __s.size())
   1.728 +      this->_M_throw_length_error();
   1.729 +    _M_insert(begin() + __pos, __s._M_Start(), __s._M_Finish(), &__s == this);
   1.730 +    return *this;
   1.731 +  }
   1.732 +
   1.733 +  _Self& insert(size_type __pos, const _Self& __s,
   1.734 +                size_type __beg, size_type __n) {
   1.735 +    if (__pos > size() || __beg > __s.size())
   1.736 +      this->_M_throw_out_of_range();
   1.737 +    size_type __len = (min) (__n, __s.size() - __beg);
   1.738 +    if (size() > max_size() - __len)
   1.739 +      this->_M_throw_length_error();
   1.740 +    _M_insert(begin() + __pos,
   1.741 +              __s._M_Start() + __beg, __s._M_Start() + __beg + __len, &__s == this);
   1.742 +    return *this;
   1.743 +  }
   1.744 +  _Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
   1.745 +    _STLP_FIX_LITERAL_BUG(__s)
   1.746 +    if (__pos > size())
   1.747 +      this->_M_throw_out_of_range();
   1.748 +    if (size() > max_size() - __n)
   1.749 +      this->_M_throw_length_error();
   1.750 +    _M_insert(begin() + __pos, __s, __s + __n, _M_inside(__s));
   1.751 +    return *this;
   1.752 +  }
   1.753 +
   1.754 +  _Self& insert(size_type __pos, const _CharT* __s) {
   1.755 +    _STLP_FIX_LITERAL_BUG(__s)
   1.756 +    if (__pos > size())
   1.757 +      this->_M_throw_out_of_range();
   1.758 +    size_type __len = _Traits::length(__s);
   1.759 +    if (size() > max_size() - __len)
   1.760 +      this->_M_throw_length_error();
   1.761 +    _M_insert(this->_M_Start() + __pos, __s, __s + __len, _M_inside(__s));
   1.762 +    return *this;
   1.763 +  }
   1.764 +
   1.765 +  _Self& insert(size_type __pos, size_type __n, _CharT __c) {
   1.766 +    if (__pos > size())
   1.767 +      this->_M_throw_out_of_range();
   1.768 +    if (size() > max_size() - __n)
   1.769 +      this->_M_throw_length_error();
   1.770 +    insert(begin() + __pos, __n, __c);
   1.771 +    return *this;
   1.772 +  }
   1.773 +
   1.774 +  iterator insert(iterator __p, _CharT __c) {
   1.775 +    _STLP_FIX_LITERAL_BUG(__p)
   1.776 +    if (__p == end()) {
   1.777 +      push_back(__c);
   1.778 +      return this->_M_Finish() - 1;
   1.779 +    }
   1.780 +    else
   1.781 +      return _M_insert_aux(__p, __c);
   1.782 +  }
   1.783 +
   1.784 +  void insert(iterator __p, size_t __n, _CharT __c);
   1.785 +
   1.786 +protected:  // Helper functions for insert.
   1.787 +
   1.788 +  void _M_insert(iterator __p, const _CharT* __first, const _CharT* __last, bool __self_ref);
   1.789 +
   1.790 +  pointer _M_insert_aux(pointer, _CharT);
   1.791 +
   1.792 +  void _M_copy(const _CharT* __f, const _CharT* __l, _CharT* __res) {
   1.793 +    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   1.794 +    _STLP_FIX_LITERAL_BUG(__res)
   1.795 +    _Traits::copy(__res, __f, __l - __f);
   1.796 +  }
   1.797 +
   1.798 +  void _M_move(const _CharT* __f, const _CharT* __l, _CharT* __res) {
   1.799 +    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   1.800 +    _Traits::move(__res, __f, __l - __f);
   1.801 +  }
   1.802 +
   1.803 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.804 +#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
   1.805 +  template <class _ForwardIter>
   1.806 +  void _M_insert_overflow(iterator __pos, _ForwardIter __first, _ForwardIter __last,
   1.807 +                          difference_type __n) {
   1.808 +    const size_type __old_size = this->size();
   1.809 +    size_type __len = __old_size + (max)(__old_size, __STATIC_CAST(size_type,__n)) + 1;
   1.810 +    pointer __new_start = this->_M_end_of_storage.allocate(__len, __len);
   1.811 +    pointer __new_finish = __new_start;
   1.812 +    _STLP_TRY {
   1.813 +      __new_finish = uninitialized_copy(this->_M_Start(), __pos, __new_start);
   1.814 +      __new_finish = uninitialized_copy(__first, __last, __new_finish);
   1.815 +      __new_finish = uninitialized_copy(__pos, this->_M_Finish(), __new_finish);
   1.816 +      _M_construct_null(__new_finish);
   1.817 +    }
   1.818 +    _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish),
   1.819 +                  this->_M_end_of_storage.deallocate(__new_start, __len)))
   1.820 +    this->_M_destroy_range();
   1.821 +    this->_M_deallocate_block();
   1.822 +    this->_M_reset(__new_start, __new_finish, __new_start + __len);
   1.823 +  }
   1.824 +
   1.825 +  template <class _InputIter>
   1.826 +  void _M_insertT(iterator __p, _InputIter __first, _InputIter __last,
   1.827 +                  const input_iterator_tag &) {
   1.828 +    for ( ; __first != __last; ++__first) {
   1.829 +      __p = insert(__p, *__first);
   1.830 +      ++__p;
   1.831 +    }
   1.832 +  }
   1.833 +
   1.834 +  template <class _ForwardIter>
   1.835 +  void _M_insertT(iterator __pos, _ForwardIter __first, _ForwardIter __last,
   1.836 +                  const forward_iterator_tag &) {
   1.837 +    if (__first != __last) {
   1.838 +      difference_type __n = distance(__first, __last);
   1.839 +      if (this->_M_end_of_storage._M_data - this->_M_finish >= __n + 1) {
   1.840 +        const difference_type __elems_after = this->_M_finish - __pos;
   1.841 +        if (__elems_after >= __n) {
   1.842 +#    if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.843 +          if (this->_M_using_static_buf())
   1.844 +            _M_copy((this->_M_Finish() - __n) + 1, this->_M_Finish() + 1, this->_M_Finish() + 1);
   1.845 +          else
   1.846 +#    endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.847 +          uninitialized_copy((this->_M_Finish() - __n) + 1, this->_M_Finish() + 1, this->_M_Finish() + 1);
   1.848 +          this->_M_finish += __n;
   1.849 +          _Traits::move(__pos + __n, __pos, (__elems_after - __n) + 1);
   1.850 +          _M_copyT(__first, __last, __pos);
   1.851 +        }
   1.852 +        else {
   1.853 +          pointer __old_finish = this->_M_Finish();
   1.854 +          _ForwardIter __mid = __first;
   1.855 +          advance(__mid, __elems_after + 1);
   1.856 +#    if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.857 +          if (this->_M_using_static_buf())
   1.858 +            _M_copyT(__mid, __last, this->_M_Finish() + 1);
   1.859 +          else
   1.860 +#    endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.861 +          uninitialized_copy(__mid, __last, this->_M_Finish() + 1);
   1.862 +          this->_M_finish += __n - __elems_after;
   1.863 +          _STLP_TRY {
   1.864 +#    if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.865 +            if (this->_M_using_static_buf())
   1.866 +              _M_copy(__pos, __old_finish + 1, this->_M_Finish());
   1.867 +            else
   1.868 +#    endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.869 +            uninitialized_copy(__pos, __old_finish + 1, this->_M_Finish());
   1.870 +            this->_M_finish += __elems_after;
   1.871 +          }
   1.872 +          _STLP_UNWIND((this->_M_destroy_ptr_range(__old_finish + 1, this->_M_Finish()),
   1.873 +                        this->_M_finish = __old_finish))
   1.874 +          _M_copyT(__first, __mid, __pos);
   1.875 +        }
   1.876 +      }
   1.877 +      else {
   1.878 +        _M_insert_overflow(__pos, __first, __last, __n);
   1.879 +      }
   1.880 +    }
   1.881 +  }
   1.882 +
   1.883 +  template <class _Integer>
   1.884 +  void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x,
   1.885 +                          const __true_type& /*Integral*/) {
   1.886 +    insert(__p, (size_type) __n, (_CharT) __x);
   1.887 +  }
   1.888 +
   1.889 +  template <class _InputIter>
   1.890 +  void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last,
   1.891 +                          const __false_type& /*Integral*/) {
   1.892 +    _STLP_FIX_LITERAL_BUG(__p)
   1.893 +    /*
   1.894 +     * Within the basic_string implementation we are only going to check for
   1.895 +     * self referencing if iterators are string iterators or _CharT pointers.
   1.896 +     * A user could encapsulate those iterator within their own iterator interface
   1.897 +     * and in this case lead to a bad behavior, this is a known limitation.
   1.898 +     */
   1.899 +    typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsIterator;
   1.900 +    typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
   1.901 +    typedef typename _Lor2<_IsIterator, _IsConstIterator>::_Ret _CheckInside;
   1.902 +    _M_insert_aux(__p, __first, __last, _CheckInside());
   1.903 +  }
   1.904 +
   1.905 +  template <class _RandomIter>
   1.906 +  void _M_insert_aux (iterator __p, _RandomIter __first, _RandomIter __last,
   1.907 +                      const __true_type& /*_CheckInside*/) {
   1.908 +    _STLP_FIX_LITERAL_BUG(__p)
   1.909 +    _M_insert(__p, &(*__first), &(*__last), _M_inside(&(*__first)));
   1.910 +  }
   1.911 +
   1.912 +  template<class _InputIter>
   1.913 +  void _M_insert_aux (iterator __p, _InputIter __first, _InputIter __last,
   1.914 +                      const __false_type& /*_CheckInside*/) {
   1.915 +    _STLP_FIX_LITERAL_BUG(__p)
   1.916 +    _M_insertT(__p, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
   1.917 +  }
   1.918 +
   1.919 +  template <class _InputIterator>
   1.920 +  void _M_copyT(_InputIterator __first, _InputIterator __last, pointer __result) {
   1.921 +    _STLP_FIX_LITERAL_BUG(__result)
   1.922 +    for ( ; __first != __last; ++__first, ++__result)
   1.923 +      _Traits::assign(*__result, *__first);
   1.924 +  }
   1.925 +
   1.926 +#    if !defined (_STLP_NO_METHOD_SPECIALIZATION)
   1.927 +  void _M_copyT(const _CharT* __f, const _CharT* __l, _CharT* __res) {
   1.928 +    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   1.929 +    _STLP_FIX_LITERAL_BUG(__res)
   1.930 +    _Traits::copy(__res, __f, __l - __f);
   1.931 +  }
   1.932 +#    endif
   1.933 +
   1.934 +public:
   1.935 +  // Check to see if _InputIterator is an integer type.  If so, then
   1.936 +  // it can't be an iterator.
   1.937 +  template <class _InputIter>
   1.938 +  void insert(iterator __p, _InputIter __first, _InputIter __last) {
   1.939 +    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
   1.940 +    _M_insert_dispatch(__p, __first, __last, _Integral());
   1.941 +  }
   1.942 +#  endif
   1.943 +#endif
   1.944 +
   1.945 +public:
   1.946 +
   1.947 +#if !defined (_STLP_MEMBER_TEMPLATES) || \
   1.948 +    !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
   1.949 +  void insert(iterator __p, const _CharT* __f, const _CharT* __l) {
   1.950 +    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
   1.951 +    _M_insert(__p, __f, __l, _M_inside(__f));
   1.952 +  }
   1.953 +#endif
   1.954 +
   1.955 +public:                         // Erase.
   1.956 +
   1.957 +  _Self& erase(size_type __pos = 0, size_type __n = npos) {
   1.958 +    if (__pos > size())
   1.959 +      this->_M_throw_out_of_range();
   1.960 +    erase(begin() + __pos, begin() + __pos + (min) (__n, size() - __pos));
   1.961 +    return *this;
   1.962 +  }
   1.963 +
   1.964 +  iterator erase(iterator __pos) {
   1.965 +    // The move includes the terminating _CharT().
   1.966 +    _Traits::move(__pos, __pos + 1, this->_M_Finish() - __pos);
   1.967 +    this->_M_destroy_back();
   1.968 +    --this->_M_finish;
   1.969 +    return __pos;
   1.970 +  }
   1.971 +
   1.972 +  iterator erase(iterator __first, iterator __last) {
   1.973 +    if (__first != __last) {
   1.974 +      // The move includes the terminating _CharT().
   1.975 +      traits_type::move(__first, __last, (this->_M_Finish() - __last) + 1);
   1.976 +      pointer __new_finish = this->_M_Finish() - (__last - __first);
   1.977 +      this->_M_destroy_ptr_range(__new_finish + 1, this->_M_Finish() + 1);
   1.978 +      this->_M_finish = __new_finish;
   1.979 +    }
   1.980 +    return __first;
   1.981 +  }
   1.982 +
   1.983 +public:                         // Replace.  (Conceptually equivalent
   1.984 +                                // to erase followed by insert.)
   1.985 +  _Self& replace(size_type __pos, size_type __n, const _Self& __s) {
   1.986 +    if (__pos > size())
   1.987 +      this->_M_throw_out_of_range();
   1.988 +    const size_type __len = (min) (__n, size() - __pos);
   1.989 +    if (size() - __len >= max_size() - __s.size())
   1.990 +      this->_M_throw_length_error();
   1.991 +    return _M_replace(begin() + __pos, begin() + __pos + __len,
   1.992 +                      __s._M_Start(), __s._M_Finish(), &__s == this);
   1.993 +  }
   1.994 +
   1.995 +  _Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
   1.996 +                 size_type __pos2, size_type __n2) {
   1.997 +    if (__pos1 > size() || __pos2 > __s.size())
   1.998 +      this->_M_throw_out_of_range();
   1.999 +    const size_type __len1 = (min) (__n1, size() - __pos1);
  1.1000 +    const size_type __len2 = (min) (__n2, __s.size() - __pos2);
  1.1001 +    if (size() - __len1 >= max_size() - __len2)
  1.1002 +      this->_M_throw_length_error();
  1.1003 +    return _M_replace(begin() + __pos1, begin() + __pos1 + __len1,
  1.1004 +                      __s._M_Start() + __pos2, __s._M_Start() + __pos2 + __len2, &__s == this);
  1.1005 +  }
  1.1006 +
  1.1007 +  _Self& replace(size_type __pos, size_type __n1,
  1.1008 +                 const _CharT* __s, size_type __n2) {
  1.1009 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1010 +    if (__pos > size())
  1.1011 +      this->_M_throw_out_of_range();
  1.1012 +    const size_type __len = (min) (__n1, size() - __pos);
  1.1013 +    if (__n2 > max_size() || size() - __len >= max_size() - __n2)
  1.1014 +      this->_M_throw_length_error();
  1.1015 +    return _M_replace(begin() + __pos, begin() + __pos + __len,
  1.1016 +                      __s, __s + __n2, _M_inside(__s));
  1.1017 +  }
  1.1018 +
  1.1019 +  _Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
  1.1020 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1021 +    if (__pos > size())
  1.1022 +      this->_M_throw_out_of_range();
  1.1023 +    const size_type __len = (min) (__n1, size() - __pos);
  1.1024 +    const size_type __n2 = _Traits::length(__s);
  1.1025 +    if (__n2 > max_size() || size() - __len >= max_size() - __n2)
  1.1026 +      this->_M_throw_length_error();
  1.1027 +    return _M_replace(begin() + __pos, begin() + __pos + __len,
  1.1028 +                      __s, __s + _Traits::length(__s), _M_inside(__s));
  1.1029 +  }
  1.1030 +
  1.1031 +  _Self& replace(size_type __pos, size_type __n1,
  1.1032 +                 size_type __n2, _CharT __c) {
  1.1033 +    if (__pos > size())
  1.1034 +      this->_M_throw_out_of_range();
  1.1035 +    const size_type __len = (min) (__n1, size() - __pos);
  1.1036 +    if (__n2 > max_size() || size() - __len >= max_size() - __n2)
  1.1037 +      this->_M_throw_length_error();
  1.1038 +    return replace(begin() + __pos, begin() + __pos + __len, __n2, __c);
  1.1039 +  }
  1.1040 +
  1.1041 +  _Self& replace(iterator __first, iterator __last, const _Self& __s) {
  1.1042 +    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
  1.1043 +    return _M_replace(__first, __last, __s._M_Start(), __s._M_Finish(), &__s == this);
  1.1044 +  }
  1.1045 +
  1.1046 +  _Self& replace(iterator __first, iterator __last,
  1.1047 +                 const _CharT* __s, size_type __n) {
  1.1048 +    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
  1.1049 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1050 +    return _M_replace(__first, __last, __s, __s + __n, _M_inside(__s));
  1.1051 +  }
  1.1052 +
  1.1053 +  _Self& replace(iterator __first, iterator __last,
  1.1054 +                 const _CharT* __s) {
  1.1055 +    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
  1.1056 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1057 +    return _M_replace(__first, __last, __s, __s + _Traits::length(__s), _M_inside(__s));
  1.1058 +  }
  1.1059 +
  1.1060 +  _Self& replace(iterator __first, iterator __last, size_type __n, _CharT __c);
  1.1061 +
  1.1062 +protected:                        // Helper functions for replace.
  1.1063 +  _Self& _M_replace(iterator __first, iterator __last,
  1.1064 +                    const _CharT* __f, const _CharT* __l, bool __self_ref);
  1.1065 +
  1.1066 +public:
  1.1067 +#if defined (_STLP_MEMBER_TEMPLATES)
  1.1068 +#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
  1.1069 +  template <class _Integer>
  1.1070 +  _Self& _M_replace_dispatch(iterator __first, iterator __last,
  1.1071 +                             _Integer __n, _Integer __x, const __true_type& /*IsIntegral*/) {
  1.1072 +    _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
  1.1073 +    return replace(__first, __last, (size_type) __n, (_CharT) __x);
  1.1074 +  }
  1.1075 +
  1.1076 +  template <class _InputIter>
  1.1077 +  _Self& _M_replace_dispatch(iterator __first, iterator __last,
  1.1078 +                             _InputIter __f, _InputIter __l, const __false_type& /*IsIntegral*/) {
  1.1079 +    _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
  1.1080 +    typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsIterator;
  1.1081 +    typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
  1.1082 +    typedef typename _Lor2<_IsIterator, _IsConstIterator>::_Ret _CheckInside;
  1.1083 +    return _M_replace_aux(__first, __last, __f, __l, _CheckInside());
  1.1084 +  }
  1.1085 +
  1.1086 +  template <class _RandomIter>
  1.1087 +  _Self& _M_replace_aux(iterator __first, iterator __last,
  1.1088 +                        _RandomIter __f, _RandomIter __l, __true_type const& /*_CheckInside*/) {
  1.1089 +    _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
  1.1090 +    return _M_replace(__first, __last, &(*__f), &(*__l), _M_inside(&(*__f)));
  1.1091 +  }
  1.1092 +
  1.1093 +  template <class _InputIter>
  1.1094 +  _Self& _M_replace_aux(iterator __first, iterator __last,
  1.1095 +                     _InputIter __f, _InputIter __l, __false_type const& /*_CheckInside*/) {
  1.1096 +    _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
  1.1097 +    return _M_replaceT(__first, __last, __f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
  1.1098 +  }
  1.1099 +
  1.1100 +  template <class _InputIter>
  1.1101 +  _Self& _M_replaceT(iterator __first, iterator __last,
  1.1102 +                     _InputIter __f, _InputIter __l, const input_iterator_tag&__ite_tag) {
  1.1103 +    _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
  1.1104 +    for ( ; __first != __last && __f != __l; ++__first, ++__f)
  1.1105 +      _Traits::assign(*__first, *__f);
  1.1106 +    if (__f == __l)
  1.1107 +      erase(__first, __last);
  1.1108 +    else
  1.1109 +      _M_insertT(__last, __f, __l, __ite_tag);
  1.1110 +    return *this;
  1.1111 +  }
  1.1112 +
  1.1113 +  template <class _ForwardIter>
  1.1114 +  _Self& _M_replaceT(iterator __first, iterator __last,
  1.1115 +                     _ForwardIter __f, _ForwardIter __l, const forward_iterator_tag &__ite_tag) {
  1.1116 +    _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
  1.1117 +    difference_type __n = distance(__f, __l);
  1.1118 +    const difference_type __len = __last - __first;
  1.1119 +    if (__len >= __n) {
  1.1120 +      _M_copyT(__f, __l, __first);
  1.1121 +      erase(__first + __n, __last);
  1.1122 +    }
  1.1123 +    else {
  1.1124 +      _ForwardIter __m = __f;
  1.1125 +      advance(__m, __len);
  1.1126 +      _M_copyT(__f, __m, __first);
  1.1127 +      _M_insertT(__last, __m, __l, __ite_tag);
  1.1128 +    }
  1.1129 +    return *this;
  1.1130 +  }
  1.1131 +
  1.1132 +public:
  1.1133 +  // Check to see if _InputIter is an integer type.  If so, then
  1.1134 +  // it can't be an iterator.
  1.1135 +  template <class _InputIter>
  1.1136 +  _Self& replace(iterator __first, iterator __last,
  1.1137 +                 _InputIter __f, _InputIter __l) {
  1.1138 +    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
  1.1139 +    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
  1.1140 +    return _M_replace_dispatch(__first, __last, __f, __l,  _Integral());
  1.1141 +  }
  1.1142 +
  1.1143 +#  endif
  1.1144 +#endif
  1.1145 +
  1.1146 +#if !defined (_STLP_MEMBER_TEMPLATES) || \
  1.1147 +    !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
  1.1148 +#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
  1.1149 +  _Self& replace(iterator __first, iterator __last,
  1.1150 +                 const _CharT* __f, const _CharT* __l) {
  1.1151 +    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
  1.1152 +    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
  1.1153 +    return _M_replace(__first, __last, __f, __l, _M_inside(__f));
  1.1154 +  }
  1.1155 +#  endif
  1.1156 +#endif
  1.1157 +
  1.1158 +public:                         // Other modifier member functions.
  1.1159 +
  1.1160 +  size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const {
  1.1161 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1162 +    if (__pos > size())
  1.1163 +      this->_M_throw_out_of_range();
  1.1164 +    const size_type __len = (min) (__n, size() - __pos);
  1.1165 +    _Traits::copy(__s, this->_M_Start() + __pos, __len);
  1.1166 +    return __len;
  1.1167 +  }
  1.1168 +
  1.1169 +  void swap(_Self& __s) {
  1.1170 +    this->_M_Swap(__s);
  1.1171 +  }
  1.1172 +
  1.1173 +public:                         // Conversion to C string.
  1.1174 +
  1.1175 +  const _CharT* c_str() const { return this->_M_Start(); }
  1.1176 +  const _CharT* data()  const { return this->_M_Start(); }
  1.1177 +
  1.1178 +public:                         // find.
  1.1179 +
  1.1180 +  size_type find(const _Self& __s, size_type __pos = 0) const
  1.1181 +    { return find(__s._M_Start(), __pos, __s.size()); }
  1.1182 +
  1.1183 +  size_type find(const _CharT* __s, size_type __pos = 0) const
  1.1184 +    { _STLP_FIX_LITERAL_BUG(__s) return find(__s, __pos, _Traits::length(__s)); }
  1.1185 +
  1.1186 +  size_type find(const _CharT* __s, size_type __pos, size_type __n) const;
  1.1187 +
  1.1188 +  // WIE: Versant schema compiler 5.2.2 ICE workaround
  1.1189 +  size_type find(_CharT __c) const { return find(__c, 0); }
  1.1190 +  size_type find(_CharT __c, size_type __pos /* = 0 */) const;
  1.1191 +
  1.1192 +public:                         // rfind.
  1.1193 +
  1.1194 +  size_type rfind(const _Self& __s, size_type __pos = npos) const
  1.1195 +    { return rfind(__s._M_Start(), __pos, __s.size()); }
  1.1196 +
  1.1197 +  size_type rfind(const _CharT* __s, size_type __pos = npos) const
  1.1198 +    { _STLP_FIX_LITERAL_BUG(__s) return rfind(__s, __pos, _Traits::length(__s)); }
  1.1199 +
  1.1200 +  size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const;
  1.1201 +  size_type rfind(_CharT __c, size_type __pos = npos) const;
  1.1202 +
  1.1203 +public:                         // find_first_of
  1.1204 +
  1.1205 +  size_type find_first_of(const _Self& __s, size_type __pos = 0) const
  1.1206 +    { return find_first_of(__s._M_Start(), __pos, __s.size()); }
  1.1207 +
  1.1208 +  size_type find_first_of(const _CharT* __s, size_type __pos = 0) const
  1.1209 +    { _STLP_FIX_LITERAL_BUG(__s) return find_first_of(__s, __pos, _Traits::length(__s)); }
  1.1210 +
  1.1211 +  size_type find_first_of(const _CharT* __s, size_type __pos,
  1.1212 +                          size_type __n) const;
  1.1213 +
  1.1214 +  size_type find_first_of(_CharT __c, size_type __pos = 0) const
  1.1215 +    { return find(__c, __pos); }
  1.1216 +
  1.1217 +public:                         // find_last_of
  1.1218 +
  1.1219 +  size_type find_last_of(const _Self& __s,
  1.1220 +                         size_type __pos = npos) const
  1.1221 +    { return find_last_of(__s._M_Start(), __pos, __s.size()); }
  1.1222 +
  1.1223 +  size_type find_last_of(const _CharT* __s, size_type __pos = npos) const
  1.1224 +    { _STLP_FIX_LITERAL_BUG(__s) return find_last_of(__s, __pos, _Traits::length(__s)); }
  1.1225 +
  1.1226 +  size_type find_last_of(const _CharT* __s, size_type __pos,
  1.1227 +                         size_type __n) const;
  1.1228 +
  1.1229 +  size_type find_last_of(_CharT __c, size_type __pos = npos) const {
  1.1230 +    return rfind(__c, __pos);
  1.1231 +  }
  1.1232 +
  1.1233 +public:                         // find_first_not_of
  1.1234 +
  1.1235 +  size_type find_first_not_of(const _Self& __s,
  1.1236 +                              size_type __pos = 0) const
  1.1237 +    { return find_first_not_of(__s._M_Start(), __pos, __s.size()); }
  1.1238 +
  1.1239 +  size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const
  1.1240 +  { _STLP_FIX_LITERAL_BUG(__s) return find_first_not_of(__s, __pos, _Traits::length(__s)); }
  1.1241 +
  1.1242 +  size_type find_first_not_of(const _CharT* __s, size_type __pos,
  1.1243 +                              size_type __n) const;
  1.1244 +
  1.1245 +  size_type find_first_not_of(_CharT __c, size_type __pos = 0) const;
  1.1246 +
  1.1247 +public:                         // find_last_not_of
  1.1248 +
  1.1249 +  size_type find_last_not_of(const _Self& __s,
  1.1250 +                             size_type __pos = npos) const
  1.1251 +  { return find_last_not_of(__s._M_Start(), __pos, __s.size()); }
  1.1252 +
  1.1253 +  size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const
  1.1254 +    { _STLP_FIX_LITERAL_BUG(__s) return find_last_not_of(__s, __pos, _Traits::length(__s)); }
  1.1255 +
  1.1256 +  size_type find_last_not_of(const _CharT* __s, size_type __pos,
  1.1257 +                             size_type __n) const;
  1.1258 +
  1.1259 +  size_type find_last_not_of(_CharT __c, size_type __pos = npos) const;
  1.1260 +
  1.1261 +public:                         // Substring.
  1.1262 +  _Self substr(size_type __pos = 0, size_type __n = npos) const
  1.1263 +  { return _Self(*this, __pos, __n, get_allocator()); }
  1.1264 +
  1.1265 +public:                         // Compare
  1.1266 +  int compare(const _Self& __s) const
  1.1267 +  { return _M_compare(this->_M_Start(), this->_M_Finish(), __s._M_Start(), __s._M_Finish()); }
  1.1268 +
  1.1269 +  int compare(size_type __pos1, size_type __n1,
  1.1270 +              const _Self& __s) const {
  1.1271 +    if (__pos1 > size())
  1.1272 +      this->_M_throw_out_of_range();
  1.1273 +    return _M_compare(this->_M_Start() + __pos1,
  1.1274 +                      this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1),
  1.1275 +                      __s._M_Start(), __s._M_Finish());
  1.1276 +  }
  1.1277 +
  1.1278 +  int compare(size_type __pos1, size_type __n1,
  1.1279 +              const _Self& __s,
  1.1280 +              size_type __pos2, size_type __n2) const {
  1.1281 +    if (__pos1 > size() || __pos2 > __s.size())
  1.1282 +      this->_M_throw_out_of_range();
  1.1283 +    return _M_compare(this->_M_Start() + __pos1,
  1.1284 +                      this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1),
  1.1285 +                      __s._M_Start() + __pos2,
  1.1286 +                      __s._M_Start() + __pos2 + (min) (__n2, __s.size() - __pos2));
  1.1287 +  }
  1.1288 +
  1.1289 +  int compare(const _CharT* __s) const {
  1.1290 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1291 +    return _M_compare(this->_M_Start(), this->_M_Finish(), __s, __s + _Traits::length(__s));
  1.1292 +  }
  1.1293 +
  1.1294 +  int compare(size_type __pos1, size_type __n1, const _CharT* __s) const {
  1.1295 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1296 +    if (__pos1 > size())
  1.1297 +      this->_M_throw_out_of_range();
  1.1298 +    return _M_compare(this->_M_Start() + __pos1,
  1.1299 +                      this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1),
  1.1300 +                      __s, __s + _Traits::length(__s));
  1.1301 +  }
  1.1302 +
  1.1303 +  int compare(size_type __pos1, size_type __n1, const _CharT* __s,
  1.1304 +              size_type __n2) const {
  1.1305 +    _STLP_FIX_LITERAL_BUG(__s)
  1.1306 +    if (__pos1 > size())
  1.1307 +      this->_M_throw_out_of_range();
  1.1308 +    return _M_compare(this->_M_Start() + __pos1,
  1.1309 +                      this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1),
  1.1310 +                      __s, __s + __n2);
  1.1311 +  }
  1.1312 +
  1.1313 +public:                        // Helper functions for compare.
  1.1314 +
  1.1315 +  static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
  1.1316 +                                   const _CharT* __f2, const _CharT* __l2) {
  1.1317 +    const ptrdiff_t __n1 = __l1 - __f1;
  1.1318 +    const ptrdiff_t __n2 = __l2 - __f2;
  1.1319 +    const int cmp = _Traits::compare(__f1, __f2, (min) (__n1, __n2));
  1.1320 +    return cmp != 0 ? cmp : (__n1 < __n2 ? -1 : (__n1 > __n2 ? 1 : 0));
  1.1321 +  }
  1.1322 +#if defined (_STLP_USE_TEMPLATE_EXPRESSION) && !defined (_STLP_DEBUG) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
  1.1323 +#  define _STLP_STRING_SUM_BASE(__reserve, __size, __alloc) _STLP_PRIV _String_base<_CharT,_Alloc>(__alloc, __size + 1)
  1.1324 +#  include <stl/_string_sum_methods.h>
  1.1325 +#  undef _STLP_STRING_SUM_BASE
  1.1326 +#endif /* _STLP_USE_TEMPLATE_EXPRESSION */
  1.1327 +};
  1.1328 +
  1.1329 +#if !defined (_STLP_STATIC_CONST_INIT_BUG)
  1.1330 +#  if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
  1.1331 +template <class _CharT, class _Traits, class _Alloc>
  1.1332 +const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;
  1.1333 +#  endif
  1.1334 +#endif
  1.1335 +
  1.1336 +#if defined (_STLP_USE_TEMPLATE_EXPORT)
  1.1337 +_STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;
  1.1338 +#  if defined (_STLP_HAS_WCHAR_T)
  1.1339 +_STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
  1.1340 +#  endif
  1.1341 +#endif /* _STLP_USE_TEMPLATE_EXPORT */
  1.1342 +
  1.1343 +#if defined (basic_string)
  1.1344 +_STLP_MOVE_TO_STD_NAMESPACE
  1.1345 +#  undef basic_string
  1.1346 +#endif
  1.1347 +
  1.1348 +_STLP_END_NAMESPACE
  1.1349 +
  1.1350 +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
  1.1351 +#  include <stl/_string_workaround.h>
  1.1352 +#endif
  1.1353 +
  1.1354 +#if defined (_STLP_DEBUG)
  1.1355 +#  include <stl/debug/_string.h>
  1.1356 +#endif
  1.1357 +
  1.1358 +_STLP_BEGIN_NAMESPACE
  1.1359 +
  1.1360 +// ------------------------------------------------------------
  1.1361 +// Non-member functions.
  1.1362 +// Swap.
  1.1363 +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
  1.1364 +template <class _CharT, class _Traits, class _Alloc>
  1.1365 +inline void _STLP_CALL
  1.1366 +swap(basic_string<_CharT,_Traits,_Alloc>& __x,
  1.1367 +     basic_string<_CharT,_Traits,_Alloc>& __y)
  1.1368 +{ __x.swap(__y); }
  1.1369 +#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
  1.1370 +
  1.1371 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
  1.1372 +template <class _CharT, class _Traits, class _Alloc>
  1.1373 +struct __move_traits<basic_string<_CharT, _Traits, _Alloc> > {
  1.1374 +  typedef __stlp_movable implemented;
  1.1375 +  //Completness depends on the allocator:
  1.1376 +  typedef typename __move_traits<_Alloc>::complete complete;
  1.1377 +};
  1.1378 +/*#else
  1.1379 + * There is no need to specialize for string and wstring in this case
  1.1380 + * as the default __move_traits will already tell that string is movable
  1.1381 + * but not complete. We cannot define it as complete as nothing guaranty
  1.1382 + * that the STLport user hasn't specialized std::allocator for char or
  1.1383 + * wchar_t.
  1.1384 + */
  1.1385 +#endif
  1.1386 +
  1.1387 +_STLP_MOVE_TO_PRIV_NAMESPACE
  1.1388 +
  1.1389 +template <class _CharT, class _Traits, class _Alloc>
  1.1390 +void _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,
  1.1391 +                               _CharT* __buf, size_t __n);
  1.1392 +
  1.1393 +#if defined(_STLP_USE_WIDE_INTERFACE)
  1.1394 +// A couple of functions to transfer between ASCII/Unicode
  1.1395 +wstring __ASCIIToWide(const char *ascii);
  1.1396 +string __WideToASCII(const wchar_t *wide);
  1.1397 +#endif
  1.1398 +
  1.1399 +inline const char* _STLP_CALL
  1.1400 +__get_c_string(const string& __str) { return __str.c_str(); }
  1.1401 +
  1.1402 +_STLP_MOVE_TO_STD_NAMESPACE
  1.1403 +
  1.1404 +_STLP_END_NAMESPACE
  1.1405 +
  1.1406 +#include <stl/_string_operators.h>
  1.1407 +
  1.1408 +#if defined(_STLP_USE_NO_IOSTREAMS) || \
  1.1409 +    (defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION))
  1.1410 +#  include <stl/_string.c>
  1.1411 +#endif
  1.1412 +
  1.1413 +#endif /* _STLP_INTERNAL_STRING_H */
  1.1414 +
  1.1415 +/*
  1.1416 + * Local Variables:
  1.1417 + * mode:C++
  1.1418 + * End:
  1.1419 + */