@@ -45,44 +45,21 @@ namespace traits{
45
45
inline iterator get () const { return start; }
46
46
inline const_iterator get_const () const { return start; }
47
47
48
- inline proxy ref () {
49
- #ifndef RCPP_NO_BOUNDS_CHECK
50
- check_index (0 ) ;
51
- #endif
52
- return start[0 ];
53
- }
54
-
55
- inline proxy ref () const {
56
- #ifndef RCPP_NO_BOUNDS_CHECK
57
- check_index (0 ) ;
58
- #endif
59
- return start[0 ] ;
60
- }
61
-
62
- inline proxy ref (R_xlen_t i) {
63
- #ifndef RCPP_NO_BOUNDS_CHECK
64
- check_index (i) ;
65
- #endif
66
- return start[i] ;
67
- }
48
+ inline proxy ref () { check_index (0 ); return start[0 ] ;}
49
+ inline proxy ref (R_xlen_t i) { check_index (i); return start[i] ; }
68
50
69
-
70
- inline proxy ref (R_xlen_t i) const {
71
- #ifndef RCPP_NO_BOUNDS_CHECK
72
- check_index (i) ;
73
- #endif
74
- return start[i] ;
75
- }
51
+ inline proxy ref () const { check_index (0 ); return start[0 ] ;}
52
+ inline proxy ref (R_xlen_t i) const { check_index (i); return start[i] ; }
76
53
77
54
private:
78
55
79
- #ifndef RCPP_NO_BOUNDS_CHECK
80
56
void check_index (R_xlen_t i) const {
57
+ #ifndef RCPP_NO_BOUNDS_CHECK
81
58
if (i >= size) {
82
59
stop (" subscript out of bounds (index %s >= vector size %s)" , i, size);
83
60
}
84
- }
85
61
#endif
62
+ }
86
63
87
64
iterator start ;
88
65
R_xlen_t size ;
@@ -102,18 +79,25 @@ namespace traits{
102
79
void update ( const VECTOR& v ){
103
80
p = const_cast <VECTOR*>(&v) ;
104
81
}
105
- inline iterator get () const { return iterator ( proxy (*p, 0 ) ) ;}
106
- // inline const_iterator get_const() const { return const_iterator( *p ) ;}
107
- inline const_iterator get_const () const { return const_iterator ( const_proxy (*p, 0 ) ) ; }
82
+ inline iterator get () const { check_index (0 ); return iterator ( proxy (*p, 0 ) ) ;}
83
+ inline const_iterator get_const () const { check_index (0 ); return const_iterator ( const_proxy (*p, 0 ) ) ; }
108
84
109
- inline proxy ref () { return proxy (*p,0 ) ; }
110
- inline proxy ref (R_xlen_t i) { return proxy (*p,i);}
85
+ inline proxy ref () { check_index ( 0 ); return proxy (*p,0 ) ; }
86
+ inline proxy ref (R_xlen_t i) { check_index (i); return proxy (*p,i);}
111
87
112
- inline const_proxy ref () const { return const_proxy (*p,0 ) ; }
113
- inline const_proxy ref (R_xlen_t i) const { return const_proxy (*p,i);}
88
+ inline const_proxy ref () const { check_index ( 0 ); return const_proxy (*p,0 ) ; }
89
+ inline const_proxy ref (R_xlen_t i) const { check_index (i); return const_proxy (*p,i);}
114
90
115
91
private:
116
92
VECTOR* p ;
93
+
94
+ void check_index (R_xlen_t i) const {
95
+ #ifndef RCPP_NO_BOUNDS_CHECK
96
+ if (i >= size) {
97
+ stop (" subscript out of bounds (index %s >= vector size %s)" , i, size);
98
+ }
99
+ #endif
100
+ }
117
101
} ;
118
102
119
103
// regular types for INTSXP, REALSXP, ...
0 commit comments