-
Notifications
You must be signed in to change notification settings - Fork 48
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
Refactor conversion to use extensible trait structs #104
base: main
Are you sure you want to change the base?
Conversation
Odd: https://github.com/r-lib/cpp11/pull/104/checks?check_run_id=1130882732#step:12:198 what feature macro should I use to disable that test case? Also, why is the |
You can use
d9eea11 should convert those warnings to failures and then fail the build in the cpp11test install step in the future. |
Thanks, I'll rebase |
7fe7d57
to
7d0867e
Compare
expect_true(ALTREP(r)); | ||
auto x1 = cpp11::as_cpp<std::vector<int>>(r); | ||
expect_true(ALTREP(r)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimhester I really expected something here to fail since as_cpp<IntegerContainer>()
currently relies on INTEGER()
, how is that working with ALTREP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vector is still an altrep when you call INTEGER()
on it, but it is then a materialized altrep vector.
The way to test that you are not materializing an alterep vector is to check that R_altrep_data2(x) == R_NilValue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. after doing this the second test fails, as you were expecting it to.
diff --git a/cpp11test/src/test-as.cpp b/cpp11test/src/test-as.cpp
index 6a3282c..0476ef2 100644
--- a/cpp11test/src/test-as.cpp
+++ b/cpp11test/src/test-as.cpp
@@ -243,9 +243,9 @@ context("as_cpp-C++") {
test_that("as_cpp<std::vector>(ALTREP_INTSXP)") {
SEXP r = PROTECT(R_compact_intrange(1, 5));
- expect_true(ALTREP(r));
+ expect_true(R_altrep_data2(r) == R_NilValue);
auto x1 = cpp11::as_cpp<std::vector<int>>(r);
- expect_true(ALTREP(r));
+ expect_true(R_altrep_data2(r) == R_NilValue);
expect_true(x1.size() == 5);
int expected = 1;
Still a little half baked: