Skip to content

Commit ce05e9d

Browse files
authored
Merge pull request #163 from vadz/cxx17-uncaught-exceptions
Define __cpp_lib_uncaught_exceptions if building C++17 mode
2 parents 12ead5c + f592ba9 commit ce05e9d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

hdr/sqlite_modern_cpp/utility/uncaught_exceptions.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,23 @@
44
#include <exception>
55
#include <iostream>
66

7+
// Consider that std::uncaught_exceptions is available if explicitly indicated
8+
// by the standard library, if compiler advertises full C++17 support or, as a
9+
// special case, for MSVS 2015+ (which doesn't define __cplusplus correctly by
10+
// default as of 2017.7 version and couldn't do it at all until it).
11+
#ifndef MODERN_SQLITE_UNCAUGHT_EXCEPTIONS_SUPPORT
12+
#ifdef __cpp_lib_uncaught_exceptions
13+
#define MODERN_SQLITE_UNCAUGHT_EXCEPTIONS_SUPPORT
14+
#elif __cplusplus >= 201703L
15+
#define MODERN_SQLITE_UNCAUGHT_EXCEPTIONS_SUPPORT
16+
#elif defined(_MSC_VER) && _MSC_VER >= 1900
17+
#define MODERN_SQLITE_UNCAUGHT_EXCEPTIONS_SUPPORT
18+
#endif
19+
#endif
20+
721
namespace sqlite {
822
namespace utility {
9-
#ifdef __cpp_lib_uncaught_exceptions
23+
#ifdef MODERN_SQLITE_UNCAUGHT_EXCEPTIONS_SUPPORT
1024
class UncaughtExceptionDetector {
1125
public:
1226
operator bool() {

tests/exception_dont_execute_nested.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct A {
2121
};
2222

2323
TEST_CASE("Nested prepered statements wont execute", "[nested_prepared_statements]") {
24-
#ifdef __cpp_lib_uncaught_exceptions
24+
#ifdef MODERN_SQLITE_UNCAUGHT_EXCEPTIONS_SUPPORT
2525
try {
2626
A a;
2727
throw 1;

0 commit comments

Comments
 (0)