29 #ifndef _GLIBCXX_DEBUG_STRING 
   30 #define _GLIBCXX_DEBUG_STRING 1 
   39   template<
typename _CharT, 
typename _Traits = std::
char_traits<_CharT>,
 
   40             typename _Allocator = std::allocator<_CharT> >
 
   51     typedef _Traits                    traits_type;
 
   52     typedef typename _Traits::char_type            value_type;
 
   53     typedef _Allocator                     allocator_type;
 
   54     typedef typename _Base::size_type                  size_type;
 
   55     typedef typename _Base::difference_type            difference_type;
 
   56     typedef typename _Base::reference                  reference;
 
   57     typedef typename _Base::const_reference            const_reference;
 
   58     typedef typename _Base::pointer                    pointer;
 
   59     typedef typename _Base::const_pointer              const_pointer;
 
   72     explicit basic_string(
const _Allocator& __a = _Allocator())
 
   90            const _Allocator& __a = _Allocator())
 
   91     : 
_Base(__str, __pos, __n, __a)
 
   95            const _Allocator& __a = _Allocator())
 
   99     basic_string(
const _CharT* __s, 
const _Allocator& __a = _Allocator())
 
  101     { this->assign(__s); }
 
  104            const _Allocator& __a = _Allocator())
 
  105     : 
_Base(__n, __c, __a)
 
  108     template<
typename _InputIterator>
 
  109       basic_string(_InputIterator __begin, _InputIterator __end,
 
  110            const _Allocator& __a = _Allocator())
 
  116 #if __cplusplus >= 201103L 
  118     : 
_Base(std::move(__str))
 
  122          const _Allocator& __a = _Allocator())
 
  132       *
static_cast<_Base*
>(
this) = __str;
 
  138     operator=(
const _CharT* __s)
 
  140       __glibcxx_check_string(__s);
 
  141       *
static_cast<_Base*
>(
this) = __s;
 
  147     operator=(_CharT __c)
 
  149       *
static_cast<_Base*
>(
this) = __c;
 
  154 #if __cplusplus >= 201103L 
  158       __glibcxx_check_self_move_assign(__str);
 
  159       *
static_cast<_Base*
>(
this) = std::move(__str);
 
  167       *
static_cast<_Base*
>(
this) = __l;
 
  179     begin() 
const _GLIBCXX_NOEXCEPT
 
  187     end() 
const _GLIBCXX_NOEXCEPT
 
  195     rbegin() 
const _GLIBCXX_NOEXCEPT
 
  203     rend() 
const _GLIBCXX_NOEXCEPT
 
  206 #if __cplusplus >= 201103L 
  208     cbegin() 
const noexcept
 
  212     cend() 
const noexcept
 
  216     crbegin() 
const noexcept
 
  220     crend() 
const noexcept
 
  230     resize(size_type __n, _CharT __c)
 
  237     resize(size_type __n)
 
  238     { this->resize(__n, _CharT()); }
 
  240 #if __cplusplus >= 201103L 
  242     shrink_to_fit() noexcept
 
  271     operator[](size_type __pos) 
const _GLIBCXX_NOEXCEPT
 
  273       _GLIBCXX_DEBUG_VERIFY(__pos <= this->
size(),
 
  274                 _M_message(__gnu_debug::__msg_subscript_oob)
 
  275                 ._M_sequence(*
this, 
"this")
 
  276                 ._M_integer(__pos, 
"__pos")
 
  277                 ._M_integer(this->
size(), 
"size"));
 
  278       return _M_base()[__pos];
 
  282     operator[](size_type __pos) 
 
  284 #ifdef _GLIBCXX_DEBUG_PEDANTIC 
  285       __glibcxx_check_subscript(__pos);
 
  288       _GLIBCXX_DEBUG_VERIFY(__pos <= this->
size(),
 
  289                 _M_message(__gnu_debug::__msg_subscript_oob)
 
  290                 ._M_sequence(*
this, 
"this")
 
  291                 ._M_integer(__pos, 
"__pos")
 
  292                 ._M_integer(this->
size(), 
"size"));
 
  294       return _M_base()[__pos];
 
  299 #if __cplusplus >= 201103L 
  314     operator+=(
const _CharT* __s)
 
  316       __glibcxx_check_string(__s);
 
  323     operator+=(_CharT __c)
 
  330 #if __cplusplus >= 201103L 
  349     append(
const basic_string& __str, size_type __pos, size_type __n)
 
  357     append(
const _CharT* __s, size_type __n)
 
  359       __glibcxx_check_string_len(__s, __n);
 
  366     append(
const _CharT* __s)
 
  368       __glibcxx_check_string(__s);
 
  375     append(size_type __n, _CharT __c)
 
  382     template<
typename _InputIterator>
 
  384       append(_InputIterator __first, _InputIterator __last)
 
  386     __glibcxx_check_valid_range(__first, __last);
 
  396     push_back(_CharT __c)
 
  410 #if __cplusplus >= 201103L 
  421     assign(
const basic_string& __str, size_type __pos, size_type __n)
 
  429     assign(
const _CharT* __s, size_type __n)
 
  431       __glibcxx_check_string_len(__s, __n);
 
  438     assign(
const _CharT* __s)
 
  440       __glibcxx_check_string(__s);
 
  447     assign(size_type __n, _CharT __c)
 
  454     template<
typename _InputIterator>
 
  456       assign(_InputIterator __first, _InputIterator __last)
 
  458     __glibcxx_check_valid_range(__first, __last);
 
  465 #if __cplusplus >= 201103L 
  485        size_type __pos2, size_type __n)
 
  493     insert(size_type __pos, 
const _CharT* __s, size_type __n)
 
  495       __glibcxx_check_string(__s);
 
  502     insert(size_type __pos, 
const _CharT* __s)
 
  504       __glibcxx_check_string(__s);
 
  511     insert(size_type __pos, size_type __n, _CharT __c)
 
  528     insert(
iterator __p, size_type __n, _CharT __c)
 
  535     template<
typename _InputIterator>
 
  537       insert(
iterator __p, _InputIterator __first, _InputIterator __last)
 
  545 #if __cplusplus >= 201103L 
  556     erase(size_type __pos = 0, size_type __n = 
_Base::npos)
 
  584 #if __cplusplus >= 201103L 
  588       __glibcxx_check_nonempty();
 
  595     replace(size_type __pos1, size_type __n1, 
const basic_string& __str)
 
  603     replace(size_type __pos1, size_type __n1, 
const basic_string& __str,
 
  604         size_type __pos2, size_type __n2)
 
  612     replace(size_type __pos, size_type __n1, 
const _CharT* __s,
 
  615       __glibcxx_check_string_len(__s, __n2);
 
  622     replace(size_type __pos, size_type __n1, 
const _CharT* __s)
 
  624       __glibcxx_check_string(__s);
 
  631     replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
 
  651       __glibcxx_check_string_len(__s, __n);
 
  661       __glibcxx_check_string(__s);
 
  676     template<
typename _InputIterator>
 
  679           _InputIterator __j1, _InputIterator __j2)
 
  682     __glibcxx_check_valid_range(__j1, __j2);
 
  688 #if __cplusplus >= 201103L 
  700     copy(_CharT* __s, size_type __n, size_type __pos = 0)
 const 
  702       __glibcxx_check_string_len(__s, __n);
 
  717     c_str() 
const _GLIBCXX_NOEXCEPT
 
  725     data() 
const _GLIBCXX_NOEXCEPT
 
  735     find(
const basic_string& __str, size_type __pos = 0) 
const 
  740     find(
const _CharT* __s, size_type __pos, size_type __n)
 const 
  742       __glibcxx_check_string(__s);
 
  747     find(
const _CharT* __s, size_type __pos = 0)
 const 
  749       __glibcxx_check_string(__s);
 
  754     find(_CharT __c, size_type __pos = 0) 
const _GLIBCXX_NOEXCEPT
 
  763     rfind(
const _CharT* __s, size_type __pos, size_type __n)
 const 
  765       __glibcxx_check_string_len(__s, __n);
 
  770     rfind(
const _CharT* __s, size_type __pos = 
_Base::npos)
 const 
  772       __glibcxx_check_string(__s);
 
  777     rfind(_CharT __c, size_type __pos = 
_Base::npos) 
const _GLIBCXX_NOEXCEPT
 
  781     find_first_of(
const basic_string& __str, size_type __pos = 0) 
const 
  786     find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
 const 
  788       __glibcxx_check_string(__s);
 
  793     find_first_of(
const _CharT* __s, size_type __pos = 0)
 const 
  795       __glibcxx_check_string(__s);
 
  800     find_first_of(_CharT __c, size_type __pos = 0) 
const _GLIBCXX_NOEXCEPT
 
  805          size_type __pos = 
_Base::npos) 
const _GLIBCXX_NOEXCEPT
 
  809     find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
 const 
  811       __glibcxx_check_string(__s);
 
  816     find_last_of(
const _CharT* __s, size_type __pos = 
_Base::npos)
 const 
  818       __glibcxx_check_string(__s);
 
  823     find_last_of(_CharT __c, size_type __pos = 
_Base::npos) 
const 
  828     find_first_not_of(
const basic_string& __str, size_type __pos = 0) 
const 
  833     find_first_not_of(
const _CharT* __s, size_type __pos, size_type __n)
 const 
  835       __glibcxx_check_string_len(__s, __n);
 
  840     find_first_not_of(
const _CharT* __s, size_type __pos = 0)
 const 
  842       __glibcxx_check_string(__s);
 
  847     find_first_not_of(_CharT __c, size_type __pos = 0) 
const _GLIBCXX_NOEXCEPT
 
  857     find_last_not_of(
const _CharT* __s, size_type __pos, size_type __n)
 const 
  859       __glibcxx_check_string(__s);
 
  864     find_last_not_of(
const _CharT* __s, size_type __pos = 
_Base::npos)
 const 
  866       __glibcxx_check_string(__s);
 
  871     find_last_not_of(_CharT __c, size_type __pos = 
_Base::npos) 
const 
  876     substr(size_type __pos = 0, size_type __n = 
_Base::npos)
 const 
  884     compare(size_type __pos1, size_type __n1,
 
  889     compare(size_type __pos1, size_type __n1, 
const basic_string& __str,
 
  890           size_type __pos2, size_type __n2)
 const 
  894     compare(
const _CharT* __s)
 const 
  896       __glibcxx_check_string(__s);
 
  903     compare(size_type __pos1, size_type __n1, 
const _CharT* __s)
 const 
  905       __glibcxx_check_string(__s);
 
  912     compare(size_type __pos1, size_type __n1,
const _CharT* __s,
 
  913           size_type __n2)
 const 
  915       __glibcxx_check_string_len(__s, __n2);
 
  920     _M_base() _GLIBCXX_NOEXCEPT       { 
return *
this; }
 
  923     _M_base() 
const _GLIBCXX_NOEXCEPT { 
return *
this; }
 
  928   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  934   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  935     inline basic_string<_CharT,_Traits,_Allocator>
 
  936     operator+(
const _CharT* __lhs,
 
  937           const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
  939       __glibcxx_check_string(__lhs);
 
  940       return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
 
  943   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  944     inline basic_string<_CharT,_Traits,_Allocator>
 
  945     operator+(_CharT __lhs,
 
  946           const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
  947     { 
return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
 
  949   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  950     inline basic_string<_CharT,_Traits,_Allocator>
 
  951     operator+(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
  954       __glibcxx_check_string(__rhs);
 
  955       return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
 
  958   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  959     inline basic_string<_CharT,_Traits,_Allocator>
 
  960     operator+(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
  962     { 
return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
 
  964   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  966     operator==(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
  967            const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
  968     { 
return __lhs._M_base() == __rhs._M_base(); }
 
  970   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  972     operator==(
const _CharT* __lhs,
 
  973            const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
  975       __glibcxx_check_string(__lhs);
 
  976       return __lhs == __rhs._M_base();
 
  979   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  981     operator==(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
  984       __glibcxx_check_string(__rhs);
 
  985       return __lhs._M_base() == __rhs;
 
  988   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  990     operator!=(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
  991            const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
  992     { 
return __lhs._M_base() != __rhs._M_base(); }
 
  994   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
  996     operator!=(
const _CharT* __lhs,
 
  997            const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
  999       __glibcxx_check_string(__lhs);
 
 1000       return __lhs != __rhs._M_base();
 
 1003   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1005     operator!=(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1006            const _CharT* __rhs)
 
 1008       __glibcxx_check_string(__rhs);
 
 1009       return __lhs._M_base() != __rhs;
 
 1012   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1014     operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1015           const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1016     { 
return __lhs._M_base() < __rhs._M_base(); }
 
 1018   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1020     operator<(
const _CharT* __lhs,
 
 1021           const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1023       __glibcxx_check_string(__lhs);
 
 1024       return __lhs < __rhs._M_base();
 
 1027   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1029     operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1030           const _CharT* __rhs)
 
 1032       __glibcxx_check_string(__rhs);
 
 1033       return __lhs._M_base() < __rhs;
 
 1036   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1038     operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1039            const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1040     { 
return __lhs._M_base() <= __rhs._M_base(); }
 
 1042   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1044     operator<=(
const _CharT* __lhs,
 
 1045            const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1047       __glibcxx_check_string(__lhs);
 
 1048       return __lhs <= __rhs._M_base();
 
 1051   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1053     operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1054            const _CharT* __rhs)
 
 1056       __glibcxx_check_string(__rhs);
 
 1057       return __lhs._M_base() <= __rhs;
 
 1060   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1062     operator>=(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1063            const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1064     { 
return __lhs._M_base() >= __rhs._M_base(); }
 
 1066   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1068     operator>=(
const _CharT* __lhs,
 
 1069            const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1071       __glibcxx_check_string(__lhs);
 
 1072       return __lhs >= __rhs._M_base();
 
 1075   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1077     operator>=(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1078            const _CharT* __rhs)
 
 1080       __glibcxx_check_string(__rhs);
 
 1081       return __lhs._M_base() >= __rhs;
 
 1084   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1086     operator>(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1087           const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1088     { 
return __lhs._M_base() > __rhs._M_base(); }
 
 1090   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1092     operator>(
const _CharT* __lhs,
 
 1093           const basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1095       __glibcxx_check_string(__lhs);
 
 1096       return __lhs > __rhs._M_base();
 
 1099   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1101     operator>(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1102           const _CharT* __rhs)
 
 1104       __glibcxx_check_string(__rhs);
 
 1105       return __lhs._M_base() > __rhs;
 
 1109   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1111     swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
 
 1112      basic_string<_CharT,_Traits,_Allocator>& __rhs)
 
 1113     { __lhs.swap(__rhs); }
 
 1115   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1117     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 
 1118            const basic_string<_CharT, _Traits, _Allocator>& __str)
 
 1119     { 
return __os << __str._M_base(); }
 
 1121   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1124            basic_string<_CharT,_Traits,_Allocator>& __str)
 
 1127       __str._M_invalidate_all();
 
 1131   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1134         basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
 
 1139       __str._M_invalidate_all();
 
 1143   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1146         basic_string<_CharT,_Traits,_Allocator>& __str)
 
 1150       __str._M_invalidate_all();
 
 1154   typedef basic_string<char>    
string;
 
 1156 #ifdef _GLIBCXX_USE_WCHAR_T 
 1157   typedef basic_string<wchar_t> 
wstring;
 
 1160   template<
typename _CharT, 
typename _Traits, 
typename _Allocator>
 
 1161     struct _Insert_range_from_self_is_safe<
 
 1162       __gnu_debug::basic_string<_CharT, _Traits, _Allocator> >
 
 1163       { 
enum { __value = 1 }; };
 
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters. 
 
const _CharT * __check_string(const _CharT *__s, const _Integer &__n __attribute__((__unused__)))
 
const _CharT * data() const noexcept
Return const pointer to contents. 
 
#define __glibcxx_check_insert_range(_Position, _First, _Last)
 
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring. 
 
Class std::basic_string with safety/checking/debug instrumentation. 
 
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string. 
 
void _M_swap(_Safe_sequence_base &__x)
 
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents. 
 
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string. 
 
size_type capacity() const noexcept
 
#define __glibcxx_check_insert(_Position)
 
size_type max_size() const noexcept
Returns the size() of the largest possible string. 
 
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string. 
 
Template class basic_istream. 
 
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters. 
 
void push_back(_CharT __c)
Append a single character. 
 
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination. 
 
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string. 
 
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string. 
 
void _M_invalidate_all() const 
 
basic_string< wchar_t > wstring
A string of wchar_t. 
 
bool empty() const noexcept
 
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring. 
 
void swap(basic_string &__s)
Swap contents with another string. 
 
static const size_type npos
Value returned by various member functions when they fail. 
 
_Iterator base() const noexcept
Return the underlying iterator. 
 
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string. 
 
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination. 
 
#define __glibcxx_check_erase(_Position)
 
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters. 
 
const_reference at(size_type __n) const
Provides access to the data contained in the string. 
 
basic_string< char > string
A string of char. 
 
basic_string & append(const basic_string &__str)
Append a string to this string. 
 
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers. 
 
bitset< _Nb > operator>>(size_t __position) const noexcept
Self-explanatory. 
 
Base class for constructing a safe sequence type that tracks iterators that reference it...
 
int compare(const basic_string &__str) const
Compare to a string. 
 
void pop_back()
Remove the last character. 
 
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string. 
 
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
 
Managing sequences of characters and character-like objects. 
 
Template class basic_ostream. 
 
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string. 
 
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters. 
 
basic_string & assign(const basic_string &__str)
Set value to contents of another string. 
 
#define __glibcxx_check_erase_range(_First, _Last)
 
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.