Dynamic exception specification
这种grammar是有一定价值的,在Theory\Error-handling
章节中进行了介绍,但是这种用法: deprecated in C++11、removed in C++17。
cppreference Dynamic exception specification
Why dynamic exception specification is removed ?
stackoverflow Throw keyword in function's signature
No, it is not considered good practice. On the contrary, it is generally considered a bad idea.
http://www.gotw.ca/publications/mill22.htm goes into a lot more detail about why, but the problem is partly that the compiler is unable to enforce this, so it has to be checked at runtime, which is usually undesirable. And it is not well supported in any case. (MSVC ignores exception specifications, except throw(), which it interprets as a guarantee that no exception will be thrown.
NOTE: 上面给出的链接指向的是: gotw A Pragmatic Look at Exception Specifications,后面对这篇文章进行了专门的阅读。
devblogs.microsoft The sad history of the C++ throw(…)
exception specifier
This has made a lot of people very angry and has been widely regarded as a bad move.