Skip to content

Commit 894d6e4

Browse files
more StoragePolicy use
1 parent 2e82c12 commit 894d6e4

File tree

6 files changed

+30
-17
lines changed

6 files changed

+30
-17
lines changed

inst/include/Rcpp/internal/Proxy_Iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Proxy_Iterator {
8181
}
8282

8383
inline reference operator*() {
84-
return proxy ;
84+
return proxy ;
8585
}
8686
inline pointer operator->(){
8787
return &proxy ;

inst/include/Rcpp/vector/Vector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ class Vector :
936936
}
937937

938938
R_xlen_t n = size() ;
939+
939940
Vector target( n - 1 ) ;
940941
iterator target_it(target.begin()) ;
941942
iterator it(begin()) ;

inst/include/Rcpp/vector/generic_proxy.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,26 @@ namespace internal{
3131
generic_proxy(): parent(0), index(-1){}
3232

3333
generic_proxy( const generic_proxy& other ) :
34-
parent(other.parent), index(other.index){} ;
34+
parent(other.parent), index(other.index)
35+
{}
3536

36-
generic_proxy( VECTOR& v, R_xlen_t i ) : parent(&v), index(i){} ;
37+
generic_proxy( VECTOR& v, R_xlen_t i ) :
38+
parent(&v), index(i)
39+
{}
3740

3841
generic_proxy& operator=(SEXP rhs) {
3942
set(rhs) ;
4043
return *this ;
4144
}
4245

43-
generic_proxy& operator=(const generic_proxy& rhs) {
44-
set(rhs.get());
46+
generic_proxy& operator=(const generic_proxy& rhs){
47+
set(rhs.get());
48+
return *this ;
49+
}
50+
51+
template <template <class> class StoragePolicy2>
52+
generic_proxy& operator=(const generic_proxy<RTYPE,StoragePolicy2>& rhs) {
53+
set(rhs.get());
4554
return *this ;
4655
}
4756

@@ -78,13 +87,15 @@ namespace internal{
7887
index = other.index ;
7988
}
8089

90+
inline SEXP get() const {
91+
return VECTOR_ELT(*parent, index );
92+
}
93+
8194
private:
8295
inline void set(SEXP x) {
8396
SET_VECTOR_ELT( *parent, index, x ) ;
8497
}
85-
inline SEXP get() const {
86-
return VECTOR_ELT(*parent, index );
87-
}
98+
8899

89100
} ;
90101

inst/include/Rcpp/vector/proxy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ namespace traits {
222222
} ;
223223
template<template <class> class StoragePolicy>
224224
struct r_vector_proxy<EXPRSXP, StoragePolicy> {
225-
typedef ::Rcpp::internal::generic_proxy<EXPRSXP> type ;
225+
typedef ::Rcpp::internal::generic_proxy<EXPRSXP, StoragePolicy> type ;
226226
} ;
227227
template<template <class> class StoragePolicy>
228228
struct r_vector_proxy<VECSXP, StoragePolicy> {
229-
typedef ::Rcpp::internal::generic_proxy<VECSXP> type ;
229+
typedef ::Rcpp::internal::generic_proxy<VECSXP, StoragePolicy> type ;
230230
} ;
231231

232232
template <int RTYPE, template <class> class StoragePolicy>

inst/include/Rcpp/vector/string_proxy.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ namespace internal{
5353
*
5454
* @param rhs another proxy, possibly from another vector
5555
*/
56-
string_proxy& operator=(const string_proxy& other){
57-
set( other.get() ) ;
58-
return *this ;
56+
template <template <class> class StoragePolicy2>
57+
string_proxy& operator=( const string_proxy<RTYPE, StoragePolicy2>& other) {
58+
set( other.get() ) ;
59+
return *this ;
5960
}
6061

6162
template <template <class> class StoragePolicy2>

inst/include/Rcpp/vector/traits.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ namespace traits{
5555
class proxy_cache{
5656
public:
5757
typedef typename ::Rcpp::Vector<RTYPE, StoragePolicy> VECTOR ;
58-
typedef typename r_vector_iterator<RTYPE>::type iterator ;
59-
typedef typename r_vector_const_iterator<RTYPE>::type const_iterator ;
58+
typedef typename r_vector_iterator<RTYPE, StoragePolicy>::type iterator ;
59+
typedef typename r_vector_const_iterator<RTYPE, StoragePolicy>::type const_iterator ;
6060
typedef typename r_vector_proxy<RTYPE, StoragePolicy>::type proxy ;
6161
typedef typename r_vector_const_proxy<RTYPE, StoragePolicy>::type const_proxy ;
6262

@@ -75,8 +75,8 @@ namespace traits{
7575
inline const_proxy ref() const { return const_proxy(*p,0) ; }
7676
inline const_proxy ref(R_xlen_t i) const { return const_proxy(*p,i);}
7777

78-
private:
79-
VECTOR* p ;
78+
private:
79+
VECTOR* p ;
8080
} ;
8181

8282
// regular types for INTSXP, REALSXP, ...

0 commit comments

Comments
 (0)