Boost logo

Boost :

From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2006-04-04 05:22:19


Joe Gottman wrote:

> 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
>
>
That's not a possibility. The OP said that his environment does not
support exception, i.e. every boost::throw_exception call leads to
immediate program abortion. There is no exception to catch, and try,
catch and throw probably don't even compile.

There seems to be no documented solution to the problem. However,
basic_regex has indeed an undocumented but public set_expression()
member, which throws no exception but instead returns status(), another
undocumented but public member.
Or you can simulate this call by passing the undocumented
regex_constants::no_except flag to the constructor and testing status()
for yourself.

Note that none of the undocumented elements here appear in the standard
proposal either.

Sebastian Redl


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk