diff --git a/src/pmt_interface.cpp b/src/pmt_interface.cpp index e624213..d504985 100644 --- a/src/pmt_interface.cpp +++ b/src/pmt_interface.cpp @@ -30,8 +30,8 @@ class StatFunc : public Function { template auto _invoke(std::true_type, Args&&... args) const { - return [r_eval = [](void* expr) { return Rf_eval(*static_cast(expr), R_GlobalEnv); }, r_call = RObject(Rf_lcons(Function(Function::operator()(std::forward(args)...)), Pairlist(std::forward(args)...)))](auto&&...) mutable { - return as(unwindProtect(r_eval, static_cast(&r_call))); + return [r_eval = [](void* expr) { return Rf_eval(*static_cast(expr), R_GlobalEnv); }, r_call = RObject(Rf_lcons(RObject(Function::operator()(std::forward(args)...)), Pairlist(std::forward(args)...)))](auto&&...) { + return as(unwindProtect(r_eval, static_cast(const_cast(&r_call)))); }; } };