File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 * inst/tinytest/cpp/ListOf.cpp: Added tests
66 * inst/tinytest/test_listof.R: Idem
77
8+ 2026-06-23 Jeroen Ooms <jeroenooms@gmail.com>
9+
10+ * Add templated integer-index overload on platforms without
11+ LONG_VECTOR_SUPPORT such as wasm32 (PR #1482)
12+
8132026-06-18 Dirk Eddelbuettel <edd@debian.org>
914
1015 * vignettes/rmd/Rcpp.bib: Updated references
Original file line number Diff line number Diff line change 2121#define Rcpp__vector__Vector_h
2222
2323#include < Rcpp/vector/Subsetter.h>
24+ #include < type_traits>
2425
2526namespace Rcpp {
2627
@@ -337,6 +338,20 @@ class Vector :
337338
338339 inline Proxy operator []( R_xlen_t i ){ return cache.ref (i) ; }
339340 inline const_Proxy operator []( R_xlen_t i ) const { return cache.ref (i) ; }
341+ #ifndef LONG_VECTOR_SUPPORT
342+ // On platforms without long vector support (notably wasm32) R_xlen_t is
343+ // int while ptrdiff_t is long, so subscripting with any wider integer
344+ // type would otherwise be ambiguous with the built-in pointer subscript
345+ // synthesised via the implicit Vector -> SEXP conversion. The template
346+ // overloads below provide an exact-match member candidate for every
347+ // integer index type other than R_xlen_t itself.
348+ template <typename T>
349+ inline typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, R_xlen_t>::value, Proxy>::type
350+ operator []( T i ){ return cache.ref (static_cast <R_xlen_t>(i)) ; }
351+ template <typename T>
352+ inline typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, R_xlen_t>::value, const_Proxy>::type
353+ operator []( T i ) const { return cache.ref (static_cast <R_xlen_t>(i)) ; }
354+ #endif
340355
341356 inline Proxy operator ()( const size_t & i) {
342357 return cache.ref ( offset (i) ) ;
You can’t perform that action at this time.
0 commit comments