MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / generic_proxy

Class generic_proxy

inst/include/Rcpp/vector/generic_proxy.h:27–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26 template <int RTYPE, template <class> class StoragePolicy>
27 class generic_proxy : public GenericProxy< generic_proxy<RTYPE, StoragePolicy> > {
28 public:
29 typedef typename ::Rcpp::Vector<RTYPE, StoragePolicy> VECTOR ;
30
31 generic_proxy(): parent(0), index(-1){}
32
33 generic_proxy( const generic_proxy& other ) :
34 parent(other.parent), index(other.index)
35 {}
36
37 generic_proxy( VECTOR& v, R_xlen_t i ) :
38 parent(&v), index(i)
39 {}
40
41 generic_proxy& operator=(SEXP rhs) {
42 set(rhs) ;
43 return *this ;
44 }
45
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());
54 return *this ;
55 }
56
57 template <typename T>
58 generic_proxy& operator=( const T& rhs){
59 set(Shield<SEXP>(wrap(rhs))) ;
60 return *this;
61 }
62
63 operator SEXP() const {
64 return get() ;
65 }
66
67 template <typename U> operator U() const {
68 return ::Rcpp::as<U>(get()) ;
69 }
70
71 // helping the compiler (not sure why it can't help itself)
72 operator bool() const { return ::Rcpp::as<bool>(get()) ; }
73 operator int() const { return ::Rcpp::as<int>(get()) ; }
74
75 void swap(generic_proxy& other){
76 Shield<SEXP> tmp(get()) ;
77 set( other.get() ) ;
78 other.set(tmp) ;
79 }
80
81 VECTOR* parent;
82 R_xlen_t index ;
83 inline void move(R_xlen_t n) { index += n ; }
84

Callers

nothing calls this directly

Calls 3

getFunction · 0.85
wrapFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected