Refactor conversion to use extensible trait structs#104
Refactor conversion to use extensible trait structs#104bkietz wants to merge 5 commits intor-lib:mainfrom
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.
@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.
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.
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: