📄 string2.html
字号:
if no such element exists.</P><P>The third member function removes up to <CODE>count</CODE> elements ofthe controlled sequence beginning at position <CODE>off</CODE>, thenreturns <CODE>*this</CODE>.</P><H3><CODE><A NAME="basic_string::find">basic_string::find</A></CODE></H3><PRE>size_type <B>find</B>(value_type ch, size_type off = 0) const;size_type <B>find</B>(const value_type *ptr, size_type off = 0) const;size_type <B>find</B>(const value_type *ptr, size_type off, size_type count) const;size_type <B>find</B>(const basic_string& right, size_type off = 0) const;</PRE><P>The member functions each find the first (lowest beginning position)subsequence in the controlled sequence, beginning on or after position<CODE>off</CODE>, that matches the<A HREF="#operand sequence">operand sequence</A> specified by theremaining operands. If it succeeds, it returns the position where thematching subsequence begins. Otherwise, the function returns<CODE><A HREF="#basic_string::npos">npos</A></CODE>.</P><H3><CODE><A NAME="basic_string::find_first_not_of">basic_string::find_first_not_of</A></CODE></H3><PRE>size_type <B>find_first_not_of</B>(value_type ch, size_type off = 0) const;size_type <B>find_first_not_of</B>(const value_type *ptr, size_type off = 0) const;size_type <B>find_first_not_of</B>(const value_type *ptr, size_type off, size_type count) const;size_type <B>find_first_not_of</B>(const basic_string& right, size_type off = 0) const;</PRE><P>The member functions each find the first (lowest position) element of thecontrolled sequence, at or after position <CODE>off</CODE>, thatmatches <I>none</I> of the elements in the<A HREF="#operand sequence">operand sequence</A> specified by theremaining operands. If it succeeds, it returns the position. Otherwise,the function returns<CODE><A HREF="#basic_string::npos">npos</A></CODE>.</P><H3><CODE><A NAME="basic_string::find_first_of">basic_string::find_first_of</A></CODE></H3><PRE>size_type <B>find_first_of</B>(value_type ch, size_type off = 0) const;size_type <B>find_first_of</B>(const value_type *ptr, size_type off = 0) const;size_type <B>find_first_of</B>(const value_type *ptr, size_type off, size_type count) const;size_type <B>find_first_of</B>(const basic_string& right, size_type off = 0) const;</PRE><P>The member functions each find the first (lowest position) element of thecontrolled sequence, at or after position <CODE>off</CODE>, thatmatches <I>any</I> of the elements in the<A HREF="#operand sequence">operand sequence</A> specified by theremaining operands. If it succeeds, it returns the position. Otherwise,the function returns<CODE><A HREF="#basic_string::npos">npos</A></CODE>.</P><H3><CODE><A NAME="basic_string::find_last_not_of">basic_string::find_last_not_of</A></CODE></H3><PRE>size_type <B>find_last_not_of</B>(value_type ch, size_type off = npos) const;size_type <B>find_last_not_of</B>(const value_type *ptr, size_type off = npos) const;size_type <B>find_last_not_of</B>(const value_type *ptr, size_type off, size_type count) const;size_type <B>find_last_not_of</B>(const basic_string& right, size_type off = npos) const;</PRE><P>The member functions each find the last (highest position) element of thecontrolled sequence, at or before position <CODE>off</CODE>, thatmatches <I>none</I> of the elements in the<A HREF="#operand sequence">operand sequence</A> specified by theremaining operands. If it succeeds, it returns the position. Otherwise,the function returns<CODE><A HREF="#basic_string::npos">npos</A></CODE>.</P><H3><CODE><A NAME="basic_string::find_last_of">basic_string::find_last_of</A></CODE></H3><PRE>size_type <B>find_last_of</B>(value_type ch, size_type off = npos) const;size_type <B>find_last_of</B>(const value_type *ptr, size_type off = npos) const;size_type <B>find_last_of</B>(const value_type *ptr, size_type off, size_type count = npos) const;size_type <B>find_last_of</B>(const basic_string& right, size_type off = npos) const;</PRE><P>The member functions each find the last (highest position) element of thecontrolled sequence, at or before position <CODE>off</CODE>, thatmatches <I>any</I> of the elements in the<A HREF="#operand sequence">operand sequence</A> specified by theremaining operands. If it succeeds, it returns the position. Otherwise,the function returns<CODE><A HREF="#basic_string::npos">npos</A></CODE>.</P><H3><CODE><A NAME="basic_string::get_allocator">basic_string::get_allocator</A></CODE></H3><PRE>allocator_type <B>get_allocator</B>() const;</PRE><P>The member function returns the stored<A HREF="memory.html#allocator object">allocator object</A>.</P><H3><CODE><A NAME="basic_string::insert">basic_string::insert</A></CODE></H3><PRE>basic_string& <B>insert</B>(size_type off, const value_type *ptr);basic_string& <B>insert</B>(size_type off, const value_type *ptr, size_type count);basic_string& <B>insert</B>(size_type off, const basic_string& right);basic_string& <B>insert</B>(size_type off, const basic_string& right, size_type roff, size_type count);basic_string& <B>insert</B>(size_type off, size_type count, value_type ch);iterator <B>insert</B>(iterator where, value_type ch = value_type());template<class InIt> void <B>insert</B>(iterator where, InIt first, InIt last);void <B>insert</B>(iterator where, size_type count, value_type ch);</PRE><P>The member functions each insert, before position <CODE>off</CODE> orbefore the element pointed to by <CODE>where</CODE> in the controlledsequence, the<A HREF="#operand sequence">operand sequence</A> specified by theremaining operands. A function that returns a value returns<CODE>*this</CODE>.If <CODE>InIt</CODE> is an integer type in the template member function,the operand sequence <CODE>first, last</CODE> behaves the same as<CODE>(size_type)first, (value_type)last</CODE>.</P><P>In this<A HREF="index.html#implementation">implementation</A>, if atranslator does not support member template functions, the template:</P><PRE>template<class InIt> void <B>insert</B>(iterator where, InIt first, InIt last);</PRE><P>is replaced by:</P><PRE>void <B>insert</B>(iterator where, const_pointer first, const_pointer last);</PRE><H3><CODE><A NAME="basic_string::iterator">basic_string::iterator</A></CODE></H3><PRE>typedef T0 <B>iterator</B>;</PRE><P>The type describes an object that can serve as a random-accessiterator for the controlled sequence.It is described here as asynonym for the implementation-defined type <CODE>T0</CODE>.</P><H3><CODE><A NAME="basic_string::length">basic_string::length</A></CODE></H3><PRE>size_type <B>length</B>() const;</PRE><P>The member function returns the length of the controlled sequence(same as <CODE><A HREF="#basic_string::size">size</A>()</CODE>).</P><H3><CODE><A NAME="basic_string::max_size">basic_string::max_size</A></CODE></H3><PRE>size_type <B>max_size</B>() const;</PRE><P>The member function returns the length of the longest sequence thatthe object can control.</P><H3><CODE><A NAME="basic_string::npos">basic_string::npos</A></CODE></H3><PRE>static const size_type <B>npos</B> = -1;</PRE><P>The constant is the largest representable value of type<A HREF="#basic_string::size_type"><CODE>size_type</CODE></A>. It isassuredly larger than<CODE><A HREF="#basic_string::max_size">max_size</A>()</CODE>, henceit serves as either a very large value or as a special code.</P><H3><CODE><A NAME="basic_string::operator+=">basic_string::operator+=</A></CODE></H3><PRE>basic_string& <B>operator+=</B>(value_type ch);basic_string& <B>operator+=</B>(const value_type *ptr);basic_string& <B>operator+=</B>(const basic_string& right);</PRE><P>The operators each append the<A HREF="#operand sequence">operand sequence</A> to the end of thesequence controlled by <CODE>*this</CODE>, then return <CODE>*this</CODE>.</P><H3><CODE><A NAME="basic_string::operator=">basic_string::operator=</A></CODE></H3><PRE>basic_string& <B>operator=</B>(value_type ch);basic_string& <B>operator=</B>(const value_type *ptr);basic_string& <B>operator=</B>(const basic_string& right);</PRE><P>The operators each replace the sequence controlled by <CODE>*this</CODE>with the<A HREF="#operand sequence">operand sequence</A>,then return <CODE>*this</CODE>.</P><H3><CODE><A NAME="basic_string::operator[]">basic_string::operator[]</A></CODE></H3><PRE>const_reference <B>operator[]</B>(size_type off) const;reference <B>operator[]</B>(size_type off);</PRE><P>The member functions each return a reference to the element of thecontrolled sequence at position <CODE>off</CODE>. If that position isinvalid, the behavior is undefined. Note, however, that<CODE>cstr[cstr.size()] == 0</CODE> for the first member function.</P><H3><CODE><A NAME="basic_string::pointer">basic_string::pointer</A></CODE></H3><PRE>typedef typename allocator_type::pointer <B>pointer</B>;</PRE><P>The type is a synonym for <CODE>allocator_type::pointer</CODE>.</P><H3><CODE><A NAME="basic_string::push_back">basic_string::push_back</A></CODE></H3><PRE>void <B>push_back</B>(value_type ch);</PRE><P>The member function effectively calls<CODE><A HREF="#basic_string::insert">insert</A>(<A HREF="#basic_string::end">end</A>(), ch)</CODE>.</P><H3><CODE><A NAME="basic_string::rbegin">basic_string::rbegin</A></CODE></H3><PRE>const_reverse_iterator <B>rbegin</B>() const;reverse_iterator <B>rbegin</B>();</PRE><P>The member function returns a reverse iterator that points justbeyond the end of the controlled sequence. Hence, it designates thebeginning of the reverse sequence.</P><H3><CODE><A NAME="basic_string::reference">basic_string::reference</A></CODE></H3><PRE>typedef typename allocator_type::reference <B>reference</B>;</PRE><P>The type is a synonym for <CODE>allocator_type::reference</CODE>.</P><H3><CODE><A NAME="basic_string::rend">basic_string::rend</A></CODE></H3><PRE>const_reverse_iterator <B>rend</B>() const;reverse_iterator <B>rend</B>();</PRE><P>The member functions each return a reverse iterator that points at thefirst element of the sequence (or just beyond the end of an emptysequence). Hence, the function designates the end of the reverse sequence.</P><H3><CODE><A NAME="basic_string::replace">basic_string::replace</A></CODE></H3><PRE>basic_string& <B>replace</B>(size_type off, size_type n0, const value_type *ptr);basic_string& <B>replace</B>(size_type off, size_type n0, const value_type *ptr, size_type count);basic_string& <B>replace</B>(size_type off, size_type n0, const basic_string& right);basic_string& <B>replace</B>(size_type off, size_type n0, const basic_string& right, size_type roff, size_type count);basic_string& <B>replace</B>(size_type off, size_type n0, size_type count, value_type ch);basic_string& <B>replace</B>(iterator first, iterator last, const value_type *ptr);basic_string& <B>replace</B>(iterator first, iterator last, const value_type *ptr, size_type count);basic_string& <B>replace</B>(iterator first, iterator last, const basic_string& right);basic_string& <B>replace</B>(iterator first, iterator last, size_type count, value_type ch);template<class InIt> basic_string& <B>replace</B>(iterator first, iterator last, InIt first2, InIt last2);</PRE><P>The member functions each replace up to <CODE>n0</CODE> elements of the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -