📄 string.htm
字号:
<html>
<head>
<title>basic_string</title>
</head>
<body bgcolor="#FFFFFF">
<a name="here"></a>
<img src="strgban.gif">
<pre>
<font size=5>Class Name</font> basic_string
<font size=5>Header File</font> <string>
<font size=5>Classification</font> abstract data type
</pre>
<a href="string.htm#crd">Class Relationship Diagram</a><br>
<br>
<a href="string.htm#class-descrip">Class Description</a>
<h1>Member Classes</h1>
<p>
None
</p>
<h1>Methods</h1>
<pre>
<a href="string.htm#append1">
basic_string& append(const basic_string& str);</a>
<a href="string.htm#append2">
basic_string& append(const basic_string& str, size_type pos,
size_type n);</a>
<a href="string.htm#append3">
basic_string& append(const charT* s, size_type n);</a>
<a href="string.htm#append4">
basic_string& append(const charT* s);</a>
<a href="string.htm#append5">
basic_string& append(size_type n, charT c);</a>
<a href="string.htm#append6">
template<class InputIterator>
basic_string& append(InputIterator first, InputIterator last);</a>
<a href="string.htm#assign1">
basic_string& assign(const basic_string&);</a>
<a href="string.htm#assign2">
basic_string& assign(const basic_string& str, size_type pos,
size_type n);</a>
<a href="string.htm#assign3">
basic_string& assign(const charT* s, size_type n);</a>
<a href="string.htm#assign4">
basic_string& assign(const charT* s);</a>
<a href="string.htm#assign5">
basic_string& assign(size_type n, charT c);</a>
<a href="string.htm#assign6">
template<class InputIterator>
basic_string& assign(InputIterator first, InputIterator last);</a>
<a href="string.htm#at2">
reference at(size_type pos);</a>
<a href="string.htm#at1">
const_reference at(size_type pos) const;</a>
<a href="string.htm#basic_string1">
explicit basic_string(const Allocator& a = Allocator());</a>
<a href="string.htm#basic_string2">
basic_string(const basic_string& str, size_type pos = 0,
size_type n = npos, const Allocator& a = Allocator());</a>
<a href="string.htm#basic_string3">
basic_string(const charT* s, size_type n,
const Allocator& a =Allocator());</a>
<a href="string.htm#basic_string4">
basic_string(const charT* s, const Allocator& a = Allocator());</a>
<a href="string.htm#basic_string5">
basic_string(size_type n, charT c, const Allocator& a = Allocator());</a>
<a href="string.htm#basic_string6">
template<class InputIterator>basic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());</a>
<a href="string.htm#~basic_string">
~basic_string();</a>
<a href="string.htm#begin1">
iterator begin();</a>
<a href="string.htm#begin2">
const_iterator begin() const;</a>
<a href="string.htm#c_str">
const charT* c_str() const;</a>
<a href="string.htm#capacity">
size_type capacity() const;</a>
<a href="string.htm#clear">
void clear();</a>
<a href="string.htm#compare1">
int compare(const basic_string& str) const;</a>
<a href="string.htm#compare2">
int compare(size_type pos1, size_type n1,
const basic_string& str) const;</a>
<a href="string.htm#compare3">
int compare(size_type pos1, size_type n1, const basic_string& str,
size_type pos2, size_type n2) const;</a>
<a href="string.htm#compare4">
int compare(const charT* s) const;</a>
<a href="string.htm#compare5">
int compare(size_type pos1, size_type n1,
const charT* s, size_type n2 = npos) const;</a>
<a href="string.htm#copy">
size_type copy(charT* s, size_type n, size_type pos = 0) const;</a>
<a href="string.htm#data">
const charT* data() const;</a>
<a href="string.htm#empty">
bool empty() const;</a>
<a href="string.htm#end1">
iterator end();</a>
<a href="string.htm#end2">
const_iterator end() const;</a>
<a href="string.htm#erase1">
basic_string& erase(size_type pos = 0, size_type n = npos);</a>
<a href="string.htm#erase2">
iterator erase(iterator position);</a>
<a href="string.htm#erase3">
iterator erase(iterator first, iterator last);</a>
<a href="string.htm#find1">
size_type find(const basic_string& str, size_type pos = 0) const;</a>
<a href="string.htm#find2">
size_type find(const charT* s, size_type pos, size_type n) const;</a>
<a href="string.htm#find3">
size_type find(const charT* s, size_type pos = 0) const;</a>
<a href="string.htm#find4">
size_type find(charT c, size_type pos = 0) const;</a>
<a href="string.htm#find-first-not-of1">
size_type find_first_not_of(const basic_string& str,
size_type pos = 0) const;</a>
<a href="string.htm#find-first-not-of2">
size_type find_first_not_of(const charT* s, size_type pos,
size_type n) const;</a>
<a href="string.htm#find-first-not-of3">
size_type find_first_not_of(const charT* s, size_type pos = 0) const;</a>
<a href="string.htm#find-first-not-of4">
size_type find_first_not_of(charT c, size_type pos = 0) const;</a>
<a href="string.htm#find-first-of1">
size_type find_first_of(const basic_string& str,
size_type pos = 0) const;</a>
<a href="string.htm#find-first-of2">
size_type find_first_of(const charT* s, size_type pos,
size_type n) const;</a>
<a href="string.htm#find-first-of3">
size_type find_first_of(const charT* s, size_type pos = 0) const;</a>
<a href="string.htm#find-first-of4">
size_type find_first_of(charT c, size_type pos = 0) const;</a>
<a href="string.htm#find-last-not-of1">
size_type find_last_not_of (const basic_string& str,
size_type pos = npos) const;</a>
<a href="string.htm#find-last-not-of2">
size_type find_last_not_of (const charT* s, size_type pos,
size_type n) const;</a>
<a href="string.htm#find-last-not-of3">
size_type find_last_not_of (const charT* s,
size_type pos = npos) const;</a>
<a href="string.htm#find-last-not-of4">
size_type find_last_not_of (charT c, size_type pos = npos) const;</a>
<a href="string.htm#find-last-of1">
size_type find_last_of (const basic_string& str,
size_type pos = npos) const;</a>
<a href="string.htm#find-last-of2">
size_type find_last_of (const charT* s, size_type pos,
size_type n) const;</a>
<a href="string.htm#find-last-of3">
size_type find_last_of (const charT* s, size_type pos = npos) const;</a>
<a href="string.htm#find-last-of4">
size_type find_last_of (charT c, size_type pos = npos) const;</a>
<a href="string.htm#get-allocator">
allocator_type get_allocator() const;</a>
<a href="string.htm#insert1">
basic_string& insert(size_type pos1, const basic_string& str);</a>
<a href="string.htm#insert2">
basic_string& insert(size_type pos1, const basic_string& str,
size_type pos2, size_type n);</a>
<a href="string.htm#insert3">
basic_string& insert(size_type pos, const charT* s, size_type n);</a>
<a href="string.htm#insert4">
basic_string& insert(size_type pos, const charT* s);</a>
<a href="string.htm#insert5">
basic_string& insert(size_type pos, size_type n, charT c);</a>
<a href="string.htm#insert6">
iterator insert(iterator p, charT c = charT());</a>
<a href="string.htm#insert7">
void insert(iterator p, size_type n, charT c);</a>
<a href="string.htm#insert8">
template<class InputIterator>
void insert(iterator p, InputIterator first, InputIterator last);</a>
<a href="string.htm#length">
size_type length() const;</a>
<a href="string.htm#max-size">
size_type max_size() const;</a>
<a href="string.htm#rbegin1">
reverse_iterator rbegin();</a>
<a href="string.htm#rbegin2">
const_reverse_iterator rbegin() const;</a>
<a href="string.htm#rend1">
reverse_iterator rend();</a>
<a href="string.htm#rend2">
const_reverse_iterator rend() const;</a>
<a href="string.htm#replace1">
basic_string& replace(size_type pos1, size_type n1,
const basic_string& str);</a>
<a href="string.htm#replace2">
basic_string& replace(size_type pos1, size_type n1,
const basic_string& str, size_type pos2, size_type n2);</a>
<a href="string.htm#replace3">
basic_string& replace(size_type pos1, size_type n1, const charT* s,
size_type n2);</a>
<a href="string.htm#replace4">
basic_string& replace(size_type pos1, size_type n1, const charT* s);</a>
<a href="string.htm#replace5">
basic_string& replace(size_type pos, size_type n1, size_type n2,
charT c);</a>
<a href="string.htm#replace6">
basic_string& replace(iterator i1, iterator i2,
const basic_string& str);</a>
<a href="string.htm#replace7">
basic_string& replace(iterator i1, iterator i2, const charT* s,
size_type n);</a>
<a href="string.htm#replace8">
basic_string& replace(iterator i1, iterator i2, const charT* s);</a>
<a href="string.htm#replace9">
basic_string& replace(iterator i1, iterator i2, size_type n, charT c);</a>
<a href="string.htm#replace10">
template<class InputIterator>
basic_string& replace(iterator i1, iterator i2,
InputIterator j1, InputIterator j2);</a>
<a href="string.htm#reserve">
void reserve(size_type res_arg = 0);</a>
<a href="string.htm#resize1">
void resize(size_type n, charT c);</a>
<a href="string.htm#resize2">
void resize(size_type n);</a>
<a href="string.htm#rfind1">
size_type rfind(const basic_string& str, size_type pos = npos) const;</a>
<a href="string.htm#rfind2">
size_type rfind(const charT* s, size_type pos, size_type n) const;</a>
<a href="string.htm#rfind3">
size_type rfind(const charT* s, size_type pos = npos) const;</a>
<a href="string.htm#rfind4">
size_type rfind(charT c, size_type pos = npos) const;</a>
<a href="string.htm#size">
size_type size() const;</a>
<a href="string.htm#substr">
basic_string substr(size_type pos = 0, size_type n = npos) const;</a>
<a href="string.htm#swap">
void swap(basic_string<charT,traits,Allocator>&);</a>
</pre>
<h1>Operators</h1>
<pre>
<a href="string.htm#operator+=1">
basic_string& operator+=(const basic_string& str);</a>
<a href="string.htm#operator+=2">
basic_string& operator+=(const charT* s);</a>
<a href="string.htm#operator+=3">
basic_string& operator+=(charT c);</a>
<a href="string.htm#operator=1">
basic_string& operator=(const basic_string& str);</a>
<a href="string.htm#operator=2">
basic_string& operator=(const charT* s);</a>
<a href="string.htm#operator=3">
basic_string& operator=(charT c);</a>
<a href="string.htm#operator[]1">
const_reference operator[](size_type pos) const;</a>
<a href="string.htm#operator[]2">
reference operator[](size_type pos);</a>
</pre>
<a href="string.htm#example"><h2>Example</h2></a>
<hr>
<a name="class-descrip"><h3>Class Description</h3></a>
<p>
A template class that describes an object that stores a sequence of varying
length characters. The characters can be of an arbitrary char-like objects.
The first object in the sequence is at position zero. The storage for
basic_string will be allocated and freed by the member functions. The
basic_string class supports random access iterators.
</p>
<hr>
<pre>
<a name="operator+=1">
Method operator+=()</a>
Access Public
Classification Operator
Syntax basic_string& operator+=(const basic_string& str);
Parameters <em>str</em> contains the character sequence that is
to be appended to the character sequence of the
calling object.
Returns This operator returns a pointer to the calling object.
</pre>
<h3>Description</h3>
<p>
The operator+=() appends basic_string <em>str</em>'s character sequence to the character
sequence of the current object. The operator returns *this.
</p>
<hr>
<pre>
<a name="operator+=2">
Method operator+=()</a>
Access Public
Classification Operator
Syntax basic_string& operator+=(const charT* s);
Parameters <em>s</em> points to a character array that is to be
appended to the character sequence of the calling object.
Returns This operator returns a pointer to the calling object.
</pre>
<h3>Description</h3>
<p>
The operator+=() appends the character array pointed to by <em>s</em> to the character sequence
of the current object. The operator returns *this.
</p>
<hr>
<pre>
<a name="operator+=3">
Method operator+=()</a>
Access Public
Classification Operator
Syntax basic_string& operator+=(charT c);
Parameters <em>c</em> is the character to be appended to the
character sequence of the calling object.
Returns This operator returns a pointer to the calling object.
</pre>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -