|
Boost : |
From: capourrait_at_[hidden]
Date: 2006-11-21 09:27:24
Hi,
It seem that there is a problem when using the substr function in regex_match().
If you build and run the following code, it works fine. But try to comment the 6th line in findC function
and uncomment the 7th line. Under Visual C++ 2005, I get the following:
Debug assertion failed!
Program: ..........exe
File: ..........\vc\include\xstring
Line: 271
Expression: string iterators incompatible
Did I miss something?
Thanks
Eric
// main.cpp
#include <string>
#include <iostream>
#include <boost/regex.hpp>
bool findC(const std::string& iText)
{
boost::regex regularExp(".*C.*");
boost::smatch match;
std::string sub( iText.substr(2) );
if ( boost::regex_match(sub, match, regularExp) )
//if ( boost::regex_match(iText.substr(2), match, regularExp) )
{
for ( int i=0; i<match.size(); ++i )
{
if (match[i].matched)
{
std::cout << "match[" << i << "] " << match[i] << std::endl;
return true;
}
}
}
else
{
std::cout << "'C' not found in '" << iText.substr(2) << "'" << std::endl;
return false;
}
}
int main( int argc, char* argv[] )
{
//findC("x:ABXDE");
findC("x:ABCDE");
return EXIT_SUCCESS;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk