Skip to content

Commit 1ab5ad9

Browse files
committed
add const and non-const operator[] for RMatrix class
1 parent 9f81d0a commit 1ab5ad9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ RcppParallel 4.3.9
22
------------------------------------------------------------------------
33

44
* Add support for TBB on Solaris
5+
* Add const and non-const operator[] for RMatrix class
56

67
RcppParallel 4.3.8
78
------------------------------------------------------------------------

inst/include/RcppParallel/RMatrix.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ class RMatrix {
239239
return Column(*const_cast<RMatrix*>(this), i);
240240
}
241241

242+
inline T& operator[](std::size_t i) {
243+
return *(data_ + i);
244+
}
245+
246+
inline const T& operator[](std::size_t i) const {
247+
return *(data_ + i);
248+
}
249+
242250
private:
243251
T* data_;
244252
std::size_t nrow_;

0 commit comments

Comments
 (0)