[導入]Exceptional C++ 之 2
標準庫中 string 的模板類:template<class charT,
class traits= char_traits
class Allocator = allocator<charT> >
class basic_string;
其中 char_traits 部分,它決定了字符的相互作用和比較運算,如eq()(相等)、ne()(不等)、lt()(小于)、compare()(比較字符序列)、find()(搜索字符序列)。因此只需重定義 char_traits 模板即可改變 string 的字符比較操作。
文章來源:http://my.donews.com/robinchow/2007/01/10/cfjorztxnorsmkaafyrckgebtdmemrppxzeo/
posted on 2007-10-23 21:01 Robin Chow 閱讀(182) 評論(0) 編輯 收藏 引用