我只注意到了在爲什麼將std :: uncaught_exception更改爲std :: uncaught_exceptions?
http://en.cppreference.com/w/cpp/error/uncaught_exception
是C++ 17將取代std::uncaught_exception()
,它返回一個bool
,與std::uncaught_exceptions()
,它返回一個int
。
中除了描述這個標準是在這裏:
http://isocpp.org/files/papers/n4259.pdf
它不提供理由,但它確實說
[注:當uncaught_exceptions()> 0,拋出一個異常可以導致std :: terminate()(15.5.1)的調用 。 - 注完]
這是奇怪的含糊。
這種改變的原因是什麼?在C++ 17或未來版本的標準中是否可以有多個活動的異常?
在所有版本的C++中都可能存在多個活動異常。 'struct foo {〜foo(){try {throw new int; } catch(...){}}}; int main(){{foo f;拋出新的雙倍; } catch(...){}}當我們銷燬'f'時,''有兩個活動異常。 – Yakk
參見[this CppCon 2015 talk](https://github.com/CppCon/CppCon2015/blob/master/Presentations/Declarative%20Control%20Flow/Declarative%20Control%20Flow%20-%20Andrei%20Alexandrescu%20-% 20CppCon%202015.pdf)由Andrei Alexandrescu提供有關'ScopeGuard'和N4259的信息。 – Adversus