Skip to content

Commit df04014

Browse files
committed
simplify three false conditions for r_vector string (fix #431)
1 parent 05c888b commit df04014

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

inst/include/cpp11/r_vector.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,18 +1392,14 @@ inline SEXP r_vector<T>::resize_names(SEXP x, R_xlen_t size) {
13921392

13931393
} // namespace writable
13941394

1395-
// TODO: is there a better condition we could use, e.g. assert something true
1396-
// rather than three things false?
1397-
template <typename C, typename T>
1398-
using is_container_but_not_sexp_or_string = typename std::enable_if<
1395+
// Ensure that C is not constructible from SEXP, and neither C nor T is a std::string
1396+
template <typename C, typename T = typename std::decay<C>::type::value_type>
1397+
typename std::enable_if<
13991398
!std::is_constructible<C, SEXP>::value &&
14001399
!std::is_same<typename std::decay<C>::type, std::string>::value &&
14011400
!std::is_same<typename std::decay<T>::type, std::string>::value,
1402-
typename std::decay<C>::type>::type;
1403-
1404-
template <typename C, typename T = typename std::decay<C>::type::value_type>
1405-
// typename T = typename C::value_type>
1406-
is_container_but_not_sexp_or_string<C, T> as_cpp(SEXP from) {
1401+
C>::type
1402+
as_cpp(SEXP from) {
14071403
auto obj = cpp11::r_vector<T>(from);
14081404
return {obj.begin(), obj.end()};
14091405
}

0 commit comments

Comments
 (0)