diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index bea986564..694688fa8 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -3,6 +3,17 @@ \newcommand{\ghpr}{\href{https://github.com/RcppCore/Rcpp/pull/#1}{##1}} \newcommand{\ghit}{\href{https://github.com/RcppCore/Rcpp/issues/#1}{##1}} +\section{Changes in Rcpp version 0.12.4 (2016-01-XX)}{ + \itemize{ + \item Changes in Rcpp API: + \itemize{ + \item \code{Nullable<>::operator SEXP()} and + \code{Nullable<>::get()} now also work for \code{const} objects + (PR \ghpr{417}). + } + } +} + \section{Changes in Rcpp version 0.12.3 (2016-01-10)}{ \itemize{ \item Changes in Rcpp API: diff --git a/inst/include/Rcpp/Nullable.h b/inst/include/Rcpp/Nullable.h index 67c02f0cc..5bbc0f183 100644 --- a/inst/include/Rcpp/Nullable.h +++ b/inst/include/Rcpp/Nullable.h @@ -76,7 +76,7 @@ namespace Rcpp { * * @throw 'not initialized' if object has not been set */ - inline operator SEXP() { + inline operator SEXP() const { checkIfSet(); return m_sexp; } @@ -86,7 +86,7 @@ namespace Rcpp { * * @throw 'not initialized' if object has not been set */ - inline SEXP get() { + inline SEXP get() const { checkIfSet(); return m_sexp; } diff --git a/inst/unitTests/cpp/misc.cpp b/inst/unitTests/cpp/misc.cpp index 452e8c872..eab3ecb14 100644 --- a/inst/unitTests/cpp/misc.cpp +++ b/inst/unitTests/cpp/misc.cpp @@ -179,22 +179,22 @@ void test_stop_variadic() { } // [[Rcpp::export]] -bool testNullableForNull(Nullable M) { +bool testNullableForNull(const Nullable& M) { return M.isNull(); } // [[Rcpp::export]] -bool testNullableForNotNull(Nullable M) { +bool testNullableForNotNull(const Nullable& M) { return M.isNotNull(); } // [[Rcpp::export]] -SEXP testNullableOperator(Nullable M) { +SEXP testNullableOperator(const Nullable& M) { return M; } // [[Rcpp::export]] -SEXP testNullableGet(Nullable M) { +SEXP testNullableGet(const Nullable& M) { return M.get(); }