Skip to content

Commit 858964c

Browse files
authored
fix: update exception handling to support gnu++17
Add __cplusplus version check an and use std::uncaught_exceptions() if __cplusplus version is greater than or equal to 201703L . This is to support compilation with gnu++17 compiler.
1 parent efbed54 commit 858964c

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/fakeit/fakeit.hpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
* https://github.com/eranpeer/FakeIt
88
*/
99

10-
11-
12-
13-
1410
#include <functional>
1511
#include <memory>
1612
#include <set>
@@ -31,6 +27,10 @@
3127
#include <atomic>
3228
#include <tuple>
3329

30+
#if defined(__cplusplus) && __cplusplus >= 201703L
31+
// replace deprecated std::uncaught_exception() with with uncaught_exceptions() for gnu++17 support
32+
#endif
33+
3434

3535
namespace fakeit {
3636

@@ -8360,9 +8360,16 @@ namespace fakeit {
83608360

83618361
virtual ~StubbingChange() THROWS {
83628362

8363+
#if defined(__cplusplus) && __cplusplus >= 201703L
8364+
if (std::uncaught_exceptions()) {
8365+
return;
8366+
}
8367+
#else
83638368
if (std::uncaught_exception()) {
83648369
return;
83658370
}
8371+
#endif
8372+
83668373

83678374
_xaction.commit();
83688375
}
@@ -8620,9 +8627,15 @@ namespace fakeit {
86208627
friend class SequenceVerificationProgress;
86218628

86228629
~SequenceVerificationExpectation() THROWS {
8630+
#if defined(__cplusplus) && __cplusplus >= 201703L
8631+
if (std::uncaught_exceptions()) {
8632+
return;
8633+
}
8634+
#else
86238635
if (std::uncaught_exception()) {
86248636
return;
86258637
}
8638+
#endif
86268639
VerifyExpectation(_fakeit);
86278640
}
86288641

@@ -8982,9 +8995,15 @@ namespace fakeit {
89828995
friend class VerifyNoOtherInvocationsVerificationProgress;
89838996

89848997
~VerifyNoOtherInvocationsExpectation() THROWS {
8998+
#if defined(__cplusplus) && __cplusplus >= 201703L
8999+
if (std::uncaught_exceptions()) {
9000+
return;
9001+
}
9002+
#else
89859003
if (std::uncaught_exception()) {
89869004
return;
89879005
}
9006+
#endif
89889007

89899008
VerifyExpectation(_fakeit);
89909009
}

0 commit comments

Comments
 (0)