Skip to content

Commit

Permalink
implement #431
Browse files Browse the repository at this point in the history
  • Loading branch information
pachadotdev committed Jan 1, 2025
1 parent aeb1895 commit 6f84867
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cpp11test/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Suggests:
xml2
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.3.2
14 changes: 5 additions & 9 deletions inst/include/cpp11/r_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,18 +1392,14 @@ inline SEXP r_vector<T>::resize_names(SEXP x, R_xlen_t size) {

} // namespace writable

// TODO: is there a better condition we could use, e.g. assert something true
// rather than three things false?
template <typename C, typename T>
using is_container_but_not_sexp_or_string = typename std::enable_if<
// Ensure that C is not constructible from SEXP, and neither C nor T is a std::string
template <typename C, typename T = typename std::decay<C>::type::value_type>
typename std::enable_if<
!std::is_constructible<C, SEXP>::value &&
!std::is_same<typename std::decay<C>::type, std::string>::value &&
!std::is_same<typename std::decay<T>::type, std::string>::value,
typename std::decay<C>::type>::type;

template <typename C, typename T = typename std::decay<C>::type::value_type>
// typename T = typename C::value_type>
is_container_but_not_sexp_or_string<C, T> as_cpp(SEXP from) {
C>::type
as_cpp(SEXP from) {
auto obj = cpp11::r_vector<T>(from);
return {obj.begin(), obj.end()};
}
Expand Down

0 comments on commit 6f84867

Please sign in to comment.