Skip to content

Commit

Permalink
Cleanup: replace deprecated std::uncaught_exception()
Browse files Browse the repository at this point in the history
`std::uncaught_exception()` was deprecated in C++17 and is to be removed in
C++20.

It has been replaced by `std::uncaught_exception()` which returns an `int`
that indicates how many exceptions are outstanding rather than the previous
`true` or `false` if there is any. This is helpful in situations where
exceptions could happen in exception handling code. That is a whole level
of brain-ache I do not even want to think about. However it provides a
perfectly suitable solution to our usage if we just drop it in as a
replacement...

For me this reduces the warning count from 662 to 510 (i.e. down by 152).

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
  • Loading branch information
SlySven committed Nov 25, 2020
1 parent 84423b9 commit a88c2bf
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Tree.h
Expand Up @@ -134,11 +134,7 @@ Tree<T>::~Tree()
delete mpMyChildrenList;
if (mpParent) {
mpParent->popChild(static_cast<T*>(this)); // tell parent about my death
// FIXME: std::uncaught_exception() is deprecated in C++17 and is to be
// removed in C++20 - and this throws out a lot of build time warnings
// that are currently being suppressed by a `-Wno-deprecated-declarations`
// but which might also be masking issues in other areas:
if (std::uncaught_exception()) {
if (std::uncaught_exceptions()) {
std::cout << "ERROR: Hook destructed during stack rewind because of an uncaught exception." << std::endl;
}
}
Expand Down

0 comments on commit a88c2bf

Please sign in to comment.