Skip to content

Commit a43c44c

Browse files
author
Florian Plaza Oñate
committed
Allow assignment of size 1 with Subsetter
1 parent d9a448a commit a43c44c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

inst/include/Rcpp/vector/Subsetter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class SubsetProxy {
5252
template <int OtherRTYPE, template <class> class OtherStoragePolicy>
5353
SubsetProxy& operator=(const Vector<OtherRTYPE, OtherStoragePolicy>& other) {
5454
int n = other.size();
55-
if (indices_n != n) stop("index error");
55+
5656
if (n == 1) {
57-
for (int i=0; i < n; ++i) {
57+
for (int i=0; i < indices_n; ++i) {
5858
lhs[ indices[i] ] = other[0];
5959
}
6060
} else if (n == indices_n) {
@@ -65,7 +65,7 @@ class SubsetProxy {
6565
stop("index error");
6666
}
6767
return *this;
68-
}
68+
}
6969

7070
// Enable e.g. x[y] = 1;
7171
// TODO: std::enable_if<primitive> with C++11

0 commit comments

Comments
 (0)