basic_string也是一个STL中的sequence container, 但是多了些针对字符串处理的方法(分析针对MS STL)
append
c_str
compare
copy
data
find_first_not_of
find_first_of
find_last_not_of
find_last_of
length
replace
substr
其中以data()和c_str()特别有意思,data()就是调用c_str(),但是msdn又说data()返回的字符串没有'/0', 和代码冲突了,调试结果是有的
compare()也有点意思,修改了自身,然后还返回自身的引用(return *this), 返回值代表表达式的值,可以直接用于表达式使用
typedef basic_string<char, char_traits<char>, allocator<char> >
string;
typedef basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> > wstring;
所以string和wstring就没有特别之处了
测试代码