⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic_string.html

📁 STL_doc
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;basic_string&lt;charT, traits, Alloc&gt;operator+(charT c,          const basic_string&lt;charT, traits, Alloc&gt;&amp; s2)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>String concatenation.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;basic_string&lt;charT, traits, Alloc&gt;operator+(const basic_string&lt;charT, traits, Alloc&gt;&amp; s1,          charT c)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>String concatenation.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator==(const basic_string&lt;charT, traits, Alloc&gt;&amp; s1,                const basic_string&lt;charT, traits, Alloc&gt;&amp; s2)</pre></TD><TD VAlign=top> <A href="Container.html">Container</A></TD><TD VAlign=top>String equality.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator==(const charT* s1,                 const basic_string&lt;charT, traits, Alloc&gt;&amp; s2)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>String equality.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator==(const basic_string&lt;charT, traits, Alloc&gt;&amp; s1,                const charT* s2)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>String equality.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator!=(const basic_string&lt;charT, traits, Alloc&gt;&amp; s1,                const basic_string&lt;charT, traits, Alloc&gt;&amp; s2)</pre></TD><TD VAlign=top> <A href="Container.html">Container</A></TD><TD VAlign=top>String inequality.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator!=(const charT* s1,                 const basic_string&lt;charT, traits, Alloc&gt;&amp; s2)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>String inequality.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator!=(const basic_string&lt;charT, traits, Alloc&gt;&amp; s1,                const charT* s2)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>String inequality.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator&lt;(const basic_string&lt;charT, traits, Alloc&gt;&amp; s1,               const basic_string&lt;charT, traits, Alloc&gt;&amp; s2)</pre></TD><TD VAlign=top> <A href="Container.html">Container</A></TD><TD VAlign=top>String comparison.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator&lt;(const charT* s1,                const basic_string&lt;charT, traits, Alloc&gt;&amp; s2)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>String comparison.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;bool operator&lt;(const basic_string&lt;charT, traits, Alloc&gt;&amp; s1,               const charT* s2)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>String comparison.  A global function, not a member function.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;void swap(basic_string&lt;charT, traits, Alloc&gt;&amp; s1,          basic_string&lt;charT, traits, Alloc&gt;&amp; s2)</pre></TD><TD VAlign=top> <A href="Container.html">Container</A></TD><TD VAlign=top>Swaps the contents of two strings.</TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;basic_istream&lt;charT, traits&gt;&amp;operator&gt;&gt;(basic_istream&lt;charT, traits&gt;&amp; is,           basic_string&lt;charT, traits, Alloc&gt;&amp; s)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>Reads <tt>s</tt> from the input stream <tt>is</tt></TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;basic_ostream&lt;charT, traits&gt;&amp;operator&lt;&lt;(basic_istream&lt;charT, traits&gt;&amp; os,           const basic_string&lt;charT, traits, Alloc&gt;&amp; s)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>Writes <tt>s</tt> to the output stream <tt>os</tt></TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;basic_istream&lt;charT, traits&gt;&amp;getline(basic_istream&lt;charT, traits&gt;&amp; is,        basic_string&lt;charT, traits, Alloc&gt;&amp; s,        charT delim)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>Reads a string from the input stream <tt>is</tt>, stopping when it reaches <tt>delim</tt></TD></TR><TR><TD VAlign=top><pre>template &lt;class charT, class traits, class Alloc&gt;basic_istream&lt;charT, traits&gt;&amp;getline(basic_istream&lt;charT, traits&gt;&amp; is,        basic_string&lt;charT, traits, Alloc&gt;&amp; s)</pre></TD><TD VAlign=top><tt>basic_string</tt></TD><TD VAlign=top>Reads a single line from the input stream <tt>is</tt></TD></tr></table><h3>New members</h3>These members are not defined in the <A href="RandomAccessContainer.html">Random Access Container</A> and <A href="Sequence.html">Sequence</A>:requirements, but are specific to <tt>basic_string</tt>.<Table border><TR><TH>Member</TH><TH>Description</TH></TR><TR><TD VAlign=top><tt>static const size_type npos</tt></TD><TD VAlign=top>The largest possible value of type <tt>size_type</tt>.  That is,   <tt>size_type(-1)</tt>.</TD></TR><TR><TD VAlign=top><tt>size_type length() const</tt></TD><TD VAlign=top>Equivalent to  <tt>size()</tt>.</TD></TR><TR><TD VAlign=top><tt>size_type capacity() const</tt></TD><TD VAlign=top>Number of elements for which memory has been allocated.  That is,   the size to which the string can grow before memory must be   reallocated.  <tt>capacity()</tt> is always greater than or equal to    <tt>size()</tt>.   </TD></TR><TR><TD VAlign=top><tt>const charT* c_str() const</tt></TD><TD VAlign=top>Returns a pointer to a null-terminated array of characters representing   the string's contents.  For any string <tt>s</tt> it is guaranteed that   the first <tt>s.size()</tt> characters in the array pointed to by <tt>s.c_str()</tt>   are equal to the character in <tt>s</tt>, and that <tt>s.c_str()[s.size()]</tt>    is a null character.  Note, however, that it not necessarily the first    null character.  Characters within a string are permitted to be null.</TD></TR><TR><TD VAlign=top><tt>const charT* data() const</tt></TD><TD VAlign=top>Returns a pointer to an array of characters, not necessarily   null-terminated, representing the string's contents.  <tt>data()</tt>   is permitted, but not required, to be identical to <tt>c_str()</tt>.   The first <tt>size()</tt> characters of that array are guaranteed to be identical   to the characters in <tt>*this</tt>.  The return value of <tt>data()</tt> is never   a null pointer, even if <tt>size()</tt> is zero.</TD></TR><TR><TD VAlign=top><tt>basic_string(const basic_string&amp; s, size_type pos = 0, size_type n = npos)</tt></TD><TD VAlign=top>Constructs a string from a substring of <tt>s</tt>.  The substring begins at   character position <tt>pos</tt> and terminates at character position    <tt>pos + n</tt> or at the end of <tt>s</tt>, whichever comes first.  This constructor   throws <tt>out_of_range</tt> if <tt>pos &gt; s.size()</tt>.  Note that when <tt>pos</tt> and <tt>n</tt>   have their default values, this is just a copy constructor.</TD></TR><TR><TD VAlign=top><tt>basic_string(const charT* s)</tt></TD><TD VAlign=top>Equivalent to <tt>basic_string(s, s + traits::length(s))</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string(const charT* s, size_type n)</tt></TD><TD VAlign=top>Equivalent to <tt>basic_string(s, s + n)</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; operator=(const charT* s)</tt></TD><TD VAlign=top>Equivalent to <tt>operator=(basic_string(s))</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; operator=(charT c)</tt></TD><TD VAlign=top>Assigns to <tt>*this</tt> a string whose size is <tt>1</tt> and whose contents is   the single character <tt>c</tt>.</TD></TR><TR><TD VAlign=top><tt>void reserve(size_t n)</tt></TD><TD VAlign=top>Requests that the string's capacity be changed; the postcondition   for this member function is that, after it is called,    <tt>capacity() &gt;= n</tt>.  You may request that a string decrease its   capacity by calling <tt>reserve()</tt> with an argument less than the   current capacity.  (If you call <tt>reserve()</tt> with an argument less    than the string's size, however, the capacity will only be reduced   to <tt>size()</tt>.  A string's size can never be greater than its capacity.)   <tt>reserve()</tt> throws <tt>length_error</tt> if <tt>n &gt; max_size()</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; insert(size_type pos, const basic_string&amp; s)</tt></TD><TD VAlign=top>If <tt>pos &gt; size()</tt>, throws <tt>out_of_range</tt>.  Otherwise, equivalent to   <tt>insert(begin() + pos, s.begin(), s.end())</tt>.</TD></TR><TR><TD VAlign=top><pre>basic_string&amp; insert(size_type pos,                      const basic_string&amp; s,                      size_type pos1, size_type n)</pre></TD><TD VAlign=top>If <tt>pos &gt; size()</tt> or <tt>pos1 &gt; s.size()</tt>, throws <tt>out_of_range</tt>.  Otherwise,   equivalent to <tt>insert(begin() + pos, s.begin() + pos1, s.begin() + pos1 + min(n, s.size() - pos1))</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; insert(size_type pos, const charT* s)</tt></TD><TD VAlign=top>If <tt>pos &gt; size()</tt>, throws <tt>out_of_range</tt>.  Otherwise, equivalent to   <tt>insert(begin() + pos, s, s + traits::length(s))</tt></TD></TR><TR><TD VAlign=top><tt>basic_string&amp; insert(size_type pos, const charT* s, size_type n)</tt></TD><TD VAlign=top>If <tt>pos &gt; size()</tt>, throws <tt>out_of_range</tt>.  Otherwise, equivalent to   <tt>insert(begin() + pos, s, s + n)</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; insert(size_type pos, size_type n, charT c)</tt></TD><TD VAlign=top>If <tt>pos &gt; size()</tt>, throws <tt>out_of_range</tt>.  Otherwise, equivalent to   <tt>insert(begin() + pos, n, c)</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; append(const basic_string&amp; s)</tt></TD><TD VAlign=top>Equivalent to <tt>insert(end(), s.begin(), s.end())</tt>.</TD></TR><TR><TD VAlign=top><pre>basic_string&amp; append(const basic_string&amp; s,                      size_type pos, size_type n)</pre></TD><TD VAlign=top>If <tt>pos &gt; s.size()</tt>, throws <tt>out_of_range</tt>.  Otherwise, equivalent to   <tt>insert(end(), s.begin() + pos, s.begin() + pos + min(n, s.size() - pos))</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; append(const charT* s)</tt></TD><TD VAlign=top>Equivalent to <tt>insert(end(), s, s + traits::length(s))</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; append(const charT* s, size_type n)</tt></TD><TD VAlign=top>Equivalent to <tt>insert(end(), s, s + n)</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; append(size_type n, charT c)</tt></TD><TD VAlign=top>Equivalent to <tt>insert(end(), n, c)</tt>.</TD></TR><TR><TD VAlign=top><pre>template &lt;class InputIterator&gt;basic_string&amp; append(InputIterator first, InputIterator last)</pre></TD><TD VAlign=top>Equivalent to <tt>insert(end(), first, last)</tt>.</TD></TR><TR><TD VAlign=top><tt>void push_back(charT c)</tt></TD><TD VAlign=top>Equivalent to <tt>insert(end(), c)</tt></TD></TR><TR><TD VAlign=top><tt>basic_string&amp; operator+=(const basic_string&amp; s)</tt></TD><TD VAlign=top>Equivalent to <tt>append(s)</tt>.</TD></TR><TR><TD VAlign=top><tt>basic_string&amp; operator+=(const charT* s)</tt></TD><TD VAlign=top>Equivalent to <tt>append(s)</tt></TD></TR><TR><TD VAlign=top><tt>basic_string&amp; operator+=(charT c)</tt></TD><TD VAlign=top>Equivalent to <tt>push_back(c)</tt></TD></TR><TR><TD VAlign=top><tt>basic_string&amp; erase(size_type pos = 0, size_type n = npos)</tt>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -