Skip to content

Commit 04ba7bc

Browse files
prepare handling of named and unnamed objects in StretchyList::push_*
1 parent 111bb4d commit 04ba7bc

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

inst/include/Rcpp/StretchyList.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,28 @@ namespace Rcpp{
4747
}
4848

4949
template <typename T>
50-
StretchyList_Impl& push_back(const T& obj ) ;
50+
inline StretchyList_Impl& push_back(const T& obj ){
51+
return push_back__impl( obj, typename traits::is_named<T>::type() ) ;
52+
}
53+
54+
template <typename T>
55+
inline StretchyList_Impl& push_front(const T& obj ){
56+
return push_front__impl( obj, typename traits::is_named<T>::type() ) ;
57+
}
58+
59+
private:
60+
61+
template <typename T>
62+
StretchyList_Impl& push_back__impl(const T& obj, traits::true_type ) ;
63+
64+
template <typename T>
65+
StretchyList_Impl& push_back__impl(const T& obj, traits::false_type ) ;
66+
67+
template <typename T>
68+
StretchyList_Impl& push_front__impl(const T& obj, traits::true_type ) ;
5169

5270
template <typename T>
53-
StretchyList_Impl& push_front(const T& obj ) ;
71+
StretchyList_Impl& push_front__impl(const T& obj, traits::false_type ) ;
5472

5573
} ;
5674

inst/include/Rcpp/api/meat/StretchyList.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Rcpp{
2222

2323
template< template <class> class StoragePolicy>
2424
template< typename T>
25-
StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_back( const T& obj){
25+
StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_back__impl( const T& obj, traits::false_type ){
2626
Shield<SEXP> s( wrap(obj) ) ;
2727
SEXP tmp = Rf_cons( s, R_NilValue );
2828
SEXP self = Storage::get__() ;
@@ -33,7 +33,7 @@ namespace Rcpp{
3333

3434
template< template <class> class StoragePolicy>
3535
template< typename T>
36-
StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_front( const T& obj){
36+
StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_front__impl( const T& obj, traits::false_type){
3737
SEXP tmp ;
3838
SEXP self = Storage::get__() ;
3939
Shield<SEXP> s( wrap(obj) ) ;

0 commit comments

Comments
 (0)