📄 string2.html
字号:
<H3><CODE><A NAME="char_traits::copy">char_traits::copy</A></CODE></H3><PRE>static char_type <B>*copy</B>(char_type *first1, const char_type *first2, size_t count);</PRE><P>The static member function copies the sequence of <CODE>count</CODE>elements beginning at <CODE>first2</CODE> to the array beginning at <CODE>first1</CODE>,then returns <CODE>first1</CODE>. The source and destinationmust not overlap.</P><H3><A NAME="char_traits::eof"><CODE>char_traits::eof</CODE></A></H3><PRE>static int_type <B>eof</B>();</PRE><P>The static member function returns a value that representsend-of-file (<CODE><A HREF="stdio.html#EOF">EOF</A></CODE>).</P><H3><CODE><A NAME="char_traits::eq">char_traits::eq</A></CODE></H3><PRE>static bool <B>eq</B>(const char_type& left, const char_type& right);</PRE><P>The static member function returns true if <CODE>left</CODE> comparesequal to <CODE>right</CODE>.</P><H3><A NAME="char_traits::eq_int_type"><CODE>char_traits::eq_int_type</CODE></A></H3><PRE>static bool <B>eq_int_type</B>(const int_type& left, const int_type& right);</PRE><P>The static member function returns true if<CODE>left</CODE> compares equal to <CODE>right</CODE>.</P><H3><CODE><A NAME="char_traits::find">char_traits::find</A></CODE></H3><PRE>static const char_type *<B>find</B>(const char_type *first, size_t count, const char_type& ch);</PRE><P>The static member function determines the lowest <CODE>N</CODE>in the range <CODE>[0, count)</CODE> for which<CODE><A HREF="#char_traits::eq">eq</A>(first[N], ch)</CODE>is true. If successful, it returns <CODE>first + N</CODE>. Otherwise,it returns a null pointer.</P><H3><A NAME="char_traits::int_type"><CODE>char_traits::int_type</CODE></A></H3><PRE>typedef int <B>int_type</B>;</PRE><P>The type is a synonym for <I>int.</I></P><H3><CODE><A NAME="char_traits::length">char_traits::length</A></CODE></H3><PRE>static size_t <B>length</B>(const char_type *first);</PRE><P>The static member function returns the number of elements<CODE>N</CODE> in the sequence beginning at <CODE>first</CODE>up to but not including the element <CODE>first[N]</CODE> whichcompares equal to <CODE>char_type()</CODE>.</P><H3><CODE><A NAME="char_traits::lt">char_traits::lt</A></CODE></H3><PRE>static bool <B>lt</B>(const char_type& left, const char_type& right);</PRE><P>The static member function returns true if <CODE>left</CODE> comparesless than <CODE>right</CODE>.</P><H3><CODE><A NAME="char_traits::move">char_traits::move</A></CODE></H3><PRE>static char_type <B>*move</B>(char_type *first1, const char_type *first2, size_t count);</PRE><P>The static member function copies the sequence of <CODE>count</CODE>elements beginning at <CODE>first2</CODE> to the array beginning at <CODE>first1</CODE>,then returns <CODE>first1</CODE>. The source and destination may overlap.</P><H3><A NAME="char_traits::not_eof"><CODE>char_traits::not_eof</CODE></A></H3><PRE>static int_type <B>not_eof</B>(const int_type& meta);</PRE><P>If<CODE>!<A HREF="#char_traits::eq_int_type">eq_int_type</A>(<A HREF="#char_traits::eof">eof</A>(), meta)</CODE>,the static member function returns <CODE>meta</CODE>.Otherwise, it returns a value other than<CODE>eof()</CODE>.</P><H3><A NAME="char_traits::off_type"><CODE>char_traits::off_type</CODE></A></H3><PRE>typedef streamoff <B>off_type</B>;</PRE><P>The type is a synonym for<CODE><A HREF="ios.html#streamoff">streamoff</A></CODE>.</P><H3><A NAME="char_traits::pos_type"><CODE>char_traits::pos_type</CODE></A></H3><PRE>typedef streampos <B>pos_type</B>;</PRE><P>The type is a synonym for<CODE><A HREF="ios.html#streampos">streampos</A></CODE>.</P><H3><A NAME="char_traits::state_type"><CODE>char_traits::state_type</CODE></A></H3><PRE>typedef mbstate_t <B>state_type</B>;</PRE><P>The type is a synonym for<CODE><A HREF="ios.html#mbstate_t">mbstate_t</A></CODE>.</P><H3><A NAME="char_traits::to_char_type"><CODE>char_traits::to_char_type</CODE></A></H3><PRE>static char_type <B>to_char_type</B>(const int_type& meta);</PRE><P>The static member function returns <CODE>meta</CODE> represented astype <CODE>Elem</CODE>. A value of <CODE>meta</CODE> that cannot be sorepresented yields an unspecified result.</P><H3><A NAME="char_traits::to_int_type"><CODE>char_traits::to_int_type</CODE></A></H3><PRE>static int_type <B>to_int_type</B>(const char_type& ch);</PRE><P>The static member function returns <CODE>ch</CODE> represented astype <CODE>int_type</CODE>. It must be possible to convert any value <CODE>ch</CODE> of type<CODE>Elem</CODE> to <CODE>int_type</CODE> (by evaluating<CODE>meta = <A HREF="#char_traits::to_int_type">to_int_type</A>(ch)</CODE>)then back to <CODE>Elem</CODE> (by evaluating<CODE>ch = <A HREF="#char_traits::to_char_type">to_char_type</A>(meta)</CODE>)and obtain a value that compares equal to <CODE>ch</CODE>.<H2><A NAME="getline"><CODE>getline</CODE></A></H2><PRE>istream& <B>getline</B>(istream& istr, string& str);istream& <B>getline</B>(istream& istr, string& str, char delim);</PRE><P>The first function returns <CODE>getline(istr, str, istr.widen('\n'))</CODE>.<P>The second function replaces the sequence controlled by<CODE>str</CODE> with a sequence of elements extracted from the stream<CODE>istr</CODE>. In order of testing, extraction stops:</P><OL><LI>at end of file</LI><LI>after the function extracts an element that compares equal to<CODE>delim</CODE>, in which case the element is neither put back norappended to the controlled sequence</LI><LI>after the function extracts<CODE>str.<A HREF="#string::max_size">max_size</A>()</CODE>elements, in which case the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(ios_base::failbit)</CODE>.</LI></OL><P>If the function extracts no elements, it calls<CODE>setstate(failbit)</CODE>.In any case, it returns <CODE>istr</CODE>.</P><H2><A NAME="operator+"><CODE>operator+</CODE></A></H2><PRE>string <B>operator+</B>( const string& left, const string& right);string <B>operator+</B>( const string& left, const char *right);string <B>operator+</B>( const string& left, char right);string <B>operator+</B>( const char *left, const string& right);string <B>operator+</B>( char left, const string& right);</PRE><P>The functions each overload <CODE>operator+</CODE> toconcatenate two objects of class<A HREF="#string"><CODE>string</CODE></A>.All effectively return<CODE>string(left).<A HREF="#string::append">append</A>(right)</CODE>.</P><H2><A NAME="operator!="><CODE>operator!=</CODE></A></H2><PRE>bool <B>operator!=</B>( const string& left, const string& right);bool <B>operator!=</B>( const string& left, const char *right);bool <B>operator!=</B>( const char *left, const string& right);</PRE><P>The functions each overload <CODE>operator!=</CODE> to comparetwo objects of class<A HREF="#string"><CODE>string</CODE></A>. All effectivelyreturn <CODE>string(left).<A HREF="#string::compare">compare</A>(right)!= 0</CODE>.</P><H2><A NAME="operator=="><CODE>operator==</CODE></A></H2><PRE>bool <B>operator==</B>( const string& left, const string& right);bool <B>operator==</B>( const string& left, const char *right);bool <B>operator==</B>( const char *left, const string& right);</PRE><P>The functions each overload <CODE>operator==</CODE> to comparetwo objects of class<A HREF="#string"><CODE>string</CODE></A>. All effectivelyreturn <CODE>string(left).<A HREF="#string::compare">compare</A>(right)== 0</CODE>.</P><H2><A NAME="operator<"><CODE>operator<</CODE></A></H2><PRE>bool <B>operator<</B>( const string& left, const string& right);bool <B>operator<</B>( const string& left, const char *right);bool <B>operator<</B>( const char *left, const string& right);</PRE><P>The functions each overload <CODE>operator<</CODE> tocompare two objects of class<A HREF="#string"><CODE>string</CODE></A>. All effectivelyreturn <CODE>string(left).<A HREF="#string::compare">compare</A>(right)< 0</CODE>.</P><H2><A NAME="operator<<"><CODE>operator<<</CODE></A></H2><PRE>ostream& <B>operator<<</B>( ostream& ostr, const string& str);</PRE><P>The function is a<A HREF="ostream.html#formatted output functions">formatted output functions</A>that overloads <CODE>operator<<</CODE> todetermine the length <CODE>len =str.<A HREF="#string::size">size</A>()</CODE>of the sequence controlled by <CODE>str</CODE>, and insert the sequence. If<CODE>len < ostr.<A HREF="ios.html#ios_base::width">width</A>()</CODE>,then the function also inserts a repetition of <CODE>ostr.width() - len</CODE><A HREF="ios.html#fill character">fill characters</A>.The repetition precedes the sequence if<CODE>(ostr.<A HREF="ios.html#ios_base::flags">flags</A>() &<A HREF="ios.html#ios_base::adjustfield">adjustfield</A> !=<A HREF="ios.html#ios_base::left">left</A></CODE>.Otherwise, the repetition follows the sequence.The function returns <CODE>ostr</CODE>.</P><H2><A NAME="operator<="><CODE>operator<=</CODE></A></H2><PRE>bool <B>operator<=</B>( const string& left, const string& right);bool <B>operator<=</B>( const string& left, const char *right);bool <B>operator<=</B>( const char *left, const string& right);</PRE><P>The functions each overload <CODE>operator<=</CODE> tocompare two objects of class<A HREF="#string"><CODE>string</CODE></A>. All effectivelyreturn <CODE>string(left).<A HREF="#string::compare">compare</A>(right)<= 0</CODE>.</P><H2><A NAME="operator>"><CODE>operator></CODE></A></H2><PRE>bool <B>operator></B>( const string& left, const string& right);bool <B>operator></B>( const string& left, const char *right);bool <B>operator></B>( const char *left, const string& right);</PRE><P>The functions each overload <CODE>operator></CODE> tocompare two objects of class<A HREF="#string"><CODE>string</CODE></A>. All effectivelyreturn <CODE>string(left).<A HREF="#string::compare">compare</A>(right)> 0</CODE>.</P><H2><A NAME="operator>="><CODE>operator>=</CODE></A></H2><PRE>bool <B>operator>=</B>( const string& left, const string& right);bool <B>operator>=</B>( const string& left, const char *right);bool <B>operator>=</B>( const char *left, const string&a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -