Skip to content

Commit b4db233

Browse files
Vector(SEXP) ctor needs a r_cast
1 parent 68beb7e commit b4db233

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ namespace Rcpp{
3131
}
3232

3333
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) ) ) ;
34+
template <bool NA, typename VEC>
35+
Vector<RTYPE, StoragePolicy>::Vector( const VectorBase<RTYPE,NA,VEC>& other ) {
36+
RCPP_DEBUG_2( "Vector<%d>( const VectorBase<RTYPE,NA,VEC>& ) [VEC = %s]", RTYPE, DEMANGLE(VEC) )
37+
import_sugar_expression( other, typename traits::same_type<Vector,VEC>::type() ) ;
3738
}
3839

3940
template <int RTYPE, template <class> class StoragePolicy>
@@ -128,14 +129,6 @@ namespace Rcpp{
128129
RCPP_DEBUG_2( "Vector<%d>( InputIterator, InputIterator, Func, int n = %d )", RTYPE, n )
129130
std::transform( first, last, begin(), func) ;
130131
}
131-
132-
133-
template <int RTYPE, template <class> class StoragePolicy>
134-
template <bool NA, typename VEC>
135-
Vector<RTYPE, StoragePolicy>::Vector( const VectorBase<RTYPE,NA,VEC>& other ) {
136-
RCPP_DEBUG_2( "Vector<%d>( const VectorBase<RTYPE,NA,VEC>& ) [VEC = %s]", RTYPE, DEMANGLE(VEC) )
137-
import_sugar_expression( other, typename traits::same_type<Vector,VEC>::type() ) ;
138-
}
139132

140133
template <int RTYPE, template <class> class StoragePolicy>
141134
template <bool NA, typename T>

inst/include/Rcpp/vector/Vector.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,9 @@ class Vector :
6969
}
7070

7171
Vector( SEXP x ) {
72-
Storage::set__(x) ;
72+
Storage::set__( r_cast<RTYPE>(x) ) ;
7373
}
7474

75-
template <typename U>
76-
explicit Vector( const U& obj) ;
77-
7875
explicit Vector( const no_init& obj) {
7976
Storage::set__( Rf_allocVector( RTYPE, obj.get() ) ) ;
8077
}

0 commit comments

Comments
 (0)