Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2007-11-22 04:41:14


Darren Garvey wrote:
>> I'm not sure if I'm missing something here, but I think this is a
>> bug.

>> GCC doesn't manage to find the right overload of regex_match and
>> says only this:
>>
>> lala.cpp: In function 'int main()':
>> lala.cpp:11: error: no matching function for call to
>> 'regex_match(std::string&, boost::cmatch&, boost::regex&)'
>> /usr/local/src/boost/trunk/boost/regex/v4/regex_match.hpp:80: note:
>> candidates are: bool boost::regex_match(const
>> std::basic_string<charT, ST,
>>> &, boost::match_results<typename std::basic_string<charT, ST,
>>>>> const_iterator, Allocator>&, const boost::basic_regex<charT,
>>>>> traits>&,
>> boost::regex_constants::match_flag_type) [with ST =
>> std::char_traits<char>, SA = std::allocator<char>, Allocator =
>> std::allocator<boost::sub_match<const char*> >, charT = char, traits
>> = boost::regex_traits<char, boost::cpp_regex_traits<char> >]
>>
>> It compiles fine if you instead pass str.c_str() as the first
>> argument. On the other hand, If you explicitly qualify the regex
>> types with boost::, gcc spews out the attached misery-ball. AFAIK,
>> these all work on msvc9.
>>
>> Is the example above supposed to work?

Nope: different iterator types: cmatch supports const char* iterators, but
basic_string::const_iterator isn't necessarily that type (though sometimes
it is, depending on the platform/compiler). You should be using
boost::smatch as the match_results type when searching a std::string.

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net