Boost logo

Boost Users :

From: Boris (boriss_at_[hidden])
Date: 2008-04-01 09:20:12


Can anyone tell me why Boost.Spirit (which reuses Boost.Regex for regular
expressions) works while the code below where Boost.Regex is used directly
can not be compiled?

std::string in = "test";

boost::wregex expr(L"test");
boost::match_results<std::string::const_iterator> what;
boost::regex_search(in, what, expr); // COMPILER ERROR

std::string out;
boost::spirit::rxstrlit<wchar_t> expr2(L"test");
boost::spirit::parse(in.c_str(), expr2[boost::spirit::assign_a(out)]);

The basic problem is of course that the regular expressions are based on
wchar_t while the input string is based on char. Thus I'm not so much
surprised why Boost.Regex does not work. I'm much more surprised though
that my compiler (VC++ 2008) doesn't report an error with the code above
which uses Boost.Spirit.

I don't know why the code using Boost.Spirit compiles (is this
implementation-dependent or guaranteed behavior)? It would make using
regular expressions in templates much easier though as regular expressions
don't seem to depend on the Char type of strings (assuming this is a
feature I can rely on)?

Boris


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