Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cpp11test/src/test-logicals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ context("logicals-C++") {
expect_true(cpp11::is_na(y));
}

test_that("FALSE and false") {
cpp11::writable::logicals x{FALSE};
expect_true(x.size() == 1);
expect_true(x[0] == FALSE);

cpp11::writable::logicals y{false};
expect_true(y.size() == 1);
expect_true(y[0] == FALSE);
}

// test_that("writable::logicals(ALTREP_SEXP)") {
// SEXP x = PROTECT(R_compact_intrange(1, 5));
//// Need to find (or create) an altrep class that implements duplicate.
Expand Down
13 changes: 13 additions & 0 deletions cpp11test/src/test-strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ context("strings-C++") {
UNPROTECT(1);
}

test_that("std::initializer_list<const char*>") {
cpp11::writable::strings x{"foo"};
expect_true(x.size() == 1);
expect_true(x[0] == "foo");
}

test_that("std::initializer_list<std::string>") {
std::string str("foo");
cpp11::writable::strings x{str};
expect_true(x.size() == 1);
expect_true(x[0] == "foo");
}

test_that("NA_STRING constructor") {
cpp11::writable::strings x({NA_STRING});

Expand Down
1 change: 1 addition & 0 deletions inst/include/cpp11/logicals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ inline void r_vector<r_bool>::push_back(r_bool value) {
typedef r_vector<r_bool> logicals;

} // namespace writable

} // namespace cpp11
6 changes: 2 additions & 4 deletions inst/include/cpp11/r_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,14 @@ class r_vector : public cpp11::r_vector<T> {
r_vector(SEXP&& data, bool is_altrep);
r_vector(std::initializer_list<T> il);
r_vector(std::initializer_list<named_arg> il);
r_vector(std::initializer_list<const char*> il);
r_vector(std::initializer_list<std::string> il);

template <typename Iter>
r_vector(Iter first, Iter last);

template <typename V, typename W = has_begin_fun<V>>
r_vector(const V& obj);

r_vector(const R_xlen_t size);
explicit r_vector(const R_xlen_t size);

~r_vector();

Expand Down Expand Up @@ -688,7 +686,7 @@ inline r_vector<T>::r_vector(const V& obj) : r_vector() {
}

template <typename T>
inline r_vector<T>::r_vector(R_xlen_t size) : r_vector() {
inline r_vector<T>::r_vector(const R_xlen_t size) : r_vector() {
resize(size);
}

Expand Down
8 changes: 0 additions & 8 deletions inst/include/cpp11/strings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ template <>
inline r_vector<r_string>::r_vector(std::initializer_list<r_string> il)
: cpp11::r_vector<r_string>(as_sexp(il)), capacity_(il.size()) {}

template <>
inline r_vector<r_string>::r_vector(std::initializer_list<const char*> il)
: cpp11::r_vector<r_string>(as_sexp(il)), capacity_(il.size()) {}

template <>
inline r_vector<r_string>::r_vector(std::initializer_list<std::string> il)
: cpp11::r_vector<r_string>(as_sexp(il)), capacity_(il.size()) {}

template <>
inline r_vector<r_string>::r_vector(std::initializer_list<named_arg> il)
: cpp11::r_vector<r_string>(safe[Rf_allocVector](STRSXP, il.size())),
Expand Down