0

I just can't get the regex_match function to find case-insensitive matches. Even though boost::xpressive::regex_constants::icase is defined and I use a cast (so there is no ambiguity to the icase method of Xpressive), I get a compilation error (VS2010):

error C2440: 'type cast' : cannot convert from 'const boost::xpressive::detail::modifier_op' to 'boost::xpressive::regex_constants::match_flag_type'

Some code to reproduce:

#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;
}

Do you know what the problem might be?

muffel
  • 7,004
  • 8
  • 57
  • 98

1 Answers1

2

Try to use

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

syntax_options_type (that is boost::xpressive::regex_constants::icase_) is not match_flag_type (3 argument for regex_match should have this type).

ForEveR
  • 55,233
  • 2
  • 119
  • 133
  • Right. And in the future, listen to what the compiler tells you. The fact that you had to cast the `icase` flag to `match_flag_type` to get it compile should have tipped you off that you were doing something wrong. And then read the docs. :-) – Eric Niebler Jul 26 '13 at 17:23