2013-07-26 1 views
0

regex_match 함수를 사용하여 대/소문자를 구별하지 못할 수 있습니다.부스트 익스프레스 (Boost Xpressive)와 대/소문자 비 구분 일치

오류 C2440 : '형식 캐스트': boost::xpressive::regex_constants::icasedefined 내가이 캐스트를 사용하더라도, 내가 컴파일 오류 (VS2010)를 얻을 수 (그래서 Xpressive의 icase 방법에 모호성이없는)에서 변환 할 수 없습니다 'const를 부스트 :: xpressive :: 자세히 :: modifier_op'에서 '부스트 : 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; 
} 

당신은 알고 계십니까 어떤 문제 아마도?

답변

2

match_flag_type (regex_match 3 인수는이 유형을 가져야한다) (즉 boost::xpressive::regex_constants::icase_입니다)하지

boost::xpressive::sregex re = boost::xpressive::sregex_compiler(). 
compile("foo", boost::xpressive::icase); 

syntax_options_type를 사용해보십시오.

+0

감사합니다. 저에게 좋습니다! – muffel

+0

오른쪽. 그리고 미래에 컴파일러가 여러분에게 말하는 것을 들어보십시오. 컴파일 할 때'icase' 플래그를'match_flag_type'으로 던져야한다는 사실은 당신이 뭔가 잘못하고 있다는 것을 알려줄 것입니다. 그런 다음 문서를 읽으십시오. :-) –

관련 문제