30 #ifndef _GLIBCXX_DEBUG_STRING
31 #define _GLIBCXX_DEBUG_STRING 1
40 template<
typename _CharT,
typename _Traits = std::
char_traits<_CharT>,
41 typename _Allocator = std::allocator<_CharT> >
52 typedef _Traits traits_type;
53 typedef typename _Traits::char_type value_type;
54 typedef _Allocator allocator_type;
55 typedef typename _Base::size_type size_type;
56 typedef typename _Base::difference_type difference_type;
57 typedef typename _Base::reference reference;
58 typedef typename _Base::const_reference const_reference;
59 typedef typename _Base::pointer pointer;
60 typedef typename _Base::const_pointer const_pointer;
73 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 #ifdef __GXX_EXPERIMENTAL_CXX0X__
118 :
_Base(std::move(__str))
122 const _Allocator& __a = _Allocator())
125 #endif // __GXX_EXPERIMENTAL_CXX0X__
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 #ifdef __GXX_EXPERIMENTAL_CXX0X__
158 *
static_cast<_Base*
>(
this) = std::move(__str);
166 *
static_cast<_Base*
>(
this) = __l;
170 #endif // __GXX_EXPERIMENTAL_CXX0X__
211 resize(size_type __n, _CharT __c)
218 resize(size_type __n)
219 { this->resize(__n, _CharT()); }
221 #ifdef __GXX_EXPERIMENTAL_CXX0X__
239 operator[](size_type __pos)
const
242 _M_message(__gnu_debug::__msg_subscript_oob)
243 ._M_sequence(*
this,
"this")
244 ._M_integer(__pos,
"__pos")
245 ._M_integer(this->
size(),
"size"));
246 return _M_base()[__pos];
250 operator[](size_type __pos)
252 #ifdef _GLIBCXX_DEBUG_PEDANTIC
253 __glibcxx_check_subscript(__pos);
257 _M_message(__gnu_debug::__msg_subscript_oob)
258 ._M_sequence(*
this,
"this")
259 ._M_integer(__pos,
"__pos")
260 ._M_integer(this->
size(),
"size"));
262 return _M_base()[__pos];
267 #ifdef __GXX_EXPERIMENTAL_CXX0X__
282 operator+=(
const _CharT* __s)
284 __glibcxx_check_string(__s);
291 operator+=(_CharT __c)
298 #ifdef __GXX_EXPERIMENTAL_CXX0X__
306 #endif // __GXX_EXPERIMENTAL_CXX0X__
317 append(
const basic_string& __str, size_type __pos, size_type __n)
325 append(
const _CharT* __s, size_type __n)
327 __glibcxx_check_string_len(__s, __n);
334 append(
const _CharT* __s)
336 __glibcxx_check_string(__s);
343 append(size_type __n, _CharT __c)
350 template<
typename _InputIterator>
352 append(_InputIterator __first, _InputIterator __last)
354 __glibcxx_check_valid_range(__first, __last);
364 push_back(_CharT __c)
378 #ifdef __GXX_EXPERIMENTAL_CXX0X__
386 #endif // __GXX_EXPERIMENTAL_CXX0X__
389 assign(
const basic_string& __str, size_type __pos, size_type __n)
397 assign(
const _CharT* __s, size_type __n)
399 __glibcxx_check_string_len(__s, __n);
406 assign(
const _CharT* __s)
408 __glibcxx_check_string(__s);
415 assign(size_type __n, _CharT __c)
422 template<
typename _InputIterator>
424 assign(_InputIterator __first, _InputIterator __last)
426 __glibcxx_check_valid_range(__first, __last);
433 #ifdef __GXX_EXPERIMENTAL_CXX0X__
441 #endif // __GXX_EXPERIMENTAL_CXX0X__
453 size_type __pos2, size_type __n)
461 insert(size_type __pos,
const _CharT* __s, size_type __n)
463 __glibcxx_check_string(__s);
470 insert(size_type __pos,
const _CharT* __s)
472 __glibcxx_check_string(__s);
479 insert(size_type __pos, size_type __n, _CharT __c)
496 insert(
iterator __p, size_type __n, _CharT __c)
503 template<
typename _InputIterator>
505 insert(
iterator __p, _InputIterator __first, _InputIterator __last)
513 #ifdef __GXX_EXPERIMENTAL_CXX0X__
521 #endif // __GXX_EXPERIMENTAL_CXX0X__
524 erase(size_type __pos = 0, size_type __n =
_Base::npos)
553 replace(size_type __pos1, size_type __n1,
const basic_string& __str)
561 replace(size_type __pos1, size_type __n1,
const basic_string& __str,
562 size_type __pos2, size_type __n2)
570 replace(size_type __pos, size_type __n1,
const _CharT* __s,
573 __glibcxx_check_string_len(__s, __n2);
580 replace(size_type __pos, size_type __n1,
const _CharT* __s)
582 __glibcxx_check_string(__s);
589 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
609 __glibcxx_check_string_len(__s, __n);
619 __glibcxx_check_string(__s);
634 template<
typename _InputIterator>
637 _InputIterator __j1, _InputIterator __j2)
640 __glibcxx_check_valid_range(__j1, __j2);
646 #ifdef __GXX_EXPERIMENTAL_CXX0X__
655 #endif // __GXX_EXPERIMENTAL_CXX0X__
658 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const
660 __glibcxx_check_string_len(__s, __n);
693 find(
const basic_string& __str, size_type __pos = 0)
const
697 find(
const _CharT* __s, size_type __pos, size_type __n)
const
699 __glibcxx_check_string(__s);
704 find(
const _CharT* __s, size_type __pos = 0)
const
706 __glibcxx_check_string(__s);
711 find(_CharT __c, size_type __pos = 0)
const
719 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
721 __glibcxx_check_string_len(__s, __n);
726 rfind(
const _CharT* __s, size_type __pos =
_Base::npos)
const
728 __glibcxx_check_string(__s);
733 rfind(_CharT __c, size_type __pos =
_Base::npos)
const
737 find_first_of(
const basic_string& __str, size_type __pos = 0)
const
741 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
743 __glibcxx_check_string(__s);
748 find_first_of(
const _CharT* __s, size_type __pos = 0)
const
750 __glibcxx_check_string(__s);
755 find_first_of(_CharT __c, size_type __pos = 0)
const
764 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
766 __glibcxx_check_string(__s);
771 find_last_of(
const _CharT* __s, size_type __pos =
_Base::npos)
const
773 __glibcxx_check_string(__s);
778 find_last_of(_CharT __c, size_type __pos =
_Base::npos)
const
782 find_first_not_of(
const basic_string& __str, size_type __pos = 0)
const
786 find_first_not_of(
const _CharT* __s, size_type __pos, size_type __n)
const
788 __glibcxx_check_string_len(__s, __n);
793 find_first_not_of(
const _CharT* __s, size_type __pos = 0)
const
795 __glibcxx_check_string(__s);
800 find_first_not_of(_CharT __c, size_type __pos = 0)
const
809 find_last_not_of(
const _CharT* __s, size_type __pos, size_type __n)
const
811 __glibcxx_check_string(__s);
816 find_last_not_of(
const _CharT* __s, size_type __pos =
_Base::npos)
const
818 __glibcxx_check_string(__s);
823 find_last_not_of(_CharT __c, size_type __pos =
_Base::npos)
const
827 substr(size_type __pos = 0, size_type __n =
_Base::npos)
const
835 compare(size_type __pos1, size_type __n1,
840 compare(size_type __pos1, size_type __n1,
const basic_string& __str,
841 size_type __pos2, size_type __n2)
const
845 compare(
const _CharT* __s)
const
847 __glibcxx_check_string(__s);
854 compare(size_type __pos1, size_type __n1,
const _CharT* __s)
const
856 __glibcxx_check_string(__s);
863 compare(size_type __pos1, size_type __n1,
const _CharT* __s,
864 size_type __n2)
const
866 __glibcxx_check_string_len(__s, __n2);
871 _M_base() {
return *
this; }
874 _M_base()
const {
return *
this; }
879 template<
typename _CharT,
typename _Traits,
typename _Allocator>
885 template<
typename _CharT,
typename _Traits,
typename _Allocator>
886 inline basic_string<_CharT,_Traits,_Allocator>
887 operator+(
const _CharT* __lhs,
888 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
890 __glibcxx_check_string(__lhs);
891 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
894 template<
typename _CharT,
typename _Traits,
typename _Allocator>
895 inline basic_string<_CharT,_Traits,_Allocator>
896 operator+(_CharT __lhs,
897 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
898 {
return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
900 template<
typename _CharT,
typename _Traits,
typename _Allocator>
901 inline basic_string<_CharT,_Traits,_Allocator>
902 operator+(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
905 __glibcxx_check_string(__rhs);
906 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
909 template<
typename _CharT,
typename _Traits,
typename _Allocator>
910 inline basic_string<_CharT,_Traits,_Allocator>
911 operator+(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
913 {
return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
915 template<
typename _CharT,
typename _Traits,
typename _Allocator>
917 operator==(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
918 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
919 {
return __lhs._M_base() == __rhs._M_base(); }
921 template<
typename _CharT,
typename _Traits,
typename _Allocator>
923 operator==(
const _CharT* __lhs,
924 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
926 __glibcxx_check_string(__lhs);
927 return __lhs == __rhs._M_base();
930 template<
typename _CharT,
typename _Traits,
typename _Allocator>
932 operator==(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
935 __glibcxx_check_string(__rhs);
936 return __lhs._M_base() == __rhs;
939 template<
typename _CharT,
typename _Traits,
typename _Allocator>
941 operator!=(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
942 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
943 {
return __lhs._M_base() != __rhs._M_base(); }
945 template<
typename _CharT,
typename _Traits,
typename _Allocator>
947 operator!=(
const _CharT* __lhs,
948 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
950 __glibcxx_check_string(__lhs);
951 return __lhs != __rhs._M_base();
954 template<
typename _CharT,
typename _Traits,
typename _Allocator>
956 operator!=(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
959 __glibcxx_check_string(__rhs);
960 return __lhs._M_base() != __rhs;
963 template<
typename _CharT,
typename _Traits,
typename _Allocator>
965 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
966 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
967 {
return __lhs._M_base() < __rhs._M_base(); }
969 template<
typename _CharT,
typename _Traits,
typename _Allocator>
971 operator<(
const _CharT* __lhs,
972 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
974 __glibcxx_check_string(__lhs);
975 return __lhs < __rhs._M_base();
978 template<
typename _CharT,
typename _Traits,
typename _Allocator>
980 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
983 __glibcxx_check_string(__rhs);
984 return __lhs._M_base() < __rhs;
987 template<
typename _CharT,
typename _Traits,
typename _Allocator>
989 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
990 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
991 {
return __lhs._M_base() <= __rhs._M_base(); }
993 template<
typename _CharT,
typename _Traits,
typename _Allocator>
995 operator<=(
const _CharT* __lhs,
996 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
998 __glibcxx_check_string(__lhs);
999 return __lhs <= __rhs._M_base();
1002 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1004 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1005 const _CharT* __rhs)
1007 __glibcxx_check_string(__rhs);
1008 return __lhs._M_base() <= __rhs;
1011 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1013 operator>=(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1014 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1015 {
return __lhs._M_base() >= __rhs._M_base(); }
1017 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1019 operator>=(
const _CharT* __lhs,
1020 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1022 __glibcxx_check_string(__lhs);
1023 return __lhs >= __rhs._M_base();
1026 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1028 operator>=(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1029 const _CharT* __rhs)
1031 __glibcxx_check_string(__rhs);
1032 return __lhs._M_base() >= __rhs;
1035 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1037 operator>(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1038 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1039 {
return __lhs._M_base() > __rhs._M_base(); }
1041 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1043 operator>(
const _CharT* __lhs,
1044 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1046 __glibcxx_check_string(__lhs);
1047 return __lhs > __rhs._M_base();
1050 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1052 operator>(
const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1053 const _CharT* __rhs)
1055 __glibcxx_check_string(__rhs);
1056 return __lhs._M_base() > __rhs;
1060 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1062 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
1063 basic_string<_CharT,_Traits,_Allocator>& __rhs)
1064 { __lhs.swap(__rhs); }
1066 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1068 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1069 const basic_string<_CharT, _Traits, _Allocator>& __str)
1070 {
return __os << __str._M_base(); }
1072 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1075 basic_string<_CharT,_Traits,_Allocator>& __str)
1078 __str._M_invalidate_all();
1082 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1085 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
1090 __str._M_invalidate_all();
1094 template<
typename _CharT,
typename _Traits,
typename _Allocator>
1097 basic_string<_CharT,_Traits,_Allocator>& __str)
1101 __str._M_invalidate_all();
1105 typedef basic_string<char> string;
1107 #ifdef _GLIBCXX_USE_WCHAR_T
1108 typedef basic_string<wchar_t> wstring;
#define __glibcxx_check_insert_range(_Position, _First, _Last)
void push_back(_CharT __c)
Append a single character.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
allocator_type get_allocator() const
Return copy of allocator used to construct this string.
Controlling output.This is the base class for all output streams. It provides text formatting of all ...
size_type find_first_of(const basic_string &__str, size_type __pos=0) const
Find position of a character of string.
void shrink_to_fit()
A non-binding request to reduce capacity() to size().
int compare(const basic_string &__str) const
Compare to a string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
Class std::basic_string with safety/checking/debug instrumentation.
void _M_swap(_Safe_sequence_base &__x)
#define __glibcxx_check_insert(_Position)
size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Find position of a C substring.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
const _CharT * data() const
Return const pointer to contents.
bitset< _Nb > operator>>(size_t __position) const
Self-explanatory.
void swap(basic_string &__s)
Swap contents with another string.
void _M_invalidate_all() const
Controlling input.This is the base class for all input streams. It provides text formatting of all bu...
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const
Find position of a character not in string.
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.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const
Find last position of a character of string.
#define __glibcxx_check_erase(_Position)
size_type max_size() const
Returns the size() of the largest possible string.
size_type size() const
Returns the number of characters in the string, not including any null-termination.
Managing sequences of characters and character-like objects.
size_type rfind(const basic_string &__str, size_type __pos=npos) const
Find last position of a string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
size_type capacity() const
const _CharT * __check_string(const _CharT *__s, const _Integer &__n __attribute__((__unused__)))
Base class for constructing a safe sequence type that tracks iterators that reference it...
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
#define _GLIBCXX_DEBUG_VERIFY(_Condition, _ErrorMessage)
_Iterator base() const
Return the underlying iterator.
basic_string & append(const basic_string &__str)
Append a string to this string.
static const size_type npos
Value returned by various member functions when they fail.
const _CharT * c_str() const
Return const pointer to null-terminated contents.
size_type length() const
Returns the number of characters in the string, not including any null-termination.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const
Find last position of a character not in string.
basic_string()
Default constructor creates an empty string.
#define __glibcxx_check_erase_range(_First, _Last)
basic_string & assign(const basic_string &__str)
Set value to contents of another string.