|
Boost Users : |
From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2005-07-01 09:06:10
Should an empty boost::regex raise a 'bad expression' exception when
you assign it to another boost::regex object? It seems to me that an
empty expression can't be bad - it hasn't had the chance to be good OR
bad yet :-)
The rationale for this is that I have an object that contains a
boost::regex that is compiled on demand. The object is likely to be
copied (into a std::vector), before the regex has been compiled (if it
is ever compiled). I know I could use things like
boost::optional<boost::regex>, or boost::scoped_ptr<boost::regex> (I
am working round it currently), but this seems like an interesting
corner case!
Here's a minimal sample:
#include <iostream>
#include <boost/regex.hpp>
int main(int, char**)
{
boost::regex re;
try
{
re = boost::regex();
}
catch (boost::bad_expression&)
{
std::cout << "It threw\n";
}
return 0;
}
It'll output "It threw" on execution (environment = Windows 2000,
VC7.1, Boost1.32.0).
Stuart Dootson
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