From 4067a444844ae57e4a86d88499c3ee7732be83fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 7 Dec 2024 20:42:58 +0100 Subject: [PATCH] feat: New `END_CPP11_EX()` macro that allows parameterizing the return value --- inst/include/cpp11/declarations.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inst/include/cpp11/declarations.hpp b/inst/include/cpp11/declarations.hpp index ed57721f..89f24a65 100644 --- a/inst/include/cpp11/declarations.hpp +++ b/inst/include/cpp11/declarations.hpp @@ -41,7 +41,7 @@ T& unmove(T&& t) { SEXP err = R_NilValue; \ char buf[CPP11_ERROR_BUFSIZE] = ""; \ try { -#define END_CPP11 \ +#define END_CPP11_EX(RET) \ } \ catch (cpp11::unwind_exception & e) { \ err = e.token; \ @@ -57,4 +57,5 @@ T& unmove(T&& t) { } else if (err != R_NilValue) { \ R_ContinueUnwind(err); \ } \ - return R_NilValue; + return RET; +#define END_CPP11 END_CPP11_EX(R_NilValue)