[Rcpp-commits] r842 - pkg/Rcpp/src/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Mar 7 12:17:52 CET 2010
Author: romain
Date: 2010-03-07 12:17:51 +0100 (Sun, 07 Mar 2010)
New Revision: 842
Modified:
pkg/Rcpp/src/Rcpp/Vector.h
Log:
make characters read only (as they are supposed to be since R uses a cache for CHARSXP)
Modified: pkg/Rcpp/src/Rcpp/Vector.h
===================================================================
--- pkg/Rcpp/src/Rcpp/Vector.h 2010-03-07 09:52:50 UTC (rev 841)
+++ pkg/Rcpp/src/Rcpp/Vector.h 2010-03-07 11:17:51 UTC (rev 842)
@@ -96,8 +96,8 @@
class string_name_proxy{
public:
typedef typename ::Rcpp::Vector<RTYPE> VECTOR ;
- typedef char* iterator ;
- typedef char& reference ;
+ typedef const char* iterator ;
+ typedef const char& reference ;
string_name_proxy( VECTOR& v, const std::string& name_) :
parent(v), name(name_){} ;
@@ -1163,8 +1163,8 @@
public:
typedef typename ::Rcpp::Vector<RTYPE> VECTOR ;
- typedef char* iterator ;
- typedef char& reference ;
+ typedef const char* iterator ;
+ typedef const char& reference ;
string_proxy() : parent(0), index(-1){};
@@ -1269,14 +1269,11 @@
SET_STRING_ELT( *parent, index, x ) ;
}
- inline iterator begin(){ return const_cast<char*>( CHAR( STRING_ELT( *parent, index ) ) ) ; }
+ inline iterator begin(){ return CHAR( STRING_ELT( *parent, index ) ) ; }
inline iterator end(){ return begin() + size() ; }
- inline int size(){ return strlen( const_begin() ) ; }
+ inline int size(){ return strlen( begin() ) ; }
inline reference operator[]( int n ){ return *( begin() + n ) ; }
-
- private:
- inline const char* const_begin(){ return CHAR( STRING_ELT( *parent, index ) ) ; }
} ;
inline std::ostream& operator<<(std::ostream& os, const string_proxy<STRSXP>& proxy) {
More information about the Rcpp-commits
mailing list