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

📄 bas_0007.htm

📁 ARM编辑、编译软件
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<HTML><TITLE>basic_string</TITLE><BODY>
<A HREF="ref.htm"><IMG SRC="images/banner.gif"></A>
<P><STRONG>Click on the banner to return to the Class Reference home page.</STRONG></P>
<P>&copy;Copyright 1996 Rogue Wave Software</P>
<H2>basic_string</H2>
<HR><PRE>     Strings Library</PRE><HR>
<A NAME="Summary"><H3>Summary</H3></A>
<P>A templated class for handling sequences of character-like entities. <B><I>string</B></I> and <B><I>wstring</B></I> are specialized versions of <B><I>basic_string</B></I> for <SAMP>char</SAMP>s and <SAMP>wchar_t</SAMP>s, respectively.</P>
<PRE>typedef basic_string &#60;char> string;</PRE>
<PRE>typedef basic_string &#60;wchar_t> wstring;</PRE>
<H3>Contents</H3>
<UL>
<A HREF="#Synopsis"><LI>Synopsis</LI></A>
<A HREF="#Description"><LI>Description</LI></A>
<A HREF="#Interface"><LI>Interface</LI></A>
<A HREF="#Constructors and Destructors"><LI>Constructors and Destructors</LI></A>
<A HREF="#Operators"><LI>Operators</LI></A>
<A HREF="#Iterators"><LI>Iterators</LI></A>
<A HREF="#Allocator"><LI>Allocator</LI></A>
<A HREF="#Member Functions"><LI>Member Functions</LI></A>
<A HREF="#Non-member Operators"><LI>Non-member Operators</LI></A>
<A HREF="#Non-member Function"><LI>Non-member Function</LI></A>
<A HREF="#Example"><LI>Example</LI></A>
<A HREF="#See Also"><LI>See Also</LI></A>
</UL>
<A NAME="Synopsis"><H3>Synopsis</H3></A>
<PRE>#include &#60;string></PRE>
<PRE>
template &#60;class charT,
          class traits = string_char_traits&#60;charT>,
          class Allocator = allocator>
class basic_string;</PRE>
<A NAME="Description"><H3>Description</H3></A>
<P><B><I>basic_string&#60;charT, traits, Allocator></B></I> is a homogeneous collection of character-like entities.  It provides general string functionality such as compare, append, assign, insert, remove, and replace , along with various searches.  <B><I>basic_string</B></I> also functions as an STL sequence container, providing random access iterators.  This allows some of the generic algorithms to apply to strings.</P>
<P>Any underlying character-like type may be used as long as an appropriate <SAMP>string_char_traits</SAMP> class is provided or the default traits class is applicable. </P>
<A NAME="Interface"><H3>Interface</H3></A>
<PRE>template &#60;class charT,
          class traits = string_char_traits&#60;charT>,
          class Allocator = allocator>
class basic_string {
public:
// Types
typedef traits                               traits_type;
typedef typename traits::char_type           value_type;
typedef Allocator                            allocator_type;
typename size_type;
typename difference_type;
typename reference;
typename const_reference;
typename pointer;
typename const_pointer;
typename iterator;
typename const_iterator;
typename const_reverse_iterator;
typename reverse_iterator;
static const size_type npos = -1;
// Constructors/Destructors
explicit basic_string(const Allocator&#38; = Allocator());
basic_string(const basic_string&#38;, size_type, size_type = npos);
basic_string(const charT*, size_type,
             const Allocator&#38; = Allocator());
basic_string(const charT*, Allocator&#38; = Allocator());
basic_string(size_type, charT,
             const Allocator&#38; = Allocator());
template &#60;class InputIterator>
basic_string(InputIterator, InputIterator,
             const Allocator&#38; = Allocator());
~basic_string();
// Assignment operators
 basic_string&#38; operator=(const basic_string&#38;);
 basic_string&#38; operator=(const charT*);
 basic_string&#38; operator=(charT);
// Iterators
 iterator       begin();
 const_iterator begin() const;
 iterator       end();
 const_iterator end() const;
 reverse_iterator       rbegin();
 const_reverse_iterator rbegin() const;
 reverse_iterator       rend();
 const_reverse_iterator rend() const;
// Capacity
   size_type       size() const;
   size_type       length() const;
   size_type       max_size() const;
   void            resize(size_type, charT);
   void            resize(size_type);
   size_type       capacity() const;
   void            reserve(size_type);
   bool            empty() const;
// Element access
   charT           operator[](size_type) const;
   reference       operator[](size_type);
   const_reference at(size_type) const;
   reference       at(size_type);
// Modifiers
   basic_string&#38; operator+=(const basic_string&#38;);
   basic_string&#38; operator+=(const charT*);
   basic_string&#38; operator+=(charT);
   
   basic_string&#38; append(const basic_string&#38;);
   basic_string&#38; append(const basic_string&#38;,
                        size_type, size_type);
   basic_string&#38; append(const charT*, size_type);
   basic_string&#38; append(const charT*);
   basic_string&#38; append(size_type, charT);
   template&#60;class InputIterator>
    basic_string&#38; append(InputIterator, InputIterator);
   
   basic_string&#38; assign(const basic_string&#38;);
   basic_string&#38; assign(const basic_string&#38;,
                        size_type, size_type);
   basic_string&#38; assign(const charT*, size_type);
   basic_string&#38; assign(const charT*);
   basic_string&#38; assign(size_type, charT);
   template&#60;class InputIterator>
    basic_string&#38; assign(InputIterator, InputIterator);
   
   basic_string&#38; insert(size_type, const basic_string&#38;);
   basic_string&#38; insert(size_type, const basic_string&#38;,
                        size_type, size_type);
   basic_string&#38; insert(size_type, const charT*, size_type);
   basic_string&#38; insert(size_type, const charT*);
   basic_string&#38; insert(size_type, size_type, charT);
   iterator insert(iterator, charT = charT());
   void insert(iterator, size_type, charT);
   template&#60;class InputIterator>
    void insert(iterator, InputIterator,
               InputIterator);
   basic_string&#38; erase(size_type = 0, size_type= npos);
   iterator erase(iterator);
   iterator erase(iterator, iterator);
   basic_string&#38; replace(size_type, size_type,
                         const basic_string&#38;);
   basic_string&#38; replace(size_type, size_type,
                         const basic_string&#38;,
                         size_type, size_type);
   basic_string&#38; replace(size_type, size_type,
                         const charT*, size_type);
   basic_string&#38; replace(size_type, size_type,
                         const charT*);
   basic_string&#38; replace(size_type, size_type,
                         size_type, charT);
   basic_string&#38; replace(iterator, iterator,
                         const basic_string&#38;);
   basic_string&#38; replace(iterator, iterator,
                         const charT*, size_type);
   basic_string&#38; replace(iterator, iterator,
                         const charT*);
   basic_string&#38; replace(iterator, iterator,
                         size_type, charT);
   template&#60;class InputIterator>
    basic_string&#38; replace(iterator, iterator,
                         InputIterator, InputIterator);
   size_type copy(charT*, size_type, size_type = 0);
   void swap(basic_string&#60;charT, traits, Allocator>&#38;);
// String operations
   const charT* c_str() const;
   const charT* data() const;
   const allocator_type&#38; get_allocator() const;
   
   size_type find(const basic_string&#38;,
                  size_type = 0) const;
   size_type find(const charT*,
                  size_type, size_type) const;
   size_type find(const charT*, size_type = 0) const;
   size_type find(charT, size_type = 0) const;
   size_type rfind(const basic_string&#38;,
                   size_type = npos) const;
   size_type rfind(const charT*,
                   size_type, size_type) const;
   size_type rfind(const charT*,
                   size_type = npos) const;
   size_type rfind(charT, size_type = npos) const;
   size_type find_first_of(const basic_string&#38;,
                           size_type = 0) const;
   size_type find_first_of(const charT*,
                           size_type, size_type) const;
   size_type find_first_of(const charT*,
                           size_type = 0) const;
   size_type find_first_of(charT, size_type = 0) const;
   size_type find_last_of(const basic_string&#38;,
                          size_type = npos) const;
   size_type find_last_of(const charT*,
                          size_type, size_type) const;
   size_type find_last_of(const charT*, size_type = npos) const;
   size_type find_last_of(charT, size_type = npos) const;
   size_type find_first_not_of(const basic_string&#38;,
                               size_type = 0) const;
   size_type find_first_not_of(const charT*,
                               size_type, size_type) const;
   size_type find_first_not_of(const charT*, size_type = 0) const;
   size_type find_first_not_of(charT, size_type = 0) const;
   size_type find_last_not_of(const basic_string&#38;,
                              size_type = npos) const;
   size_type find_last_not_of(const charT*,
                              size_type, size_type) const;
   size_type find_last_not_of(const charT*, 
                              size_type = npos) const;
   size_type find_last_not_of(charT, size_type = npos) const;
   basic_string substr(size_type = 0, size_type = npos) const;
   int compare(const basic_string&#38;) const;
   int compare(size_type, size_type, const basic_string&#38;) const;
   int compare(size_type, size_type, const basic_string&#38;,
               size_type, size_type) const;
   int compare(size_type, size_type, charT*) const;
   int compare(charT*) const;
   int compare(size_type, size_type, const charT*, size_type) const;
};
// Non-member Operators
template &#60;class charT, class traits, class Allocator>
 basic_string operator+ (const basic_string&#38;,
                         const basic_string&#38;);
template &#60;class charT, class traits, class Allocator>
 basic_string operator+ (const charT*, const basic_string&#38;);
template &#60;class charT, class traits, class Allocator>
 basic_string operator+ (charT, const basic_string&#38;);
template &#60;class charT, class traits, class Allocator>
 basic_string operator+ (const basic_string&#38;, const charT*);

⌨️ 快捷键说明

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