在审核一些代码时,我发现了这样一段代码:
struct MyFooStructure
{
//Nothing unusual, just basic types
}
class Foo : public QObject
{
Q_Object
public:
void fooMethod(const MyStructure &s);
signals:
void fooSignal(const MyStructure &);
}
void Foo::fooMethod(const MyStructure &s)
{
try
{
emit fooSignal(s)
}
catch(const std::exception &e)
{
qDebug() << "An exception!";
}
}
在这里有进入catch的可能性吗?据我所知,没有可能抛出任何异常:emit只是一个宏,用于创建一个表格,在*.moc文件中调用与该信号连接的适当函数。那么,真的需要try catch吗?