File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 1
1
# cpp11 (development version)
2
2
3
+ * ` data_frame() ` objects now have the number of rows correctly set as real length, not the reserved length (#91 )
4
+
3
5
# cpp11 0.2.1
4
6
5
7
* Ensures backwards compatibility with code generation from cpp11 0.1.0 (#88 )
Original file line number Diff line number Diff line change @@ -90,4 +90,17 @@ context("data_frame-C++") {
90
90
expect_true (cpp11::integers (df[" a" ])[0 ] == 1 );
91
91
expect_true (cpp11::strings (df[" b" ])[2 ] == " c" );
92
92
}
93
+
94
+ test_that (" growing vectors uses proper length" ) {
95
+ using namespace cpp11 ::literals;
96
+
97
+ cpp11::writable::integers x, y;
98
+ for (int i = 0 ; i < 10 ; ++i) {
99
+ x.push_back (i);
100
+ y.push_back (i);
101
+ }
102
+ cpp11::writable::data_frame out ({" x" _nm = x, " y" _nm = y});
103
+
104
+ expect_true (out.nrow () == 10 );
105
+ }
93
106
}
Original file line number Diff line number Diff line change @@ -760,22 +760,20 @@ inline typename r_vector<T>::iterator r_vector<T>::find(const r_string& name) co
760
760
761
761
template <typename T>
762
762
inline r_vector<T>::r_vector(const r_vector<T>& rhs)
763
- : cpp11::r_vector<T>(safe[Rf_shallow_duplicate](rhs.data_ )),
763
+ : cpp11::r_vector<T>(safe[Rf_shallow_duplicate](rhs)),
764
764
protect_ (protect_sexp(data_)),
765
765
capacity_(rhs.capacity_) {}
766
766
767
767
template <typename T>
768
768
inline r_vector<T>::r_vector(r_vector<T>&& rhs)
769
- : cpp11::r_vector<T>(rhs.data_),
770
- protect_ (protect_sexp(data_)),
771
- capacity_(rhs.capacity_) {
769
+ : cpp11::r_vector<T>(rhs), protect_(protect_sexp(data_)), capacity_(rhs.capacity_) {
772
770
rhs.data_ = R_NilValue;
773
771
rhs.protect_ = R_NilValue;
774
772
}
775
773
776
774
template <typename T>
777
775
inline r_vector<T>::r_vector(const cpp11::r_vector<T>& rhs)
778
- : cpp11::r_vector<T>(safe[Rf_shallow_duplicate](rhs.data_ )),
776
+ : cpp11::r_vector<T>(safe[Rf_shallow_duplicate](rhs)),
779
777
protect_ (protect_sexp(data_)),
780
778
capacity_(rhs.length_) {}
781
779
You can’t perform that action at this time.
0 commit comments