📄 string2.html
字号:
basic_string& <B>append</B>(const basic_string& right, size_type roff, size_type count);basic_string& <B>append</B>(const basic_string& right);basic_string& <B>append</B>(size_type count, value_type ch);template<class InIt> basic_string& <B>append</B>(InIt first, InIt last);</PRE><P>If <CODE>InIt</CODE> is an integer type, the template memberfunction behaves the same as <CODE>append((size_type)first, (value_type)last)</CODE>.Otherwise, themember functions 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><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> basic_string& <B>append</B>(InIt first, InIt last);</PRE><P>is replaced by:</P><PRE>basic_string& <B>append</B>(const_pointer first, const_pointer last);</PRE><H3><CODE><A NAME="basic_string::assign">basic_string::assign</A></CODE></H3><PRE>basic_string& <B>assign</B>(const value_type *ptr);basic_string& <B>assign</B>(const value_type *ptr, size_type count);basic_string& <B>assign</B>(const basic_string& right, size_type roff, size_type count);basic_string& <B>assign</B>(const basic_string& right);basic_string& <B>assign</B>(size_type count, value_type ch);template<class InIt> basic_string& <B>assign</B>(InIt first, InIt last);</PRE><P>If <CODE>InIt</CODE> is an integer type, the template memberfunction behaves the same as <CODE>assign((size_type)first, (value_type)last)</CODE>.Otherwise, themember functions each replacethe sequence controlled by <CODE>*this</CODE> with the<A HREF="#operand sequence">operand sequence</A>, then return <CODE>*this</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> basic_string& <B>assign</B>(InIt first, InIt last);</PRE><P>is replaced by:</P><PRE>basic_string& <B>assign</B>(const_pointer first, const_pointer last);</PRE><H3><CODE><A NAME="basic_string::at">basic_string::at</A></CODE></H3><PRE>const_reference <B>at</B>(size_type off) const;reference <B>at</B>(size_type off);</PRE><P>The member functions each return a reference to the element of thecontrolled sequence at position <CODE>off</CODE>,or report an <A HREF="#out-of-range error">out-of-range error</A>.</P><H3><CODE><A NAME="basic_string::basic_string">basic_string::basic_string</A></CODE></H3><PRE><B>basic_string</B>(const value_type *ptr);<B>basic_string</B>(const value_type *ptr, const allocator_type& al);<B>basic_string</B>(const value_type *ptr, size_type count);<B>basic_string</B>(const value_type *ptr, size_type count, const allocator_type& al);<B>basic_string</B>(const basic_string& right);<B>basic_string</B>(const basic_string& right, size_type roff, size_type count = npos);<B>basic_string</B>(const basic_string& right, size_type roff, size_type count, const allocator_type& al);<B>basic_string</B>(size_type count, value_type ch);<B>basic_string</B>(size_type count, value_type ch, const allocator_type& al);<B>basic_string</B>();explicit <B>basic_string</B>(const allocator_type& al);template <class InIt> <B>basic_string</B>(InIt first, InIt last);template <class InIt> <B>basic_string</B>(InIt first, InIt last, const allocator_type& al);</PRE><P>All constructors store an<A HREF="memory.html#allocator object">allocator object</A> andinitialize the controlled sequence. The allocator object is the argument<CODE>al</CODE>, if present. For the copy constructor, it is<CODE>right.<A HREF="#basic_string::get_allocator">get_allocator</A>()</CODE>.Otherwise, it is <CODE>Alloc()</CODE>.</P><P>The controlled sequence is initialized to a copy of the<A HREF="#operand sequence">operand sequence</A> specified by theremaining operands. A constructor with no operand sequence specifies anempty initial controlled sequence.If <CODE>InIt</CODE> is an integer type in a template constructor,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 templates:</P><PRE>template <class InIt> <B>basic_string</B>(InIt first, InIt last);template <class InIt> <B>basic_string</B>(InIt first, InIt last, const allocator_type& al);</PRE><P>are replaced by:</P><PRE><B>basic_string</B>(const_pointer first, const_pointer last);<B>basic_string</B>(const_pointer first, const_pointer last, const allocator_type& al);</PRE><H3><CODE><A NAME="basic_string::begin">basic_string::begin</A></CODE></H3><PRE>const_iterator <B>begin</B>() const;iterator <B>begin</B>();</PRE><P>The member functions each return a random-access iterator that points atthe first element of the sequence (or just beyond the end of an emptysequence).</P><H3><CODE><A NAME="basic_string::c_str">basic_string::c_str</A></CODE></H3><PRE>const value_type <B>*c_str</B>() const;</PRE><P>The member function returns a pointer to a non-modifiable<A HREF="lib_over.html#C string">C string</A> constructed by adding aterminating null element(<CODE>value_type()</CODE>) to the controlledsequence. Calling any non-const member function for<CODE>*this</CODE> can invalidate the pointer.</P><H3><CODE><A NAME="basic_string::capacity">basic_string::capacity</A></CODE></H3><PRE>size_type <B>capacity</B>() const;</PRE><P>The member function returns the storage currently allocated to holdthe controlled sequence, a value at least as large as<CODE><A HREF="#basic_string::size">size</A>()</CODE>.</P><H3><CODE><A NAME="basic_string::clear">basic_string::clear</A></CODE></H3><PRE>void <B>clear</B>();</PRE><P>The member function calls<CODE><A HREF="#basic_string::erase">erase</A>(<A HREF="#basic_string::begin">begin</A>(),<A HREF="#basic_string::end">end</A>())</CODE>.</P><H3><CODE><A NAME="basic_string::compare">basic_string::compare</A></CODE></H3><PRE>int <B>compare</B>(const basic_string& right) const;int <B>compare</B>(size_type off, size_type n0, const basic_string& right) const;int <B>compare</B>(size_type off, size_type n0, const basic_string& right, size_type roff, size_type count) const;int <B>compare</B>(const value_type *ptr) const;int <B>compare</B>(size_type off, size_type n0, const value_type *ptr) const;int <B>compare</B>(size_type off, size_type n0, const value_type *ptr, size_type off) const;</PRE><P>The member functions each compare up to <CODE>n0</CODE> elements of thecontrolled sequence beginning with position <CODE>off</CODE>, or theentire controlled sequence if these arguments are not supplied,to the <A HREF="#operand sequence">operand sequence</A>.Each function returns:</P><UL><LI>a negative value if the first differing element in the controlledsequence compares less than the corresponding element in the operandsequence (as determined by<CODE>traits_type::<A HREF="#char_traits::compare">compare</A></CODE>), or if thetwo have a common prefix but the operand sequence is longer</LI><LI>zero if the two compare equal element by element and are the samelength</LI><LI>a positive value otherwise</LI></UL><H3><CODE><A NAME="basic_string::const_iterator">basic_string::const_iterator</A></CODE></H3><PRE>typedef T1 <B>const_iterator</B>;</PRE><P>The type describes an object that can serve as a constantrandom-access iterator for the controlled sequence.It is described here as asynonym for the implementation-defined type <CODE>T1</CODE>.</P><H3><CODE><A NAME="basic_string::const_pointer">basic_string::const_pointer</A></CODE></H3><PRE>typedef typename allocator_type::const_pointer <B>const_pointer</B>;</PRE><P>The type is a synonym for <CODE>allocator_type::const_pointer</CODE>.</P><H3><CODE><A NAME="basic_string::const_reference">basic_string::const_reference</A></CODE></H3><PRE>typedef typename allocator_type::const_reference <B>const_reference</B>;</PRE><P>The type is a synonym for <CODE>allocator_type::const_reference</CODE>.</P><H3><CODE><A NAME="basic_string::const_reverse_iterator">basic_string::const_reverse_iterator</A></CODE></H3><PRE>typedef reverse_iterator<const_iterator> <B>const_reverse_iterator</B>;</PRE><P>The type describes an object that can serve as a constant reverseiterator for the controlled sequence.</P><H3><CODE><A NAME="basic_string::copy">basic_string::copy</A></CODE></H3><PRE>size_type <B>copy</B>(value_type *ptr, size_type count, size_type off = 0) const;</PRE><P>The member function copies up to <CODE>count</CODE> elements from thecontrolled sequence, beginning at position <CODE>off</CODE>, to thearray of <CODE>value_type</CODE> beginning at <CODE>ptr</CODE>. It returns thenumber of elements actually copied.</P><H3><CODE><A NAME="basic_string::data">basic_string::data</A></CODE></H3><PRE>const value_type <B>*data</B>() const;</PRE><P>The member function returns a pointer to the first elementof the sequence (or, for an empty sequence, a non-null pointerthat cannot be dereferenced).</P><H3><CODE><A NAME="basic_string::difference_type">basic_string::difference_type</A></CODE></H3><PRE>typedef T3 <B>difference_type</B>;</PRE><P>The signed integer type describes an object that can represent thedifference between the addresses of any two elements in the controlledsequence. It is described here as asynonym for the implementation-defined type <CODE>T3</CODE>.</P><H3><CODE><A NAME="basic_string::empty">basic_string::empty</A></CODE></H3><PRE>bool <B>empty</B>() const;</PRE><P>The member function returns true for an empty controlled sequence.</P><H3><CODE><A NAME="basic_string::end">basic_string::end</A></CODE></H3><PRE>const_iterator <B>end</B>() const;iterator <B>end</B>();</PRE><P>The member functions each return a random-access iterator that pointsjust beyond the end of the sequence.</P><H3><CODE><A NAME="basic_string::erase">basic_string::erase</A></CODE></H3><PRE>iterator <B>erase</B>(iterator first, iterator last);iterator <B>erase</B>(iterator where);basic_string& <B>erase</B>(size_type off = 0, size_type count = npos);</PRE><P>The first member function removes the elements of the controlledsequence in the range <CODE>[first, last)</CODE>.The second member function removes the element of the controlledsequence pointed to by <CODE>where</CODE>.Both return an iterator that designates the first element remainingbeyond any elements removed, or<CODE><A HREF="#basic_string::end">end</A>()</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -