Skip to content

Commit 7ce0f59

Browse files
committed
Support ListOfs of ListOfs
1 parent 9ed6840 commit 7ce0f59

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

inst/include/Rcpp/vector/ChildVector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ChildVector : public T {
3333
i(i_) {}
3434

3535
ChildVector(const ChildVector& other):
36-
T(other),
36+
T(wrap(other)),
3737
parent(other.parent),
3838
i(other.i) {}
3939

inst/include/Rcpp/vector/ListOf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class ListOf {
3636
template <typename U>
3737
ListOf(const U& data_): list(data_) {}
3838

39-
ListOf(const ListOf& other): list(other.list) {}
39+
ListOf(const ListOf& other): list(other.get()) {}
40+
4041
ListOf& operator=(const ListOf& other) {
4142
if (this != &other) {
4243
list = other.list;

inst/unitTests/cpp/ListOf.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ int test_sub_calls(NVList x) {
8888
int sz = x[0].size() + x[1].size() + x[2].size();
8989
return sz;
9090
}
91+
92+
// [[Rcpp::export]]
93+
NumericVector test_nested_listof(ListOf< ListOf<NumericVector> > x) {
94+
return x[0][0];
95+
}

inst/unitTests/runit.ListOf.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,11 @@ if (.runThisTest) {
6767
checkEquals(test_sub_calls( list(1, 2, 3) ), 3)
6868
}
6969

70+
test.ListOf.nested <- function() {
71+
checkEquals(
72+
test_nested_listof( list(list(1)) ),
73+
1
74+
)
75+
}
76+
7077
}

0 commit comments

Comments
 (0)