File tree Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,16 @@ context("logicals-C++") {
134
134
expect_true (cpp11::is_na (y));
135
135
}
136
136
137
+ test_that (" FALSE and false" ) {
138
+ cpp11::writable::logicals x{FALSE };
139
+ expect_true (x.size () == 1 );
140
+ expect_true (x[0 ] == FALSE );
141
+
142
+ cpp11::writable::logicals y{false };
143
+ expect_true (y.size () == 1 );
144
+ expect_true (y[0 ] == FALSE );
145
+ }
146
+
137
147
// test_that("writable::logicals(ALTREP_SEXP)") {
138
148
// SEXP x = PROTECT(R_compact_intrange(1, 5));
139
149
// // Need to find (or create) an altrep class that implements duplicate.
Original file line number Diff line number Diff line change @@ -132,6 +132,19 @@ context("strings-C++") {
132
132
UNPROTECT (1 );
133
133
}
134
134
135
+ test_that (" std::initializer_list<const char*>" ) {
136
+ cpp11::writable::strings x{" foo" };
137
+ expect_true (x.size () == 1 );
138
+ expect_true (x[0 ] == " foo" );
139
+ }
140
+
141
+ test_that (" std::initializer_list<std::string>" ) {
142
+ std::string str (" foo" );
143
+ cpp11::writable::strings x{str};
144
+ expect_true (x.size () == 1 );
145
+ expect_true (x[0 ] == " foo" );
146
+ }
147
+
135
148
test_that (" NA_STRING constructor" ) {
136
149
cpp11::writable::strings x ({NA_STRING});
137
150
Original file line number Diff line number Diff line change @@ -138,4 +138,5 @@ inline void r_vector<r_bool>::push_back(r_bool value) {
138
138
typedef r_vector<r_bool> logicals;
139
139
140
140
} // namespace writable
141
+
141
142
} // namespace cpp11
Original file line number Diff line number Diff line change @@ -285,16 +285,14 @@ class r_vector : public cpp11::r_vector<T> {
285
285
r_vector (SEXP&& data, bool is_altrep);
286
286
r_vector (std::initializer_list<T> il);
287
287
r_vector (std::initializer_list<named_arg> il);
288
- r_vector (std::initializer_list<const char *> il);
289
- r_vector (std::initializer_list<std::string> il);
290
288
291
289
template <typename Iter>
292
290
r_vector (Iter first, Iter last);
293
291
294
292
template <typename V, typename W = has_begin_fun<V>>
295
293
r_vector (const V& obj);
296
294
297
- r_vector (const R_xlen_t size);
295
+ explicit r_vector (const R_xlen_t size);
298
296
299
297
~r_vector ();
300
298
@@ -688,7 +686,7 @@ inline r_vector<T>::r_vector(const V& obj) : r_vector() {
688
686
}
689
687
690
688
template <typename T>
691
- inline r_vector<T>::r_vector(R_xlen_t size) : r_vector() {
689
+ inline r_vector<T>::r_vector(const R_xlen_t size) : r_vector() {
692
690
resize (size);
693
691
}
694
692
Original file line number Diff line number Diff line change @@ -112,14 +112,6 @@ template <>
112
112
inline r_vector<r_string>::r_vector(std::initializer_list<r_string> il)
113
113
: cpp11::r_vector<r_string>(as_sexp(il)), capacity_(il.size()) {}
114
114
115
- template <>
116
- inline r_vector<r_string>::r_vector(std::initializer_list<const char *> il)
117
- : cpp11::r_vector<r_string>(as_sexp(il)), capacity_(il.size()) {}
118
-
119
- template <>
120
- inline r_vector<r_string>::r_vector(std::initializer_list<std::string> il)
121
- : cpp11::r_vector<r_string>(as_sexp(il)), capacity_(il.size()) {}
122
-
123
115
template <>
124
116
inline r_vector<r_string>::r_vector(std::initializer_list<named_arg> il)
125
117
: cpp11::r_vector<r_string>(safe[Rf_allocVector](STRSXP, il.size())),
You can’t perform that action at this time.
0 commit comments