0
我只是无法获得regex_match
函数来查找不区分大小写的匹配。尽管boost::xpressive::regex_constants::icase
是defined我用铸造(所以没有歧义,以xpressive中的icase
方法),我得到一个编译错误(VS2010):与Boost不区分大小写匹配Xpressive
错误C2440:“类型转换”:不能从转换'常量的boost :: xpressive中::详细:: modifier_op' 到 '的boost :: xpressive中:: regex_constants :: match_flag_type'
一些代码来重现:
#include <stdio.h>
#include <boost/xpressive/xpressive.hpp>
int main(){
std::string str("FOO");
boost::xpressive::sregex re = boost::xpressive::sregex_compiler().compile("foo");
bool result = regex_match(str,re,(boost::xpressive::regex_constants::match_flag_type)boost::xpressive::regex_constants::icase);
if(result){
std::cout << "Match!";
}else{
std::cout << "No match!";
}
return 0;
}
你知道是什么问题可能?
谢谢,这对我有用! – muffel
对。并且在将来,听听编译器告诉你什么。事实上,你必须将'icase'标志转换为'match_flag_type'才能进行编译,这应该会引发你错误的做法。然后阅读文档。 :-) –