📄 string
字号:
#endif // _RWSTD_NO_MEMBER_TEMPLATES
basic_string& append (size_type __n, value_type __c) {
return replace (size (), 0, __n, __c);
}
void push_back (value_type __c) {
append (size_type (1), __c);
}
basic_string& assign (const basic_string &__str) {
return *this = __str;
}
basic_string& assign (const basic_string&, size_type, size_type);
basic_string& assign (const_pointer __s, size_type __n) {
return replace (0, size (), __s, __n, 0, __n), *this;
}
basic_string& assign (const_pointer __s) {
return *this = __s;
}
#if !defined (_RWSTD_NO_MEMBER_TEMPLATES) \
&& !defined (_RWSTD_NO_CLASS_PARTIAL_SPEC)
template<class _InputIterator>
basic_string& assign (_InputIterator __first, _InputIterator __last) {
// resolves to assign (size_type, value_type) if _InputIterator
// is any integral type (even not an exact match, such as char)
// the cast to int is necessary to prevent an exact match
return assign (__first, __last, _RWSTD_DISPATCH (_InputIterator));
}
template<class _InputIterator>
basic_string& assign (_InputIterator __first, _InputIterator __last,
_RWSTD_DISPATCH_INT (false)) {
// unnamed arg is used for overload resolution
// _RWSTD_COMPILE_ASSERT (sizeof (*__first));
return replace (_C_make_iter (_C_data),
_C_make_iter (_C_data + size ()), __first, __last);
}
basic_string& assign (size_type __n, value_type __c,
_RWSTD_DISPATCH_INT (true)) {
// unnamed arg is used for overload resolution
return replace (0, size (), __n, __c);
}
#else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
basic_string& assign (const_pointer __first, const_pointer __last) {
replace (size_type (), size (), __first,
__last - __first, size_type (), __last - __first);
return *this;
}
#endif // _RWSTD_NO_MEMBER_TEMPLATES
basic_string& assign (size_type __n, value_type __c) {
return replace (0, size (), __n, __c);
}
basic_string& insert (size_type, const basic_string&);
basic_string& insert (size_type, const basic_string&,
size_type, size_type);
basic_string& insert (size_type __pos, const_pointer __s, size_type __n) {
return replace (__pos, 0, __s, __n, 0, __n), *this;
}
basic_string& insert (size_type __pos, const_pointer __s) {
return insert (__pos, __s, traits_type::length (__s));
}
// 21.3.5.4, p10
iterator insert (iterator __pos, value_type __c) {
_RWSTD_ASSERT_RANGE (_C_make_iter (_C_data), __pos);
size_type __inx = __pos - _C_make_iter (_C_data);
return insert (__inx, &__c, 1), begin () + __inx;
}
#if !defined (_RWSTD_NO_MEMBER_TEMPLATES) \
&& !defined (_RWSTD_NO_CLASS_PARTIAL_SPEC)
template<class _InputIterator>
void insert (iterator __p,
_InputIterator __first, _InputIterator __last) {
// resolves to insert (iterator, size_type, value_type)
// if _InputIterator is any integral type (even not an exact match,
// such as char)
// the cast to int is necessary to avoid an exact match
insert (__p, __first, __last, _RWSTD_DISPATCH (_InputIterator));
}
void insert (iterator __p, const_iterator __first, const_iterator __last) {
iterator __begin = _C_make_iter (_C_data);
iterator __end = _C_make_iter (_C_data + size ());
_RWSTD_ASSERT_RANGE (__begin, __p);
if (__first >= __begin && __first <= __end)
insert (__p - __begin, basic_string (__first, __last));
else
replace (__p, __p, __first, __last);
}
void insert (iterator __p, iterator __first, iterator __last) {
insert (__p, const_iterator (__first), const_iterator (__last));
}
template <class _InputIterator>
void insert (iterator __p, _InputIterator __first, _InputIterator __last,
_RWSTD_DISPATCH_INT (false)) {
// unnamed arg is used for overload resolution
// _RWSTD_COMPILE_ASSERT (sizeof (*__first));
replace (__p, __p, __first, __last);
}
void insert (iterator __p, size_type __n, value_type __c,
_RWSTD_DISPATCH_INT (true)) {
// unnamed arg is used for overload resolution
replace (__p - _C_make_iter (_C_data), 0, __n, __c);
}
#else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
void insert (iterator __p, const_pointer __first, const_pointer __last) {
replace (__p - _C_make_iter (_C_data), 0, __first,
__last - __first, 0, __last - __first);
}
#endif // _RWSTD_NO_MEMBER_TEMPLATES
void insert (iterator __p, size_type __n, value_type __c) {
replace (__p - _C_make_iter (_C_data), 0, __n, __c);
}
basic_string& insert (size_type __pos, size_type __n, value_type __c) {
return replace (__pos, 0, __n, __c);
}
basic_string& erase (size_type = 0, size_type = npos);
iterator erase (iterator __it) {
return replace (__it - _C_make_iter (_C_data), 1,
const_pointer (0), 0, 0, 0);
}
iterator erase (iterator __first, iterator __last) {
return replace (__first - _C_make_iter (_C_data), __last - __first,
const_pointer (0), 0, 0, 0);
}
private:
iterator replace (size_type, size_type, const_pointer,
size_type, size_type, size_type);
iterator __replace_aux (size_type pos1, size_type __n1,
const basic_string &__str,
size_type pos2 = 0,
size_type __n2 = npos) {
return replace (pos1, __n1, __str.c_str(), __str.size(), pos2, __n2);
}
#ifndef _RWSTD_NO_MEMBER_TEMPLATES
template<class _InputIterator>
basic_string& __replace_aux (iterator first1,
iterator last1,
_InputIterator first2,
_InputIterator last2);
#endif // _RWSTD_NO_MEMBER_TEMPLATES
public:
basic_string& replace (size_type pos1, size_type __n1,
const basic_string &__s,
size_type pos2, size_type __n2) {
replace (pos1, __n1, __s.c_str (), __s.size (), pos2, __n2);
return *this;
}
basic_string& replace (size_type __pos, size_type __n,
const basic_string &__s) {
return replace (__pos, __n, __s, 0, __s.size ());
}
basic_string& replace (size_type __pos, size_type __n1, const_pointer __s,
size_type __n2) {
return replace (__pos, __n1, __s, __n2, 0, __n2), *this;
}
basic_string& replace (size_type __pos, size_type __n, const_pointer __s) {
return replace (__pos, __n, __s, traits_type::length (__s));
}
basic_string& replace (size_type, size_type, size_type, value_type);
basic_string& replace (iterator __first, iterator __last,
const basic_string &__str) {
return replace (__first - _C_make_iter (_C_data),
__last - __first, __str);
}
basic_string& replace (iterator __first, iterator __last,
const_pointer __s, size_type __n) {
replace (__first - _C_make_iter (_C_data), __last - __first,
__s, __n, 0, __n);
return *this;;
}
basic_string&
replace (iterator __first, iterator __last, const_pointer __s) {
return replace (__first, __last, __s, traits_type::length(__s));
}
#if !defined (_RWSTD_NO_MEMBER_TEMPLATES) \
&& !defined (_RWSTD_NO_CLASS_PARTIAL_SPEC)
template<class _InputIterator>
basic_string& replace (iterator, iterator,
_InputIterator, _InputIterator,
_RWSTD_DISPATCH_INT (false));
basic_string& replace (iterator __first, iterator __last,
size_type __n, value_type __c,
_RWSTD_DISPATCH_INT (true)) {
// unnamed arg is used for overload resolution
return replace (__first - _C_make_iter (_C_data), __last - __first,
__n, __c);
}
template<class _InputIterator>
basic_string& replace (iterator __first1, iterator __last1,
_InputIterator __first2, _InputIterator __last2) {
// resolves to replace (iterator, iterator, size_type, value_type)
// if _InputIterator is any integral type (even not an exact match,
// Such as char)
// the cast to int is necessary to prevent an exact match
return replace (__first1, __last1, __first2, __last2,
_RWSTD_DISPATCH (_InputIterator));
}
#else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
basic_string& replace (iterator first1, iterator last1,
const_pointer first2, const_pointer last2) {
return replace (first1 - _C_make_iter (_C_data), last1 - first1,
first2, last2 - first2, 0, last2 - first2), *this;
}
#endif // _RWSTD_NO_MEMBER_TEMPLATES
basic_string& replace (iterator __first, iterator __last,
size_type __n, value_type __c) {
// unnamed arg is used for overload resolution
return replace (__first - _C_make_iter (_C_data), __last - __first,
__n, __c);
}
size_type copy (pointer, size_type, size_type = 0) const;
#ifndef _RWSTD_NO_EXT_DEEP_STRING_COPY
basic_string copy () const {
return basic_string (data (), data () + size ());
}
#endif //_RWSTD_NO_EXT_DEEP_STRING_COPY
void swap (basic_string &__s) {
if (get_allocator () == __s.get_allocator ()) {
pointer __temp = _C_data;
_C_data = __s._C_data;
__s._C_data = __temp;
}
else {
basic_string __tmp = *this;
*this = __s;
__s = __tmp;
}
}
//
// string operations
//
const_pointer c_str () const {
return _C_data;
}
const_pointer data () const {
return _C_data;
}
allocator_type get_allocator() const {
return *this;
}
// 21.3.6.1, p1
size_type find (const basic_string &__str, size_type __pos = 0) const {
return find (__str.c_str (), __pos, __str.size ());
}
// 21.3.6.1, p4
size_type find (const_pointer, size_type, size_type) const;
// 21.3.6.1, p5
size_type find (const_pointer, size_type = 0) const;
// 21.3.6.1, p7
size_type find (value_type, size_type = 0) const;
// 21.3.6.2, p1
size_type rfind (const basic_string &__str, size_type __pos = npos) const {
return rfind (__str.c_str (), __pos, __str.size ());
}
// 21.3.6.2, p4
size_type rfind (const_pointer, size_type, size_type) const;
// 21.3.6.2, p5
size_type rfind (const_pointer __s, size_type __pos = npos) const {
return rfind (__s, __pos, traits_type::length (__s));
}
// 21.3.6.2, p7
size_type rfind (value_type, size_type = npos) const;
// 21.3.6.3, p1
size_type find_first_of (const basic_string &__str,
size_type __pos = 0) const {
return find_first_of (__str.c_str (), __pos, __str.size ());
}
// 21.3.6.3, p4
size_type find_first_of (const_pointer, size_type, size_type) const;
// 21.3.6.3, p5
size_type find_first_of (const_pointer, size_type = 0) const;
// 21.3.6.3, p6
size_type find_first_of (value_type __c, size_type __pos = 0) const {
return find (__c, __pos);
}
// 21.3.6.4, p1
size_type find_last_of (const basic_string &__str,
size_type __pos = npos) const {
return find_last_of (__str.c_str (), __pos, __str.size ());
}
// 21.3.6.4, p4
size_type find_last_of (const_pointer, size_type, size_type) const;
// 21.3.6.4, p5
size_type find_last_of (const_pointer __s, size_type __pos = npos) const {
return find_last_of (__s, __pos, traits_type::length (__s));
}
// 21.3.6.4, p7
size_type find_last_of (value_type __c, size_type __pos = npos) const {
return rfind (__c, __pos);
}
// 21.3.6.5, p1
size_type find_first_not_of (const basic_string &__str,
size_type __pos = 0) const {
return find_first_not_of (__str.c_str (), __pos, __str.size ());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -