File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,19 @@ namespace Rcpp{
3131 return *this ;
3232 }
3333
34+ template < template <class > class StoragePolicy >
35+ template < typename T>
36+ StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_back__impl( const T& obj, traits::true_type ){
37+ Shield<SEXP> s ( wrap (obj.object ) ) ;
38+ SEXP tmp = Rf_cons ( s, R_NilValue );
39+ Symbol tag = obj.name ;
40+ SET_TAG (tmp, tag) ;
41+ SEXP self = Storage::get__ () ;
42+ SETCDR ( CAR (self), tmp) ;
43+ SETCAR ( self, tmp ) ;
44+ return *this ;
45+ }
46+
3447 template < template <class > class StoragePolicy >
3548 template < typename T>
3649 StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_front__impl( const T& obj, traits::false_type){
@@ -42,6 +55,19 @@ namespace Rcpp{
4255 return *this ;
4356 }
4457
58+ template < template <class > class StoragePolicy >
59+ template < typename T>
60+ StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_front__impl( const T& obj, traits::true_type){
61+ SEXP tmp ;
62+ SEXP self = Storage::get__ () ;
63+ Shield<SEXP> s ( wrap (obj.object ) ) ;
64+ Symbol tag = obj.name ;
65+ tmp = Rf_cons (s, CDR (self) ) ;
66+ SET_TAG (tmp, tag );
67+ SETCDR (self, tmp) ;
68+ return *this ;
69+ }
70+
4571
4672}
4773
Original file line number Diff line number Diff line change @@ -142,3 +142,12 @@ StretchyList stretchy_list(){
142142 return out;
143143}
144144
145+ // [[Rcpp::export]]
146+ StretchyList named_stretchy_list (){
147+ StretchyList out ;
148+ out.push_back ( _[" b" ] = 1 ) ;
149+ out.push_front ( _[" a" ] = " foo" ) ;
150+ out.push_back ( _[" c" ] = 3.2 ) ;
151+ return out;
152+ }
153+
Original file line number Diff line number Diff line change @@ -133,4 +133,11 @@ test.StretchyList <- function(){
133133 )
134134}
135135
136+ test.named_StretchyList <- function (){
137+ checkEquals(
138+ named_stretchy_list(),
139+ pairlist( a = " foo" , b = 1L , c = 3.2 )
140+ )
141+ }
142+
136143}
You can’t perform that action at this time.
0 commit comments