Skip to content

Commit 5aa46bf

Browse files
added generic Vector ctor
1 parent 4daf7f0 commit 5aa46bf

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ namespace Rcpp{
3030
init() ;
3131
}
3232

33+
template <int RTYPE, template <class> class StoragePolicy>
34+
template <typename U>
35+
Vector<RTYPE, StoragePolicy>::Vector( const U& obj) {
36+
Storage::set__( r_cast<RTYPE>( wrap(obj) ) ) ;
37+
}
38+
3339
template <int RTYPE, template <class> class StoragePolicy>
3440
Vector<RTYPE, StoragePolicy>::Vector( const int& size ) {
3541
Storage::set__( Rf_allocVector( RTYPE, size) ) ;

inst/include/Rcpp/vector/Vector.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class Vector :
7373
Vector( SEXP x ) {
7474
Storage::set__(x) ;
7575
}
76+
77+
template <typename U>
78+
explicit Vector( const U& obj) ;
79+
7680
Vector( const int& size, const stored_type& u ) {
7781
RCPP_DEBUG_2( "Vector<%d>( const int& size = %d, const stored_type& u )", RTYPE, size)
7882
Storage::set__( Rf_allocVector( RTYPE, size) ) ;

0 commit comments

Comments
 (0)