
4 Apr
2006
4 Apr
'06
12:03 a.m.
"Anne Martens" <mail@anne-martens.de> wrote in message news:443140C5.6020007@anne-martens.de...
Hi,
I'm trying to use boost-regex in my project that doesn't support exceptions. Thus, when constructing a regular expression with boost::regex expression(expr); and passig an invalid regular expression, my program crashes.
What can I do to make sure my regular expression is valid before passing it to exception-throwing methods like that one?
One possibility is to use a try-catch inside your function that produces the regex, and return optional<regex> optional<regex> maybe_make_regex(const string &s) { try { return regex(s); } catch (...) { return none; } } Joe Gottman