STL - string
构造函数
string();
string( const string& s );
string( size_type length, const char& ch );
string( const char* str );
string( const char* str, size_type length );
string( const string& str, size_type index, size_type length );
string( input_iterator start, input_iterator end );
~string();
运算符
[], =, ==, !=, >, >=, <, <=, +, <<, >>
两个string相等:所有相同位置的元素相等
两个string大小比较:按照词典规则
迭代器
iterator begin();
iterator end();
reverse_iterator rbegin();
reverse_iterator rend();
访问
TYPE& at( size_type loc );
新增
string& append( const string& str );
string& append( const char* str );
string& append( const string& str, size_type index, size_type len );
string& append( const char* str, size_type num );
string& append( size_type num, char ch );
string& append( input_iterator start, input_iterator end );
void assign( size_type num, const char& val );
void assign( input_iterator start, input_iterator end );
string& assign( const string& str );
string& assign( const char* str );
string& assign( const char* str, size_type num );
string& assign( const string& str, size_type index, size_type len );
string& assign( size_type num, const char& ch );
iterator insert( iterator i, const char& ch );
string& insert( size_type index, const string& str );
string& insert( size_type index, const char* str );
string& insert( size_type index1, const string& str, size_type index2, size_type num );
string& insert( size_type index, const char* str, size_type num );
string& insert( size_type index, size_type num, char ch );
void insert( iterator i, size_type num, const char& ch );
void insert( iterator i, iterator start, iterator end );
void push_back( const TYPE& val );
istream& getline( istream& is, string& s, char delimiter = '\n' );
移除
iterator erase( iterator loc );
iterator erase( iterator start, iterator end );
string& erase( size_type index = 0, size_type num = npos );
void clear();
比较
int compare( const string& str );
int compare( const char* str );
int compare( size_type index, size_type length, const string& str );
int compare( size_type index, size_type length, const string& str, size_type index2, size_type length2 );
int compare( size_type index, size_type length, const char* str, size_type length2 );
查找
size_type find( const string& str, size_type index );
size_type find( const char* str, size_type index );
size_type find( const char* str, size_type index, size_type length );
size_type find( char ch, size_type index );
size_type rfind( const string& str, size_type index );
size_type rfind( const char* str, size_type index );
size_type rfind( const char* str, size_type index, size_type num );
size_type rfind( char ch, size_type index );
size_type find_first_not_of( const string& str, size_type index = 0 );
size_type find_first_not_of( const char* str, size_type index = 0 );
size_type find_first_not_of( const char* str, size_type index, size_type num );
size_type find_first_not_of( char ch, size_type index = 0 );
size_type find_first_of( const string &str, size_type index = 0 );
size_type find_first_of( const char* str, size_type index = 0 );
size_type find_first_of( const char* str, size_type index, size_type num );
size_type find_first_of( char ch, size_type index = 0 );
size_type find_last_not_of( const string& str, size_type index = npos );
size_type find_last_not_of( const char* str, size_type index = npos);
size_type find_last_not_of( const char* str, size_type index, size_type num );
size_type find_last_not_of( char ch, size_type index = npos );
size_type find_last_of( const string& str, size_type index = npos );
size_type find_last_of( const char* str, size_type index = npos );
size_type find_last_of( const char* str, size_type index, size_type num );
size_type find_last_of( char ch, size_type index = npos );
替换
string& replace( size_type index, size_type num, const string& str );
string& replace( size_type index1, size_type num1, const string& str, size_type index2, size_type num2 );
string& replace( size_type index, size_type num, const char* str );
string& replace( size_type index, size_type num1, const char* str, size_type num2 );
string& replace( size_type index, size_type num1, size_type num2, char ch );
string& replace( iterator start, iterator end, const string& str );
string& replace( iterator start, iterator end, const char* str );
string& replace( iterator start, iterator end, const char* str, size_type num );
string& replace( iterator start, iterator end, size_type num, char ch );
截取
string substr( size_type index, size_type num = npos );
复制
size_type copy( char* str, size_type num, size_type index = 0 );
转换
const char* c_str();
const char* data();
交换
void swap( container& from );
大小
bool empty();
size_type length();
size_type size();
容量
size_type capacity();
void reserve( size_type size );