views:

46

answers:

0

This simple example using Boost xpressive (latest version) throws 'Access violation reading location 0x000000'. The error occurs on regex_match. This has to be something simple but I've looked it until I am crazy. Why does this not work? Is my regex wrong? Am I using xpressive wrong? Please help and thanks!

using namespace boost::xpressive;

std::string hello( "Apple Orange_" );

const boost::xpressive::sregex rex = boost::xpressive::sregex::compile("(\\w+)\\s(\\w+)_"); 

boost::xpressive::smatch what;

if( regex_match( hello, what, rex ) )
{
  std::string s1 = what[0]; // whole match
  std::string s2 = what[1]; // first capture
}