Skip to content

Commit 617bb76

Browse files
committed
ListOf<T> inherits from relevant proxies (#183)
1 parent ed35e2e commit 617bb76

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2014-10-01 Kevin Ushey <kevinushey@gmail.com>
2+
3+
* inst/include/Rcpp/vector/ListOf.h ListOf<T> inherits relevant proxies
4+
* inst/unitTests/cpp/ListOf.cpp: Idem
5+
* inst/unitTests/runit.ListOf.R: Idem
6+
17
2014-09-29 Dirk Eddelbuettel <edd@debian.org>
28

39
* debian/*: Changes for Debian release of 0.11.3

inst/include/Rcpp/vector/ListOf.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
namespace Rcpp {
2424

2525
template <typename T>
26-
class ListOf {
26+
class ListOf
27+
: public NamesProxyPolicy<T>
28+
, public AttributeProxyPolicy<T>
29+
, public RObjectMethods<T>
30+
{
2731

2832
public:
2933
typedef typename traits::r_vector_iterator<VECSXP>::type iterator;

inst/unitTests/cpp/ListOf.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,13 @@ NumericVector test_nested_listof(ListOf< ListOf<NumericVector> > x) {
9898
ListOf<IntegerVector> test_return_IVList(List x) {
9999
return x;
100100
}
101+
102+
// [[Rcpp::export]]
103+
CharacterVector listof_names(ListOf<NumericVector> x) {
104+
return x.names();
105+
}
106+
107+
// [[Rcpp::export]]
108+
SEXP listof_attr_foo(ListOf<NumericVector> x) {
109+
return x.attr("foo");
110+
}

inst/unitTests/runit.ListOf.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,15 @@ if (.runThisTest) {
8787
)
8888
}
8989

90+
test.ListOf.names <- function() {
91+
l <- list(a = 1L, b = 2L, c = 3L)
92+
checkEquals(listof_names(l), c("a", "b", "c"))
93+
}
94+
95+
test.ListOf.attr.foo <- function() {
96+
l <- list(a = 1L)
97+
attr(l, "foo") <- "bar"
98+
checkEquals(listof_attr_foo(l), "bar")
99+
}
100+
90101
}

0 commit comments

Comments
 (0)