[Boost-users] [regex] BOOST_REGEX_MATCH_EXTRA not working?

92 views
Skip to first unread message

Christian Henning

unread,
Oct 27, 2010, 10:34:11 PM10/27/10
to boost...@lists.boost.org
Hi there, pretty new to boost::regex and though I'm just toying around
with the documentation and some basic test code. The following code
crashes when setting the BOOST_REGEX_MATCH_EXTRA symbol.

#include <iostream>

#include <boost/regex.hpp>

void print_captures( const std::string& regx
, const std::string& text
)
{
boost::regex e( regx );
boost::smatch what;

std::cout << "Expression: \"" << regx << "\"\n";
std::cout << "Text: \"" << text << "\"\n";

// crash occurs in the next statement
if( boost::regex_match( text, what, e, boost::match_extra ))
{
unsigned int i,j;

std::cout << "**Match found ** \n Sub-Expressions:\n";

for( i = 0; i < what.size(); ++i )
{
std::cout << " $" << i << " = \"" << what[i] << "\"\n";
}

std::cout << " Captures:\n";

for( i = 0; i < what.size(); ++i )
{
std::cout << " $" << i << " = {";

for( j = 0; j < what.captures(i).size(); ++j )
{
}
}
}
}


int _tmain(int argc, _TCHAR* argv[])
{
print_captures( "(.*)bar|(.*)bah", "abcbar" );

return 0;
}

I'm using MSVC10 express. Am I doing something wrong?

Regards,
Christian
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

John Maddock

unread,
Oct 28, 2010, 5:04:43 AM10/28/10
to boost...@lists.boost.org
> I'm using MSVC10 express. Am I doing something wrong?

Did you compile the regex library with BOOST_REGEX_MATCH_EXTRA set? If not
the library is binary incompatible with your code.

HTH, John.

Christian Henning

unread,
Oct 28, 2010, 10:18:09 AM10/28/10
to boost...@lists.boost.org
Hi there,

On 10/28/10, John Maddock <boost...@virgin.net> wrote:
>> I'm using MSVC10 express. Am I doing something wrong?
>
> Did you compile the regex library with BOOST_REGEX_MATCH_EXTRA set? If not
> the library is binary incompatible with your code.

No, I did not do that. Good to know!

Thanks,
Christian

Reply all
Reply to author
Forward
0 new messages