/* * demo_versions/dynamic_exception_spec.cpp * -------------------------------------------------------------------------- * 演示:动态异常规范 throw(类型...) —— C++17 起被移除(C++11 弃用)。 * * 来源:wiki 块 [58954474:4]「7.2.4 异常接口声明」原意演示 throw(int,char,char*) * 与 throw() 异常规范。这些在 C++17 已是语法错误(动态规范被移除)。 * * 验证: * g++ -std=c++14 → PASS(动态规范仍合法,仅弃用警告) * g++ -std=c++17 → ERROR (动态异常规范非法) * * 运行: * tools/std_probe.py --lang c++ --file tools/demo_versions/dynamic_exception_spec.cpp \ * --standards c++11,c++14,c++17,c++20 * -------------------------------------------------------------------------- */ #include void may_throw_anything() throw(int, char) { // C++17 移除:动态异常规范 throw 1; } void throws_nothing() throw() { // C++17: throw() 等价 noexcept } int main() { return 0; }