Skip to content

Commit 3e1116e

Browse files
authored
Merge pull request #38 from pachadotdev/3Fto1T-clean
simplify three false conditions for r_vector string (fix r-lib#431)
2 parents 21e343b + fe2bf32 commit 3e1116e

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
@@ -1432,18 +1432,14 @@ inline SEXP r_vector<T>::resize_names(SEXP x, R_xlen_t size) {
14321432

14331433
} // namespace writable
14341434

1435-
// TODO: is there a better condition we could use, e.g. assert something true
1436-
// rather than three things false?
1437-
template <typename C, typename T>
1438-
using is_container_but_not_sexp_or_string = typename std::enable_if<
1435+
// Ensure that C is not constructible from SEXP, and neither C nor T is a std::string
1436+
template <typename C, typename T = typename std::decay<C>::type::value_type>
1437+
typename std::enable_if<
14391438
!std::is_constructible<C, SEXP>::value &&
14401439
!std::is_same<typename std::decay<C>::type, std::string>::value &&
14411440
!std::is_same<typename std::decay<T>::type, std::string>::value,
1442-
typename std::decay<C>::type>::type;
1443-
1444-
template <typename C, typename T = typename std::decay<C>::type::value_type>
1445-
// typename T = typename C::value_type>
1446-
is_container_but_not_sexp_or_string<C, T> as_cpp(SEXP from) {
1441+
C>::type
1442+
as_cpp(SEXP from) {
14471443
auto obj = cpp11::r_vector<T>(from);
14481444
return {obj.begin(), obj.end()};
14491445
}

0 commit comments

Comments
 (0)