Skip to content

Commit 2238c77

Browse files
handling proxy = const proxy operator for CharacterVector. added test for bug found while working on RcppArmadillo
1 parent c2ec64c commit 2238c77

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

inst/include/Rcpp/vector/const_string_proxy.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ namespace internal{
152152
return x + static_cast<const char*>(y) ;
153153
}
154154

155+
156+
template <int RTYPE>
157+
string_proxy<RTYPE>& string_proxy<RTYPE>::operator=(const const_string_proxy<RTYPE>& other){
158+
set( other.get() ) ;
159+
return *this ;
160+
}
161+
155162

156163
}
157164

inst/include/Rcpp/vector/string_proxy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ namespace internal{
5757
return *this ;
5858
}
5959

60+
string_proxy& operator=( const const_string_proxy<RTYPE>& other) ;
61+
6062
string_proxy& operator=( const String& s) ;
6163

6264
/**

inst/unitTests/cpp/Vector.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,3 +729,11 @@ std::string character_vector_const_proxy(const CharacterVector& str){
729729
return cstr ;
730730
}
731731

732+
// [[Rcpp::export]]
733+
CharacterVector CharacterVector_test_const_proxy(const CharacterVector x){
734+
CharacterVector out( x.size() ) ;
735+
for( int i=0; i<x.size(); i++){
736+
out[i] = x[i] ;
737+
}
738+
return out ;
739+
}

inst/unitTests/runit.Vector.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,5 +654,9 @@ if (.runThisTest) {
654654
checkEquals( res, "fooo", msg = "CharacterVector const proxy. #32" )
655655
}
656656

657+
test.CharacterVector.test.const.proxy <- function(){
658+
res <- CharacterVector_test_const_proxy( letters )
659+
checkEquals( res, letters )
660+
}
657661
}
658662

0 commit comments

Comments
 (0)