Boost logo

Boost Users :

Subject: [Boost-users] [regex] BOOST_REGEX_MATCH_EXTRA not working?
From: Christian Henning (chhenning_at_[hidden])
Date: 2010-10-27 22:34:11


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 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