Skip to content

Commit

Permalink
Switch to simpler construct_call() signature (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan authored Aug 26, 2024
1 parent cd55bdf commit 5c89f23
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions inst/include/cpp11/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,23 @@ class function {
SEXP data_;

template <typename... Args>
SEXP construct_call(SEXP val, const named_arg& arg, Args&&... args) const {
void construct_call(SEXP val, const named_arg& arg, Args&&... args) const {
SETCAR(val, arg.value());
SET_TAG(val, safe[Rf_install](arg.name()));
val = CDR(val);
return construct_call(val, std::forward<Args>(args)...);
construct_call(val, std::forward<Args>(args)...);
}

// Construct the call recursively, each iteration adds an Arg to the pairlist.
// We need
template <typename T, typename... Args>
SEXP construct_call(SEXP val, const T& arg, Args&&... args) const {
void construct_call(SEXP val, const T& arg, Args&&... args) const {
SETCAR(val, as_sexp(arg));
val = CDR(val);
return construct_call(val, std::forward<Args>(args)...);
construct_call(val, std::forward<Args>(args)...);
}

// Base case, just return
SEXP construct_call(SEXP val) const { return val; }
void construct_call(SEXP val) const {}
};

class package {
Expand Down

0 comments on commit 5c89f23

Please sign in to comment.