19720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block/*
29720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Copyright (c) 1997-1999
39720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Silicon Graphics Computer Systems, Inc.
49720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block *
59720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Copyright (c) 1999
69720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Boris Fomitchev
79720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block *
89720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * This material is provided "as is", with absolutely no warranty expressed
99720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * or implied. Any use is at your own risk.
109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block *
119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Permission to use or copy this software for any purpose is hereby granted
129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * without fee, provided the above notices are retained on all copies.
139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Permission to modify the code and to distribute modified code is granted,
149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * provided the above notices are retained, and a notice that the code was
159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * modified is included with the above copyright notice.
169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block *
179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block */
189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_STRING_H
209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#define _STLP_INTERNAL_STRING_H
219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_ALLOC_H
239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_alloc.h>
249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_STRING_FWD_H
279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_string_fwd.h>
289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_function_base.h>
329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_ALGOBASE_H
359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_algobase.h>
369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_ITERATOR_H
399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_iterator.h>
409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_UNINITIALIZED_H
439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_uninitialized.h>
449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_USE_TEMPLATE_EXPRESSION)
479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_string_sum.h>
489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif /* _STLP_USE_TEMPLATE_EXPRESSION */
499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (__MWERKS__) && ! defined (_STLP_USE_OWN_NAMESPACE)
519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// MSL implementation classes expect to see the definition of streampos
539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// when this header is included. We expect this to be fixed in later MSL
549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// implementations
559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  if !defined( __MSL_CPP__ ) || __MSL_CPP__ < 0x4105
569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#    include <stl/msl_string.h>
579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  endif
589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif // __MWERKS__
599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block/*
619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Standard C++ string class.  This class has performance
629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * characteristics very much like vector<>, meaning, for example, that
639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * it does not perform reference-count or copy-on-write, and that
649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * concatenation of two strings is an O(N) operation.
659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * There are three reasons why basic_string is not identical to
679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * vector.
68e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * First, basic_string always stores a null character at the end;
69e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * this makes it possible for c_str to be a fast operation.
709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Second, the C++ standard requires basic_string to copy elements
719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * using char_traits<>::assign, char_traits<>::copy, and
729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * char_traits<>::move.  This means that all of vector<>'s low-level
739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * operations must be rewritten.  Third, basic_string<> has a lot of
749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * extra functions in its interface that are convenient but, strictly
759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * speaking, redundant.
769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block */
779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#include <stl/_string_base.h>
799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_BEGIN_NAMESPACE
819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// ------------------------------------------------------------
839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Class basic_string.
849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Class invariants:
869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// (1) [start, finish) is a valid range.
879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// (2) Each iterator in [start, finish) points to a valid object
889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block//     of type value_type.
899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// (3) *finish is a valid object of type value_type; when
909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block//     value_type is not a POD it is value_type().
919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// (4) [finish + 1, end_of_storage) is a valid range.
929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// (5) Each iterator in [finish + 1, end_of_storage) points to
939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block//     unininitialized memory.
949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Note one important consequence: a string of length n must manage
969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// a block of memory whose size is at least n + 1.
979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
98e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott_STLP_MOVE_TO_PRIV_NAMESPACE
999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockstruct _String_reserve_t {};
100e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott_STLP_MOVE_TO_STD_NAMESPACE
1019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  define basic_string _STLP_NO_MEM_T_NAME(str)
1049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#elif defined (_STLP_DEBUG)
1059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  define basic_string _STLP_NON_DBG_NAME(str)
1069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
1079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (basic_string)
1099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_MOVE_TO_PRIV_NAMESPACE
1109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
1119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
112e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (__DMC__)
113e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  define _STLP_PRIVATE public
114e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#elif defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
115e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  define _STLP_PRIVATE protected
116e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else
117e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  define _STLP_PRIVATE private
118e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif
119e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
1209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _CharT, class _Traits, class _Alloc>
121e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottclass basic_string : _STLP_PRIVATE _STLP_PRIV _String_base<_CharT,_Alloc>
1229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string)
1239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                   , public __stlport_class<basic_string<_CharT, _Traits, _Alloc> >
1249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
1259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block{
126e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott_STLP_PRIVATE:                        // Private members inherited from base.
1279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef _STLP_PRIV _String_base<_CharT,_Alloc> _Base;
1289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef basic_string<_CharT, _Traits, _Alloc> _Self;
1299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
1319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef _CharT value_type;
1329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef _Traits traits_type;
1339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef value_type* pointer;
1359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef const value_type* const_pointer;
1369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef value_type& reference;
1379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef const value_type& const_reference;
1389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef typename _Base::size_type size_type;
1399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef ptrdiff_t difference_type;
1409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef random_access_iterator_tag _Iterator_category;
1419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef const value_type* const_iterator;
1439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef value_type*       iterator;
1449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
1469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#include <stl/_string_npos.h>
1489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
149e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  typedef _STLP_PRIV _String_reserve_t _Reserve_t;
1509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Constructor, destructor, assignment.
1529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef typename _Base::allocator_type allocator_type;
1539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  allocator_type get_allocator() const
155e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_start_of_storage, _CharT); }
1569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
1589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  explicit basic_string(const allocator_type& __a = allocator_type())
1599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#else
1609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string()
1619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), _Base::_DEFAULT_SIZE)
1629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _M_terminate_string(); }
1639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  explicit basic_string(const allocator_type& __a)
1649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
1659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, _Base::_DEFAULT_SIZE)
1669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _M_terminate_string(); }
1679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
1699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(_Reserve_t, size_t __n,
1709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block               const allocator_type& __a = allocator_type())
1719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#else
1729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(_Reserve_t, size_t __n)
1739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), __n + 1)
1749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _M_terminate_string(); }
1759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(_Reserve_t, size_t __n, const allocator_type& __a)
1769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
1779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, __n + 1)
1789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _M_terminate_string(); }
1799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _Self&);
1819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
1839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
1849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block               const allocator_type& __a = allocator_type())
1859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#else
1869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _Self& __s, size_type __pos)
1879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
1889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > __s.size())
1899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
1909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    else
1919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _M_range_initialize(__s._M_Start() + __pos, __s._M_Finish());
1929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
1939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _Self& __s, size_type __pos, size_type __n)
1949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
1959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > __s.size())
1969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
1979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    else
1989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _M_range_initialize(__s._M_Start() + __pos,
1999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                          __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));
2009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
2019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _Self& __s, size_type __pos, size_type __n,
2029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block               const allocator_type& __a)
2039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
2049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
2059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > __s.size())
2069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
2079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    else
2089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _M_range_initialize(__s._M_Start() + __pos,
2099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                          __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));
2109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
2119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
2139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _CharT* __s, size_type __n,
2149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block               const allocator_type& __a = allocator_type())
2159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#else
2169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _CharT* __s, size_type __n)
2179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
2189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _STLP_FIX_LITERAL_BUG(__s)
2199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _M_range_initialize(__s, __s + __n);
2209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
2219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _CharT* __s, size_type __n, const allocator_type& __a)
2229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
2239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
2249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _STLP_FIX_LITERAL_BUG(__s)
2259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _M_range_initialize(__s, __s + __n);
2269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
2279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
2299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _CharT* __s,
2309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block               const allocator_type& __a = allocator_type());
2319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#else
2329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _CharT* __s);
2339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _CharT* __s, const allocator_type& __a);
2349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
2359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
2379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(size_type __n, _CharT __c,
2389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block               const allocator_type& __a = allocator_type())
2399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#else
2409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(size_type __n, _CharT __c)
2419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type(), __n + 1) {
2429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __c);
2439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_terminate_string();
2449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
2459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(size_type __n, _CharT __c, const allocator_type& __a)
2469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
2479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a, __n + 1) {
2489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __c);
2499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_terminate_string();
2509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
2519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
252e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if !defined (_STLP_NO_MOVE_SEMANTIC)
2539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(__move_source<_Self> src)
2549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(__move_source<_Base>(src.get())) {}
255e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif
2569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // Check to see if _InputIterator is an integer type.  If so, then
2589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // it can't be an iterator.
259e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
2609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIterator>
2619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(_InputIterator __f, _InputIterator __l,
2629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block               const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
2639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
2649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
2659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_initialize_dispatch(__f, __l, _Integral());
2669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
267e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
2689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIterator>
2699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(_InputIterator __f, _InputIterator __l)
2709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
2719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
2729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_initialize_dispatch(__f, __l, _Integral());
2739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
274e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  endif
275e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else
276e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
2779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _CharT* __f, const _CharT* __l,
2789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block               const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
2799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(__a) {
2809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f)  _STLP_FIX_LITERAL_BUG(__l)
2819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_range_initialize(__f, __l);
2829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
283e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#    if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
2849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  basic_string(const _CharT* __f, const _CharT* __l)
2859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    : _STLP_PRIV _String_base<_CharT,_Alloc>(allocator_type()) {
2869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f)  _STLP_FIX_LITERAL_BUG(__l)
2879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_range_initialize(__f, __l);
2889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
289e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#    endif
290e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  endif
291e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
292e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  /* We need an additionnal constructor to build an empty string without
293e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott   * any allocation or termination char*/
294e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottprotected:
295e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  struct _CalledFromWorkaround_t {};
296e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  basic_string(_CalledFromWorkaround_t, const allocator_type &__a)
297e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    : _String_base<_CharT,_Alloc>(__a) {}
2989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  endif
299e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif
300e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
301e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott_STLP_PRIVATE:
302e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type _M_compute_next_size(size_type __n) {
303e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __size = size();
304e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__n > max_size() - __size)
305e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      this->_M_throw_length_error();
306e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    size_type __len = __size + (max)(__n, __size) + 1;
307e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__len > max_size() || __len < __size)
308e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      __len = max_size(); // overflow
309e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    return __len;
310e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  }
3119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
3139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_range_initialize(_InputIter __f, _InputIter __l,
3149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                           const input_iterator_tag &__tag) {
3159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_allocate_block();
3169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_construct_null(this->_M_Finish());
317e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    _M_appendT(__f, __l, __tag);
3189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _ForwardIter>
3219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_range_initialize(_ForwardIter __f, _ForwardIter __l,
3229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                           const forward_iterator_tag &) {
323e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    difference_type __n = _STLP_STD::distance(__f, __l);
3249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_allocate_block(__n + 1);
3259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start());
3269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_terminate_string();
3279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
3309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_range_initializeT(_InputIter __f, _InputIter __l) {
3319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_range_initialize(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
3329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _Integer>
3359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
3369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_allocate_block(__n + 1);
3379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __x);
3389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_terminate_string();
3399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
3429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_initialize_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
3439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_range_initializeT(__f, __l);
3449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
3479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& operator=(const _Self& __s) {
3489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (&__s != this)
3499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _M_assign(__s._M_Start(), __s._M_Finish());
3509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
3519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& operator=(const _CharT* __s) {
3549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
3559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_assign(__s, __s + traits_type::length(__s));
3569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& operator=(_CharT __c)
3599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return assign(__STATIC_CAST(size_type,1), __c); }
3609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
361e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottprivate:
3629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  static _CharT _STLP_CALL _M_null()
3639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return _STLP_DEFAULT_CONSTRUCTED(_CharT); }
3649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
365e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott_STLP_PRIVATE:                     // Helper functions used by constructors
366e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                                   // and elsewhere.
367e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  void _M_construct_null(_CharT* __p) const
368e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { _STLP_STD::_Construct(__p); }
369e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  void _M_terminate_string()
370e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { _M_construct_null(this->_M_Finish()); }
3719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  bool _M_inside(const _CharT* __s) const {
3729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
3739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return (__s >= this->_M_Start()) && (__s < this->_M_Finish());
3749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_range_initialize(const _CharT* __f, const _CharT* __l) {
3779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
3789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    ptrdiff_t __n = __l - __f;
3799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_allocate_block(__n + 1);
3809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start());
3819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_terminate_string();
3829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Iterators.
3859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  iterator begin()             { return this->_M_Start(); }
3869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  iterator end()               { return this->_M_Finish(); }
3879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  const_iterator begin() const { return this->_M_Start(); }
3889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  const_iterator end()   const { return this->_M_Finish(); }
3899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  reverse_iterator rbegin()
391e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return reverse_iterator(this->_M_Finish()); }
3929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  reverse_iterator rend()
393e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return reverse_iterator(this->_M_Start()); }
3949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  const_reverse_iterator rbegin() const
395e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return const_reverse_iterator(this->_M_Finish()); }
3969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  const_reverse_iterator rend()   const
397e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return const_reverse_iterator(this->_M_Start()); }
3989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Size, capacity, etc.
400e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type size() const     { return this->_M_Finish() - this->_M_Start(); }
401e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type length() const   { return size(); }
402e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type max_size() const { return _Base::max_size(); }
4039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void resize(size_type __n, _CharT __c) {
4059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__n <= size())
4069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      erase(begin() + __n, end());
4079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    else
4089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      append(__n - size(), __c);
4099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
4109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void resize(size_type __n) { resize(__n, _M_null()); }
4129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
413e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottprivate:
414e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  void _M_reserve(size_type);
415e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic:
4169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void reserve(size_type = 0);
4179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type capacity() const
419e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return this->_M_capacity() - 1; }
4209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void clear() {
4229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (!empty()) {
4239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _Traits::assign(*(this->_M_Start()), _M_null());
4249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_finish = this->_M_Start();
4259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
4269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
4279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  bool empty() const { return this->_M_Start() == this->_M_Finish(); }
4299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Element access.
4319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  const_reference operator[](size_type __n) const
4339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return *(this->_M_Start() + __n); }
4349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  reference operator[](size_type __n)
4359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return *(this->_M_Start() + __n); }
4369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  const_reference at(size_type __n) const {
4389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__n >= size())
4399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
4409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *(this->_M_Start() + __n);
4419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
4429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  reference at(size_type __n) {
4449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__n >= size())
4459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
4469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *(this->_M_Start() + __n);
4479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
4489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Append, operator+=, push_back.
4509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& operator+=(const _Self& __s) { return append(__s); }
4529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); }
4539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& operator+=(_CharT __c) { push_back(__c); return *this; }
4549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
455e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottprivate:
456e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  _Self& _M_append(const _CharT* __first, const _CharT* __last);
457e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
458e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
4599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
4609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_appendT(_InputIter __first, _InputIter __last,
4619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                    const input_iterator_tag &) {
4629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    for ( ; __first != __last ; ++__first)
4639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      push_back(*__first);
4649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
4659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
4669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _ForwardIter>
4689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_appendT(_ForwardIter __first, _ForwardIter __last,
4699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                    const forward_iterator_tag &) {
4709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__first != __last) {
471e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      size_type __n = __STATIC_CAST(size_type, _STLP_STD::distance(__first, __last));
472e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      if (__n >= this->_M_rest()) {
473e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        size_type __len = _M_compute_next_size(__n);
474e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
475e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        pointer __new_finish = uninitialized_copy(this->_M_Start(), this->_M_Finish(), __new_start);
476e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        __new_finish = uninitialized_copy(__first, __last, __new_finish);
477e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        _M_construct_null(__new_finish);
4789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        this->_M_deallocate_block();
4799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        this->_M_reset(__new_start, __new_finish, __new_start + __len);
4809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      }
4819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      else {
482e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        _Traits::assign(*this->_M_finish, *__first++);
483e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        uninitialized_copy(__first, __last, this->_M_Finish() + 1);
484e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        _M_construct_null(this->_M_Finish() + __n);
4859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        this->_M_finish += __n;
4869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      }
4879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
4889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
4899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
4909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _Integer>
4929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_append_dispatch(_Integer __n, _Integer __x, const __true_type& /*Integral*/)
4939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return append((size_type) __n, (_CharT) __x); }
4949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
4969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_append_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*Integral*/)
4979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); }
4989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
5009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // Check to see if _InputIterator is an integer type.  If so, then
5019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // it can't be an iterator.
5029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
5039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& append(_InputIter __first, _InputIter __last) {
5049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
5059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_append_dispatch(__first, __last, _Integral());
5069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
507e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else
5089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
5099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& append(const _CharT* __first, const _CharT* __last) {
5109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
5119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_append(__first, __last);
5129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
5139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
5149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
515e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic:
5169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& append(const _Self& __s)
5179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return _M_append(__s._M_Start(), __s._M_Finish()); }
5189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& append(const _Self& __s,
5209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                size_type __pos, size_type __n) {
5219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > __s.size())
5229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
5239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_append(__s._M_Start() + __pos,
5249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                     __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));
5259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
5269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& append(const _CharT* __s, size_type __n)
5289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _STLP_FIX_LITERAL_BUG(__s) return _M_append(__s, __s+__n); }
5299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& append(const _CharT* __s)
5309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _STLP_FIX_LITERAL_BUG(__s) return _M_append(__s, __s + traits_type::length(__s)); }
5319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& append(size_type __n, _CharT __c);
5329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
5349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void push_back(_CharT __c) {
535e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (this->_M_rest() == 1 )
536e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      _M_reserve(_M_compute_next_size(1));
5379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_construct_null(this->_M_Finish() + 1);
5389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _Traits::assign(*(this->_M_Finish()), __c);
5399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    ++this->_M_finish;
5409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
5419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void pop_back() {
5439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _Traits::assign(*(this->_M_Finish() - 1), _M_null());
5449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    --this->_M_finish;
5459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
5469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Assign
5489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& assign(const _Self& __s)
5499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return _M_assign(__s._M_Start(), __s._M_Finish()); }
5509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& assign(const _Self& __s,
5529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                size_type __pos, size_type __n) {
5539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > __s.size())
5549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
5559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_assign(__s._M_Start() + __pos,
5569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                     __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));
5579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
5589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& assign(const _CharT* __s, size_type __n)
5609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _STLP_FIX_LITERAL_BUG(__s) return _M_assign(__s, __s + __n); }
5619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& assign(const _CharT* __s)
5639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _STLP_FIX_LITERAL_BUG(__s) return _M_assign(__s, __s + _Traits::length(__s)); }
5649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& assign(size_type __n, _CharT __c);
5669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
567e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottprivate:
568e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  _Self& _M_assign(const _CharT* __f, const _CharT* __l);
569e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
570e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
571e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  // Helper functions for assign.
5729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _Integer>
5739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/)
5749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return assign((size_type) __n, (_CharT) __x); }
5759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
5779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
5789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    pointer __cur = this->_M_Start();
5799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    while (__f != __l && __cur != this->_M_Finish()) {
5809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _Traits::assign(*__cur, *__f);
5819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      ++__f;
5829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      ++__cur;
5839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
5849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__f == __l)
5859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      erase(__cur, this->end());
5869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    else
5879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));
5889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
5899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
5909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
5919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
5929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // Check to see if _InputIterator is an integer type.  If so, then
5939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // it can't be an iterator.
5949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
5959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& assign(_InputIter __first, _InputIter __last) {
5969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
5979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_assign_dispatch(__first, __last, _Integral());
5989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
599e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else
6009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
6019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& assign(const _CharT* __f, const _CharT* __l) {
6029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
6039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_assign(__f, __l);
6049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
6069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Insert
6089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& insert(size_type __pos, const _Self& __s) {
6099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > size())
6109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
611e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__s.size() > max_size() - size())
6129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
6139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_insert(begin() + __pos, __s._M_Start(), __s._M_Finish(), &__s == this);
6149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
6159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& insert(size_type __pos, const _Self& __s,
6189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                size_type __beg, size_type __n) {
6199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > size() || __beg > __s.size())
6209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
6219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    size_type __len = (min) (__n, __s.size() - __beg);
622e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__len > max_size() - size())
6239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
6249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_insert(begin() + __pos,
6259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block              __s._M_Start() + __beg, __s._M_Start() + __beg + __len, &__s == this);
6269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
6279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
6299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
6309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > size())
6319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
632e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__n > max_size() - size())
6339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
6349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_insert(begin() + __pos, __s, __s + __n, _M_inside(__s));
6359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
6369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& insert(size_type __pos, const _CharT* __s) {
6399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
6409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > size())
6419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
6429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    size_type __len = _Traits::length(__s);
643e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__len > max_size() - size())
6449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
6459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_insert(this->_M_Start() + __pos, __s, __s + __len, _M_inside(__s));
6469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
6479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& insert(size_type __pos, size_type __n, _CharT __c) {
6509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > size())
6519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
652e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__n > max_size() - size())
6539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
6549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    insert(begin() + __pos, __n, __c);
6559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
6569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  iterator insert(iterator __p, _CharT __c) {
6599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__p)
6609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__p == end()) {
6619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      push_back(__c);
6629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      return this->_M_Finish() - 1;
6639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
6649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    else
6659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      return _M_insert_aux(__p, __c);
6669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void insert(iterator __p, size_t __n, _CharT __c);
6699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
670e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott_STLP_PRIVATE:  // Helper functions for insert.
6719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_insert(iterator __p, const _CharT* __first, const _CharT* __last, bool __self_ref);
6729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  pointer _M_insert_aux(pointer, _CharT);
6749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_copy(const _CharT* __f, const _CharT* __l, _CharT* __res) {
6769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
6779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__res)
6789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _Traits::copy(__res, __f, __l - __f);
6799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_move(const _CharT* __f, const _CharT* __l, _CharT* __res) {
6829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
6839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _Traits::move(__res, __f, __l - __f);
6849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
6859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
6869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_MEMBER_TEMPLATES)
6879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
6889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _ForwardIter>
6899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_insert_overflow(iterator __pos, _ForwardIter __first, _ForwardIter __last,
690e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                          size_type __n) {
691e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    size_type __len = _M_compute_next_size(__n);
692e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    pointer __new_start = this->_M_start_of_storage.allocate(__len, __len);
693e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    pointer __new_finish = uninitialized_copy(this->_M_Start(), __pos, __new_start);
694e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    __new_finish = uninitialized_copy(__first, __last, __new_finish);
695e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    __new_finish = uninitialized_copy(__pos, this->_M_Finish(), __new_finish);
696e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    _M_construct_null(__new_finish);
6979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_deallocate_block();
6989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    this->_M_reset(__new_start, __new_finish, __new_start + __len);
6999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
7019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
7029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_insertT(iterator __p, _InputIter __first, _InputIter __last,
7039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                  const input_iterator_tag &) {
7049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    for ( ; __first != __last; ++__first) {
7059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      __p = insert(__p, *__first);
7069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      ++__p;
7079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
7089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
7109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _ForwardIter>
7119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_insertT(iterator __pos, _ForwardIter __first, _ForwardIter __last,
7129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                  const forward_iterator_tag &) {
7139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__first != __last) {
714e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      size_type __n = _STLP_STD::distance(__first, __last);
715e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      if (__n < this->_M_rest()) {
716e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        const size_type __elems_after = this->_M_finish - __pos;
7179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        if (__elems_after >= __n) {
7189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          uninitialized_copy((this->_M_Finish() - __n) + 1, this->_M_Finish() + 1, this->_M_Finish() + 1);
7199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          this->_M_finish += __n;
7209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          _Traits::move(__pos + __n, __pos, (__elems_after - __n) + 1);
7219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          _M_copyT(__first, __last, __pos);
7229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
7239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        else {
7249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          pointer __old_finish = this->_M_Finish();
7259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          _ForwardIter __mid = __first;
726e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          _STLP_STD::advance(__mid, __elems_after + 1);
727e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          _STLP_STD::uninitialized_copy(__mid, __last, this->_M_Finish() + 1);
7289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          this->_M_finish += __n - __elems_after;
729e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          uninitialized_copy(__pos, __old_finish + 1, this->_M_Finish());
730e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          this->_M_finish += __elems_after;
7319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          _M_copyT(__first, __mid, __pos);
7329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
7339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      }
7349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      else {
7359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        _M_insert_overflow(__pos, __first, __last, __n);
7369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      }
7379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
7389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
7409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _Integer>
7419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_insert_dispatch(iterator __p, _Integer __n, _Integer __x,
742e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                          const __true_type& /*Integral*/)
743e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { insert(__p, (size_type) __n, (_CharT) __x); }
7449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
7459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
7469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_insert_dispatch(iterator __p, _InputIter __first, _InputIter __last,
7479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                          const __false_type& /*Integral*/) {
7489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__p)
749e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    /* We are forced to do a temporary string to avoid the self referencing issue. */
750e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const _Self __self(__first, __last, get_allocator());
751e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    _M_insertT(__p, __self.begin(), __self.end(), forward_iterator_tag());
7529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
7549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIterator>
7559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_copyT(_InputIterator __first, _InputIterator __last, pointer __result) {
7569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__result)
7579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    for ( ; __first != __last; ++__first, ++__result)
7589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      _Traits::assign(*__result, *__first);
7599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
7619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#    if !defined (_STLP_NO_METHOD_SPECIALIZATION)
7629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void _M_copyT(const _CharT* __f, const _CharT* __l, _CharT* __res) {
7639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
7649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__res)
7659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _Traits::copy(__res, __f, __l - __f);
7669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#    endif
7689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
7699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // Check to see if _InputIterator is an integer type.  If so, then
7709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // it can't be an iterator.
7719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
7729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void insert(iterator __p, _InputIter __first, _InputIter __last) {
7739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
7749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_insert_dispatch(__p, __first, __last, _Integral());
7759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  endif
7779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
7789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
779e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
7809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
7819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  void insert(iterator __p, const _CharT* __f, const _CharT* __l) {
7829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
7839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _M_insert(__p, __f, __l, _M_inside(__f));
7849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
7869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
7879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Erase.
7889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& erase(size_type __pos = 0, size_type __n = npos) {
7899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > size())
7909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
7919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    erase(begin() + __pos, begin() + __pos + (min) (__n, size() - __pos));
7929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return *this;
7939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
7949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
7959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  iterator erase(iterator __pos) {
7969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    // The move includes the terminating _CharT().
7979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _Traits::move(__pos, __pos + 1, this->_M_Finish() - __pos);
7989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    --this->_M_finish;
7999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return __pos;
8009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  iterator erase(iterator __first, iterator __last) {
8039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__first != __last) {
8049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      // The move includes the terminating _CharT().
8059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      traits_type::move(__first, __last, (this->_M_Finish() - __last) + 1);
806e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      this->_M_finish = this->_M_Finish() - (__last - __first);
8079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
8089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return __first;
8099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Replace.  (Conceptually equivalent
8129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                // to erase followed by insert.)
8139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(size_type __pos, size_type __n, const _Self& __s) {
814e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __size = size();
815e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__pos > __size)
8169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
817e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __len = (min) (__n, __size - __pos);
818e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__s.size() > max_size() - (__size - __len))
8199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
8209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_replace(begin() + __pos, begin() + __pos + __len,
8219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      __s._M_Start(), __s._M_Finish(), &__s == this);
8229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
8259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                 size_type __pos2, size_type __n2) {
826e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __size1 = size();
827e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __size2 = __s.size();
828e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__pos1 > __size1 || __pos2 > __size2)
8299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
830e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __len1 = (min) (__n1, __size1 - __pos1);
831e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __len2 = (min) (__n2, __size2 - __pos2);
832e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__len2 > max_size() - (__size1 - __len1))
8339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
8349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_replace(begin() + __pos1, begin() + __pos1 + __len1,
8359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      __s._M_Start() + __pos2, __s._M_Start() + __pos2 + __len2, &__s == this);
8369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(size_type __pos, size_type __n1,
8399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                 const _CharT* __s, size_type __n2) {
8409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
841e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __size = size();
842e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__pos > __size)
8439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
844e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __len = (min) (__n1, __size - __pos);
845e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__n2 > max_size() - (__size - __len))
8469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
8479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_replace(begin() + __pos, begin() + __pos + __len,
8489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      __s, __s + __n2, _M_inside(__s));
8499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
8529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
853e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    return replace(__pos, __n1, __s, _Traits::length(__s));
8549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(size_type __pos, size_type __n1,
8579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                 size_type __n2, _CharT __c) {
858e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __size = size();
859e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__pos > __size)
8609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
861e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const size_type __len = (min) (__n1, __size - __pos);
862e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    if (__n2 > max_size() - (__size - __len))
8639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_length_error();
8649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return replace(begin() + __pos, begin() + __pos + __len, __n2, __c);
8659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(iterator __first, iterator __last, const _Self& __s) {
8689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
8699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_replace(__first, __last, __s._M_Start(), __s._M_Finish(), &__s == this);
8709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(iterator __first, iterator __last,
8739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                 const _CharT* __s, size_type __n) {
8749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
8759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
8769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_replace(__first, __last, __s, __s + __n, _M_inside(__s));
8779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(iterator __first, iterator __last,
8809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                 const _CharT* __s) {
8819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
8829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
8839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_replace(__first, __last, __s, __s + _Traits::length(__s), _M_inside(__s));
8849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
8869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(iterator __first, iterator __last, size_type __n, _CharT __c);
8879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
888e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott_STLP_PRIVATE:                        // Helper functions for replace.
8899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_replace(iterator __first, iterator __last,
8909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                    const _CharT* __f, const _CharT* __l, bool __self_ref);
8919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
892e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
8939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _Integer>
8949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_replace_dispatch(iterator __first, iterator __last,
8959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                             _Integer __n, _Integer __x, const __true_type& /*IsIntegral*/) {
8969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
8979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return replace(__first, __last, (size_type) __n, (_CharT) __x);
8989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
8999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
9019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& _M_replace_dispatch(iterator __first, iterator __last,
9029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                             _InputIter __f, _InputIter __l, const __false_type& /*IsIntegral*/) {
9039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
904e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    /* We are forced to do a temporary string to avoid the self referencing issue. */
905e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    const _Self __self(__f, __l, get_allocator());
906e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    return _M_replace(__first, __last, __self._M_Start(), __self._M_Finish(), false);
9079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
9089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:
9109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // Check to see if _InputIter is an integer type.  If so, then
9119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // it can't be an iterator.
9129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  template <class _InputIter>
9139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(iterator __first, iterator __last,
9149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                 _InputIter __f, _InputIter __l) {
9159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
9169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
9179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_replace_dispatch(__first, __last, __f, __l,  _Integral());
9189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
9199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
9209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
921e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
922e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic:
9239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self& replace(iterator __first, iterator __last,
9249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                 const _CharT* __f, const _CharT* __l) {
9259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)
9269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
9279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_replace(__first, __last, __f, __l, _M_inside(__f));
9289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
9299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
9309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Other modifier member functions.
9329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const {
9349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
9359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos > size())
9369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
9379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    const size_type __len = (min) (__n, size() - __pos);
9389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _Traits::copy(__s, this->_M_Start() + __pos, __len);
9399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return __len;
9409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
9419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
942e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  void swap(_Self& __s) { this->_M_swap(__s); }
943e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
944e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  void _M_swap_workaround(_Self& __x) { swap(__x); }
945e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif
9469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockpublic:                         // Conversion to C string.
9489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  const _CharT* c_str() const { return this->_M_Start(); }
9509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  const _CharT* data()  const { return this->_M_Start(); }
9519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
952e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // find.
9539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find(const _Self& __s, size_type __pos = 0) const
954e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return find(__s._M_Start(), __pos, __s.size()); }
9559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find(const _CharT* __s, size_type __pos = 0) const
957e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { _STLP_FIX_LITERAL_BUG(__s) return find(__s, __pos, _Traits::length(__s)); }
9589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find(const _CharT* __s, size_type __pos, size_type __n) const;
9609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  // WIE: Versant schema compiler 5.2.2 ICE workaround
9629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find(_CharT __c) const { return find(__c, 0); }
9639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find(_CharT __c, size_type __pos /* = 0 */) const;
9649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
965e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // rfind.
9669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type rfind(const _Self& __s, size_type __pos = npos) const
967e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return rfind(__s._M_Start(), __pos, __s.size()); }
9689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type rfind(const _CharT* __s, size_type __pos = npos) const
970e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { _STLP_FIX_LITERAL_BUG(__s) return rfind(__s, __pos, _Traits::length(__s)); }
9719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const;
9739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type rfind(_CharT __c, size_type __pos = npos) const;
9749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
975e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // find_first_of
9769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find_first_of(const _Self& __s, size_type __pos = 0) const
977e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return find_first_of(__s._M_Start(), __pos, __s.size()); }
9789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find_first_of(const _CharT* __s, size_type __pos = 0) const
980e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { _STLP_FIX_LITERAL_BUG(__s) return find_first_of(__s, __pos, _Traits::length(__s)); }
9819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
982e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
9839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find_first_of(_CharT __c, size_type __pos = 0) const
985e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return find(__c, __pos); }
9869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
987e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // find_last_of
988e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type find_last_of(const _Self& __s, size_type __pos = npos) const
989e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return find_last_of(__s._M_Start(), __pos, __s.size()); }
9909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
9919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find_last_of(const _CharT* __s, size_type __pos = npos) const
992e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { _STLP_FIX_LITERAL_BUG(__s) return find_last_of(__s, __pos, _Traits::length(__s)); }
9939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
994e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
9959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
996e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type find_last_of(_CharT __c, size_type __pos = npos) const
997e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return rfind(__c, __pos); }
9989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
999e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // find_first_not_of
1000e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const
1001e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { return find_first_not_of(__s._M_Start(), __pos, __s.size()); }
10029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
10039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const
10049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { _STLP_FIX_LITERAL_BUG(__s) return find_first_not_of(__s, __pos, _Traits::length(__s)); }
10059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1006e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const;
10079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
10089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find_first_not_of(_CharT __c, size_type __pos = 0) const;
10099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1010e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // find_last_not_of
1011e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const
10129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return find_last_not_of(__s._M_Start(), __pos, __s.size()); }
10139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
10149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const
1015e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  { _STLP_FIX_LITERAL_BUG(__s) return find_last_not_of(__s, __pos, _Traits::length(__s)); }
10169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1017e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const;
10189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
10199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_type find_last_not_of(_CharT __c, size_type __pos = npos) const;
10209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1021e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // Substring.
10229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  _Self substr(size_type __pos = 0, size_type __n = npos) const
10239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return _Self(*this, __pos, __n, get_allocator()); }
10249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1025e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // Compare
10269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  int compare(const _Self& __s) const
10279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  { return _M_compare(this->_M_Start(), this->_M_Finish(), __s._M_Start(), __s._M_Finish()); }
10289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1029e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  int compare(size_type __pos1, size_type __n1, const _Self& __s) const {
10309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos1 > size())
10319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
10329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_compare(this->_M_Start() + __pos1,
10339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1),
10349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      __s._M_Start(), __s._M_Finish());
10359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
10369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1037e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  int compare(size_type __pos1, size_type __n1, const _Self& __s,
10389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block              size_type __pos2, size_type __n2) const {
10399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos1 > size() || __pos2 > __s.size())
10409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
10419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_compare(this->_M_Start() + __pos1,
10429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1),
10439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      __s._M_Start() + __pos2,
10449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      __s._M_Start() + __pos2 + (min) (__n2, __s.size() - __pos2));
10459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
10469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
10479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  int compare(const _CharT* __s) const {
10489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
10499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_compare(this->_M_Start(), this->_M_Finish(), __s, __s + _Traits::length(__s));
10509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
10519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
10529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  int compare(size_type __pos1, size_type __n1, const _CharT* __s) const {
10539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
10549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos1 > size())
10559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
10569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_compare(this->_M_Start() + __pos1,
10579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1),
10589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      __s, __s + _Traits::length(__s));
10599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
10609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1061e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const {
10629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    _STLP_FIX_LITERAL_BUG(__s)
10639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__pos1 > size())
10649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      this->_M_throw_out_of_range();
10659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return _M_compare(this->_M_Start() + __pos1,
10669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      this->_M_Start() + __pos1 + (min) (__n1, size() - __pos1),
10679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                      __s, __s + __n2);
10689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
10699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1070e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottpublic: // Helper functions for compare.
10719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
10729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                   const _CharT* __f2, const _CharT* __l2) {
10739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    const ptrdiff_t __n1 = __l1 - __f1;
10749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    const ptrdiff_t __n2 = __l2 - __f2;
10759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    const int cmp = _Traits::compare(__f1, __f2, (min) (__n1, __n2));
10769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return cmp != 0 ? cmp : (__n1 < __n2 ? -1 : (__n1 > __n2 ? 1 : 0));
10779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
10789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_USE_TEMPLATE_EXPRESSION) && !defined (_STLP_DEBUG) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
10799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  define _STLP_STRING_SUM_BASE(__reserve, __size, __alloc) _STLP_PRIV _String_base<_CharT,_Alloc>(__alloc, __size + 1)
10809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_string_sum_methods.h>
10819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  undef _STLP_STRING_SUM_BASE
1082e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif
10839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block};
10849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1085e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#undef _STLP_PRIVATE
1086e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
1087e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
10889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _CharT, class _Traits, class _Alloc>
10899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockconst size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;
10909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
10919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
10929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_USE_TEMPLATE_EXPORT)
10939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;
10949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  if defined (_STLP_HAS_WCHAR_T)
10959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
10969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  endif
10979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif /* _STLP_USE_TEMPLATE_EXPORT */
10989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
10999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (basic_string)
11009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_MOVE_TO_STD_NAMESPACE
11019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  undef basic_string
11029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
11039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_END_NAMESPACE
11059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
11079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_string_workaround.h>
11089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
11099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_DEBUG)
11119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/debug/_string.h>
11129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
11139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_BEGIN_NAMESPACE
11159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// ------------------------------------------------------------
11179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Non-member functions.
11189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Swap.
11199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
11209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _CharT, class _Traits, class _Alloc>
11219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockinline void _STLP_CALL
11229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockswap(basic_string<_CharT,_Traits,_Alloc>& __x,
11239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block     basic_string<_CharT,_Traits,_Alloc>& __y)
11249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block{ __x.swap(__y); }
1125e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else
1126e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottinline void _STLP_CALL swap(string& __x, string& __y)
1127e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott{ __x.swap(__y); }
1128e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  if defined (_STLP_HAS_WCHAR_T)
1129e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottinline void _STLP_CALL swap(wstring& __x, wstring& __y)
1130e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott{ __x.swap(__y); }
1131e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#  endif
1132e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif
11339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1134e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
11359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _CharT, class _Traits, class _Alloc>
11369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockstruct __move_traits<basic_string<_CharT, _Traits, _Alloc> > {
1137e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  typedef __true_type implemented;
11389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  //Completness depends on the allocator:
11399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef typename __move_traits<_Alloc>::complete complete;
11409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block};
11419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block/*#else
11429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * There is no need to specialize for string and wstring in this case
11439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * as the default __move_traits will already tell that string is movable
11449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * but not complete. We cannot define it as complete as nothing guaranty
11459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * that the STLport user hasn't specialized std::allocator for char or
11469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * wchar_t.
11479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block */
11489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
11499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_MOVE_TO_PRIV_NAMESPACE
11519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _CharT, class _Traits, class _Alloc>
11539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockvoid _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,
11549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                               _CharT* __buf, size_t __n);
11559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined(_STLP_USE_WIDE_INTERFACE)
11579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// A couple of functions to transfer between ASCII/Unicode
11589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockwstring __ASCIIToWide(const char *ascii);
11599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockstring __WideToASCII(const wchar_t *wide);
11609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
11619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockinline const char* _STLP_CALL
11639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block__get_c_string(const string& __str) { return __str.c_str(); }
11649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_MOVE_TO_STD_NAMESPACE
11669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_END_NAMESPACE
11689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#include <stl/_string_operators.h>
11709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#if defined(_STLP_USE_NO_IOSTREAMS) || \
11729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    (defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION))
11739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_string.c>
11749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
11759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif /* _STLP_INTERNAL_STRING_H */
11779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
11789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block/*
11799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Local Variables:
11809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * mode:C++
11819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * End:
11829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block */
1183