Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
2026-04-09 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll micro version and date
* inst/include/Rcpp/Nullable.h (T): Also add 'operator T()'
(conditional on R (>= 4.3.0) as older versions croak)

2026-04-08 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/Nullable.h (as): Enhance by adding an explicit
Rcpp::as<T>() aiding cases where implicit as<> does not suffice

2026-04-07 Dirk Eddelbuettel <edd@debian.org>

Expand Down
14 changes: 13 additions & 1 deletion inst/include/Rcpp/Nullable.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ namespace Rcpp {
return m_sexp;
}

#if R_VERSION > R_Version(4,3,0)
/**
* operator T() to return nullable object
*
* @throw 'not initialized' if object has not been set
*/
inline operator T() const {
checkIfSet();
return Rcpp::as<T>(m_sexp);
}
#endif

/**
* get() accessor for object
*
Expand Down Expand Up @@ -126,7 +138,7 @@ namespace Rcpp {
/**
* Returns m_sexp as a T
*/
inline T as() { return get(); }
inline T as() { return Rcpp::as<T>(get()); }

/**
* Return a clone of m_sexp as a T
Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ expect_equal( testNullableIsUsable(M), M)
# test.NullableIsUsableFalse <- function() {
expect_true(is.null(testNullableIsUsable(NULL)))

# test.NullableString <- function() {
## test.NullableString <- function() {
expect_equal(testNullableString(), "")
expect_equal(testNullableString("blah"), "blah")

Expand Down
Loading