kuse2002

vc,stl,mfc and so on

C++博客 首页 新随笔 联系 聚合 管理
  4 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks
vc7导入一个vc6的工程
有如下语句
regex_match((LPCSTR)s, what, ex)

在vc6中完全正常
到vc7中出现编译错误:

“bool boost::regex_match(BidiIterator,BidiIterator,boost::match_results<BidiIterator,Allocator> &,const boost::reg_expression<charT,traits,Allocator2> &,boost::regex_constants::match_flag_type)” : 应输入 5 个参数,却提供了 3 个

解决方法:

regex_match(string((LPCSTR)s), what, ex)


解释: 由于LPCSTR类型对于regex_match 并不明确, 指向了其他重载方法, 故需明确一下类型

补充: 由于regex_match的第一个参数需要的是字符串的引用, 所以直接用string((LPCSTR)s) 作为参数是不行的, 出现匹配结果乱码

正确的做法是定义string tmp((LPCSTR)s); 然后调用regex_match(tmp, what, ex)
posted on 2006-05-11 14:23 kuse的流水帐 阅读(1412) 评论(0)  编辑 收藏 引用 所属分类: 正则表达式

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理