以下示例来自教程。当我运行它时,它会抛出异常,然后是 coredump。我尝试使用 catch() 来捕获异常以避免 coredump,如下所示:
但它不起作用。有什么建议么?
谢谢
-托德
----核心转储消息开始---
在抛出一个实例后调用终止
'boost::exception_detail::clone_impl >'
what():重复运算符“ ”不能启动正则表达式。解析正则表达式时发生错误:'>>>HERE>>> '。
中止(核心转储)
- - 结尾 - -
--- 程序开始 ----
#include <boost/regex.hpp>
#include <iostream>
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";
try {
// boost::regex_match(text, what, e, boost::match_extra);
boost::regex_match(text, e);
}
**catch(boost::regex_error& e) {
std::cout <<"!!!!\n";
}
catch (...) {
std::cout << "###\n";
}**
}
int main(int , char* [])
{
print_captures("*", "AAA");
}
- - 结尾 -