A throw-expression with no operand re-throws the exception currently being handled. Such an expression should appear only in a catch handler or in a function called from within a catch handler. The re-thrown exception object is the original exception object (not a copy). For example:
try {
throw CSomeOtherException();
}
catch(...) { // Handle all exceptions
// Respond (perhaps only partially) to exception
// ...
throw; // Pass exception to some other handler
}
An empty throw statement tells the compiler that the function does not throw any exceptions. It is the equivalent to using__declspec(nothrow). For example:
本文探讨了C++中使用空抛表达式重新抛出当前正在处理的异常的方法,并解释了这种做法仅适用于catch处理器或从catch处理器内部调用的函数。此外,还介绍了空抛表达式与声明函数不抛出异常的区别。
417

被折叠的 条评论
为什么被折叠?



