1
- // cpp11 version: 0.5.0
2
- // vendored on: 2024-09-24
1
+ // cpp11 version: 0.5.1
2
+ // vendored on: 2024-12-07
3
3
#pragma once
4
4
5
5
#include < csetjmp> // for longjmp, setjmp, jmp_buf
15
15
#include " R_ext/Error.h" // for Rf_error, Rf_warning
16
16
#include " R_ext/Print.h" // for REprintf
17
17
#include " R_ext/Utils.h" // for R_CheckUserInterrupt
18
- #include " Rversion.h" // for R_VERSION, R_Version
19
18
20
- #if defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0)
19
+ // We would like to remove this, since all supported versions of R now support proper
20
+ // unwind protect, but some groups rely on it existing, like arrow and systemfonts
21
+ // https://github.com/r-lib/cpp11/issues/412
21
22
#define HAS_UNWIND_PROTECT
22
- #endif
23
23
24
24
#ifdef CPP11_USE_FMT
25
25
#define FMT_HEADER_ONLY
@@ -33,8 +33,6 @@ class unwind_exception : public std::exception {
33
33
unwind_exception (SEXP token_) : token(token_) {}
34
34
};
35
35
36
- #ifdef HAS_UNWIND_PROTECT
37
-
38
36
// / Unwind Protection from C longjmp's, like those used in R error handling
39
37
// /
40
38
// / @param code The code to which needs to be protected, as a nullary callable
@@ -97,15 +95,6 @@ unwind_protect(Fun&& code) {
97
95
return out;
98
96
}
99
97
100
- #else
101
- // Don't do anything if we don't have unwind protect. This will leak C++ resources,
102
- // including those held by cpp11 objects, but the other alternatives are also not great.
103
- template <typename Fun>
104
- decltype (std::declval<Fun&&>()()) unwind_protect(Fun&& code) {
105
- return std::forward<Fun>(code)();
106
- }
107
- #endif
108
-
109
98
namespace detail {
110
99
111
100
template <size_t ...>
0 commit comments