Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable should be able to take R_NilValue as a default parameter in a function #394

Closed
dcdillon opened this issue Nov 8, 2015 · 2 comments · Fixed by #395
Closed

Nullable should be able to take R_NilValue as a default parameter in a function #394

dcdillon opened this issue Nov 8, 2015 · 2 comments · Fixed by #395

Comments

@dcdillon
Copy link
Contributor

dcdillon commented Nov 8, 2015

It currently can't.

@dcdillon
Copy link
Contributor Author

dcdillon commented Nov 8, 2015

To elaborate, the following code didn't compile before because of the protected constructor Nullable(SEXP rhs). The constructor is no longer protected.

#include <string>
#include <vector>
#include <Rcpp.h>

// [[Rcpp::export]]
double getFirst(Rcpp::Nullable< Rcpp::NumericVector > v = R_NilValue)
{
        if (!v.isNull())
        {
                return Rcpp::as< Rcpp::NumericVector >(v)[0];
        }

        return NA_REAL;
}

@eddelbuettel
Copy link
Member

+1 -- that was on my TODO list for today as well.

eddelbuettel added a commit that referenced this issue Nov 8, 2015
Nullable now accepts R_NilValue as a default parameter.  See issue #394.
eddelbuettel added a commit that referenced this issue Nov 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants